diff --git a/Models/AccountPermission.php b/Models/AccountPermission.php index 7533f79..f584335 100644 --- a/Models/AccountPermission.php +++ b/Models/AccountPermission.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Modules\Admin\Models; +use phpOMS\Account\PermissionAbstract; + /** * InfoManager class. * diff --git a/Models/GroupPermission.php b/Models/GroupPermission.php index 20cb8ed..b7cd650 100644 --- a/Models/GroupPermission.php +++ b/Models/GroupPermission.php @@ -14,6 +14,8 @@ declare(strict_types=1); namespace Modules\Admin\Models; +use phpOMS\Account\PermissionAbstract; + /** * InfoManager class. * diff --git a/Models/GroupPermissionMapper.php b/Models/GroupPermissionMapper.php index 06503a7..f980a42 100644 --- a/Models/GroupPermissionMapper.php +++ b/Models/GroupPermissionMapper.php @@ -30,7 +30,7 @@ class GroupPermissionMapper extends DataMapperAbstract 'group_permission_id' => ['name' => 'group_permission_id', 'type' => 'int', 'internal' => 'id'], 'group_permission_group' => ['name' => 'group_permission_group', 'type' => 'int', 'internal' => 'group'], 'group_permission_unit' => ['name' => 'group_permission_unit', 'type' => 'int', 'internal' => 'unit'], - 'group_permission_app' => ['name' => 'group_permission_app', 'type' => 'int', 'internal' => 'app'], + 'group_permission_app' => ['name' => 'group_permission_app', 'type' => 'string', 'internal' => 'app'], 'group_permission_module' => ['name' => 'group_permission_module', 'type' => 'int', 'internal' => 'module'], 'group_permission_from' => ['name' => 'group_permission_from', 'type' => 'int', 'internal' => 'from'], 'group_permission_type' => ['name' => 'group_permission_type', 'type' => 'int', 'internal' => 'type'], diff --git a/Models/PermissionAbstract.php b/Models/PermissionAbstract.php deleted file mode 100644 index 7d395cf..0000000 --- a/Models/PermissionAbstract.php +++ /dev/null @@ -1,136 +0,0 @@ -unit; - } - - public function getApp() - { - return $this->app; - } - - public function getModule() - { - return $this->module; - } - - public function getFrom() - { - return $this->from; - } - - public function getType() - { - return $this->type; - } - - public function getElement() - { - return $this->element; - } - - public function getComponent() - { - return $this->component; - } - - public function getPermission() : int - { - return $this->permission; - } - - public function setUnit(int $unit = null) /* : void */ - { - $this->unit = $unit; - } - - public function setApp(int $app = null) /* : void */ - { - $this->app = $app; - } - - public function setModule(int $module = null) /* : void */ - { - $this->module = $module; - } - - public function setFrom(int $from = null) /* : void */ - { - $this->from = $from; - } - - public function setType(int $type = null) /* : void */ - { - $this->type = $type; - } - - public function setElement(int $element = null) /* : void */ - { - $this->element = $element; - } - - public function setComponent(int $component = null) /* : void */ - { - $this->component = $component; - } - - public function setPermission(int $permission = 0) /* : void */ - { - if($permission === 0) { - $this->permission = 0; - } else { - $this->permission |= $permission; - } - } -} diff --git a/Models/PermissionManager.php b/Models/PermissionManager.php deleted file mode 100644 index 78741ea..0000000 --- a/Models/PermissionManager.php +++ /dev/null @@ -1,61 +0,0 @@ -id = $id; - $this->permissions = $permissions; - } - - public function getId() : int - { - return $this->id; - } - - public function hasPermission(int $permission, int $unit = null, int $app = null, int $module = null, int $type = null, $element = null, $component = null) : bool - { - foreach($this->permissions as $p) { - if(($p->getUnit() === $unit || $p->getUnit() === null) - && ($p->getApp() === $app || $p->getApp() === null) - && ($p->getModule() === $module || $p->getModule() === null) - && ($p->getType() === $type || $p->getType() === null) - && ($p->getElement() === $element || $p->getElement() === null) - && ($p->getComponent() === $component || $p->getComponent() === null) - && ($permissions | $p->getPermission()) === $p->getPermission()) { - return true; - } - } - - return false; - } -}