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

PHP get_user_accessdata函数代码示例

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

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



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

示例1: load_all_capabilities

/**
 * A convenience function to completely load all the capabilities
 * for the current user. It is called from has_capability() and functions change permissions.
 *
 * Call it only _after_ you've setup $USER and called check_enrolment_plugins();
 * @see check_enrolment_plugins()
 *
 * @private
 * @return void
 */
function load_all_capabilities()
{
    global $USER;
    // roles not installed yet - we are in the middle of installation
    if (during_initial_install()) {
        return;
    }
    if (!isset($USER->id)) {
        // this should not happen
        $USER->id = 0;
    }
    unset($USER->access);
    $USER->access = get_user_accessdata($USER->id);
    // deduplicate the overrides to minimize session size
    dedupe_user_access();
    // Clear to force a refresh
    unset($USER->mycourses);
    // init/reset internal enrol caches - active course enrolments and temp access
    $USER->enrol = array('enrolled' => array(), 'tempguest' => array());
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:30,代码来源:accesslib.php


示例2: test_getallowedclusterswithparentpermission

 /**
  * Test whether a user can enrol users into a sub-userset if they have the required capability on the
  * parent userset.
  */
 public function test_getallowedclusterswithparentpermission()
 {
     global $DB;
     $this->load_csv_data();
     // Create role with cap: 'local/elisprogram:class_view'.
     $testrole = new stdClass();
     $testrole->name = 'ELIS Sub-Userset Manager';
     $testrole->shortname = '_test_ELIS_3848';
     $testrole->description = 'ELIS userset enrol into sub-userser';
     $testrole->archetype = '';
     $testrole->id = create_role($testrole->name, $testrole->shortname, $testrole->description, $testrole->archetype);
     // Ensure our new role is assignable to ELIS class contexts.
     set_role_contextlevels($testrole->id, array(CONTEXT_ELIS_USERSET));
     // Ensure the role has our required capability assigned.
     $syscontext = context_system::instance();
     assign_capability('local/elisprogram:userset', CAP_ALLOW, $testrole->id, $syscontext->id, true);
     assign_capability('local/elisprogram:userset_view', CAP_ALLOW, $testrole->id, $syscontext->id, true);
     assign_capability('local/elisprogram:userset_create', CAP_ALLOW, $testrole->id, $syscontext->id, true);
     assign_capability('local/elisprogram:userset_enrol_userset_user', CAP_ALLOW, $testrole->id, $syscontext->id, true);
     $syscontext->mark_dirty();
     // Assign a test user a role within the parent userset.
     $context = \local_elisprogram\context\userset::instance(1);
     role_assign($testrole->id, 100, $context->id);
     // Assign a test user a role within the sub-sub-userset.
     $ctx2 = \local_elisprogram\context\userset::instance(4);
     role_assign($testrole->id, 100, $ctx2->id);
     // Switch to testuser.
     $USER = $DB->get_record('user', array('id' => 100));
     $USER->access = get_user_accessdata($USER->id);
     load_role_access_by_context($testrole->id, $context, $USER->access);
     // We need to force the accesslib cache to refresh.
     $GLOBALS['USER'] = $USER;
     // Check which of the parent usersets the user has access to based on the sub-userset.
     $allowed = userset::get_allowed_clusters(2);
     $this->assertInternalType('array', $allowed);
     $this->assertEquals(1, count($allowed));
     // Check which of the parent usersets the user has access to basdd on the sub-sub-userset.
     $allowed = userset::get_allowed_clusters(4);
     $this->assertInternalType('array', $allowed);
     $this->assertEquals(2, count($allowed));
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:45,代码来源:userset_test.php


示例3: inituser

 /**
  * Initialize a new user description object
  */
 protected function inituser()
 {
     global $CFG, $DB, $USER;
     $data = array('idnumber' => '__fcH__TESTID001__', 'username' => '__fcH__testuser1__', 'firstname' => 'Test', 'lastname' => 'User1', 'email' => '[email protected]', 'country' => 'us');
     $newuser = new user($data);
     $newuser->save();
     $this->tuserid = $newuser->id;
     $usernew = new stdClass();
     $usernew->username = '__fcH__testuser__';
     $usernew->idnumber = '__fcH__testuser__';
     $usernew->firstname = 'Test';
     $usernew->lastname = 'User';
     $usernew->email = '[email protected]';
     $usernew->confirmed = 1;
     $usernew->auth = 'manual';
     $usernew->mnethostid = $CFG->mnet_localhost_id;
     $usernew->confirmed = 1;
     $usernew->timecreated = time();
     $usernew->password = hash_internal_user_password('testpassword');
     $this->mdluserid = $DB->insert_record('user', $usernew);
     // Setup the global user to be this new test user we have created.
     $USER = $DB->get_record('user', array('id' => $this->mdluserid));
     $USER->access = get_user_accessdata($USER->id);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:27,代码来源:fakecontexthierarchy_test.php


示例4: load_all_capabilities

/**
 * A convenience function to completely load all the capabilities
 * for the current user. It is called from has_capability() and functions change permissions.
 *
 * Call it only _after_ you've setup $USER and called check_enrolment_plugins();
 * @see check_enrolment_plugins()
 *
 * @private
 * @return void
 */
function load_all_capabilities()
{
    global $USER;
    // roles not installed yet - we are in the middle of installation
    if (during_initial_install()) {
        return;
    }
    if (!isset($USER->id)) {
        // this should not happen
        $USER->id = 0;
    }
    unset($USER->access);
    $USER->access = get_user_accessdata($USER->id);
    // deduplicate the overrides to minimize session size
    dedupe_user_access();
    // Clear to force a refresh
    unset($USER->mycourses);
    unset($USER->enrol);
}
开发者ID:rosenclever,项目名称:moodle,代码行数:29,代码来源:accesslib.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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