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


PHP get_default_capabilities函数代码示例

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


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

示例1: tool_editrolesbycap_get_default_permission

function tool_editrolesbycap_get_default_permission($role, $capability)
{
    static $cache = array();
    if (empty($role->archetype)) {
        return CAP_INHERIT;
    }
    if (isset($cache[$capability->name][$role->archetype])) {
        return $cache[$capability->name][$role->archetype];
    }
    $defaults = get_default_capabilities($role->archetype);
    if (isset($defaults[$capability->name])) {
        $cache[$capability->name][$role->archetype] = $defaults[$capability->name];
    } else {
        $cache[$capability->name][$role->archetype] = CAP_INHERIT;
    }
    return $cache[$capability->name][$role->archetype];
}
开发者ID:Keneth1212,项目名称:moodle,代码行数:17,代码来源:locallib.php

示例2: reset_role_capabilities

/**
 * Reset role capabilities to default according to selected role archetype.
 * If no archetype selected, removes all capabilities.
 *
 * @param int $roleid
 * @return void
 */
function reset_role_capabilities($roleid)
{
    global $DB;
    $role = $DB->get_record('role', array('id' => $roleid), '*', MUST_EXIST);
    $defaultcaps = get_default_capabilities($role->archetype);
    $systemcontext = context_system::instance();
    $DB->delete_records('role_capabilities', array('roleid' => $roleid));
    foreach ($defaultcaps as $cap => $permission) {
        assign_capability($cap, $permission, $roleid, $systemcontext->id);
    }
}
开发者ID:rolandovanegas,项目名称:moodle,代码行数:18,代码来源:accesslib.php

示例3: load_parent_permissions

 protected function load_parent_permissions()
 {
     $this->parentpermissions = get_default_capabilities($this->role->archetype);
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:4,代码来源:lib.php

示例4: reset_role_capabilities

/**
 * Reset role capabilitites to default according to selected legacy capability.
 * If several legacy caps selected, use the first from get_default_capabilities.
 * If no legacy selected, removes all capabilities.
 *
 * @param int @roleid
 */
function reset_role_capabilities($roleid)
{
    global $DB;
    $sitecontext = get_context_instance(CONTEXT_SYSTEM);
    $legacyroles = get_legacy_roles();
    $defaultcaps = array();
    foreach ($legacyroles as $ltype => $lcap) {
        $localoverride = get_local_override($roleid, $sitecontext->id, $lcap);
        if (!empty($localoverride->permission) and $localoverride->permission == CAP_ALLOW) {
            //choose first selected legacy capability
            $defaultcaps = get_default_capabilities($ltype);
            break;
        }
    }
    $DB->delete_records('role_capabilities', array('roleid' => $roleid));
    if (!empty($defaultcaps)) {
        foreach ($defaultcaps as $cap => $permission) {
            assign_capability($cap, $permission, $roleid, $sitecontext->id);
        }
    }
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:28,代码来源:accesslib.php

示例5: load_parent_permissions

 protected function load_parent_permissions()
 {
     if ($this->role->legacytype) {
         $this->parentpermissions = get_default_capabilities($this->role->legacytype);
     } else {
         $this->parentpermissions = array();
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:8,代码来源:lib.php


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