changed badly named permission type to permission category because type should only be read/write/...

This commit is contained in:
Dennis Eichhorn 2022-03-17 23:01:29 +01:00
parent 2b27aec9f5
commit b1be45f365
10 changed files with 65 additions and 65 deletions

View File

@ -615,8 +615,8 @@
"default": null, "default": null,
"null": true "null": true
}, },
"group_permission_type": { "group_permission_category": {
"name": "group_permission_type", "name": "group_permission_category",
"type": "INT", "type": "INT",
"default": null, "default": null,
"null": true "null": true
@ -863,8 +863,8 @@
"default": null, "default": null,
"null": true "null": true
}, },
"account_permission_type": { "account_permission_category": {
"name": "account_permission_type", "name": "account_permission_category",
"type": "INT", "type": "INT",
"default": null, "default": null,
"null": true "null": true

View File

@ -13,7 +13,7 @@
declare(strict_types=1); declare(strict_types=1);
use Modules\Admin\Controller\ApiController; use Modules\Admin\Controller\ApiController;
use Modules\Admin\Models\PermissionState; use Modules\Admin\Models\PermissionCategory;
use phpOMS\Account\PermissionType; use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb; use phpOMS\Router\RouteVerb;
@ -60,7 +60,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::SETTINGS, 'state' => PermissionCategory::SETTINGS,
], ],
], ],
[ [
@ -69,7 +69,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::SETTINGS, 'state' => PermissionCategory::SETTINGS,
], ],
], ],
], ],
@ -81,7 +81,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::SETTINGS, 'state' => PermissionCategory::SETTINGS,
], ],
], ],
], ],
@ -93,7 +93,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::CREATE, 'type' => PermissionType::CREATE,
'state' => PermissionState::GROUP, 'state' => PermissionCategory::GROUP,
], ],
], ],
[ [
@ -102,7 +102,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::GROUP, 'state' => PermissionCategory::GROUP,
], ],
], ],
[ [
@ -111,7 +111,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::DELETE, 'type' => PermissionType::DELETE,
'state' => PermissionState::GROUP, 'state' => PermissionCategory::GROUP,
], ],
], ],
[ [
@ -120,7 +120,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::GROUP, 'state' => PermissionCategory::GROUP,
], ],
], ],
], ],
@ -132,7 +132,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::SEARCH, 'state' => PermissionCategory::SEARCH,
], ],
], ],
], ],
@ -143,7 +143,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::SEARCH, 'state' => PermissionCategory::SEARCH,
], ],
], ],
], ],
@ -154,7 +154,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::SEARCH, 'state' => PermissionCategory::SEARCH,
], ],
], ],
], ],
@ -166,7 +166,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::CREATE, 'type' => PermissionType::CREATE,
'state' => PermissionState::ACCOUNT, 'state' => PermissionCategory::ACCOUNT,
], ],
], ],
[ [
@ -175,7 +175,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::ACCOUNT, 'state' => PermissionCategory::ACCOUNT,
], ],
], ],
[ [
@ -184,7 +184,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::DELETE, 'type' => PermissionType::DELETE,
'state' => PermissionState::ACCOUNT, 'state' => PermissionCategory::ACCOUNT,
], ],
], ],
[ [
@ -193,7 +193,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::ACCOUNT, 'state' => PermissionCategory::ACCOUNT,
], ],
], ],
], ],
@ -204,7 +204,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::ACCOUNT_SETTINGS, 'state' => PermissionCategory::ACCOUNT_SETTINGS,
], ],
], ],
], ],
@ -216,7 +216,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],
@ -228,7 +228,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],
@ -239,7 +239,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],
@ -251,7 +251,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::PERMISSION, 'type' => PermissionType::PERMISSION,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
[ [
@ -260,7 +260,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::PERMISSION, 'type' => PermissionType::PERMISSION,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
[ [
@ -269,7 +269,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::PERMISSION, 'type' => PermissionType::PERMISSION,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
[ [
@ -278,7 +278,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::PERMISSION, 'type' => PermissionType::PERMISSION,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],
@ -289,7 +289,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::PERMISSION, 'type' => PermissionType::PERMISSION,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
[ [
@ -298,7 +298,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::PERMISSION, 'type' => PermissionType::PERMISSION,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
[ [
@ -307,7 +307,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::PERMISSION, 'type' => PermissionType::PERMISSION,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
[ [
@ -316,7 +316,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::PERMISSION, 'type' => PermissionType::PERMISSION,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],
@ -327,7 +327,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::CREATE, 'type' => PermissionType::CREATE,
'state' => PermissionState::ROUTE, 'state' => PermissionCategory::ROUTE,
], ],
], ],
], ],
@ -339,7 +339,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::CREATE, 'type' => PermissionType::CREATE,
'state' => PermissionState::APP, 'state' => PermissionCategory::APP,
], ],
], ],
], ],
@ -350,7 +350,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::CREATE, 'type' => PermissionType::CREATE,
'state' => PermissionState::APP, 'state' => PermissionCategory::APP,
], ],
], ],
], ],
@ -361,7 +361,7 @@ return [
'permission' => [ 'permission' => [
'module' => ApiController::NAME, 'module' => ApiController::NAME,
'type' => PermissionType::CREATE, 'type' => PermissionType::CREATE,
'state' => PermissionState::APP, 'state' => PermissionCategory::APP,
], ],
], ],
], ],

