/** * Common method to get a project * * @access protected * @param integer $project_id Default project id * @return array */ protected function getProject($project_id = 0) { $project_id = $this->request->getIntegerParam('project_id', $project_id); $project = $this->project->getById($project_id); if (!$project) { $this->session->flashError(t('Project not found.')); $this->response->redirect('?controller=project'); } return $project; }
/** * Common method to get a project with administration rights * * @access protected * @return array */ protected function getProjectManagement() { $project = $this->project->getById($this->request->getIntegerParam('project_id')); if (!$project) { $this->notfound(); } if ($this->acl->isRegularUser() && !$this->projectPermission->adminAllowed($project['id'], $this->acl->getUserId())) { $this->forbidden(); } return $project; }
/** * Common method to get the user * * @access protected * @return array */ protected function getUser() { $user = $this->user->getById($this->request->getIntegerParam('user_id', $this->userSession->getId())); if (empty($user)) { $this->notfound(); } if (!$this->userSession->isAdmin() && $this->userSession->getId() != $user['id']) { $this->forbidden(); } return $user; }