Files
OrganonTweaks/Controller/OrganonSortController.php

62 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2026-07-13 10:25:28 -03:00
<?php
namespace Kanboard\Plugin\OrganonTweaks\Controller;
use Kanboard\Controller\BaseController;
use Kanboard\Core\Controller\AccessForbiddenException;
use Kanboard\Plugin\OrganonTweaks\Helper\OrganonSortHelper;
/**
* Per-column persistent sort, driven from the column's sort control on the board. Project-member
* (task-update) gated + CSRF, mirroring core TaskReorderController; returns to the board.
*/
class OrganonSortController extends BaseController
{
private function authorize()
{
$project = $this->getProject();
if (! $this->helper->user->hasProjectAccess('TaskModificationController', 'update', $project['id'])) {
throw new AccessForbiddenException();
}
return $project;
}
private function sorter()
{
return new OrganonSortHelper($this->container);
}
private function backToBoard(array $project)
{
$this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id'])));
}
public function sort()
{
$this->checkCSRFParam();
$project = $this->authorize();
$this->sorter()->applySort(
$project['id'],
$this->request->getIntegerParam('swimlane_id'),
$this->request->getIntegerParam('column_id'),
$this->request->getStringParam('sort'),
$this->request->getStringParam('direction')
);
$this->backToBoard($project);
}
public function toggle()
{
$this->checkCSRFParam();
$project = $this->authorize();
$this->sorter()->toggle($project['id'], $this->request->getIntegerParam('column_id'));
$this->backToBoard($project);
}
}