isAuthorizedAction($user, $action, $scope) || $this->isAuthorizedSuperAdmin($user)); } protected function isAuthorizedSuperAdmin(UserInterface $user): bool { return $user->authorize('admin.super'); } protected function isAuthorizedAction(UserInterface $user, string $action, string $scope = null) : bool { $scope = $scope ?? isset(Grav::instance()['admin']) ? 'admin' : 'site'; if ($action === 'save' && $this instanceof FlexObjectInterface) { $action = $this->exists() ? 'update' : 'create'; } $directory = $this instanceof FlexDirectory ? $this : $this->getFlexDirectory(); $config = $directory->getConfig(); $allowed = $config->get("{$scope}.actions.{$action}") ?? $config->get("actions.{$action}") ?? true; return $allowed && $user->authorize(sprintf($this->_authorize, $scope, $action)); } protected function setAuthorizeRule(string $authorize) : void { $this->_authorize = $authorize; } }