本文整理汇总了PHP中set_user_preference函数的典型用法代码示例。如果您正苦于以下问题:PHP set_user_preference函数的具体用法?PHP set_user_preference怎么用?PHP set_user_preference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_user_preference函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __create
public function __create($bookmarkurl, $title, $tokenval)
{
global $CFG, $DB;
$response = new CliniqueServiceResponce();
$token_val = array('token' => $tokenval);
$userId = array_values($DB->get_records_sql('SELECT userid FROM {external_tokens} et WHERE et.token=?', $token_val));
if ($userId) {
$user_id = array('id' => $userId[0]->userid);
//if(confirm_sesskey()){
$user = array_values($DB->get_records_sql('SELECT * FROM {user} u WHERE u.id=?', $user_id));
Favorites::__fav_user_login($user['0']);
if (get_user_preferences('user_bookmarks')) {
$bookmarks = explode(',', get_user_preferences('user_bookmarks'));
if (in_array($bookmarkurl . ";" . $title, $bookmarks)) {
$response->response(true, 'You have already bookmarked');
die;
}
} else {
$bookmarks = array();
}
//adds the bookmark at end of array
$bookmarks[] = $bookmarkurl . ";" . $title;
$bookmarks = implode(',', $bookmarks);
//adds to preferences table
set_user_preference('user_bookmarks', $bookmarks);
global $CFG;
//header("Location: " . $CFG->wwwroot . "/");
//print "Added Favourite Successfully";
$response->response(false, 'Added Favourite Successfully');
die;
} else {
$response->response(false, 'Invalid user');
die;
}
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:35,代码来源:create.php
示例2: blog_check_and_install_blocks
/**
* Checks to see if user has visited blogpages before, if not, install 2
* default blocks (blog_menu and blog_tags).
*/
function blog_check_and_install_blocks()
{
global $USER, $DB;
if (isloggedin() && !isguest()) {
// if this user has not visited this page before
if (!get_user_preferences('blogpagesize')) {
// find the correct ids for blog_menu and blog_from blocks
$menublock = $DB->get_record('block', array('name' => 'blog_menu'));
$tagsblock = $DB->get_record('block', array('name' => 'blog_tags'));
// add those 2 into block_instance page
// Commmented out since the block changes broke it. Hopefully nico will fix it ;-)
// // add blog_menu block
// $newblock = new object();
// $newblock->blockid = $menublock->id;
// $newblock->pageid = $USER->id;
// $newblock->pagetype = 'blog-view';
// $newblock->position = 'r';
// $newblock->weight = 0;
// $newblock->visible = 1;
// $DB->insert_record('block_instances', $newblock);
//
// // add blog_tags menu
// $newblock -> blockid = $tagsblock->id;
// $newblock -> weight = 1;
// $DB->insert_record('block_instances', $newblock);
// finally we set the page size pref
set_user_preference('blogpagesize', 10);
}
}
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:34,代码来源:lib.php
示例3: update_user_preferences
public function update_user_preferences()
{
parent::update_user_preferences();
set_user_preference('quiz_report_responses_qtext', $this->showqtext);
set_user_preference('quiz_report_responses_resp', $this->showresponses);
set_user_preference('quiz_report_responses_right', $this->showright);
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:7,代码来源:responses_options.php
示例4: test_are_notification_preferences_configured
/**
* Test are_notification_preferences_configured
*/
public function test_are_notification_preferences_configured()
{
$this->resetAfterTest(true);
$user1 = self::getDataGenerator()->create_user();
$user2 = self::getDataGenerator()->create_user();
$user3 = self::getDataGenerator()->create_user();
self::setUser($user1);
set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user1);
set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'airnotifier', $user1);
set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user2);
set_user_preference('message_provider_moodle_instantmessage_loggedin', 'airnotifier', $user3);
$params = array($user1->id, $user2->id, $user3->id);
$preferences = message_airnotifier_external::are_notification_preferences_configured($params);
$expected = array(array('userid' => $user1->id, 'configured' => 1));
$this->assertEquals(1, count($preferences['users']));
$this->assertEquals($expected, $preferences['users']);
$this->assertEquals(2, count($preferences['warnings']));
// Now, remove one user.
delete_user($user2);
$preferences = message_airnotifier_external::are_notification_preferences_configured($params);
$this->assertEquals(1, count($preferences['users']));
$this->assertEquals($expected, $preferences['users']);
$this->assertEquals(2, count($preferences['warnings']));
// Now, remove one user1 preference (the user still has one prefernce for airnotifier).
unset_user_preference('message_provider_moodle_instantmessage_loggedin', $user1);
$preferences = message_airnotifier_external::are_notification_preferences_configured($params);
$this->assertEquals($expected, $preferences['users']);
// Delete the last user1 preference.
unset_user_preference('message_provider_moodle_instantmessage_loggedoff', $user1);
$preferences = message_airnotifier_external::are_notification_preferences_configured($params);
$expected = array(array('userid' => $user1->id, 'configured' => 0));
$this->assertEquals($expected, $preferences['users']);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:36,代码来源:externallib_test.php
示例5: blog_check_and_install_blocks
/**
* Checks to see if user has visited blogpages before, if not, install 2
* default blocks (blog_menu and blog_tags).
*/
function blog_check_and_install_blocks()
{
global $USER;
if (isloggedin() && !isguest()) {
// if this user has not visited this page before
if (!get_user_preferences('blogpagesize')) {
// find the correct ids for blog_menu and blog_from blocks
$menublock = get_record('block', 'name', 'blog_menu');
$tagsblock = get_record('block', 'name', 'blog_tags');
// add those 2 into block_instance page
// add blog_menu block
$newblock = new object();
$newblock->blockid = $menublock->id;
$newblock->pageid = $USER->id;
$newblock->pagetype = 'blog-view';
$newblock->position = 'r';
$newblock->weight = 0;
$newblock->visible = 1;
insert_record('block_instance', $newblock);
// add blog_tags menu
$newblock->blockid = $tagsblock->id;
$newblock->weight = 1;
insert_record('block_instance', $newblock);
// finally we set the page size pref
set_user_preference('blogpagesize', 10);
}
}
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:32,代码来源:lib.php
示例6: update_user_preferences
public function update_user_preferences()
{
parent::update_user_preferences();
if (quiz_has_grades($this->quiz)) {
set_user_preference('quiz_overview_slotmarks', $this->slotmarks);
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:7,代码来源:overview_options.php
示例7: keats_check_fontswitch
function keats_check_fontswitch()
{
$changefont = optional_param('keatsfont', null, PARAM_ALPHA);
if (in_array($changefont, array('fontSmall', 'fontBig'))) {
return set_user_preference('theme_keats_chosen_font', $changefont);
}
return false;
}
开发者ID:simonsCatalyst,项目名称:simonsCatalyst-keats,代码行数:8,代码来源:lib.php
示例8: user_update_password
/**
* Updates the user's password.
*
* Called when the user password is updated.
*
* @param object $user User table object
* @param string $newpassword Plaintext password
* @return boolean result
*/
function user_update_password($user, $newpassword)
{
$user = get_complete_user_data('id', $user->id);
set_user_preference('auth_manual_passwordupdatetime', time(), $user->id);
// This will also update the stored hash to the latest algorithm
// if the existing hash is using an out-of-date algorithm (or the
// legacy md5 algorithm).
return update_internal_user_password($user, $newpassword);
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:18,代码来源:auth.php
示例9: useredit_update_user_preference
function useredit_update_user_preference($usernew) {
$ua = (array)$usernew;
foreach($ua as $key=>$value) {
if (strpos($key, 'preference_') === 0) {
$name = substr($key, strlen('preference_'));
set_user_preference($name, $value, $usernew->id);
}
}
}
开发者ID:JP-Git,项目名称:moodle,代码行数:9,代码来源:editlib.php
示例10: block_course_overview_update_myorder
/**
* Sets user course sorting preference in course_overview block
*
* @param array $sortorder list of course ids
*/
function block_course_overview_update_myorder($sortorder)
{
$value = implode(',', $sortorder);
if (core_text::strlen($value) > 1333) {
// The value won't fit into the user preference. Remove courses in the end of the list (mostly likely user won't even notice).
$value = preg_replace('/,[\\d]*$/', '', core_text::substr($value, 0, 1334));
}
set_user_preference('course_overview_course_sortorder', $value);
}
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:locallib.php
示例11: get_maxheight
/**
* Returns maximum height for images
*
* Takes the maximum height for images eithre from search form or from
* user preferences, updates user preferences if needed
*
* @return int
*/
public function get_maxheight()
{
$param = optional_param('wikimedia_maxheight', 0, PARAM_INT);
$pref = get_user_preferences('repository_wikimedia_maxheight', WIKIMEDIA_IMAGE_SIDE_LENGTH);
if ($param > 0 && $param != $pref) {
$pref = $param;
set_user_preference('repository_wikimedia_maxheight', $pref);
}
return $pref;
}
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:lib.php
示例12: get_userid
public static function get_userid()
{
global $USER;
// Get the users whose annotations are to be shown
$annotationuser = get_user_preferences(AN_USER_PREF, null);
if (null == $annotationuser) {
$annotationuser = isguest() ? null : $USER->username;
set_user_preference(AN_USER_PREF, $annotationuser);
}
return $annotationuser;
}
开发者ID:njorth,项目名称:marginalia,代码行数:11,代码来源:lib.php
示例13: check_login
/**
* Checks if username is set
*
* @return boolean
*/
public function check_login()
{
$username = get_user_preferences(self::USERNAME, '');
if (empty($username)) {
$username = optional_param('bitbucket_username', '', PARAM_ALPHANUM);
}
if ($username) {
set_user_preference(self::USERNAME, $username);
$this->client = new bitbucket($username);
return true;
}
return false;
}
开发者ID:robertboloc,项目名称:moodle-repository_bitbucket,代码行数:18,代码来源:lib.php
示例14: test_load_users
/**
* Test load_users method.
*/
public function test_load_users()
{
global $DB;
$this->setAdminUser();
$this->resetAfterTest(true);
$roleteacher = $DB->get_record('role', array('shortname' => 'teacher'), '*', MUST_EXIST);
// Create a course, users and groups.
$course = $this->getDataGenerator()->create_course();
$coursecontext = context_course::instance($course->id);
$group = $this->getDataGenerator()->create_group(array('courseid' => $course->id));
$teacher = $this->getDataGenerator()->create_user();
$user1 = $this->getDataGenerator()->create_user();
$user2 = $this->getDataGenerator()->create_user();
$this->getDataGenerator()->enrol_user($teacher->id, $course->id, $roleteacher->id);
$this->getDataGenerator()->enrol_user($user1->id, $course->id);
$this->getDataGenerator()->enrol_user($user2->id, $course->id);
$this->getDataGenerator()->create_group_member(array('groupid' => $group->id, 'userid' => $teacher->id));
$this->getDataGenerator()->create_group_member(array('groupid' => $group->id, 'userid' => $user1->id));
$this->getDataGenerator()->create_group_member(array('groupid' => $group->id, 'userid' => $user2->id));
// Perform a regrade before creating the report.
grade_regrade_final_grades($course->id);
$screentest = new gradereport_singleview_screen_testable($course->id, 0, $group->id);
$groupusers = $screentest->test_load_users();
$this->assertCount(2, $groupusers);
// Now, let's suspend the enrolment of a user. Should return only one user.
$this->getDataGenerator()->enrol_user($user2->id, $course->id, $roleteacher->id, 'manual', 0, 0, ENROL_USER_SUSPENDED);
$users = $screentest->test_load_users();
$this->assertCount(1, $users);
// Change the viewsuspendedusers capabilities and set the user preference to display suspended users.
assign_capability('moodle/course:viewsuspendedusers', CAP_ALLOW, $roleteacher->id, $coursecontext, true);
set_user_preference('grade_report_showonlyactiveenrol', false, $teacher);
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($teacher);
$screentest = new gradereport_singleview_screen_testable($course->id, 0, $group->id);
$users = $screentest->test_load_users();
$this->assertCount(2, $users);
// Change the capability again, now the user can't see the suspended enrolments.
assign_capability('moodle/course:viewsuspendedusers', CAP_PROHIBIT, $roleteacher->id, $coursecontext, true);
set_user_preference('grade_report_showonlyactiveenrol', false, $teacher);
accesslib_clear_all_caches_for_unit_testing();
$users = $screentest->test_load_users();
$this->assertCount(1, $users);
// Now, activate the user enrolment again. We shall get 2 users now.
$this->getDataGenerator()->enrol_user($user2->id, $course->id, $roleteacher->id, 'manual', 0, 0, ENROL_USER_ACTIVE);
$users = $screentest->test_load_users();
$this->assertCount(2, $users);
}
开发者ID:evltuma,项目名称:moodle,代码行数:50,代码来源:screen_test.php
示例15: user_login
/**
* Returns true if the username and password work and false if they are
* wrong or don't exist. (Non-mnet accounts only!)
*
* @param string $username The username
* @param string $password The password
* @return bool Authentication success or failure.
*/
function user_login($username, $password)
{
global $CFG, $DB, $USER;
if (!($user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id)))) {
return false;
}
if (!validate_internal_user_password($user, $password)) {
return false;
}
if ($password === 'changeme') {
// force the change - this is deprecated and it makes sense only for manual auth,
// because most other plugins can not change password easily or
// passwords are always specified by users
set_user_preference('auth_forcepasswordchange', true, $user->id);
}
return true;
}
开发者ID:JP-Git,项目名称:moodle,代码行数:25,代码来源:auth.php
示例16: __remove
public function __remove($bookmarkurl, $title, $tokenval)
{
global $CFG, $DB;
$bookmarkurl = htmlspecialchars_decode($bookmarkurl);
$title = htmlspecialchars_decode($title);
$response = new CliniqueServiceResponce();
$token_val = array('token' => $tokenval);
// Get user token
/**
* @get user id from external_tokens table
*
*/
$userId = array_values($DB->get_records_sql('SELECT userid FROM {external_tokens} et WHERE et.token=?', $token_val));
if ($userId) {
$user_id = array('id' => $userId[0]->userid);
//if(confirm_sesskey()){
$user = array_values($DB->get_records_sql('SELECT * FROM {user} u WHERE u.id=?', $user_id));
Favorites::__fav_user_login($user['0']);
$bookmarks = explode(',', get_user_preferences('user_bookmarks'));
$bookmarkremoved = false;
foreach ($bookmarks as $bookmark) {
// check the bookmarkurl and title given values to delete from preference
$tempBookmark = explode(';', $bookmark);
if ($tempBookmark[0] == $bookmarkurl && $tempBookmark[1] == $title) {
$keyToRemove = array_search($bookmark, $bookmarks);
unset($bookmarks[$keyToRemove]);
$bookmarkremoved = true;
}
}
if ($bookmarkremoved == false) {
$response->response(true, 'The bookmark you requested does not exist');
die;
}
$bookmarks = implode(',', $bookmarks);
set_user_preference('user_bookmarks', $bookmarks);
global $CFG;
//header("Location: " . $CFG->wwwroot . $bookmarkurl);
$response->response(false, 'Removed Favorite Successfully');
die;
} else {
$response->response(true, 'Invalid user');
die;
}
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:44,代码来源:delete.php
示例17: test_get_preferred_editor
/**
* Tests the installation of event handlers from file
*/
public function test_get_preferred_editor()
{
// Fake a user agent.
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.21 5 Safari/534.10';
$enabled = editors_get_enabled();
// Array assignment is always a clone.
$editors = $enabled;
$first = array_shift($enabled);
// Get the default editor which should be the first in the list.
set_user_preference('htmleditor', '');
$preferred = editors_get_preferred_editor();
$this->assertEquals($first, $preferred);
foreach ($editors as $key => $editor) {
// User has set a preference for a specific editor.
set_user_preference('htmleditor', $key);
$preferred = editors_get_preferred_editor();
$this->assertEquals($editor, $preferred);
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:22,代码来源:editorlib_test.php
示例18: xmldb_auth_manual_upgrade
/**
* @param int $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_auth_manual_upgrade($oldversion)
{
global $CFG, $DB, $OUTPUT;
if ($oldversion < 2011022700) {
// force creation of missing passwords
$createpassword = hash_internal_user_password('');
$rs = $DB->get_recordset('user', array('password' => $createpassword, 'auth' => 'manual'));
foreach ($rs as $user) {
if (validate_email($user->email)) {
$DB->set_field('user', 'password', 'to be created', array('id' => $user->id));
unset_user_preference('auth_forcepasswordchange', $user);
set_user_preference('create_password', 1, $user);
}
}
$rs->close();
upgrade_plugin_savepoint(true, 2011022700, 'auth', 'manual');
}
return true;
}
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:23,代码来源:upgrade.php
示例19: __sendPassword
public function __sendPassword($email)
{
global $CFG, $DB;
$systemcontext = context_system::instance();
$response = new CliniqueServiceResponce();
if (!empty($email) || !$email) {
$select = $DB->sql_like('email', ':email', false, true, false, '|') . " AND mnethostid = :mnethostid AND deleted=0 AND suspended=0";
$params = array('email' => $DB->sql_like_escape($email, '|'), 'mnethostid' => $CFG->mnet_localhost_id);
$user = $DB->get_record_select('user', $select, $params, '*', IGNORE_MULTIPLE);
if ($user and ($user->auth === 'nologin' or !is_enabled_auth($user->auth))) {
// bad luck - user is not able to login, do not let them reset password
$user = false;
$response->response(true, 'fp_nologin');
die;
}
if (!empty($user)) {
if (is_mnet_remote_user($user)) {
add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Forgot password - mnet user trying to access.', 0, $user->id);
$response->response(true, 'cp_mnet_user');
die;
}
if (isguestuser($user)) {
add_to_log(-1, 'custom_webservice', 'guest_user', null, 'Forgot password - guest user credential supplied.', 0, $user->id);
$response->response(true, 'fp_guest');
die;
}
// make sure user is allowed to change password
require_capability('moodle/user:changeownpassword', $systemcontext, $user->id);
if (!ForgotPassword::__app_reset_password_and_mail($user)) {
add_to_log(-1, 'custom_webservice', 'trigger_mail', null, 'Forgot password - email triggering failure.', 0, $user->id);
$response->response(true, 'fp_email_failure');
} else {
set_user_preference('auth_forcepasswordchange', true, $user->id);
$response->response(true, 'fp_email_success');
}
} else {
$response->response(false, 'fp_no_record');
}
} else {
add_to_log(-1, 'custom_webservice', 'input_parameters', null, 'Forgot password - input parameters missing.', 0, $user->id);
}
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:42,代码来源:clinique_forgot_password.php
示例20: mode_onenote
/**
* Manage calendar syncing.
*/
public function mode_onenote()
{
global $OUTPUT;
$mform = new \local_o365\form\onenote('?action=onenote');
if ($mform->is_cancelled()) {
redirect(new \moodle_url('/local/o365/ucp.php'));
} else {
if ($fromform = $mform->get_data()) {
$disableo365onenote = !empty($fromform->disableo365onenote) ? 1 : 0;
set_user_preference('local_o365_disableo365onenote', $disableo365onenote);
redirect(new \moodle_url('/local/o365/ucp.php'));
} else {
$defaultdata = ['disableo365onenote' => get_user_preferences('local_o365_disableo365onenote', 0)];
$mform->set_data($defaultdata);
echo $OUTPUT->header();
$mform->display();
echo $OUTPUT->footer();
}
}
}
开发者ID:eugeneventer,项目名称:o365-moodle,代码行数:23,代码来源:ucp.php
注:本文中的set_user_preference函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论