diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-28 17:26:33 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-28 17:26:33 -0400 |
commit | 88ee691bb9c17bd6d2b93873ed789d2edc120b37 (patch) | |
tree | 9e462fae3e61345f8ffba170b00906848a9eac63 /app/Controller | |
parent | 9e218032c485b7ab6ef8e00f45890151988b0f90 (diff) |
Fix wrong redirect after removing a task from the task view page
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/TaskSuppressionController.php | 53 | ||||
-rw-r--r-- | app/Controller/TaskViewController.php | 30 |
2 files changed, 53 insertions, 30 deletions
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 @@ +<?php + +namespace Kanboard\Controller; + +use Kanboard\Core\Controller\AccessForbiddenException; + +/** + * Class TaskSuppressionController + * + * @package Kanboard\Controller + * @author Frederic Guillot + */ +class TaskSuppressionController extends BaseController +{ + /** + * Confirmation dialog box before to remove the task + */ + public function confirm() + { + $task = $this->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, - ))); - } } |