本文整理汇总了PHP中Authority::has_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Authority::has_all方法的具体用法?PHP Authority::has_all怎么用?PHP Authority::has_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Authority
的用法示例。
在下文中一共展示了Authority::has_all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_rules
/**
* @param $user
*
*/
protected static function set_rules($user)
{
// Always get again the rules
// To comment if rules should be placed in session
// (will need logout / login) to set new rules.
// self::on_logout();
// Rules : From Session
if (self::$session->userdata('authority_rules')) {
$rules = self::$session->userdata('authority_rules');
} else {
// Models
self::$ci->load->model(array('role_model', 'rule_model'), '', TRUE);
// Roles rules
$rules = self::$ci->rule_model->get_from_role($user->get_role());
// To Session
self::$session->set_userdata('authority_rules', $rules);
}
// Check for Super Admin role
foreach ($rules as $rule) {
if ($rule['resource'] == 'all') {
self::$has_all = TRUE;
Authority::allow('manage', 'all');
break;
}
}
// Other role
if (!self::$has_all) {
foreach ($rules as $rule) {
// Read action
$rule['permission'] == 1 ? Authority::allow('access', $rule['resource']) : Authority::deny('access', $rule['resource']);
// Other actions
if (!empty($rule['actions'])) {
$actions = explode(',', $rule['actions']);
foreach ($actions as $action) {
$rule['permission'] == 1 ? Authority::allow($action, $rule['resource']) : Authority::deny($action, $rule['resource']);
}
}
}
}
}