diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-15 18:31:47 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-15 18:31:47 -0400 |
commit | 67b836164997527b91452b19adbcb8aa3c5decf1 (patch) | |
tree | b5876d311912e97b0592c7e208639f7b52813a75 /app/Controller/Task.php | |
parent | 108e867605dbc7ece4cbcbecc89a674e9c154a9b (diff) |
Refactoring: added controlled middleware and changed response class
Diffstat (limited to 'app/Controller/Task.php')
-rw-r--r-- | app/Controller/Task.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/Controller/Task.php b/app/Controller/Task.php index 072df87b..1ce13f69 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -2,6 +2,8 @@ namespace Kanboard\Controller; +use Kanboard\Core\Controller\AccessForbiddenException; +use Kanboard\Core\Controller\PageNotFoundException; use Kanboard\Core\DateParser; /** @@ -10,7 +12,7 @@ use Kanboard\Core\DateParser; * @package controller * @author Frederic Guillot */ -class Task extends Base +class Task extends BaseController { /** * Public access (display a task) @@ -23,17 +25,17 @@ class Task extends Base // Token verification if (empty($project)) { - return $this->forbidden(true); + throw AccessForbiddenException::getInstance()->withoutLayout(); } $task = $this->taskFinder->getDetails($this->request->getIntegerParam('task_id')); if (empty($task)) { - return $this->notfound(true); + throw PageNotFoundException::getInstance()->withoutLayout(); } if ($task['project_id'] != $project['id']) { - return $this->forbidden(true); + throw AccessForbiddenException::getInstance()->withoutLayout(); } $this->response->html($this->helper->layout->app('task/public', array( @@ -152,7 +154,7 @@ class Task extends Base $task = $this->getTask(); if (! $this->helper->user->canRemoveTask($task)) { - $this->forbidden(); + throw new AccessForbiddenException(); } if ($this->request->getStringParam('confirmation') === 'yes') { @@ -164,10 +166,10 @@ class Task extends Base $this->flash->failure(t('Unable to remove this task.')); } - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])), true); + return $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])), true); } - $this->response->html($this->template->render('task/remove', array( + return $this->response->html($this->template->render('task/remove', array( 'task' => $task, ))); } |