mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-22 01:17:42 +02:00
Role: Add param $cascadeUpwards
also to public method grant()
This commit is contained in:
parent
c203ffdd79
commit
ab90b3e0a1
@ -253,19 +253,20 @@ class Role
|
|||||||
*
|
*
|
||||||
* @param string $permission
|
* @param string $permission
|
||||||
* @param bool $ignoreParent Only evaluate the role's own permissions
|
* @param bool $ignoreParent Only evaluate the role's own permissions
|
||||||
|
* @param bool $cascadeUpwards `false` if `foo/bar/*` and `foo/bar/raboof` should not match `foo/*`
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function grants($permission, $ignoreParent = false)
|
public function grants($permission, $ignoreParent = false, $cascadeUpwards = true)
|
||||||
{
|
{
|
||||||
foreach ($this->permissions as $grantedPermission) {
|
foreach ($this->permissions as $grantedPermission) {
|
||||||
if ($this->match($grantedPermission, $permission)) {
|
if ($this->match($grantedPermission, $permission, $cascadeUpwards)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $ignoreParent && $this->getParent() !== null) {
|
if (! $ignoreParent && $this->getParent() !== null) {
|
||||||
return $this->getParent()->grants($permission);
|
return $this->getParent()->grants($permission, false, $cascadeUpwards);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user