diff --git a/application/Espo/Core/Acl.php b/application/Espo/Core/Acl.php index bb9031e1f2..940b1ac514 100644 --- a/application/Espo/Core/Acl.php +++ b/application/Espo/Core/Acl.php @@ -248,6 +248,19 @@ class Acl ->getScopeForbiddenFieldList($this->user, $scope, $action, $thresholdLevel); } + /** + * Check access to a field. + * + * @param string $scope A scope (entity type). + * @param string $field A field to check. + * @param Table::ACTION_READ|Table::ACTION_EDIT $action An action. + * @return bool + */ + public function checkField(string $scope, string $field, string $action = Table::ACTION_READ): bool + { + return $this->aclManager->checkField($this->user, $scope, $field, $action); + } + /** * Get links forbidden for a user. * diff --git a/application/Espo/Core/AclManager.php b/application/Espo/Core/AclManager.php index 40f999d7d2..2176ea13a2 100644 --- a/application/Espo/Core/AclManager.php +++ b/application/Espo/Core/AclManager.php @@ -556,6 +556,20 @@ class AclManager ); } + /** + * Check access to a field. + * + * @param User $user A user. + * @param string $scope A scope (entity type). + * @param string $field A field to check. + * @param Table::ACTION_READ|Table::ACTION_EDIT $action An action. + * @return bool + */ + public function checkField(User $user, string $scope, string $field, string $action = Table::ACTION_READ): bool + { + return !in_array($field, $this->getScopeForbiddenFieldList($user, $scope, $action)); + } + /** * Whether a user has access to another user over a specific permission. *