View File

@ -13,7 +13,7 @@
declare(strict_types=1); declare(strict_types=1);
use Modules\Admin\Controller\BackendController; use Modules\Admin\Controller\BackendController;
use Modules\Admin\Models\PermissionState; use Modules\Admin\Models\PermissionCategory;
use phpOMS\Account\PermissionType; use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb; use phpOMS\Router\RouteVerb;
@ -34,7 +34,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => \Modules\Admin\Models\PermissionState::MODULE, 'state' => \Modules\Admin\Models\PermissionCategory::MODULE,
], ],
], ],
], ],
@ -46,7 +46,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::ACCOUNT, 'state' => PermissionCategory::ACCOUNT,
], ],
], ],
], ],
@ -57,7 +57,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::ACCOUNT, 'state' => PermissionCategory::ACCOUNT,
], ],
], ],
], ],
@ -68,7 +68,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::CREATE, 'type' => PermissionType::CREATE,
'state' => PermissionState::ACCOUNT, 'state' => PermissionCategory::ACCOUNT,
], ],
], ],
], ],
@ -79,7 +79,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::GROUP, 'state' => PermissionCategory::GROUP,
], ],
], ],
], ],
@ -90,7 +90,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::MODIFY, 'type' => PermissionType::MODIFY,
'state' => PermissionState::GROUP, 'state' => PermissionCategory::GROUP,
], ],
], ],
], ],
@ -101,7 +101,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::CREATE, 'type' => PermissionType::CREATE,
'state' => PermissionState::GROUP, 'state' => PermissionCategory::GROUP,
], ],
], ],
], ],
@ -112,7 +112,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],
@ -123,7 +123,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],
@ -134,7 +134,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],
@ -145,7 +145,7 @@ return [
'permission' => [ 'permission' => [
'module' => BackendController::NAME, 'module' => BackendController::NAME,
'type' => PermissionType::READ, 'type' => PermissionType::READ,
'state' => PermissionState::MODULE, 'state' => PermissionCategory::MODULE,
], ],
], ],
], ],

View File

