mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -102,6 +102,24 @@ trait PermissionHandlingTrait
|
|||
++$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.
|
||||
*
|
||||
|
|
@ -142,8 +160,8 @@ trait PermissionHandlingTrait
|
|||
) : bool {
|
||||
$app = $app !== null ? \strtolower($app) : $app;
|
||||
|
||||
for ($i = 0; $i < $this->pLength; ++$i) {
|
||||
if ($this->permissions[$i]->hasPermission($permission, $unit, $app, $module, $type, $element, $component)) {
|
||||
foreach ($this->permissions as $p) {
|
||||
if ($p->hasPermission($permission, $unit, $app, $module, $type, $element, $component)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user