• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP unset_user_preference函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中unset_user_preference函数的典型用法代码示例。如果您正苦于以下问题:PHP unset_user_preference函数的具体用法?PHP unset_user_preference怎么用?PHP unset_user_preference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了unset_user_preference函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: 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


示例2: __getPassword

 public function __getPassword($username, $email, $old_password, $new_password)
 {
     global $CFG, $DB;
     $systemcontext = context_system::instance();
     $response = new CliniqueServiceResponce();
     if (!empty($username) && !empty($old_password) && !empty($new_password)) {
         $user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 0, 'suspended' => 0));
         if (!empty($user)) {
             if (is_mnet_remote_user($user)) {
                 add_to_log(-1, 'custom_webservice', 'mnet_user', null, 'Change 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', 'mnet_user', null, 'Change password - guest user credential supplied.', 0, $user->id);
                 $response->response(true, 'cp_guest');
                 die;
             }
             // make sure user is allowed to change password
             require_capability('moodle/user:changeownpassword', $systemcontext, $user->id);
             // $generatePasswordResult = generatePassword::app_validate_internal_user_password($user, $old_password);
             if (!ChangePassword::__app_validate_internal_user_password($user, $old_password)) {
                 $response->response(true, 'cp_wrong_oldpwd');
             } else {
                 $userauth = get_auth_plugin($user->auth);
                 if ($userauth->user_update_password($user, $new_password)) {
                     unset_user_preference('auth_forcepasswordchange', $user);
                     unset_user_preference('create_password', $user);
                     $response->response(false, 'cp_success');
                 } else {
                     add_to_log(-1, 'custom_webservice', 'trigger_mail', null, 'Change password - password change updation failure.', 0, $user->id);
                     $response->response(true, 'cp_failure');
                 }
             }
         } else {
             $response->response(false, 'cp_no_mail_record');
         }
     } else {
         add_to_log(-1, 'custom_webservice', 'input_parameters', null, 'Change password - input parameters missing.', 0, $user->id);
     }
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:41,代码来源:clinique_change_password.php


示例3: __app_reset_password_and_mail

    private function __app_reset_password_and_mail($user)
    {
        global $CFG;
        $site = get_site();
        $supportuser = generate_email_supportuser();
        $userauth = get_auth_plugin($user->auth);
        if (!$userauth->can_reset_password() or !is_enabled_auth($user->auth)) {
            trigger_error("Attempt to reset user password for user {$user->username} with Auth {$user->auth}.");
            return false;
        }
        $newpassword = generate_password();
        if (!$userauth->user_update_password($user, $newpassword)) {
            $error->error = true;
            $error->msg = 'fp_passwordgen_failure';
            echo json_encode($error);
            die;
        }
        $a = new stdClass();
        $a->firstname = $user->firstname;
        $a->lastname = $user->lastname;
        $a->sitename = format_string($site->fullname);
        $a->username = $user->username;
        $a->newpassword = $newpassword;
        //$a->signoff = generate_email_signoff();
        $message = 'Hi ' . $a->firstname . ',

Your account password at \'' . $a->sitename . '\' has been reset
and you have been issued with a new temporary password.

Your current login information is now:
   username: ' . $a->username . '
   password: ' . $a->newpassword . '

Cheers from the \'' . $a->sitename . '\' administrator.';
        //$message = get_string('newpasswordtext', '', $a);
        $subject = format_string($site->fullname) . ': ' . get_string('changedpassword');
        unset_user_preference('create_password', $user);
        // prevent cron from generating the password
        //directly email rather than using the messaging system to ensure its not routed to a popup or jabber
        return email_to_user($user, $supportuser, $subject, $message);
    }
开发者ID:vinoth4891,项目名称:clinique,代码行数:41,代码来源:clinique_forgot_password.php