@ -28,7 +28,7 @@ use Modules\Admin\Models\Module;
use Modules\Admin\Models\ModuleMapper; use Modules\Admin\Models\ModuleMapper;
use Modules\Admin\Models\ModuleStatusUpdateType; use Modules\Admin\Models\ModuleStatusUpdateType;
use Modules\Admin\Models\NullAccount; use Modules\Admin\Models\NullAccount;
use Modules\Admin\Models\PermissionState; use Modules\Admin\Models\PermissionCategory;
use Modules\Media\Models\Collection; use Modules\Media\Models\Collection;
use Modules\Media\Models\CollectionMapper; use Modules\Media\Models\CollectionMapper;
use Modules\Media\Models\UploadFile; use Modules\Media\Models\UploadFile;
@ -483,7 +483,7 @@ final class ApiController extends Controller
$this->app->orgId, $this->app->orgId,
$this->app->appName, $this->app->appName,
self::NAME, self::NAME,
PermissionState::ACCOUNT_SETTINGS, PermissionCategory::ACCOUNT_SETTINGS,
$accountId $accountId
) )
) { ) {

View File

@ -45,7 +45,7 @@ class AccountPermission extends PermissionAbstract
* @param null|string $app App App to check (null if all are acceptable) * @param null|string $app App App to check (null if all are acceptable)
* @param null|string $module Module to check (null if all are acceptable) * @param null|string $module Module to check (null if all are acceptable)
* @param null|string $from Module providing this permission * @param null|string $from Module providing this permission
* @param null|int $type Type (e.g. customer) (null if all are acceptable) * @param null|int $category Category (e.g. customer) (null if all are acceptable)
* @param null|int $element (e.g. customer id) (null if all are acceptable) * @param null|int $element (e.g. customer id) (null if all are acceptable)
* @param null|int $component (e.g. address) (null if all are acceptable) * @param null|int $component (e.g. address) (null if all are acceptable)
* @param int $permission Permission to check * @param int $permission Permission to check
@ -58,13 +58,13 @@ class AccountPermission extends PermissionAbstract
string $app = null, string $app = null,
string $module = null, string $module = null,
string $from = null, string $from = null,
int $type = null, int $category = null,
int $element = null, int $element = null,
int $component = null, int $component = null,
int $permission = PermissionType::NONE int $permission = PermissionType::NONE
) { ) {
$this->account = $account; $this->account = $account;
parent::__construct($unit, $app, $module, $from, $type, $element, $component, $permission); parent::__construct($unit, $app, $module, $from, $category, $element, $component, $permission);
} }
/** /**

View File

@ -39,7 +39,7 @@ final class AccountPermissionMapper extends DataMapperFactory
'account_permission_app' => ['name' => 'account_permission_app', 'type' => 'string', 'internal' => 'app'], 'account_permission_app' => ['name' => 'account_permission_app', 'type' => 'string', 'internal' => 'app'],
'account_permission_module' => ['name' => 'account_permission_module', 'type' => 'string', 'internal' => 'module'], 'account_permission_module' => ['name' => 'account_permission_module', 'type' => 'string', 'internal' => 'module'],
'account_permission_from' => ['name' => 'account_permission_from', 'type' => 'string', 'internal' => 'from'], 'account_permission_from' => ['name' => 'account_permission_from', 'type' => 'string', 'internal' => 'from'],
'account_permission_type' => ['name' => 'account_permission_type', 'type' => 'int', 'internal' => 'type'], 'account_permission_category' => ['name' => 'account_permission_category', 'type' => 'int', 'internal' => 'category'],
'account_permission_element' => ['name' => 'account_permission_element', 'type' => 'int', 'internal' => 'element'], 'account_permission_element' => ['name' => 'account_permission_element', 'type' => 'int', 'internal' => 'element'],
'account_permission_component' => ['name' => 'account_permission_component', 'type' => 'int', 'internal' => 'component'], 'account_permission_component' => ['name' => 'account_permission_component', 'type' => 'int', 'internal' => 'component'],
'account_permission_hasread' => ['name' => 'account_permission_hasread', 'type' => 'bool', 'internal' => 'hasRead'], 'account_permission_hasread' => ['name' => 'account_permission_hasread', 'type' => 'bool', 'internal' => 'hasRead'],

View File

@ -45,7 +45,7 @@ class GroupPermission extends PermissionAbstract
* @param null|string $app App App to check (null if all are acceptable) * @param null|string $app App App to check (null if all are acceptable)
* @param null|string $module Module to check (null if all are acceptable) * @param null|string $module Module to check (null if all are acceptable)
* @param null|string $from Module providing this permission * @param null|string $from Module providing this permission
* @param null|int $type Type (e.g. customer) (null if all are acceptable) * @param null|int $category Category (e.g. customer) (null if all are acceptable)
* @param null|int $element (e.g. customer id) (null if all are acceptable) * @param null|int $element (e.g. customer id) (null if all are acceptable)
* @param null|int $component (e.g. address) (null if all are acceptable) * @param null|int $component (e.g. address) (null if all are acceptable)
* @param int $permission Permission to check * @param int $permission Permission to check
@ -58,13 +58,13 @@ class GroupPermission extends PermissionAbstract
string $app = null, string $app = null,
string $module = null, string $module = null,
string $from = null, string $from = null,
int $type = null, int $category = null,
int $element = null, int $element = null,
int $component = null, int $component = null,
int $permission = PermissionType::NONE int $permission = PermissionType::NONE
) { ) {
$this->group = $group; $this->group = $group;
parent::__construct($unit, $app, $module, $from, $type, $element, $component, $permission); parent::__construct($unit, $app, $module, $from, $category, $element, $component, $permission);
} }
/** /**

View File

@ -39,7 +39,7 @@ final class GroupPermissionMapper extends DataMapperFactory
'group_permission_app' => ['name' => 'group_permission_app', 'type' => 'string', 'internal' => 'app'], 'group_permission_app' => ['name' => 'group_permission_app', 'type' => 'string', 'internal' => 'app'],
'group_permission_module' => ['name' => 'group_permission_module', 'type' => 'string', 'internal' => 'module'], 'group_permission_module' => ['name' => 'group_permission_module', 'type' => 'string', 'internal' => 'module'],
'group_permission_from' => ['name' => 'group_permission_from', 'type' => 'string', 'internal' => 'from'], 'group_permission_from' => ['name' => 'group_permission_from', 'type' => 'string', 'internal' => 'from'],
'group_permission_type' => ['name' => 'group_permission_type', 'type' => 'int', 'internal' => 'type'], 'group_permission_category' => ['name' => 'group_permission_category', 'type' => 'int', 'internal' => 'category'],
'group_permission_element' => ['name' => 'group_permission_element', 'type' => 'int', 'internal' => 'element'], 'group_permission_element' => ['name' => 'group_permission_element', 'type' => 'int', 'internal' => 'element'],
'group_permission_component' => ['name' => 'group_permission_component', 'type' => 'int', 'internal' => 'component'], 'group_permission_component' => ['name' => 'group_permission_component', 'type' => 'int', 'internal' => 'component'],
'group_permission_hasread' => ['name' => 'group_permission_hasread', 'type' => 'bool', 'internal' => 'hasRead'], 'group_permission_hasread' => ['name' => 'group_permission_hasread', 'type' => 'bool', 'internal' => 'hasRead'],

View File

@ -24,7 +24,7 @@ use phpOMS\Stdlib\Base\Enum;
* @link https://karaka.app * @link https://karaka.app
* @since 1.0.0 * @since 1.0.0
*/ */
abstract class PermissionState extends Enum abstract class PermissionCategory extends Enum
{ {
public const SETTINGS = 1; public const SETTINGS = 1;

View File

@ -40,7 +40,7 @@ final class PermissionQueryBuilder
private array $modules = [null]; private array $modules = [null];
private array $types = [null]; private array $categories = [null];
private int $permission = 0; private int $permission = 0;
@ -78,9 +78,9 @@ final class PermissionQueryBuilder
return $this; return $this;
} }
public function types(array $types) : self public function categories(array $categories) : self
{ {
$this->types = $types; $this->categories = $categories;
return $this; return $this;
} }
@ -132,8 +132,8 @@ final class PermissionQueryBuilder
$accountPermission->where($subWhere); $accountPermission->where($subWhere);
$subWhere = new Where($this->connection); $subWhere = new Where($this->connection);
foreach ($this->types as $type) { foreach ($this->categories as $category) {
$subWhere->orWhere('account_permission_type', '=', $type); $subWhere->orWhere('account_permission_category', '=', $category);
} }
$accountPermission->where($subWhere); $accountPermission->where($subWhere);
@ -171,8 +171,8 @@ final class PermissionQueryBuilder
$groupPermission->where($subWhere); $groupPermission->where($subWhere);
$subWhere = new Where($this->connection); $subWhere = new Where($this->connection);
foreach ($this->types as $type) { foreach ($this->categories as $category) {
$subWhere->orWhere('group_permission_type', '=', $type); $subWhere->orWhere('group_permission_category', '=', $category);
} }
$groupPermission->where($subWhere); $groupPermission->where($subWhere);