summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorFrédéric Guillot <fguillot@users.noreply.github.com>2014-04-27 15:14:13 -0400
committerFrédéric Guillot <fguillot@users.noreply.github.com>2014-04-27 15:14:13 -0400
commit096b282a473fa2b27c3bfe3061f54b5fd83c75e0 (patch)
treefc358e47860c50ab8505e0666043d76196e48016 /controllers
parent6551609d1b248011d301080c1be7c48085dc5d55 (diff)
Add a basic task search
Diffstat (limited to 'controllers')
-rw-r--r--controllers/project.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/controllers/project.php b/controllers/project.php
index 6085caec..a9ce8634 100644
--- a/controllers/project.php
+++ b/controllers/project.php
@@ -26,6 +26,57 @@ class Project extends Base
}
/**
+ * Task search for a given project
+ *
+ * @access public
+ */
+ public function search()
+ {
+ $project_id = $this->request->getIntegerParam('project_id');
+ $search = $this->request->getStringParam('search');
+
+ $project = $this->project->getById($project_id);
+ $tasks = array();
+ $nb_tasks = 0;
+
+ if (! $project) {
+ $this->session->flashError(t('Project not found.'));
+ $this->response->redirect('?controller=project');
+ }
+
+ $this->checkProjectPermissions($project['id']);
+
+ if ($search !== '') {
+
+ $filters = array(
+ array('column' => 'project_id', 'operator' => 'eq', 'value' => $project_id),
+ 'or' => array(
+ array('column' => 'title', 'operator' => 'like', 'value' => '%'.$search.'%'),
+ array('column' => 'description', 'operator' => 'like', 'value' => '%'.$search.'%'),
+ )
+ );
+
+ $tasks = $this->task->find($filters);
+ $nb_tasks = count($tasks);
+ }
+
+ $this->response->html($this->template->layout('project_search', array(
+ 'tasks' => $tasks,
+ 'nb_tasks' => $nb_tasks,
+ 'values' => array(
+ 'search' => $search,
+ 'controller' => 'project',
+ 'action' => 'search',
+ 'project_id' => $project['id'],
+ ),
+ 'menu' => 'projects',
+ 'project' => $project,
+ 'columns' => $this->board->getColumnsList($project_id),
+ 'title' => $project['name'].($nb_tasks > 0 ? ' ('.$nb_tasks.')' : '')
+ )));
+ }
+
+ /**
* List of completed tasks for a given project
*
* @access public