/** * Checks if the user is allowed to perform the given task with its associated permissions * * @param string $task The task to execute * @param array $permissions The permissions given * @return bool True if authorized. False if not. */ protected function authoriseTask($task = '', $permissions = []) { if (!$this->admin->authorise($permissions)) { if ($this->grav['uri']->extension() === 'json') { $this->admin->json_response = ['status' => 'unauthorized', 'message' => 'You have insufficient permissions for task ' . $task . '.']; } else { $this->admin->setMessage('You have insufficient permissions for task ' . $task . '.', 'error'); } return false; } return true; }
/** * Checks if the user is allowed to perform the given task with its associated permissions * * @param string $task The task to execute * @param array $permissions The permissions given * @return bool True if authorized. False if not. */ protected function authoriseTask($task = '', $permissions = []) { if (!$this->admin->authorise($permissions)) { if ($this->grav['uri']->extension() === 'json') { $this->admin->json_response = ['status' => 'unauthorized', 'message' => $this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK') . ' ' . $task . '.']; } else { $this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.INSUFFICIENT_PERMISSIONS_FOR_TASK') . ' ' . $task . '.', 'error'); } return false; } return true; }