diff options
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/TaskModificationController.php | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/app/Controller/TaskModificationController.php b/app/Controller/TaskModificationController.php index 07e9d932..dcf9ec2a 100644 --- a/app/Controller/TaskModificationController.php +++ b/app/Controller/TaskModificationController.php @@ -14,6 +14,19 @@ use Kanboard\Core\ExternalTask\ExternalTaskException; */ class TaskModificationController extends BaseController { + public function assignToMe() + { + $task = $this->getTask(); + $values = ['id' => $task['id'], 'owner_id' => $this->userSession->getId()]; + + if (! $this->helper->projectRole->canUpdateTask($task)) { + throw new AccessForbiddenException(t('You are not allowed to update tasks assigned to someone else.')); + } + + $this->taskModificationModel->update($values); + $this->redirectAfterQuickAction($task); + } + /** * Set the start date automatically * @@ -22,12 +35,34 @@ class TaskModificationController extends BaseController public function start() { $task = $this->getTask(); - $values = array('id' => $task['id'], 'date_started' => time()); + $values = ['id' => $task['id'], 'date_started' => time()]; + if (! $this->helper->projectRole->canUpdateTask($task)) { throw new AccessForbiddenException(t('You are not allowed to update tasks assigned to someone else.')); } + $this->taskModificationModel->update($values); - $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); + $this->redirectAfterQuickAction($task); + } + + protected function redirectAfterQuickAction(array $task) + { + switch ($this->request->getStringParam('redirect')) { + case 'board': + $this->response->redirect($this->helper->url->to('BoardViewController', 'show', ['project_id' => $task['project_id']])); + break; + case 'list': + $this->response->redirect($this->helper->url->to('TaskListController', 'show', ['project_id' => $task['project_id']])); + break; + case 'dashboard': + $this->response->redirect($this->helper->url->to('DashboardController', 'show', [], 'project-tasks-'.$task['project_id'])); + break; + case 'dashboard-tasks': + $this->response->redirect($this->helper->url->to('DashboardController', 'tasks', ['user_id' => $this->userSession->getId()])); + break; + default: + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', ['project_id' => $task['project_id'], 'task_id' => $task['id']])); + } } /** |