mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
updating Acl, should fix #2733
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5273 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
dad80d947d
commit
335a384613
1 changed files with 18 additions and 9 deletions
|
@ -313,7 +313,7 @@ class DB_ACL extends AclBase {
|
|||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function allow($aro, $aco, $action = "*", $value = 1) {
|
||||
function allow($aro, $aco, $actions = "*", $value = 1) {
|
||||
$perms = $this->getAclLink($aro, $aco);
|
||||
$permKeys = $this->_getAcoKeys($this->Aro->Permission->loadInfo());
|
||||
$save = array();
|
||||
|
@ -327,28 +327,37 @@ class DB_ACL extends AclBase {
|
|||
$save = $perms[0]['Permission'];
|
||||
}
|
||||
|
||||
if ($action == "*") {
|
||||
if ($actions == "*") {
|
||||
$permKeys = $this->_getAcoKeys($this->Aro->Permission->loadInfo());
|
||||
|
||||
foreach($permKeys as $key) {
|
||||
$save[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
if (in_array('_' . $action, $permKeys)) {
|
||||
$save['_' . $action] = $value;
|
||||
} else {
|
||||
trigger_error(__('DB_ACL::allow() - Invalid ACO action', true), E_USER_WARNING);
|
||||
return false;
|
||||
if(!is_array($actions)) {
|
||||
$actions = array('_' . $action);
|
||||
$actions = am($permKeys, $actions);
|
||||
}
|
||||
if(is_array($actions)) {
|
||||
foreach($actions as $action) {
|
||||
if ($action{0} != '_') {
|
||||
$action = '_' . $action;
|
||||
}
|
||||
if (in_array($action, $permKeys)) {
|
||||
$save[$action] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$save['aro_id'] = $perms['aro'];
|
||||
$save['aco_id'] = $perms['aco'];
|
||||
|
||||
if ($perms['link'] != null && count($perms['link']) > 0) {
|
||||
$save['id'] = $perms['link'][0]['Permission']['id'];
|
||||
}
|
||||
return $this->Aro->Permission->save(array('Permission' => $save));
|
||||
$this->Aro->Permission->create($save);
|
||||
return $this->Aro->Permission->save();
|
||||
}
|
||||
/**
|
||||
* Deny
|
||||
|
|
Loading…
Add table
Reference in a new issue