diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-25 22:34:19 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-25 22:34:19 -0400 |
commit | 24ce1b42f8c23293f504ae312dc5e6b903ab869c (patch) | |
tree | 9833b30965f9e73b98bbc14a47f4e4972905288d /app/Controller/ProjectPermission.php | |
parent | ff892c5d25e0bab560f005c788189d38c2bcab7b (diff) |
Rename ProjectPermission controller
Diffstat (limited to 'app/Controller/ProjectPermission.php')
-rw-r--r-- | app/Controller/ProjectPermission.php | 198 |
1 files changed, 0 insertions, 198 deletions
diff --git a/app/Controller/ProjectPermission.php b/app/Controller/ProjectPermission.php deleted file mode 100644 index f50a96b8..00000000 --- a/app/Controller/ProjectPermission.php +++ /dev/null @@ -1,198 +0,0 @@ -<?php - -namespace Kanboard\Controller; - -use Kanboard\Core\Controller\AccessForbiddenException; -use Kanboard\Core\Security\Role; - -/** - * Project Permission - * - * @package controller - * @author Frederic Guillot - */ -class ProjectPermission extends BaseController -{ - /** - * Permissions are only available for team projects - * - * @access protected - * @param integer $project_id Default project id - * @return array - * @throws AccessForbiddenException - */ - protected function getProject($project_id = 0) - { - $project = parent::getProject($project_id); - - if ($project['is_private'] == 1) { - throw new AccessForbiddenException(); - } - - return $project; - } - - /** - * Show all permissions - * - * @access public - * @param array $values - * @param array $errors - * @throws AccessForbiddenException - */ - public function index(array $values = array(), array $errors = array()) - { - $project = $this->getProject(); - - if (empty($values)) { - $values['role'] = Role::PROJECT_MEMBER; - } - - $this->response->html($this->helper->layout->project('project_permission/index', array( - 'project' => $project, - 'users' => $this->projectUserRole->getUsers($project['id']), - 'groups' => $this->projectGroupRole->getGroups($project['id']), - 'roles' => $this->role->getProjectRoles(), - 'values' => $values, - 'errors' => $errors, - 'title' => t('Project Permissions'), - ))); - } - - /** - * Allow everybody - * - * @access public - */ - public function allowEverybody() - { - $project = $this->getProject(); - $values = $this->request->getValues() + array('is_everybody_allowed' => 0); - - if ($this->project->update($values)) { - $this->flash->success(t('Project updated successfully.')); - } else { - $this->flash->failure(t('Unable to update this project.')); - } - - $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id']))); - } - - /** - * Add user to the project - * - * @access public - */ - public function addUser() - { - $project = $this->getProject(); - $values = $this->request->getValues(); - - if (empty($values['user_id'])) { - $this->flash->failure(t('User not found.')); - } elseif ($this->projectUserRole->addUser($values['project_id'], $values['user_id'], $values['role'])) { - $this->flash->success(t('Project updated successfully.')); - } else { - $this->flash->failure(t('Unable to update this project.')); - } - - $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id']))); - } - - /** - * Revoke user access - * - * @access public - */ - public function removeUser() - { - $this->checkCSRFParam(); - $project = $this->getProject(); - $user_id = $this->request->getIntegerParam('user_id'); - - if ($this->projectUserRole->removeUser($project['id'], $user_id)) { - $this->flash->success(t('Project updated successfully.')); - } else { - $this->flash->failure(t('Unable to update this project.')); - } - - $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id']))); - } - - /** - * Change user role - * - * @access public - */ - public function changeUserRole() - { - $project = $this->getProject(); - $values = $this->request->getJson(); - - if (! empty($project) && ! empty($values) && $this->projectUserRole->changeUserRole($project['id'], $values['id'], $values['role'])) { - $this->response->json(array('status' => 'ok')); - } else { - $this->response->json(array('status' => 'error')); - } - } - - /** - * Add group to the project - * - * @access public - */ - public function addGroup() - { - $project = $this->getProject(); - $values = $this->request->getValues(); - - if (empty($values['group_id']) && ! empty($values['external_id'])) { - $values['group_id'] = $this->group->create($values['name'], $values['external_id']); - } - - if ($this->projectGroupRole->addGroup($project['id'], $values['group_id'], $values['role'])) { - $this->flash->success(t('Project updated successfully.')); - } else { - $this->flash->failure(t('Unable to update this project.')); - } - - $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id']))); - } - - /** - * Revoke group access - * - * @access public - */ - public function removeGroup() - { - $this->checkCSRFParam(); - $project = $this->getProject(); - $group_id = $this->request->getIntegerParam('group_id'); - - if ($this->projectGroupRole->removeGroup($project['id'], $group_id)) { - $this->flash->success(t('Project updated successfully.')); - } else { - $this->flash->failure(t('Unable to update this project.')); - } - - $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id']))); - } - - /** - * Change group role - * - * @access public - */ - public function changeGroupRole() - { - $project = $this->getProject(); - $values = $this->request->getJson(); - - if (! empty($project) && ! empty($values) && $this->projectGroupRole->changeGroupRole($project['id'], $values['id'], $values['role'])) { - $this->response->json(array('status' => 'ok')); - } else { - $this->response->json(array('status' => 'error')); - } - } -} |