当前位置: 首页>>代码示例>>PHP>>正文


PHP mark_user_preferences_changed函数代码示例

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


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

示例1: test_mark_user_preferences_changed

 public function test_mark_user_preferences_changed()
 {
     $this->resetAfterTest();
     $otheruser = $this->getDataGenerator()->create_user();
     $otheruserid = $otheruser->id;
     set_cache_flag('userpreferenceschanged', $otheruserid, null);
     mark_user_preferences_changed($otheruserid);
     $this->assertEquals(get_cache_flag('userpreferenceschanged', $otheruserid, time() - 10), 1);
     set_cache_flag('userpreferenceschanged', $otheruserid, null);
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:10,代码来源:moodlelib_test.php

示例2: test_mark_user_preferences_changed

 public function test_mark_user_preferences_changed()
 {
     if (!($otheruserid = $this->get_fake_preference_test_userid())) {
         $this->fail('Can not find unused user id for the preferences test');
         return;
     }
     set_cache_flag('userpreferenceschanged', $otheruserid, NULL);
     mark_user_preferences_changed($otheruserid);
     $this->assertEqual(get_cache_flag('userpreferenceschanged', $otheruserid, time() - 10), 1);
     set_cache_flag('userpreferenceschanged', $otheruserid, NULL);
 }
开发者ID:richheath,项目名称:moodle,代码行数:11,代码来源:testmoodlelib.php

示例3: unset_user_preference

/**
 * Unsets a preference completely by deleting it from the database
 *
 * If a $user object is submitted it's 'preference' property is used for the preferences cache.
 *
 * @package  core
 * @category preference
 * @access   public
 * @param    string            $name The key to unset as preference for the specified user
 * @param    stdClass|int|null $user A moodle user object or id, null means current user
 * @throws   coding_exception
 * @return   bool                    Always true or exception
 */
function unset_user_preference($name, $user = null)
{
    global $USER, $DB;
    if (empty($name) or is_numeric($name) or $name === '_lastloaded') {
        throw new coding_exception('Invalid preference name in unset_user_preference() call');
    }
    if (is_null($user)) {
        $user = $USER;
    } else {
        if (isset($user->id)) {
            // It is a valid object.
        } else {
            if (is_numeric($user)) {
                $user = (object) array('id' => (int) $user);
            } else {
                throw new coding_exception('Invalid $user parameter in unset_user_preference() call');
            }
        }
    }
    check_user_preferences_loaded($user);
    if (empty($user->id) or isguestuser($user->id)) {
        // No permanent storage for not-logged-in user and guest.
        unset($user->preference[$name]);
        return true;
    }
    // Delete from DB.
    $DB->delete_records('user_preferences', array('userid' => $user->id, 'name' => $name));
    // Delete the preference from cache.
    unset($user->preference[$name]);
    // Set reload flag for other sessions.
    mark_user_preferences_changed($user->id);
    return true;
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:46,代码来源:moodlelib.php

示例4: unset_user_preference

/**
 * Unsets a preference completely by deleting it from the database
 *
 * Optionally, can set a preference for a different user id
 *
 * @global object
 * @param string  $name The key to unset as preference for the specified user
 * @param int $otheruserid A moodle user ID
 */
function unset_user_preference($name, $otheruserid = NULL)
{
    global $USER, $DB;
    if (empty($otheruserid)) {
        $userid = $USER->id;
        check_user_preferences_loaded();
    } else {
        $userid = $otheruserid;
    }
    //Then from DB
    $DB->delete_records('user_preferences', array('userid' => $userid, 'name' => $name));
    mark_user_preferences_changed($userid);
    //Delete the preference from $USER if needed
    if ($userid == $USER->id) {
        unset($USER->preference[$name]);
        $USER->preference['_lastloaded'] = time();
    }
    return true;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:28,代码来源:moodlelib.php


注:本文中的mark_user_preferences_changed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。