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 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 app/Controller/TaskSuppressionController.php (limited to 'app/Controller/TaskSuppressionController.php') 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); + } +} -- cgit v1.2.3