summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2018-06-07 15:02:10 -0700
committerFrédéric Guillot <fred@kanboard.net>2018-06-07 15:02:10 -0700
commit9d4be201aaaeaac23f4b18fb6c91caca857a2f0f (patch)
tree0b669aa0d7d382679100a69c0f9a59287b906568 /app/Controller
parentdfea2f23653644b574322a5199c120a32e1f29f3 (diff)
Add quick link assign me in different views
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/TaskModificationController.php39
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']]));
+ }
}
/**