diff --git a/application/Espo/Core/Acl.php b/application/Espo/Core/Acl.php index 2034ad0300..1b9dc798d7 100644 --- a/application/Espo/Core/Acl.php +++ b/application/Espo/Core/Acl.php @@ -244,16 +244,34 @@ class Acl return $this->aclManager->checkAssignmentPermission($this->user, $target); } + /** + * Get a restricted field list for a specific scope by a restriction type. + * + * @param string|array $type + * @return array + */ public function getScopeRestrictedFieldList(string $scope, $type): array { return $this->aclManager->getScopeRestrictedFieldList($scope, $type); } + /** + * Get a restricted attribute list for a specific scope by a restriction type. + * + * @param string|array $type + * @return array + */ public function getScopeRestrictedAttributeList(string $scope, $type): array { return $this->aclManager->getScopeRestrictedAttributeList($scope, $type); } + /** + * Get a restricted link list for a specific scope by a restriction type. + * + * @param string|array $type + * @return array + */ public function getScopeRestrictedLinkList(string $scope, $type): array { return $this->aclManager->getScopeRestrictedLinkList($scope, $type); diff --git a/application/Espo/Core/Acl/Acl.php b/application/Espo/Core/Acl/Acl.php index 5b8186a986..2e59240308 100644 --- a/application/Espo/Core/Acl/Acl.php +++ b/application/Espo/Core/Acl/Acl.php @@ -87,22 +87,22 @@ class Acl implements ScopeAcl, EntityAcl, EntityDeleteAcl return $this->checkScopeInternal($user, $data, $action, $entity); } - public function checkScope(User $user, ScopeData $data, ?string $action = null) : bool + public function checkScope(User $user, ScopeData $data, ?string $action = null): bool { return $this->checkScopeInternal($user, $data, $action); } - public function checkReadOnlyTeam(User $user, ScopeData $data) : bool + public function checkReadOnlyTeam(User $user, ScopeData $data): bool { return $data->getRead() === Table::LEVEL_TEAM; } - public function checkReadNo(User $user, ScopeData $data) : bool + public function checkReadNo(User $user, ScopeData $data): bool { return $data->getRead() === Table::LEVEL_NO; } - public function checkReadOnlyOwn(User $user, ScopeData $data) : bool + public function checkReadOnlyOwn(User $user, ScopeData $data): bool { return $data->getRead() === Table::LEVEL_OWN; } @@ -113,7 +113,7 @@ class Acl implements ScopeAcl, EntityAcl, EntityDeleteAcl ?string $action = null, ?Entity $entity = null, array $entityAccessData = [] - ) : bool { + ): bool { if ($data->isFalse()) { return false; @@ -238,7 +238,7 @@ class Acl implements ScopeAcl, EntityAcl, EntityDeleteAcl return false; } - public function checkEntityDelete(User $user, Entity $entity, ScopeData $data) : bool + public function checkEntityDelete(User $user, Entity $entity, ScopeData $data): bool { if ($user->isAdmin()) { return true; @@ -296,7 +296,7 @@ class Acl implements ScopeAcl, EntityAcl, EntityDeleteAcl return true; } - public function getOwnerUserIdAttribute(Entity $entity) : ?string + public function getOwnerUserIdAttribute(Entity $entity): ?string { if ($this->ownerUserIdAttribute) { return $this->ownerUserIdAttribute; @@ -320,7 +320,7 @@ class Acl implements ScopeAcl, EntityAcl, EntityDeleteAcl /** * @deprecated Use `$this->config`. */ - protected function getConfig() : Config + protected function getConfig(): Config { return $this->config; } @@ -328,7 +328,7 @@ class Acl implements ScopeAcl, EntityAcl, EntityDeleteAcl /** * @deprecated Use `$this->entityManager`. */ - protected function getEntityManager() : EntityManager + protected function getEntityManager(): EntityManager { return $this->entityManager; } @@ -336,7 +336,7 @@ class Acl implements ScopeAcl, EntityAcl, EntityDeleteAcl /** * @deprecated Use `$this->aclManager`. */ - protected function getAclManager() : AclManager + protected function getAclManager(): AclManager { return $this->aclManager; } diff --git a/application/Espo/Core/Acl/AclFactory.php b/application/Espo/Core/Acl/AclFactory.php index 9488ab3424..0846f363a3 100644 --- a/application/Espo/Core/Acl/AclFactory.php +++ b/application/Espo/Core/Acl/AclFactory.php @@ -48,7 +48,7 @@ class AclFactory $this->injectableFactory = $injectableFactory; } - public function create(string $scope) : ScopeAcl + public function create(string $scope): ScopeAcl { $className = $this->classFinder->find('Acl', $scope); diff --git a/application/Espo/Core/Acl/GlobalRestricton.php b/application/Espo/Core/Acl/GlobalRestricton.php index e4bf75085c..bf480e6593 100644 --- a/application/Espo/Core/Acl/GlobalRestricton.php +++ b/application/Espo/Core/Acl/GlobalRestricton.php @@ -181,7 +181,7 @@ class GlobalRestricton $this->data = $data; } - public function getScopeRestrictedFieldList(string $scope, string $type) : array + public function getScopeRestrictedFieldList(string $scope, string $type): array { if (!property_exists($this->data, $scope)) { return []; @@ -197,7 +197,7 @@ class GlobalRestricton return $this->data->$scope->fields->$type; } - public function getScopeRestrictedAttributeList(string $scope, string $type) : array + public function getScopeRestrictedAttributeList(string $scope, string $type): array { if (!property_exists($this->data, $scope)) { return []; @@ -214,7 +214,7 @@ class GlobalRestricton return $this->data->$scope->attributes->$type; } - public function getScopeRestrictedLinkList(string $scope, string $type) : array + public function getScopeRestrictedLinkList(string $scope, string $type): array { if (!property_exists($this->data, $scope)) { return []; diff --git a/application/Espo/Core/Acl/GlobalRestrictonFactory.php b/application/Espo/Core/Acl/GlobalRestrictonFactory.php index f5e36aa2f5..dcf05b5a7d 100644 --- a/application/Espo/Core/Acl/GlobalRestrictonFactory.php +++ b/application/Espo/Core/Acl/GlobalRestrictonFactory.php @@ -46,7 +46,7 @@ class GlobalRestrictonFactory $this->injectableFactory = $injectableFactory; } - public function create() : GlobalRestricton + public function create(): GlobalRestricton { return $this->injectableFactory->createWith(GlobalRestricton::class, [ 'useCache' => $this->config->get('useCache'), diff --git a/application/Espo/Core/Acl/ScopeData.php b/application/Espo/Core/Acl/ScopeData.php index dffb0c3d8d..77570ef3ee 100644 --- a/application/Espo/Core/Acl/ScopeData.php +++ b/application/Espo/Core/Acl/ScopeData.php @@ -64,7 +64,7 @@ class ScopeData /** * Is of boolean type. */ - public function isBoolean() : bool + public function isBoolean(): bool { return $this->isBoolean; } @@ -72,7 +72,7 @@ class ScopeData /** * Is true. */ - public function isTrue() : bool + public function isTrue(): bool { if (!$this->isBoolean) { return false; @@ -84,7 +84,7 @@ class ScopeData /** * Is false. */ - public function isFalse() : bool + public function isFalse(): bool { if (!$this->isBoolean) { return false; @@ -96,7 +96,7 @@ class ScopeData /** * Has any level other than 'no'. */ - public function hasNotNo() : bool + public function hasNotNo(): bool { foreach ($this->actionData as $level) { if ($level !== Table::LEVEL_NO) { @@ -110,7 +110,7 @@ class ScopeData /** * Get a level for an action. */ - public function get(string $action) : string + public function get(string $action): string { return $this->actionData[$action] ?? Table::LEVEL_NO; } @@ -118,7 +118,7 @@ class ScopeData /** * Get a 'read' level. */ - public function getRead() : string + public function getRead(): string { return $this->get(Table::ACTION_READ); } @@ -126,7 +126,7 @@ class ScopeData /** * Get a 'stream' level. */ - public function getStream() : string + public function getStream(): string { return $this->get(Table::ACTION_STREAM); } @@ -134,7 +134,7 @@ class ScopeData /** * Get a 'create' level. */ - public function getCreate() : string + public function getCreate(): string { return $this->get(Table::ACTION_CREATE); } @@ -142,7 +142,7 @@ class ScopeData /** * Get an 'edit' level. */ - public function getEdit() : string + public function getEdit(): string { return $this->get(Table::ACTION_EDIT); } @@ -150,7 +150,7 @@ class ScopeData /** * Get a 'delete' level. */ - public function getDelete() : string + public function getDelete(): string { return $this->get(Table::ACTION_DELETE); } @@ -161,7 +161,7 @@ class ScopeData * @param StdClass|bool $raw * @return self */ - public static function fromRaw($raw) : self + public static function fromRaw($raw): self { $obj = new self(); diff --git a/application/Espo/Core/Acl/Table.php b/application/Espo/Core/Acl/Table.php index e499a26175..c54705bb2e 100644 --- a/application/Espo/Core/Acl/Table.php +++ b/application/Espo/Core/Acl/Table.php @@ -164,17 +164,17 @@ class Table } } - protected function initCacheKey() : void + protected function initCacheKey(): void { $this->cacheKey = 'acl/' . $this->user->id; } - public function getMap() : StdClass + public function getMap(): StdClass { return ObjectUtil::clone($this->data); } - public function getScopeData(string $scope) : ScopeData + public function getScopeData(string $scope): ScopeData { if (!isset($this->data->table->$scope)) { return ScopeData::fromRaw(false); @@ -189,7 +189,7 @@ class Table return ScopeData::fromRaw($data); } - public function get(string $permission) : ?string + public function get(string $permission): ?string { if ($permission === 'table') { return null; @@ -202,7 +202,7 @@ class Table return self::LEVEL_NO; } - public function getLevel(string $scope, string $action) : string + public function getLevel(string $scope, string $action): string { if (isset($this->data->table->$scope)) { if (isset($this->data->table->$scope->$action)) { @@ -213,7 +213,7 @@ class Table return self::LEVEL_NO; } - public function getHighestLevel(string $scope, string $action) : string + public function getHighestLevel(string $scope, string $action): string { if (in_array($action, $this->booleanActionList)) { return self::LEVEL_YES; @@ -367,7 +367,7 @@ class Table public function getScopeForbiddenAttributeList( string $scope, string $action = self::ACTION_READ, string $thresholdLevel = self::LEVEL_NO - ) : array { + ): array { $key = $scope . '_'. $action . '_' . $thresholdLevel; @@ -417,7 +417,7 @@ class Table public function getScopeForbiddenFieldList( string $scope, string $action = self::ACTION_READ, string $thresholdLevel = self::LEVEL_NO - ) : array { + ): array { $key = $scope . '_'. $action . '_' . $thresholdLevel; @@ -465,7 +465,7 @@ class Table return $fieldList; } - protected function fillFieldTableQuickAccess() : void + protected function fillFieldTableQuickAccess(): void { $fieldTable = $this->data->fieldTable; @@ -511,7 +511,7 @@ class Table $this->data->fieldTableQuickAccess = $fieldTableQuickAccess; } - protected function applyDefault(&$table, &$fieldTable) : void + protected function applyDefault(&$table, &$fieldTable): void { if ($this->user->isAdmin()) { return; @@ -630,7 +630,7 @@ class Table } } - protected function applyMandatory(&$table, &$fieldTable) : void + protected function applyMandatory(&$table, &$fieldTable): void { if ($this->user->isAdmin()) { return; @@ -693,7 +693,7 @@ class Table } } - protected function applyDisabled(&$table, &$fieldTable) : void + protected function applyDisabled(&$table, &$fieldTable): void { if ($this->user->isAdmin()) { return; @@ -708,7 +708,7 @@ class Table } } - protected function applyAdditional(&$table, &$fieldTable, &$valuePermissionLists) : void + protected function applyAdditional(&$table, &$fieldTable, &$valuePermissionLists): void { if ($this->user->isPortal()) { foreach ($this->getScopeList() as $scope) { @@ -723,7 +723,7 @@ class Table } } - private function mergeValueList(array $list, string $defaultValue) : string + private function mergeValueList(array $list, string $defaultValue): string { $result = null; @@ -748,7 +748,7 @@ class Table return $result; } - protected function getScopeWithAclList() : array + protected function getScopeWithAclList(): array { $scopeList = []; @@ -765,7 +765,7 @@ class Table return $scopeList; } - protected function getScopeList() : array + protected function getScopeList(): array { $scopeList = []; @@ -778,7 +778,7 @@ class Table return $scopeList; } - private function mergeTableList(array $tableList) : StdClass + private function mergeTableList(array $tableList): StdClass { $data = (object) []; @@ -853,7 +853,7 @@ class Table return $data; } - private function mergeFieldTableList(array $tableList) : StdClass + private function mergeFieldTableList(array $tableList): StdClass { $data = (object) []; @@ -916,7 +916,7 @@ class Table return $data; } - private function buildCache() : void + private function buildCache(): void { $this->dataCache->store($this->cacheKey, $this->data); } diff --git a/application/Espo/Core/AclManager.php b/application/Espo/Core/AclManager.php index 9bb7555947..af1d9d06e7 100644 --- a/application/Espo/Core/AclManager.php +++ b/application/Espo/Core/AclManager.php @@ -526,6 +526,12 @@ class AclManager return $acl; } + /** + * Get a restricted field list for a specific scope by a restriction type. + * + * @param string|array $type + * @return array + */ public function getScopeRestrictedFieldList(string $scope, $type): array { if (is_array($type)) { @@ -543,6 +549,12 @@ class AclManager return $this->globalRestricton->getScopeRestrictedFieldList($scope, $type); } + /** + * Get a restricted attribute list for a specific scope by a restriction type. + * + * @param string|array $type + * @return array + */ public function getScopeRestrictedAttributeList(string $scope, $type): array { if (is_array($type)) { @@ -560,6 +572,12 @@ class AclManager return $this->globalRestricton->getScopeRestrictedAttributeList($scope, $type); } + /** + * Get a restricted link list for a specific scope by a restriction type. + * + * @param string|array $type + * @return array + */ public function getScopeRestrictedLinkList(string $scope, $type): array { if (is_array($type)) {