示例4: execute

 /**
  * Do the job.
  * Throw exceptions on errors (the job will be retried).
  */
 public function execute()
 {
     global $DB;
     // Generate new password emails for users - ppl expect these generated asap.
     if ($DB->count_records('user_preferences', array('name' => 'create_password', 'value' => '1'))) {
         mtrace('Creating passwords for new users...');
         $usernamefields = get_all_user_name_fields(true, 'u');
         $newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.auth, u.deleted,\n                                                     u.suspended, u.emailstop, u.mnethostid, u.mailformat,\n                                                     {$usernamefields}, u.username, u.lang,\n                                                     p.id as prefid\n                                                FROM {user} u\n                                                JOIN {user_preferences} p ON u.id=p.userid\n                                               WHERE p.name='create_password' AND p.value='1' AND\n                                                     u.email !='' AND u.suspended = 0 AND\n                                                     u.auth != 'nologin' AND u.deleted = 0");
         // Note: we can not send emails to suspended accounts.
         foreach ($newusers as $newuser) {
             // Use a low cost factor when generating bcrypt hash otherwise
             // hashing would be slow when emailing lots of users. Hashes
             // will be automatically updated to a higher cost factor the first
             // time the user logs in.
             if (setnew_password_and_mail($newuser, true)) {
                 unset_user_preference('create_password', $newuser);
                 set_user_preference('auth_forcepasswordchange', 1, $newuser);
             } else {
                 trigger_error("Could not create and mail new user password!");
             }
         }
         $newusers->close();
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:28,代码来源:send_new_user_passwords_task.php


示例5: unset_user_preference

     unset_user_preference('auth_forcepasswordchange', $existinguser);
 } else {
     if (!empty($user->password)) {
         if ($updatepasswords) {
             $errmsg = null;
             $weak = !check_password_policy($user->password, $errmsg);
             if ($resetpasswords == UU_PWRESET_ALL or $resetpasswords == UU_PWRESET_WEAK and $weak) {
                 if ($weak) {
                     $weakpasswords++;
                     $upt->track('password', $strinvalidpasswordpolicy, 'warning');
                 }
                 set_user_preference('auth_forcepasswordchange', 1, $existinguser);
             } else {
                 unset_user_preference('auth_forcepasswordchange', $existinguser);
             }
             unset_user_preference('create_password', $existinguser);
             // no need to create password any more
             $existinguser->password = hash_internal_user_password($user->password);
             $upt->track('password', $user->password, 'normal', false);
         } else {
             // do not print password when not changed
             $upt->track('password', '', 'normal', false);
         }
     }
 }
 if ($doupdate or $existinguser->password !== $oldpw) {
     // we want only users that were really updated
     $DB->update_record('user', $existinguser);
     $upt->track('status', $struserupdated);
     $usersupdated++;
     // save custom profile fields data from csv file
开发者ID:richheath,项目名称:moodle,代码行数:31,代码来源:uploaduser.php


示例6: test_set_user_preference

 public function test_set_user_preference()
 {
     global $DB, $USER;
     $this->resetAfterTest();
     $this->setAdminUser();
     $otheruser = $this->getDataGenerator()->create_user();
     $otheruserid = $otheruser->id;
     $DB->delete_records('user_preferences', array('userid' => $otheruserid));
     set_cache_flag('userpreferenceschanged', $otheruserid, null);
     $user = new stdClass();
     $user->id = $otheruserid;
     set_user_preference('aaa', 'bbb', $otheruserid);
     $this->assertSame('bbb', $DB->get_field('user_preferences', 'value', array('userid' => $otheruserid, 'name' => 'aaa')));
     $this->assertSame('bbb', get_user_preferences('aaa', null, $otheruserid));
     set_user_preference('xxx', 'yyy', $user);
     $this->assertSame('yyy', $DB->get_field('user_preferences', 'value', array('userid' => $otheruserid, 'name' => 'xxx')));
     $this->assertSame('yyy', get_user_preferences('xxx', null, $otheruserid));
     $this->assertTrue(is_array($user->preference));
     $this->assertSame('bbb', $user->preference['aaa']);
     $this->assertSame('yyy', $user->preference['xxx']);
     set_user_preference('xxx', null, $user);
     $this->assertFalse($DB->get_field('user_preferences', 'value', array('userid' => $otheruserid, 'name' => 'xxx')));
     $this->assertNull(get_user_preferences('xxx', null, $otheruserid));
     set_user_preference('ooo', true, $user);
     $prefs = get_user_preferences(null, null, $otheruserid);
     $this->assertSame($user->preference['aaa'], $prefs['aaa']);
     $this->assertSame($user->preference['ooo'], $prefs['ooo']);
     $this->assertSame('1', $prefs['ooo']);
     set_user_preference('null', 0, $user);
     $this->assertSame('0', get_user_preferences('null', null, $otheruserid));
     $this->assertSame('lala', get_user_preferences('undefined', 'lala', $otheruserid));
     $DB->delete_records('user_preferences', array('userid' => $otheruserid));
     set_cache_flag('userpreferenceschanged', $otheruserid, null);
     // Test $USER default.
     set_user_preference('_test_user_preferences_pref', 'ok');
     $this->assertSame('ok', $USER->preference['_test_user_preferences_pref']);
     unset_user_preference('_test_user_preferences_pref');
     $this->assertTrue(!isset($USER->preference['_test_user_preferences_pref']));
     // Test 1333 char values (no need for unicode, there are already tests for that in DB tests).
     $longvalue = str_repeat('a', 1333);
     set_user_preference('_test_long_user_preference', $longvalue);
     $this->assertEquals($longvalue, get_user_preferences('_test_long_user_preference'));
     $this->assertEquals($longvalue, $DB->get_field('user_preferences', 'value', array('userid' => $USER->id, 'name' => '_test_long_user_preference')));
     // Test > 1333 char values, coding_exception expected.
     $longvalue = str_repeat('a', 1334);
     try {
         set_user_preference('_test_long_user_preference', $longvalue);
         $this->fail('Exception expected - longer than 1333 chars not allowed as preference value');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     // Test invalid params.
     try {
         set_user_preference('_test_user_preferences_pref', array());
         $this->fail('Exception expected - array not valid preference value');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         set_user_preference('_test_user_preferences_pref', new stdClass());
         $this->fail('Exception expected - class not valid preference value');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         set_user_preference('_test_user_preferences_pref', 1, array('xx' => 1));
         $this->fail('Exception expected - user instance expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         set_user_preference('_test_user_preferences_pref', 1, 'abc');
         $this->fail('Exception expected - user instance expected');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         set_user_preference('', 1);
         $this->fail('Exception expected - invalid name accepted');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
     try {
         set_user_preference('1', 1);
         $this->fail('Exception expected - invalid name accepted');
     } catch (moodle_exception $ex) {
         $this->assertInstanceOf('coding_exception', $ex);
     }
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:89,代码来源:moodlelib_test.php


示例7: get_content

 /**
  * Gets the content for this block by grabbing it from $this->page
  *
  * @return object $this->content
  */
 function get_content()
 {
     global $CFG, $OUTPUT;
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return $this->content;
     }
     // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
     // $this->page->requires->js('/lib/javascript-navigation.js');
     // Navcount is used to allow us to have multiple trees although I dont' know why
     // you would want two trees the same
     block_navigation::$navcount++;
     // Check if this block has been docked
     if ($this->docked === null) {
         $this->docked = get_user_preferences('nav_in_tab_panel_globalnav' . block_navigation::$navcount, 0);
     }
     // Check if there is a param to change the docked state
     if ($this->docked && optional_param('undock', null, PARAM_INT) == $this->instance->id) {
         unset_user_preference('nav_in_tab_panel_globalnav' . block_navigation::$navcount);
         $url = $this->page->url;
         $url->remove_params(array('undock'));
         redirect($url);
     } else {
         if (!$this->docked && optional_param('dock', null, PARAM_INT) == $this->instance->id) {
             set_user_preferences(array('nav_in_tab_panel_globalnav' . block_navigation::$navcount => 1));
             $url = $this->page->url;
             $url->remove_params(array('dock'));
             redirect($url);
         }
     }
     $trimmode = self::TRIM_LEFT;
     $trimlength = 50;
     if (!empty($this->config->trimmode)) {
         $trimmode = (int) $this->config->trimmode;
     }
     if (!empty($this->config->trimlength)) {
         $trimlength = (int) $this->config->trimlength;
     }
     // Initialise (only actually happens if it hasn't already been done yet
     $this->page->navigation->initialise();
     $navigation = clone $this->page->navigation;
     $expansionlimit = null;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
         $navigation->set_expansion_limit($this->config->expansionlimit);
     }
     $this->trim($navigation, $trimmode, $trimlength, ceil($trimlength / 2));
     // Get the expandable items so we can pass them to JS
     $expandable = array();
     $navigation->find_expandable($expandable);
     if ($expansionlimit) {
         foreach ($expandable as $key => $node) {
             if ($node['type'] > $expansionlimit && !($expansionlimit == navigation_node::TYPE_COURSE && $node['type'] == $expansionlimit && $node['branchid'] == SITEID)) {
                 unset($expandable[$key]);
             }
         }
     }
     $this->page->requires->data_for_js('navtreeexpansions' . $this->instance->id, $expandable);
     $options = array();
     $options['linkcategories'] = !empty($this->config->linkcategories) && $this->config->linkcategories == 'yes';
     // Grab the items to display
     $renderer = $this->page->get_renderer('block_navigation');
     $this->content = new stdClass();
     $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options);
     // Set content generated to true so that we know it has been done
     $this->contentgenerated = true;
     return $this->content;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:73,代码来源:block_navigation.php


示例8: reset_password_and_mail

/**
 * Resets specified user's password and send the new password to the user via email.
 *
 * @param stdClass $user A {@link $USER} object
 * @return bool Returns true if mail was sent OK and false if there was an error.
 */
function reset_password_and_mail($user)
{
    global $CFG;
    $site = get_site();
    $supportuser = core_user::get_support_user();
    $userauth = get_auth_plugin($user->auth);
    if (!$userauth->can_reset_password() or !is_enabled_auth($user->auth)) {
        trigger_error("Attempt to reset user password for user {$user->username} with Auth {$user->auth}.");
        return false;
    }
    $newpassword = generate_password();
    if (!$userauth->user_update_password($user, $newpassword)) {
        print_error("cannotsetpassword");
    }
    $a = new stdClass();
    $a->firstname = $user->firstname;
    $a->lastname = $user->lastname;
    $a->sitename = format_string($site->fullname);
    $a->username = $user->username;
    $a->newpassword = $newpassword;
    $a->link = $CFG->httpswwwroot . '/login/change_password.php';
    $a->signoff = generate_email_signoff();
    $message = get_string('newpasswordtext', '', $a);
    $subject = format_string($site->fullname) . ': ' . get_string('changedpassword');
    unset_user_preference('create_password', $user);
    // Prevent cron from generating the password.
    // Directly email rather than using the messaging system to ensure its not routed to a popup or jabber.
    return email_to_user($user, $supportuser, $subject, $message);
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:35,代码来源:moodlelib.php


示例9: print_error

    print_error('nocourseid');
}
require_login($course->id);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('gradereport/grader:view', $context);
require 'preferences_form.php';
$mform = new grader_report_preferences_form('preferences.php', compact('course'));
// If data submitted, then process and store.
if (!$mform->is_cancelled() && ($data = $mform->get_data())) {
    foreach ($data as $preference => $value) {
        if (substr($preference, 0, 6) !== 'grade_') {
            continue;
        }
        if ($value == GRADE_REPORT_PREFERENCE_DEFAULT || strlen($value) == 0) {
            unset_user_preference($preference);
        } else {
            set_user_preference($preference, $value);
        }
    }
    redirect($CFG->wwwroot . '/grade/report/grader/index.php?id=' . $courseid);
    // message here breaks accessability and is sloooowww
    exit;
}
if ($mform->is_cancelled()) {
    redirect($CFG->wwwroot . '/grade/report/grader/index.php?id=' . $courseid);
}
print_grade_page_head($courseid, 'preferences', 'grader', get_string('preferences', 'gradereport_grader'));
// If USER has admin capability, print a link to the site config page for this report
if (has_capability('moodle/site:config', $systemcontext)) {
    echo '<div id="siteconfiglink"><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=gradereportgrader">';
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:preferences.php


示例10: test_set_user_preference

 public function test_set_user_preference()
 {
     global $DB, $USER;
     if (!($otheruserid = $this->get_fake_preference_test_userid())) {
         $this->fail('Can not find unused user id for the preferences test');
         return;
     }
     $DB->delete_records('user_preferences', array('userid' => $otheruserid));
     set_cache_flag('userpreferenceschanged', $otheruserid, null);
     $user = new stdClass();
     $user->id = $otheruserid;
     set_user_preference('aaa', 'bbb', $otheruserid);
     $this->assertEqual('bbb', $DB->get_field('user_preferences', 'value', array('userid' => $otheruserid, 'name' => 'aaa')));
     $this->assertEqual('bbb', get_user_preferences('aaa', null, $otheruserid));
     set_user_preference('xxx', 'yyy', $user);
     $this->assertEqual('yyy', $DB->get_field('user_preferences', 'value', array('userid' => $otheruserid, 'name' => 'xxx')));
     $this->assertEqual('yyy', get_user_preferences('xxx', null, $otheruserid));
     $this->assertTrue(is_array($user->preference));
     $this->assertEqual($user->preference['aaa'], 'bbb');
     $this->assertEqual($user->preference['xxx'], 'yyy');
     set_user_preference('xxx', NULL, $user);
     $this->assertIdentical(false, $DB->get_field('user_preferences', 'value', array('userid' => $otheruserid, 'name' => 'xxx')));
     $this->assertIdentical(null, get_user_preferences('xxx', null, $otheruserid));
     set_user_preference('ooo', true, $user);
     $prefs = get_user_preferences(null, null, $otheruserid);
     $this->assertIdentical($prefs['aaa'], $user->preference['aaa']);
     $this->assertIdentical($prefs['ooo'], $user->preference['ooo']);
     $this->assertIdentical($prefs['ooo'], '1');
     set_user_preference('null', 0, $user);
     $this->assertIdentical('0', get_user_preferences('null', null, $otheruserid));
     $this->assertIdentical('lala', get_user_preferences('undefined', 'lala', $otheruserid));
     $DB->delete_records('user_preferences', array('userid' => $otheruserid));
     set_cache_flag('userpreferenceschanged', $otheruserid, null);
     // test $USER default
     set_user_preference('_test_user_preferences_pref', 'ok');
     $this->assertIdentical('ok', $USER->preference['_test_user_preferences_pref']);
     unset_user_preference('_test_user_preferences_pref');
     $this->assertTrue(!isset($USER->preference['_test_user_preferences_pref']));
     //test invalid params
     try {
         set_user_preference('_test_user_preferences_pref', array());
         $this->assertFail('Exception expected - array not valid preference value');
     } catch (Exception $ex) {
         $this->assertTrue(true);
     }
     try {
         set_user_preference('_test_user_preferences_pref', new stdClass());
         $this->assertFail('Exception expected - class not valid preference value');
     } catch (Exception $ex) {
         $this->assertTrue(true);
     }
     try {
         set_user_preference('_test_user_preferences_pref', 1, array('xx' => 1));
         $this->assertFail('Exception expected - user instance expected');
     } catch (Exception $ex) {
         $this->assertTrue(true);
     }
     try {
         set_user_preference('_test_user_preferences_pref', 1, 'abc');
         $this->assertFail('Exception expected - user instance expected');
     } catch (Exception $ex) {
         $this->assertTrue(true);
     }
     try {
         set_user_preference('', 1);
         $this->assertFail('Exception expected - invalid name accepted');
     } catch (Exception $ex) {
         $this->assertTrue(true);
     }
     try {
         set_user_preference('1', 1);
         $this->assertFail('Exception expected - invalid name accepted');
     } catch (Exception $ex) {
         $this->assertTrue(true);
     }
 }
开发者ID:richheath,项目名称:moodle,代码行数:76,代码来源:testmoodlelib.php


示例11: get_content

 /**
  * Gets the content for this block by grabbing it from $this->page
  *
  * @return object $this->content
  */
 function get_content()
 {
     // First check if we have already generated, don't waste cycles
     if ($this->contentgenerated === true) {
         return $this->content;
     }
     // JS for navigation moved to the standard theme, the code will probably have to depend on the actual page structure
     // $this->page->requires->js('/lib/javascript-navigation.js');
     // Navcount is used to allow us to have multiple trees although I dont' know why
     // you would want two trees the same
     block_navigation::$navcount++;
     // Check if this block has been docked
     if ($this->docked === null) {
         $this->docked = get_user_preferences('nav_in_tab_panel_globalnav' . block_navigation::$navcount, 0);
     }
     // Check if there is a param to change the docked state
     if ($this->docked && optional_param('undock', null, PARAM_INT) == $this->instance->id) {
         unset_user_preference('nav_in_tab_panel_globalnav' . block_navigation::$navcount);
         $url = $this->page->url;
         $url->remove_params(array('undock'));
         redirect($url);
     } else {
         if (!$this->docked && optional_param('dock', null, PARAM_INT) == $this->instance->id) {
             set_user_preferences(array('nav_in_tab_panel_globalnav' . block_navigation::$navcount => 1));
             $url = $this->page->url;
             $url->remove_params(array('dock'));
             redirect($url);
         }
     }
     $trimmode = self::TRIM_LEFT;
     $trimlength = 50;
     if (!empty($this->config->trimmode)) {
         $trimmode = (int) $this->config->trimmode;
     }
     if (!empty($this->config->trimlength)) {
         $trimlength = (int) $this->config->trimlength;
     }
     // Get the navigation object or don't display the block if none provided.
     if (!($navigation = $this->get_navigation())) {
         return null;
     }
     $expansionlimit = null;
     if (!empty($this->config->expansionlimit)) {
         $expansionlimit = $this->config->expansionlimit;
         $navigation->set_expansion_limit($this->config->expansionlimit);
     }
     $this->trim($navigation, $trimmode, $trimlength, ceil($trimlength / 2));
     // Get the expandable items so we can pass them to JS
     $expandable = array();
     $navigation->find_expandable($expandable);
     if ($expansionlimit) {
         foreach ($expandable as $key => $node) {
             if ($node['type'] > $expansionlimit && !($expansionlimit == navigation_node::TYPE_COURSE && $node['type'] == $expansionlimit && $node['branchid'] == SITEID)) {
                 unset($expandable[$key]);
             }
         }
     }
     $this->page->requires->data_for_js('navtreeexpansions' . $this->instance->id, $expandable);
     $options = array();
     $options['linkcategories'] = !empty($this->config->linkcategories) && $this->config->linkcategories == 'yes';
     // Grab the items to display
     $renderer = $this->page->get_renderer($this->blockname);
     $this->content = new stdClass();
     $this->content->text = $renderer->navigation_tree($navigation, $expansionlimit, $options);
     // Set content generated to true so that we know it has been done
     $this->contentgenerated = true;
     global $PAGE, $CFG;
     //sujets link
     if (has_capability('moodle/course:create', $PAGE->context)) {
         $this->content->text .= '<ul class="block_tree list><li class=" type_setting="" depth_1="" item_with_icon"="">';
         $this->content->text .= '<a href="' . $CFG->wwwroot . '/local/template_course/index.php">';
         $this->content->text .= '<img alt="" class="smallicon navicon" title="" src="' . $CFG->wwwroot . '/theme/image.php/formfactor/core/1404983571/i/navigationitem"/>';
         $this->content->text .= 'Matières</a></li></ul>';
     }
     return $this->content;
 }
开发者ID:helenagarcia90,项目名称:moodle-esi,代码行数:81,代码来源:block_navigation.php


示例12: 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


示例13: array

$mform->set_data(array('id'=>$course->id));

$navlinks = array();
$navlinks[] = array('name' => $strparticipants, 'link' => "$CFG->wwwroot/user/index.php?id=$course->id", 'type' => 'misc');

if ($mform->is_cancelled()) {
    redirect($CFG->wwwroot.'/user/view.php?id='.$USER->id.'&amp;course='.$course->id);
} else if ($data = $mform->get_data()) {

    if (!$userauth->user_update_password($USER, $data->newpassword1)) {
        print_error('errorpasswordupdate', 'auth');
    }

    // register success changing password
    unset_user_preference('auth_forcepasswordchange', $USER);
    unset_user_preference('create_password', $USER);

    $strpasswordchanged = get_string('passwordchanged');

    add_to_log($course->id, 'user', 'change password', "view.php?id=$USER->id&amp;course=$course->id", "$USER->id");

    $fullname = fullname($USER, true);

    $PAGE->navbar->add($fullname, new moodle_url('/user/view.php', array('id'=>$USER->id, 'course'=>$course->id)));
    $PAGE->navbar->add($strpasswordchanged);
    $PAGE->set_title($strpasswordchanged);
    $PAGE->set_heading($COURSE->fullname);
    echo $OUTPUT->header();

    notice($strpasswordchanged, new moodle_url($PAGE->url, array('return'=>1)));
开发者ID:JP-Git,项目名称:moodle,代码行数:30,代码来源:change_password.php


示例14: if

                    $forcechangepassword = false;
                } else if ($updatepasswords){
                    $existinguser->password = hash_internal_user_password($existinguser->password);
                } else {
                    $existinguser->password = $temppasswordhandler;
                }

                $DB->update_record('user', $existinguser);

                //remove user preference

                if (get_user_preferences('create_password', false, $existinguser)) {
                    unset_user_preference('create_password', $existinguser);
                }
                if (get_user_preferences('auth_forcepasswordchange', false, $existinguser)) {
                    unset_user_preference('auth_forcepasswordchange', $existinguser);
                }

                if ($isinternalauth && $updatepasswords) {
                    if (empty($existinguser->password)) {
                        set_user_preference('create_password', 1, $existinguser->id);
                        set_user_preference('auth_forcepasswordchange', 1, $existinguser->id);
                        $upt->track('password', get_string('new'));
                    } else if ($forcechangepassword) {
                        set_user_preference('auth_forcepasswordchange', 1, $existinguser->id);
                    }
                }
                $upt->track('status', $struserupdated);
                $usersupdated++;
                // save custom profile fields data from csv file
                profile_save_data($existinguser);
开发者ID:nuckey,项目名称:moodle,代码行数:31,代码来源:uploaduser.php


示例15: test_set_user_preference

    public function test_set_user_preference() {
        global $DB, $USER;
        $this->resetAfterTest(true);

        $olduser = $USER;
        $USER = $DB->get_record('user', array('id'=>2)); //admin

        if (!$otheruserid = $this->get_fake_preference_test_userid()) {
            $this->fail('Can not find unused user id for the preferences test');
            return;
        }

        $DB->delete_records('user_preferences', array('userid'=>$otheruserid));
        set_cache_flag('userpreferenceschanged', $otheruserid, null);

        $user = new stdClass();
        $user->id = $otheruserid;

        set_user_preference('aaa', 'bbb', $otheruserid);
        $this->assertEquals('bbb', $DB->get_field('user_preferences', 'value', array('userid'=>$otheruserid, 'name'=>'aaa')));
        $this->assertEquals('bbb', get_user_preferences('aaa', null, $otheruserid));

        set_user_preference('xxx', 'yyy', $user);
        $this->assertEquals('yyy', $DB->get_field('user_preferences', 'value', array('userid'=>$otheruserid, 'name'=>'xxx')));
        $this->assertEquals('yyy', get_user_preferences('xxx', null, $otheruserid));
        $this->assertTrue(is_array($user->preference));
        $this->assertEquals($user->preference['aaa'], 'bbb');
        $this->assertEquals($user->preference['xxx'], 'yyy');

        set_user_preference('xxx', NULL, $user);
        $this->assertSame(false, $DB->get_field('user_preferences', 'value', array('userid'=>$otheruserid, 'name'=>'xxx')));
        $this->assertSame(null, get_user_preferences('xxx', null, $otheruserid));

        set_user_preference('ooo', true, $user);
        $prefs = get_user_preferences(null, null, $otheruserid);
        $this->assertSame($prefs['aaa'], $user->preference['aaa']);
        $this->assertSame($prefs['ooo'], $user->preference['ooo']);
        $this->assertSame($prefs['ooo'], '1');

        set_user_preference('null', 0, $user);
        $this->assertSame('0', get_user_preferences('null', null, $otheruserid));

        $this->assertSame('lala', get_user_preferences('undefined', 'lala', $otheruserid));

        $DB->delete_records('user_preferences', array('userid'=>$otheruserid));
        set_cache_flag('userpreferenceschanged', $otheruserid, null);

        // test $USER default
        set_user_preference('_test_user_preferences_pref', 'ok');
        $this->assertSame('ok', $USER->preference['_test_user_preferences_pref']);
        unset_user_preference('_test_user_preferences_pref');
        $this->assertTrue(!isset($USER->preference['_test_user_preferences_pref']));

        // Test 1333 char values (no need for unicode, there are already tests for that in DB tests)
        $longvalue = str_repeat('a', 1333);
        set_user_preference('_test_long_user_preference', $longvalue);
        $this->assertEquals($longvalue, get_user_preferences('_test_long_user_preference'));
        $this->assertEquals($longvalue,
            $DB->get_field('user_preferences', 'value', array('userid' => $USER->id, 'name' => '_test_long_user_preference')));

        // Test > 1333 char values, coding_exception expected
        $longvalue = str_repeat('a', 1334);
        try {
            set_user_preference('_test_long_user_preference', $longvalue);
            $this->assertFail('Exception expected - longer than 1333 chars not allowed as preference value');
        } catch (Exception $e) {
            $this->assertTrue($e instanceof coding_exception);
        }

        //test invalid params
        try {
            set_user_preference('_test_user_preferences_pref', array());
            $this->assertFail('Exception expected - array not valid preference value');
        } catch (Exception $ex) {
            $this->assertTrue(true);
        }
        try {
            set_user_preference('_test_user_preferences_pref', new stdClass);
            $this->assertFail('Exception expected - class not valid preference value');
        } catch (Exception $ex) {
            $this->assertTrue(true);
        }
        try {
            set_user_preference('_test_user_preferences_pref', 1, array('xx'=>1));
            $this->assertFail('Exception expected - user instance expected');
        } catch (Exception $ex) {
            $this->assertTrue(true);
        }
        try {
            set_user_preference('_test_user_preferences_pref', 1, 'abc');
            $this->assertFail('Exception expected - user instance expected');
        } catch (Exception $ex) {
            $this->assertTrue(true);
        }
        try {
            set_user_preference('', 1);
            $this->assertFail('Exception expected - invalid name accepted');
        } catch (Exception $ex) {
            $this->assertTrue(true);
        }
//.........这里部分代码省略.........
开发者ID:netspotau,项目名称:moodle-mod_assign,代码行数:101,代码来源:moodlelib_test.php


示例16: set_pref

 /**
  * Uses set_user_preferences() to update the value of a user preference. If 'default' is given as the value,
  * the preference will be removed in favour of a higher-level preference.
  * @static
  * @param string $pref_name The name of the preference.
  * @param mixed $pref_value The value of the preference.
  * @param int $itemid An optional itemid to which the preference will be assigned
  * @return bool Success or failure.
  */
 public function set_pref($pref, $pref_value = 'default', $itemid = null)
 {
     $fullprefname = 'grade_report_' . $pref;
     if ($pref_value == 'default') {
         return unset_user_preference($fullprefname . $itemid);
     } else {
         return set_user_preference($fullprefname . $itemid, $pref_value);
     }
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:18,代码来源:lib.php


示例17: display

    /**
     * Display the report.
     */
    public function display($quiz, $cm, $course) {
        global $CFG, $DB, $OUTPUT, $PAGE;

        $this->context = context_module::instance($cm->id);

        // Work out the display options.
        $download = optional_param('download', '', PARAM_ALPHA);
        $everything = optional_param('everything', 0, PARAM_BOOL);
        $recalculate = optional_param('recalculate', 0, PARAM_BOOL);
        // A qid paramter indicates we should display the detailed analysis of a question.
        $qid = optional_param('qid', 0, PARAM_INT);
        $slot = optional_param('slot', 0, PARAM_INT);

        $pageoptions = array();
        $pageoptions['id'] = $cm->id;
        $pageoptions['mode'] = 'statistics';

        $reporturl = new moodle_url('/mod/quiz/report.php', $pageoptions);

        $mform = new quiz_statistics_settings_form($reporturl);
        if ($fromform = $mform->get_data()) {
            $useallattempts = $fromform->useallattempts;
            if ($fromform->useallattempts) {
                set_user_preference('quiz_report_statistics_useallattempts',
                        $fromform->useallattempts);
            } else {
        

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP unslash函数代码示例发布时间:2022-05-23
下一篇:
PHP unset_global函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap