summaryrefslogtreecommitdiff
path: root/plugins/Bigboard/Controller
diff options
context:
space:
mode:
authorDzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl>2019-12-10 11:34:53 +0100
committerDzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl>2019-12-10 11:34:53 +0100
commitb8fa0246803dab40cf57d40b45984c53046f2d55 (patch)
treedc92b167c7542137c385614a1d558e57669a4339 /plugins/Bigboard/Controller
parent2a43146236fd8fb16f84398d85720ad84aa0a0b1 (diff)
Plugins directory and local modifications
Diffstat (limited to 'plugins/Bigboard/Controller')
-rw-r--r--plugins/Bigboard/Controller/Bigboard.php103
-rw-r--r--plugins/Bigboard/Controller/BoardAjaxController.php145
2 files changed, 248 insertions, 0 deletions
diff --git a/plugins/Bigboard/Controller/Bigboard.php b/plugins/Bigboard/Controller/Bigboard.php
new file mode 100644
index 00000000..80573d07
--- /dev/null
+++ b/plugins/Bigboard/Controller/Bigboard.php
@@ -0,0 +1,103 @@
+<?php
+
+namespace Kanboard\Plugin\Bigboard\Controller;
+
+use Kanboard\Controller\BaseController;
+use Kanboard\Formatter\BoardFormatter;
+use Kanboard\Model\UserMetadataModel;
+
+/**
+ * Bigboard Controller.
+ *
+ * @author Thomas Stinner
+ */
+ class Bigboard extends BaseController
+ {
+ /**
+ * Display a Board which contains multiple projects.
+ */
+ public function index()
+ {
+ if ($this->userSession->isAdmin()) {
+ $project_ids = $this->projectModel->getAllIds();
+ } else {
+ $project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId());
+ }
+
+ $nb_projects = count($project_ids);
+ // Draw a header First
+ $this->response->html($this->helper->layout->app('bigboard:board/show', array(
+ 'title' => t('Bigboard').' ('.$nb_projects.')',
+ 'board_selector' => false,
+ )));
+
+ echo $this->template->render('bigboard:board/dropdown', array(
+ 'bigboarddisplaymode' => $this->userSession->isBigboardCollapsed(),
+ ));
+
+ $this->showProjects($project_ids);
+
+ }
+
+ /**
+ * Show projects.
+ *
+ * @param $project_ids list of project ids to show
+ *
+ * @return bool
+ */
+ private function showProjects($project_ids)
+ {
+ print "<div id='bigboard'>";
+
+ foreach ($project_ids as $project_id) {
+ $project = $this->projectModel->getByIdWithOwner($project_id);
+ $search = $this->helper->projectHeader->getSearchQuery($project);
+
+ $this->userMetadataCacheDecorator->set(UserMetadataModel::KEY_BOARD_COLLAPSED.$project_id, $this->userSession->isBigboardCollapsed());
+
+ echo $this->template->render('bigboard:board/view', array(
+ 'no_layout' => true,
+ 'board_selector' => false,
+ 'project' => $project,
+ 'title' => $project['name'],
+ 'description' => $this->helper->projectHeader->getDescription($project),
+ 'board_private_refresh_interval' => $this->configModel->get('board_private_refresh_interval'),
+ 'board_highlight_period' => $this->configModel->get('board_highlight_period'),
+ 'swimlanes' => $this->taskLexer
+ ->build($search)
+ ->format(BoardFormatter::getInstance($this->container)->withProjectId($project['id'])),
+ ));
+ }
+
+ print "</div>";
+
+ }
+
+ public function collapseAll()
+ {
+ $this->changeDisplayMode(true);
+ }
+
+ public function expandAll()
+ {
+ $this->changeDisplayMode(false);
+ }
+
+ private function changeDisplayMode($mode)
+ {
+ session_set('bigboardCollapsed', $mode);
+
+ if ($this->userSession->isAdmin()) {
+ $project_ids = $this->projectModel->getAllIds();
+ } else {
+ $project_ids = $this->projectPermissionModel->getActiveProjectIds(session_get('user')['id']);
+ }
+
+ if ($this->request->isAjax()) {
+ $this->showProjects($project_ids);
+ } else {
+ $this->response->redirect($this->helper->url->to('Bigboard', 'index', array('plugin' => 'Bigboard')));
+ }
+ }
+ }
diff --git a/plugins/Bigboard/Controller/BoardAjaxController.php b/plugins/Bigboard/Controller/BoardAjaxController.php
new file mode 100644
index 00000000..57832fd5
--- /dev/null
+++ b/plugins/Bigboard/Controller/BoardAjaxController.php
@@ -0,0 +1,145 @@
+<?php
+
+namespace Kanboard\Plugin\Bigboard\Controller;
+
+use Kanboard\Controller\BaseController;
+use Kanboard\Core\Controller\AccessForbiddenException;
+use Kanboard\Model\UserMetadataModel;
+
+/**
+ * Class BoardAjaxController
+ *
+ * @package Kanboard\Controller
+ * @author Fredric Guillot
+ */
+class BoardAjaxController extends BaseController
+{
+ /**
+ * Save new task positions (Ajax request made by the drag and drop)
+ *
+ * @access public
+ */
+ public function save()
+ {
+ $project_id = $this->request->getIntegerParam('project_id');
+
+ if (! $project_id || ! $this->request->isAjax()) {
+ throw new AccessForbiddenException();
+ }
+
+ $values = $this->request->getJson();
+
+ if (! $this->helper->projectRole->canMoveTask($project_id, $values['src_column_id'], $values['dst_column_id'])) {
+ throw new AccessForbiddenException(e("You don't have the permission to move this task"));
+ }
+
+ $result =$this->taskPositionModel->movePosition(
+ $project_id,
+ $values['task_id'],
+ $values['dst_column_id'],
+ $values['position'],
+ $values['swimlane_id']
+ );
+
+ if (! $result) {
+ $this->response->status(400);
+ } else {
+ $this->response->html($this->renderBoard($project_id), 201);
+ }
+ }
+
+ /**
+ * Check if the board have been changed
+ *
+ * @access public
+ */
+ public function check()
+ {
+ $project_id = $this->request->getIntegerParam('project_id');
+ $timestamp = $this->request->getIntegerParam('timestamp');
+
+ if (! $project_id || ! $this->request->isAjax()) {
+ throw new AccessForbiddenException();
+ } elseif (! $this->projectModel->isModifiedSince($project_id, $timestamp)) {
+ $this->response->status(304);
+ } else {
+ $this->response->html($this->renderBoard($project_id));
+ }
+ }
+
+ /**
+ * Reload the board with new filters
+ *
+ * @access public
+ */
+ public function reload()
+ {
+ $project_id = $this->request->getIntegerParam('project_id');
+
+ if (! $project_id || ! $this->request->isAjax()) {
+ throw new AccessForbiddenException();
+ }
+
+ $values = $this->request->getJson();
+ $this->userSession->setFilters($project_id, empty($values['search']) ? '' : $values['search']);
+
+ $this->response->html($this->renderBoard($project_id));
+ }
+
+ /**
+ * Enable collapsed mode
+ *
+ * @access public
+ */
+ public function collapse()
+ {
+ $this->changeDisplayMode(1);
+ }
+
+ /**
+ * Enable expanded mode
+ *
+ * @access public
+ */
+ public function expand()
+ {
+ $this->changeDisplayMode(0);
+ }
+
+ /**
+ * Change display mode
+ *
+ * @access private
+ * @param int $mode
+ */
+ private function changeDisplayMode($mode)
+ {
+ $project_id = $this->request->getIntegerParam('project_id');
+ $this->userMetadataCacheDecorator->set(UserMetadataModel::KEY_BOARD_COLLAPSED.$project_id, $mode);
+
+ if ($this->request->isAjax()) {
+ $this->response->html($this->renderBoard($project_id));
+ } else {
+ $this->response->redirect($this->helper->url->to('BoardViewController', 'show', array('project_id' => $project_id)));
+ }
+ }
+
+ /**
+ * Render board
+ *
+ * @access protected
+ * @param integer $project_id
+ * @return string
+ */
+ protected function renderBoard($project_id)
+ {
+ return $this->template->render('bigboard:board/table_container', array(
+ 'project' => $this->projectModel->getById($project_id),
+ 'board_private_refresh_interval' => $this->configModel->get('board_private_refresh_interval'),
+ 'board_highlight_period' => $this->configModel->get('board_highlight_period'),
+ 'swimlanes' => $this->taskLexer
+ ->build($this->userSession->getFilters($project_id))
+ ->format($this->boardFormatter->withProjectId($project_id))
+ ));
+ }
+}