本文整理汇总了PHP中set_user_preference函数的典型用法代码示例。如果您正苦于以下问题:PHP set_user_preference函数的具体用法?PHP set_user_preference怎么用?PHP set_user_preference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_user_preference函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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);
}
}
}
示例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);
}
示例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']);
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}