summaryrefslogtreecommitdiff
path: root/app/Controller/Projectinfo.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-05-31 17:57:02 -0400
committerFrederic Guillot <fred@kanboard.net>2015-05-31 17:57:02 -0400
commit599b6624dde8cb1c1f6416ee0af530402089da4d (patch)
tree2cc995b09a4b2e67de276389fb28b0040d484296 /app/Controller/Projectinfo.php
parent380aacd3f586089ae5c1e69841c0e0cb99478dcd (diff)
Improve project navigation
Diffstat (limited to 'app/Controller/Projectinfo.php')
-rw-r--r--app/Controller/Projectinfo.php97
1 files changed, 97 insertions, 0 deletions
diff --git a/app/Controller/Projectinfo.php b/app/Controller/Projectinfo.php
new file mode 100644
index 00000000..a9498f43
--- /dev/null
+++ b/app/Controller/Projectinfo.php
@@ -0,0 +1,97 @@
+<?php
+
+namespace Controller;
+
+/**
+ * Project Info controller (ActivityStream + completed tasks)
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class Projectinfo extends Base
+{
+ /**
+ * Activity page for a project
+ *
+ * @access public
+ */
+ public function activity()
+ {
+ $project = $this->getProject();
+
+ $this->response->html($this->template->layout('projectinfo/activity', array(
+ 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
+ 'events' => $this->projectActivity->getProject($project['id']),
+ 'project' => $project,
+ 'title' => t('%s\'s activity', $project['name'])
+ )));
+ }
+
+ /**
+ * Task search for a given project
+ *
+ * @access public
+ */
+ public function search()
+ {
+ $project = $this->getProject();
+ $search = $this->request->getStringParam('search');
+ $nb_tasks = 0;
+
+ $paginator = $this->paginator
+ ->setUrl('projectinfo', 'search', array('search' => $search, 'project_id' => $project['id']))
+ ->setMax(30)
+ ->setOrder('tasks.id')
+ ->setDirection('DESC');
+
+ if ($search !== '') {
+
+ $paginator
+ ->setQuery($this->taskFinder->getSearchQuery($project['id'], $search))
+ ->calculate();
+
+ $nb_tasks = $paginator->getTotal();
+ }
+
+ $this->response->html($this->template->layout('projectinfo/search', array(
+ 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
+ 'values' => array(
+ 'search' => $search,
+ 'controller' => 'projectinfo',
+ 'action' => 'search',
+ 'project_id' => $project['id'],
+ ),
+ 'paginator' => $paginator,
+ 'project' => $project,
+ 'columns' => $this->board->getColumnsList($project['id']),
+ 'categories' => $this->category->getList($project['id'], false),
+ 'title' => t('Search in the project "%s"', $project['name']).($nb_tasks > 0 ? ' ('.$nb_tasks.')' : '')
+ )));
+ }
+
+ /**
+ * List of completed tasks for a given project
+ *
+ * @access public
+ */
+ public function tasks()
+ {
+ $project = $this->getProject();
+ $paginator = $this->paginator
+ ->setUrl('projectinfo', 'tasks', array('project_id' => $project['id']))
+ ->setMax(30)
+ ->setOrder('tasks.id')
+ ->setDirection('DESC')
+ ->setQuery($this->taskFinder->getClosedTaskQuery($project['id']))
+ ->calculate();
+
+ $this->response->html($this->template->layout('projectinfo/tasks', array(
+ 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
+ 'project' => $project,
+ 'columns' => $this->board->getColumnsList($project['id']),
+ 'categories' => $this->category->getList($project['id'], false),
+ 'paginator' => $paginator,
+ 'title' => t('Completed tasks for "%s"', $project['name']).' ('.$paginator->getTotal().')'
+ )));
+ }
+}