本文整理汇总了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];
}
示例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);
}
}
示例3: load_parent_permissions
protected function load_parent_permissions()
{
$this->parentpermissions = get_default_capabilities($this->role->archetype);
}
示例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);
}
}
}
示例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();
}
}