diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-28 14:05:57 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-28 14:05:57 -0400 |
commit | 8d12e2fe736a72d6ad69807ac853a7e325c8cbf3 (patch) | |
tree | ea18a49b44db9bfa55c7e09ee8c939a98b088239 /app/Controller | |
parent | 1353929a7dbd3f2e897fa7d3ab88e959ca573f9f (diff) |
Split board controller into multiple classes
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/BoardAjaxController.php (renamed from app/Controller/Board.php) | 70 | ||||
-rw-r--r-- | app/Controller/BoardPopoverController.php | 2 | ||||
-rw-r--r-- | app/Controller/BoardViewController.php | 65 | ||||
-rw-r--r-- | app/Controller/TaskBulkController.php | 2 | ||||
-rw-r--r-- | app/Controller/TaskCreationController.php | 2 | ||||
-rw-r--r-- | app/Controller/TaskPopoverController.php | 4 | ||||
-rw-r--r-- | app/Controller/TaskViewController.php | 2 |
7 files changed, 80 insertions, 67 deletions
diff --git a/app/Controller/Board.php b/app/Controller/BoardAjaxController.php index 0f6b3b14..d4714699 100644 --- a/app/Controller/Board.php +++ b/app/Controller/BoardAjaxController.php @@ -6,67 +6,15 @@ use Kanboard\Core\Controller\AccessForbiddenException; use Kanboard\Formatter\BoardFormatter; /** - * Board controller + * Class BoardAjaxController * - * @package controller - * @author Frederic Guillot + * @package Kanboard\Controller + * @author Fredric Guillot */ -class Board extends BaseController +class BoardAjaxController extends BaseController { /** - * Display the public version of a board - * Access checked by a simple token, no user login, read only, auto-refresh - * - * @access public - */ - public function readonly() - { - $token = $this->request->getStringParam('token'); - $project = $this->project->getByToken($token); - - // Token verification - if (empty($project)) { - throw AccessForbiddenException::getInstance()->withoutLayout(); - } - - // Display the board with a specific layout - $this->response->html($this->helper->layout->app('board/view_public', array( - 'project' => $project, - 'swimlanes' => $this->board->getBoard($project['id']), - 'title' => $project['name'], - 'description' => $project['description'], - 'no_layout' => true, - 'not_editable' => true, - 'board_public_refresh_interval' => $this->config->get('board_public_refresh_interval'), - 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), - 'board_highlight_period' => $this->config->get('board_highlight_period'), - ))); - } - - /** - * Show a board for a given project - * - * @access public - */ - public function show() - { - $project = $this->getProject(); - $search = $this->helper->projectHeader->getSearchQuery($project); - - $this->response->html($this->helper->layout->app('board/view_private', array( - 'project' => $project, - 'title' => $project['name'], - 'description' => $this->helper->projectHeader->getDescription($project), - 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), - 'board_highlight_period' => $this->config->get('board_highlight_period'), - 'swimlanes' => $this->taskLexer - ->build($search) - ->format(BoardFormatter::getInstance($this->container)->setProjectId($project['id'])) - ))); - } - - /** - * Save the board (Ajax request made by the drag and drop) + * Save new task positions (Ajax request made by the drag and drop) * * @access public */ @@ -106,7 +54,7 @@ class Board extends BaseController $timestamp = $this->request->getIntegerParam('timestamp'); if (! $project_id || ! $this->request->isAjax()) { - $this->response->status(403); + throw new AccessForbiddenException(); } elseif (! $this->project->isModifiedSince($project_id, $timestamp)) { $this->response->status(304); } else { @@ -167,18 +115,18 @@ class Board extends BaseController if ($this->request->isAjax()) { $this->response->html($this->renderBoard($project_id)); } else { - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project_id))); + $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project_id))); } } /** * Render board * - * @access private + * @access protected * @param integer $project_id * @return string */ - private function renderBoard($project_id) + protected function renderBoard($project_id) { return $this->template->render('board/table_container', array( 'project' => $this->project->getById($project_id), diff --git a/app/Controller/BoardPopoverController.php b/app/Controller/BoardPopoverController.php index b204af39..2c2e5dc6 100644 --- a/app/Controller/BoardPopoverController.php +++ b/app/Controller/BoardPopoverController.php @@ -42,6 +42,6 @@ class BoardPopoverController extends BaseController $this->taskStatus->closeTasksBySwimlaneAndColumn($values['swimlane_id'], $values['column_id']); $this->flash->success(t('All tasks of the column "%s" and the swimlane "%s" have been closed successfully.', $this->column->getColumnTitleById($values['column_id']), $this->swimlane->getNameById($values['swimlane_id']) ?: t($project['default_swimlane']))); - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id']))); + $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id']))); } } diff --git a/app/Controller/BoardViewController.php b/app/Controller/BoardViewController.php new file mode 100644 index 00000000..3c96af73 --- /dev/null +++ b/app/Controller/BoardViewController.php @@ -0,0 +1,65 @@ +<?php + +namespace Kanboard\Controller; + +use Kanboard\Core\Controller\AccessForbiddenException; +use Kanboard\Formatter\BoardFormatter; + +/** + * Board controller + * + * @package Kanboard\Controller + * @author Frederic Guillot + */ +class BoardViewController extends BaseController +{ + /** + * Display the public version of a board + * Access checked by a simple token, no user login, read only, auto-refresh + * + * @access public + */ + public function readonly() + { + $token = $this->request->getStringParam('token'); + $project = $this->project->getByToken($token); + + if (empty($project)) { + throw AccessForbiddenException::getInstance()->withoutLayout(); + } + + $this->response->html($this->helper->layout->app('board/view_public', array( + 'project' => $project, + 'swimlanes' => $this->board->getBoard($project['id']), + 'title' => $project['name'], + 'description' => $project['description'], + 'no_layout' => true, + 'not_editable' => true, + 'board_public_refresh_interval' => $this->config->get('board_public_refresh_interval'), + 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), + 'board_highlight_period' => $this->config->get('board_highlight_period'), + ))); + } + + /** + * Show a board for a given project + * + * @access public + */ + public function show() + { + $project = $this->getProject(); + $search = $this->helper->projectHeader->getSearchQuery($project); + + $this->response->html($this->helper->layout->app('board/view_private', array( + 'project' => $project, + 'title' => $project['name'], + 'description' => $this->helper->projectHeader->getDescription($project), + 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'), + 'board_highlight_period' => $this->config->get('board_highlight_period'), + 'swimlanes' => $this->taskLexer + ->build($search) + ->format(BoardFormatter::getInstance($this->container)->setProjectId($project['id'])) + ))); + } +} diff --git a/app/Controller/TaskBulkController.php b/app/Controller/TaskBulkController.php index c0214ea7..528ae7a3 100644 --- a/app/Controller/TaskBulkController.php +++ b/app/Controller/TaskBulkController.php @@ -50,7 +50,7 @@ class TaskBulkController extends BaseController if ($valid) { $this->createTasks($project, $values); $this->response->redirect($this->helper->url->to( - 'Board', + 'BoardViewController', 'show', array('project_id' => $project['id']), 'swimlane-'. $values['swimlane_id'] diff --git a/app/Controller/TaskCreationController.php b/app/Controller/TaskCreationController.php index 2a63ddcc..b7af6d87 100644 --- a/app/Controller/TaskCreationController.php +++ b/app/Controller/TaskCreationController.php @@ -82,6 +82,6 @@ class TaskCreationController extends BaseController )); } - return $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id'])), true); + return $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id'])), true); } } diff --git a/app/Controller/TaskPopoverController.php b/app/Controller/TaskPopoverController.php index 9bac2206..9916a5d1 100644 --- a/app/Controller/TaskPopoverController.php +++ b/app/Controller/TaskPopoverController.php @@ -44,7 +44,7 @@ class TaskPopoverController extends BaseController $this->flash->failure(t('Unable to update your task.')); } - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])), true); + $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $values['project_id'])), true); } /** @@ -81,7 +81,7 @@ class TaskPopoverController extends BaseController $this->flash->failure(t('Unable to update your task.')); } - $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $values['project_id'])), true); + $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $values['project_id'])), true); } /** diff --git a/app/Controller/TaskViewController.php b/app/Controller/TaskViewController.php index 833d42a4..6d3cc5c5 100644 --- a/app/Controller/TaskViewController.php +++ b/app/Controller/TaskViewController.php @@ -166,7 +166,7 @@ class TaskViewController extends BaseController $this->flash->failure(t('Unable to remove this task.')); } - return $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])), true); + return $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $task['project_id'])), true); } return $this->response->html($this->template->render('task/remove', array( |