mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-10 14:08:40 +00:00
fixes #200
This commit is contained in:
parent
3c8a8c31d5
commit
d0d77c9b9b
|
|
@ -416,6 +416,26 @@ class PermissionAbstract implements \JsonSerializable
|
||||||
&& ($this->permission | $permission) === $this->permission;
|
&& ($this->permission | $permission) === $this->permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is equals.
|
||||||
|
*
|
||||||
|
* @param self $permission Permission
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the permission is the same
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function isEqual(self $permission) : bool
|
||||||
|
{
|
||||||
|
return $this->unit === $permission->getUnit()
|
||||||
|
&& $this->app === $permission->getApp()
|
||||||
|
&& $this->module === $permission->getModule()
|
||||||
|
&& $this->type === $permission->getType()
|
||||||
|
&& $this->element === $permission->getElement()
|
||||||
|
&& $this->component === $permission->getComponent()
|
||||||
|
&& $this->permission === $permission->getPermission();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,24 @@ trait PermissionHandlingTrait
|
||||||
++$this->pLength;
|
++$this->pLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove permission.
|
||||||
|
*
|
||||||
|
* @param PermissionAbstract $permission Permission to remove
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public function removePermission(PermissionAbstract $permission) : void
|
||||||
|
{
|
||||||
|
foreach ($this->permissions as $key => $p) {
|
||||||
|
if ($p->isEqual($permission)) {
|
||||||
|
unset($this->permission[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get permissions.
|
* Get permissions.
|
||||||
*
|
*
|
||||||
|
|
@ -142,8 +160,8 @@ trait PermissionHandlingTrait
|
||||||
) : bool {
|
) : bool {
|
||||||
$app = $app !== null ? \strtolower($app) : $app;
|
$app = $app !== null ? \strtolower($app) : $app;
|
||||||
|
|
||||||
for ($i = 0; $i < $this->pLength; ++$i) {
|
foreach ($this->permissions as $p) {
|
||||||
if ($this->permissions[$i]->hasPermission($permission, $unit, $app, $module, $type, $element, $component)) {
|
if ($p->hasPermission($permission, $unit, $app, $module, $type, $element, $component)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user