summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-28 21:53:50 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-28 21:53:50 -0400
commit3f084916e3befbaadf8dc86c8329a408dfcdf351 (patch)
treefcf79fbb59469dea4bb0fe8a8f657bd4bf29695e /app/Model
parent7c1222fc595091d9e292bae9d563a3fdaf660d7b (diff)
Add category attribute for advanced search
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/TaskFilter.php27
-rw-r--r--app/Model/TaskFinder.php15
2 files changed, 27 insertions, 15 deletions
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php
index bdfbb190..b14dad0a 100644
--- a/app/Model/TaskFilter.php
+++ b/app/Model/TaskFilter.php
@@ -59,6 +59,9 @@ class TaskFilter extends Base
case 'T_DESCRIPTION':
$this->filterByDescription($value);
break;
+ case 'T_CATEGORY':
+ $this->filterByCategoryName($value);
+ break;
}
}
@@ -203,6 +206,30 @@ class TaskFilter extends Base
}
/**
+ * Filter by category
+ *
+ * @access public
+ * @param array $values List of assignees
+ * @return TaskFilter
+ */
+ public function filterByCategoryName(array $values)
+ {
+ $this->query->join(Category::TABLE, 'id', 'category_id');
+ $this->query->beginOr();
+
+ foreach ($values as $category) {
+ if ($category === 'none') {
+ $this->query->eq(Task::TABLE.'.category_id', 0);
+ }
+ else {
+ $this->query->eq(Category::TABLE.'.name', $category);
+ }
+ }
+
+ $this->query->closeOr();
+ }
+
+ /**
* Filter by assignee
*
* @access public
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index 9c46f4a9..e007187f 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -27,21 +27,6 @@ class TaskFinder extends Base
}
/**
- * Get query for task search
- *
- * @access public
- * @param integer $project_id Project id
- * @param string $search Search terms
- * @return \PicoDb\Table
- */
- public function getSearchQuery($project_id, $search)
- {
- return $this->getExtendedQuery()
- ->eq('project_id', $project_id)
- ->ilike('title', '%'.$search.'%');
- }
-
- /**
* Get query for assigned user tasks
*
* @access public