acl checkField

This commit is contained in:
Yuri Kuznetsov
2022-11-21 18:13:04 +02:00
parent 04eaf4db02
commit ac28ae5a9b
2 changed files with 27 additions and 0 deletions
+13
View File
@@ -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.
*
+14
View File
@@ -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.
*