summaryrefslogtreecommitdiff
path: root/app/Controller/TaskReorderController.php
blob: 32bdfc5217c4889d2b35b8f568e99cc0f7ef6963 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

namespace Kanboard\Controller;

use Kanboard\Core\Controller\AccessForbiddenException;

class TaskReorderController extends BaseController
{
    public function reorderColumn()
    {
        $project = $this->getProject();

        if (! $this->helper->user->hasProjectAccess('TaskModificationController', 'update', $project['id'])) {
            throw new AccessForbiddenException();
        }

        $swimlaneID = $this->request->getIntegerParam('swimlane_id');
        $columnID = $this->request->getIntegerParam('column_id');
        $direction = $this->request->getStringParam('direction');
        $sort = $this->request->getStringParam('sort');

        switch ($sort) {
            case 'priority':
                $this->taskReorderModel->reorderByPriority($project['id'], $swimlaneID, $columnID, $direction);
                break;
            case 'assignee-priority':
                $this->taskReorderModel->reorderByAssigneeAndPriority($project['id'], $swimlaneID, $columnID, $direction);
                break;
            case 'assignee':
                $this->taskReorderModel->reorderByAssignee($project['id'], $swimlaneID, $columnID, $direction);
                break;
        }

        $this->response->redirect($this->helper->url->to('BoardViewController', 'show', ['project_id' => $project['id']]));
    }
}