From 88ee691bb9c17bd6d2b93873ed789d2edc120b37 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 28 May 2016 17:26:33 -0400 Subject: Fix wrong redirect after removing a task from the task view page --- app/Controller/TaskSuppressionController.php | 53 ++++++++++++++++++++++++++ app/Controller/TaskViewController.php | 30 --------------- app/ServiceProvider/AuthenticationProvider.php | 2 +- app/Template/task/dropdown.php | 2 +- app/Template/task/remove.php | 15 -------- app/Template/task/sidebar.php | 2 +- app/Template/task_suppression/remove.php | 15 ++++++++ 7 files changed, 71 insertions(+), 48 deletions(-) create mode 100644 app/Controller/TaskSuppressionController.php delete mode 100644 app/Template/task/remove.php create mode 100644 app/Template/task_suppression/remove.php (limited to 'app') diff --git a/app/Controller/TaskSuppressionController.php b/app/Controller/TaskSuppressionController.php new file mode 100644 index 00000000..7c9165eb --- /dev/null +++ b/app/Controller/TaskSuppressionController.php @@ -0,0 +1,53 @@ +getTask(); + + if (! $this->helper->user->canRemoveTask($task)) { + throw new AccessForbiddenException(); + } + + $this->response->html($this->template->render('task_suppression/remove', array( + 'task' => $task, + 'redirect' => $this->request->getStringParam('redirect'), + ))); + } + + /** + * Remove a task + */ + public function remove() + { + $task = $this->getTask(); + $this->checkCSRFParam(); + + if (! $this->helper->user->canRemoveTask($task)) { + throw new AccessForbiddenException(); + } + + if ($this->task->remove($task['id'])) { + $this->flash->success(t('Task removed successfully.')); + } else { + $this->flash->failure(t('Unable to remove this task.')); + } + + $redirect = $this->request->getStringParam('redirect') === ''; + $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), $redirect); + } +} diff --git a/app/Controller/TaskViewController.php b/app/Controller/TaskViewController.php index 6d3cc5c5..b16c15de 100644 --- a/app/Controller/TaskViewController.php +++ b/app/Controller/TaskViewController.php @@ -143,34 +143,4 @@ class TaskViewController extends BaseController 'transitions' => $this->transition->getAllByTask($task['id']), ))); } - - /** - * Remove a task - * - * @access public - */ - public function remove() - { - $task = $this->getTask(); - - if (! $this->helper->user->canRemoveTask($task)) { - throw new AccessForbiddenException(); - } - - if ($this->request->getStringParam('confirmation') === 'yes') { - $this->checkCSRFParam(); - - if ($this->task->remove($task['id'])) { - $this->flash->success(t('Task removed successfully.')); - } else { - $this->flash->failure(t('Unable to remove this task.')); - } - - return $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), true); - } - - return $this->response->html($this->template->render('task/remove', array( - 'task' => $task, - ))); - } } diff --git a/app/ServiceProvider/AuthenticationProvider.php b/app/ServiceProvider/AuthenticationProvider.php index f8ea9b19..2fad8a3a 100644 --- a/app/ServiceProvider/AuthenticationProvider.php +++ b/app/ServiceProvider/AuthenticationProvider.php @@ -92,7 +92,7 @@ class AuthenticationProvider implements ServiceProviderInterface $acl->add('SubtaskRestrictionController', '*', Role::PROJECT_MEMBER); $acl->add('SubtaskStatusController', '*', Role::PROJECT_MEMBER); $acl->add('SwimlaneController', '*', Role::PROJECT_MANAGER); - $acl->add('TaskViewController', 'remove', Role::PROJECT_MEMBER); + $acl->add('TaskSuppressionController', '*', Role::PROJECT_MEMBER); $acl->add('TaskCreationController', '*', Role::PROJECT_MEMBER); $acl->add('TaskBulkController', '*', Role::PROJECT_MEMBER); $acl->add('TaskDuplicationController', '*', Role::PROJECT_MEMBER); diff --git a/app/Template/task/dropdown.php b/app/Template/task/dropdown.php index 472c819f..b6b9c789 100644 --- a/app/Template/task/dropdown.php +++ b/app/Template/task/dropdown.php @@ -58,7 +58,7 @@ user->canRemoveTask($task)): ?>
  • - url->link(t('Remove'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> + url->link(t('Remove'), 'TaskSuppressionController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
  • diff --git a/app/Template/task/remove.php b/app/Template/task/remove.php deleted file mode 100644 index f963a325..00000000 --- a/app/Template/task/remove.php +++ /dev/null @@ -1,15 +0,0 @@ - - -
    -

    - text->e($task['title'])) ?> -

    - -
    - url->link(t('Yes'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'confirmation' => 'yes'), true, 'btn btn-red popover-link') ?> - - url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?> -
    -
    diff --git a/app/Template/task/sidebar.php b/app/Template/task/sidebar.php index ff3883e1..e77ec18a 100644 --- a/app/Template/task/sidebar.php +++ b/app/Template/task/sidebar.php @@ -90,7 +90,7 @@ user->canRemoveTask($task)): ?>
  • - url->link(t('Remove'), 'TaskViewController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> + url->link(t('Remove'), 'TaskSuppressionController', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'popover') ?>
  • diff --git a/app/Template/task_suppression/remove.php b/app/Template/task_suppression/remove.php new file mode 100644 index 00000000..5d0f7720 --- /dev/null +++ b/app/Template/task_suppression/remove.php @@ -0,0 +1,15 @@ + + +
    +

    + text->e($task['title'])) ?> +

    + +
    + url->link(t('Yes'), 'TaskSuppressionController', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => $redirect), true, 'btn btn-red popover-link') ?> + + url->link(t('cancel'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?> +
    +
    -- cgit v1.2.3