diff options
Diffstat (limited to 'app/Controller/TaskMovePositionController.php')
-rw-r--r-- | app/Controller/TaskMovePositionController.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/app/Controller/TaskMovePositionController.php b/app/Controller/TaskMovePositionController.php new file mode 100644 index 00000000..39687b79 --- /dev/null +++ b/app/Controller/TaskMovePositionController.php @@ -0,0 +1,51 @@ +<?php + +namespace Kanboard\Controller; + +use Kanboard\Core\Controller\AccessForbiddenException; +use Kanboard\Model\TaskModel; + +/** + * Class TaskMovePositionController + * + * @package Kanboard\Controller + * @author Frederic Guillot + */ +class TaskMovePositionController extends BaseController +{ + public function show() + { + $task = $this->getTask(); + + $this->response->html($this->template->render('task_move_position/show', array( + 'task' => $task, + 'board' => $this->boardFormatter + ->withProjectId($task['project_id']) + ->withQuery($this->taskFinderModel->getExtendedQuery() + ->eq(TaskModel::TABLE.'.is_active', TaskModel::STATUS_OPEN) + ->neq(TaskModel::TABLE.'.id', $task['id']) + ) + ->format() + ))); + } + + public function save() + { + $task = $this->getTask(); + $values = $this->request->getJson(); + + if (! $this->helper->projectRole->canMoveTask($task['project_id'], $task['column_id'], $values['column_id'])) { + throw new AccessForbiddenException(e('You are not allowed to move this task.')); + } + + $this->taskPositionModel->movePosition( + $task['project_id'], + $task['id'], + $values['column_id'], + $values['position'], + $values['swimlane_id'] + ); + + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); + } +} |