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

PHP get_role_access函数代码示例

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

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



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

示例1: get_user_accessdata

/**
 * Get accessdata for a given user.
 *
 * @private
 * @param int $userid
 * @param bool $preloadonly true means do not return access array
 * @return array accessdata
 */
function get_user_accessdata($userid, $preloadonly = false)
{
    global $CFG, $ACCESSLIB_PRIVATE, $USER;
    if (!empty($USER->acces['rdef']) and empty($ACCESSLIB_PRIVATE->rolepermissions)) {
        // share rdef from USER session with rolepermissions cache in order to conserve memory
        foreach ($USER->acces['rdef'] as $k => $v) {
            $ACCESSLIB_PRIVATE->rolepermissions[$k] =& $USER->acces['rdef'][$k];
        }
        $ACCESSLIB_PRIVATE->accessdatabyuser[$USER->id] = $USER->acces;
    }
    if (!isset($ACCESSLIB_PRIVATE->accessdatabyuser[$userid])) {
        if (empty($userid)) {
            if (!empty($CFG->notloggedinroleid)) {
                $accessdata = get_role_access($CFG->notloggedinroleid);
            } else {
                // weird
                return get_empty_accessdata();
            }
        } else {
            if (isguestuser($userid)) {
                if ($guestrole = get_guest_role()) {
                    $accessdata = get_role_access($guestrole->id);
                } else {
                    //weird
                    return get_empty_accessdata();
                }
            } else {
                $accessdata = get_user_access_sitewide($userid);
                // includes default role and frontpage role
            }
        }
        $ACCESSLIB_PRIVATE->accessdatabyuser[$userid] = $accessdata;
    }
    if ($preloadonly) {
        return;
    } else {
        return $ACCESSLIB_PRIVATE->accessdatabyuser[$userid];
    }
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:47,代码来源:accesslib.php


示例2: test_get_role_access

 /**
  * Test getting of role access
  */
 public function test_get_role_access()
 {
     global $DB;
     $roles = $DB->get_records('role');
     foreach ($roles as $role) {
         $access = get_role_access($role->id);
         $this->assertTrue(is_array($access));
         $this->assertTrue(is_array($access['ra']));
         $this->assertTrue(is_array($access['rdef']));
         $this->assertTrue(isset($access['rdef_count']));
         $this->assertTrue(is_array($access['loaded']));
         $this->assertTrue(isset($access['time']));
         $this->assertTrue(is_array($access['rsw']));
     }
     // Note: the data is validated in the functional permission evaluation test at the end of this testcase.
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:19,代码来源:accesslib_test.php


示例3: load_all_capabilities

/**
 *  A convenience function to completely load all the capabilities
 *  for the current user.   This is what gets called from complete_user_login()
 *  for example. Call it only _after_ you've setup $USER and called
 *  check_enrolment_plugins();
 *
 */
function load_all_capabilities()
{
    global $USER, $CFG, $ACCESSLIB_PRIVATE;
    // roles not installed yet - we are in the middle of installation
    if (empty($CFG->rolesactive)) {
        return;
    }
    $base = '/' . SYSCONTEXTID;
    if (isguestuser()) {
        $guest = get_guest_role();
        // Load the rdefs
        $USER->access = get_role_access($guest->id);
        // Put the ghost enrolment in place...
        $USER->access['ra'][$base] = array($guest->id);
    } else {
        if (isloggedin()) {
            $accessdata = get_user_access_sitewide($USER->id);
            //
            // provide "default role" & set 'dr'
            //
            if (!empty($CFG->defaultuserroleid)) {
                $accessdata = get_role_access($CFG->defaultuserroleid, $accessdata);
                if (!isset($accessdata['ra'][$base])) {
                    $accessdata['ra'][$base] = array($CFG->defaultuserroleid);
                } else {
                    array_push($accessdata['ra'][$base], $CFG->defaultuserroleid);
                }
                $accessdata['dr'] = $CFG->defaultuserroleid;
            }
            $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
            //
            // provide "default frontpage role"
            //
            if (!empty($CFG->defaultfrontpageroleid)) {
                $base = '/' . SYSCONTEXTID . '/' . $frontpagecontext->id;
                $accessdata = get_default_frontpage_role_access($CFG->defaultfrontpageroleid, $accessdata);
                if (!isset($accessdata['ra'][$base])) {
                    $accessdata['ra'][$base] = array($CFG->defaultfrontpageroleid);
                } else {
                    array_push($accessdata['ra'][$base], $CFG->defaultfrontpageroleid);
                }
            }
            $USER->access = $accessdata;
        } else {
            if (!empty($CFG->notloggedinroleid)) {
                $USER->access = get_role_access($CFG->notloggedinroleid);
                $USER->access['ra'][$base] = array($CFG->notloggedinroleid);
            }
        }
    }
    // Timestamp to read dirty context timestamps later
    $USER->access['time'] = time();
    $ACCESSLIB_PRIVATE->dirtycontexts = array();
    // Clear to force a refresh
    unset($USER->mycourses);
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:63,代码来源:accesslib.php


示例4: get_role_access

// This duplicates code in load_all_capabilities and has_capability.
$systempath = '/' . SYSCONTEXTID;
if ($userid == 0) {
    if (!empty($CFG->notloggedinroleid)) {
        $accessdata = get_role_access($CFG->notloggedinroleid);
        $accessdata['ra'][$systempath] = array($CFG->notloggedinroleid);
    } else {
        $accessdata = array();
        $accessdata['ra'] = array();
        $accessdata['rdef'] = array();
        $accessdata['loaded'] = array();
    }
} else {
    if (isguestuser($user)) {
        $guestrole = get_guest_role();
        $accessdata = get_role_access($guestrole->id);
        $accessdata['ra'][$systempath] = array($guestrole->id);
    } else {
        load_user_accessdata($userid);
        $accessdata = $ACCESS[$userid];
    }
}
if ($context->contextlevel > CONTEXT_COURSE && !path_inaccessdata($context->path, $accessdata)) {
    load_subcontext($userid, $context, $accessdata);
}
// Load the roles we need.
$roleids = array();
foreach ($accessdata['ra'] as $roleassignments) {
    $roleids = array_merge($roleassignments, $roleids);
}
$roles = get_records_list('role', 'id', $roleids);
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:explainhascapabiltiy.php


示例5: load_all_capabilities

/**
 * A convenience function to completely load all the capabilities
 * for the current user.   This is what gets called from complete_user_login()
 * for example. Call it only _after_ you've setup $USER and called
 * check_enrolment_plugins();
 * @see check_enrolment_plugins()
 *
 * @return void
 */
function load_all_capabilities()
{
    global $CFG, $ACCESSLIB_PRIVATE;
    //NOTE: we can not use $USER here because it may no be linked to $_SESSION['USER'] yet!
    // roles not installed yet - we are in the middle of installation
    if (during_initial_install()) {
        return;
    }
    $base = '/' . SYSCONTEXTID;
    if (isguestuser($_SESSION['USER'])) {
        $guest = get_guest_role();
        // Load the rdefs
        $_SESSION['USER']->access = get_role_access($guest->id);
        // Put the ghost enrolment in place...
        $_SESSION['USER']->access['ra'][$base] = array($guest->id => $guest->id);
    } else {
        if (!empty($_SESSION['USER']->id)) {
            // can not use isloggedin() yet
            $accessdata = get_user_access_sitewide($_SESSION['USER']->id);
            //
            // provide "default role" & set 'dr'
            //
            if (!empty($CFG->defaultuserroleid)) {
                $accessdata = get_role_access($CFG->defaultuserroleid, $accessdata);
                if (!isset($accessdata['ra'][$base])) {
                    $accessdata['ra'][$base] = array();
                }
                $accessdata['ra'][$base][$CFG->defaultuserroleid] = $CFG->defaultuserroleid;
                $accessdata['dr'] = $CFG->defaultuserroleid;
            }
            $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
            //
            // provide "default frontpage role"
            //
            if (!empty($CFG->defaultfrontpageroleid)) {
                $base = '/' . SYSCONTEXTID . '/' . $frontpagecontext->id;
                $accessdata = get_default_frontpage_role_access($CFG->defaultfrontpageroleid, $accessdata);
                if (!isset($accessdata['ra'][$base])) {
                    $accessdata['ra'][$base] = array();
                }
                $accessdata['ra'][$base][$CFG->defaultfrontpageroleid] = $CFG->defaultfrontpageroleid;
            }
            $_SESSION['USER']->access = $accessdata;
        } else {
            if (!empty($CFG->notloggedinroleid)) {
                $_SESSION['USER']->access = get_role_access($CFG->notloggedinroleid);
                $_SESSION['USER']->access['ra'][$base] = array($CFG->notloggedinroleid => $CFG->notloggedinroleid);
            }
        }
    }
    // Timestamp to read dirty context timestamps later
    $_SESSION['USER']->access['time'] = time();
    $ACCESSLIB_PRIVATE->dirtycontexts = array();
    // Clear to force a refresh
    unset($_SESSION['USER']->mycourses);
}
开发者ID:LMSeXT,项目名称:SAWEE-WS_server-lib,代码行数:65,代码来源:accesslib.php


示例6: load_all_capabilities

/**
 *  A convenience function to completely load all the capabilities 
 *  for the current user.   This is what gets called from login, for example.
 */
function load_all_capabilities()
{
    global $USER, $CFG;
    $base = '/' . SYSCONTEXTID;
    if (isguestuser()) {
        $guest = get_guest_role();
        // Load the rdefs
        $USER->access = get_role_access($guest->id);
        // Put the ghost enrolment in place...
        $USER->access['ra'][$base] = array($guest->id);
    } else {
        if (isloggedin()) {
            check_enrolment_plugins($USER);
            $accessdata = get_user_access_sitewide($USER->id);
            //
            // provide "default role" & set 'dr'
            //
            if (!empty($CFG->defaultuserroleid)) {
                $accessdata = get_role_access($CFG->defaultuserroleid, $accessdata);
                if (!isset($accessdata['ra'][$base])) {
                    $accessdata['ra'][$base] = array($CFG->defaultuserroleid);
                } else {
                    array_push($accessdata['ra'][$base], $CFG->defaultuserroleid);
                }
                $accessdata['dr'] = $CFG->defaultuserroleid;
            }
            $frontpagecontext = get_context_instance(CONTEXT_COURSE, SITEID);
            //
            // provide "default frontpage role"
            //
            if (!empty($CFG->defaultfrontpageroleid)) {
                $base = '/' . SYSCONTEXTID . '/' . $frontpagecontext->id;
                $accessdata = get_default_frontpage_role_access($CFG->defaultfrontpageroleid, $accessdata);
                if (!isset($accessdata['ra'][$base])) {
                    $accessdata['ra'][$base] = array($CFG->defaultfrontpageroleid);
                } else {
                    array_push($accessdata['ra'][$base], $CFG->defaultfrontpageroleid);
                }
            }
            $USER->access = $accessdata;
        } else {
            if (!empty($CFG->notloggedinroleid)) {
                $USER->access = get_role_access($CFG->notloggedinroleid);
                $USER->access['ra'][$base] = array($CFG->notloggedinroleid);
            }
        }
    }
    // Timestamp to read
    // dirty context timestamps
    $USER->access['time'] = time();
    // Clear to force a refresh
    unset($USER->mycourses);
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:57,代码来源:accesslib.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP get_role_archetypes函数代码示例发布时间:2022-05-15
下一篇:
PHP get_role函数代码示例发布时间: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