From 24ce1b42f8c23293f504ae312dc5e6b903ab869c Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 25 May 2016 22:34:19 -0400 Subject: Rename ProjectPermission controller --- app/Controller/ProjectPermission.php | 198 ------------------------- app/Controller/ProjectPermissionController.php | 198 +++++++++++++++++++++++++ app/ServiceProvider/AuthenticationProvider.php | 2 +- app/ServiceProvider/RouteProvider.php | 2 +- app/Template/project/sidebar.php | 2 +- app/Template/project_permission/index.php | 14 +- 6 files changed, 208 insertions(+), 208 deletions(-) delete mode 100644 app/Controller/ProjectPermission.php create mode 100644 app/Controller/ProjectPermissionController.php 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 @@ -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')); - } - } -} diff --git a/app/Controller/ProjectPermissionController.php b/app/Controller/ProjectPermissionController.php new file mode 100644 index 00000000..d27681b1 --- /dev/null +++ b/app/Controller/ProjectPermissionController.php @@ -0,0 +1,198 @@ +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('ProjectPermissionController', '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('ProjectPermissionController', '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('ProjectPermissionController', '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('ProjectPermissionController', '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('ProjectPermissionController', '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')); + } + } +} diff --git a/app/ServiceProvider/AuthenticationProvider.php b/app/ServiceProvider/AuthenticationProvider.php index fd61c1f6..fe9cee3c 100644 --- a/app/ServiceProvider/AuthenticationProvider.php +++ b/app/ServiceProvider/AuthenticationProvider.php @@ -82,7 +82,7 @@ class AuthenticationProvider implements ServiceProviderInterface $acl->add('TaskFile', array('screenshot', 'create', 'save', 'remove', 'confirm'), Role::PROJECT_MEMBER); $acl->add('Gantt', '*', Role::PROJECT_MANAGER); $acl->add('ProjectViewController', array('share', 'updateSharing', 'integrations', 'updateIntegrations', 'notifications', 'updateNotifications', 'duplicate', 'doDuplication'), Role::PROJECT_MANAGER); - $acl->add('ProjectPermission', '*', Role::PROJECT_MANAGER); + $acl->add('ProjectPermissionController', '*', Role::PROJECT_MANAGER); $acl->add('ProjectEdit', '*', Role::PROJECT_MANAGER); $acl->add('ProjectFile', '*', Role::PROJECT_MEMBER); $acl->add('Projectuser', '*', Role::PROJECT_MANAGER); diff --git a/app/ServiceProvider/RouteProvider.php b/app/ServiceProvider/RouteProvider.php index 86e00cbd..e52b0762 100644 --- a/app/ServiceProvider/RouteProvider.php +++ b/app/ServiceProvider/RouteProvider.php @@ -57,7 +57,7 @@ class RouteProvider implements ServiceProviderInterface $container['route']->addRoute('project/:project_id/notifications', 'ProjectViewController', 'notifications'); $container['route']->addRoute('project/:project_id/integrations', 'ProjectViewController', 'integrations'); $container['route']->addRoute('project/:project_id/duplicate', 'ProjectViewController', 'duplicate'); - $container['route']->addRoute('project/:project_id/permissions', 'ProjectPermission', 'index'); + $container['route']->addRoute('project/:project_id/permissions', 'ProjectPermissionController', 'index'); $container['route']->addRoute('project/:project_id/import', 'taskImport', 'step1'); $container['route']->addRoute('project/:project_id/activity', 'activity', 'project'); diff --git a/app/Template/project/sidebar.php b/app/Template/project/sidebar.php index 50929977..2d49ca58 100644 --- a/app/Template/project/sidebar.php +++ b/app/Template/project/sidebar.php @@ -34,7 +34,7 @@
  • app->checkMenuSelection('ProjectPermission') ?>> - url->link(t('Permissions'), 'ProjectPermission', 'index', array('project_id' => $project['id'])) ?> + url->link(t('Permissions'), 'ProjectPermissionController', 'index', array('project_id' => $project['id'])) ?>
  • app->checkMenuSelection('action') ?>> diff --git a/app/Template/project_permission/index.php b/app/Template/project_permission/index.php index 6c454a28..d850ec50 100644 --- a/app/Template/project_permission/index.php +++ b/app/Template/project_permission/index.php @@ -26,12 +26,12 @@ $roles, array('role-'.$user['id'] => $user['role']), array(), - array('data-url="'.$this->url->href('ProjectPermission', 'changeUserRole', array('project_id' => $project['id'])).'"', 'data-id="'.$user['id'].'"'), + array('data-url="'.$this->url->href('ProjectPermissionController', 'changeUserRole', array('project_id' => $project['id'])).'"', 'data-id="'.$user['id'].'"'), 'project-change-role' ) ?> - url->link(t('Remove'), 'ProjectPermission', 'removeUser', array('project_id' => $project['id'], 'user_id' => $user['id']), true) ?> + url->link(t('Remove'), 'ProjectPermissionController', 'removeUser', array('project_id' => $project['id'], 'user_id' => $user['id']), true) ?> @@ -40,7 +40,7 @@
    -
    + form->csrf() ?> form->hidden('project_id', array('project_id' => $project['id'])) ?> form->hidden('user_id', $values) ?> @@ -86,12 +86,12 @@ $roles, array('role-'.$group['id'] => $group['role']), array(), - array('data-url="'.$this->url->href('ProjectPermission', 'changeGroupRole', array('project_id' => $project['id'])).'"', 'data-id="'.$group['id'].'"'), + array('data-url="'.$this->url->href('ProjectPermissionController', 'changeGroupRole', array('project_id' => $project['id'])).'"', 'data-id="'.$group['id'].'"'), 'project-change-role' ) ?> - url->link(t('Remove'), 'ProjectPermission', 'removeGroup', array('project_id' => $project['id'], 'group_id' => $group['id']), true) ?> + url->link(t('Remove'), 'ProjectPermissionController', 'removeGroup', array('project_id' => $project['id'], 'group_id' => $group['id']), true) ?> @@ -100,7 +100,7 @@
    - + form->csrf() ?> form->hidden('project_id', array('project_id' => $project['id'])) ?> form->hidden('group_id', $values) ?> @@ -128,7 +128,7 @@
    - + form->csrf() ?> form->hidden('id', array('id' => $project['id'])) ?> -- cgit v1.2.3