summaryrefslogtreecommitdiff
path: root/app/Model/TaskFilter.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-07-01 19:32:51 -0400
committerFrederic Guillot <fred@kanboard.net>2015-07-01 19:32:51 -0400
commit471e46e70294684efc6d7edfc814d5b9ca04738b (patch)
treebe35eb01fe0f9222406ec1c3c165a78d07397788 /app/Model/TaskFilter.php
parent107699e5ed61175cc45eba6d59219d8a40946291 (diff)
Add project and column attributes for advanced search
Diffstat (limited to 'app/Model/TaskFilter.php')
-rw-r--r--app/Model/TaskFilter.php50
1 files changed, 48 insertions, 2 deletions
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php
index 4a086078..31080cb5 100644
--- a/app/Model/TaskFilter.php
+++ b/app/Model/TaskFilter.php
@@ -62,6 +62,12 @@ class TaskFilter extends Base
case 'T_CATEGORY':
$this->filterByCategoryName($value);
break;
+ case 'T_PROJECT':
+ $this->filterByProjectName($value);
+ break;
+ case 'T_COLUMN':
+ $this->filterByColumnName($value);
+ break;
}
}
@@ -190,6 +196,29 @@ class TaskFilter extends Base
}
/**
+ * Filter by project name
+ *
+ * @access public
+ * @param array $values List of project name
+ * @return TaskFilter
+ */
+ public function filterByProjectName(array $values)
+ {
+ $this->query->beginOr();
+
+ foreach ($values as $project) {
+ if (ctype_digit($project)) {
+ $this->query->eq(Task::TABLE.'.project_id', $project);
+ }
+ else {
+ $this->query->ilike(Project::TABLE.'.name', $project);
+ }
+ }
+
+ $this->query->closeOr();
+ }
+
+ /**
* Filter by category id
*
* @access public
@@ -326,6 +355,24 @@ class TaskFilter extends Base
}
/**
+ * Filter by column name
+ *
+ * @access public
+ * @param array $values List of column name
+ * @return TaskFilter
+ */
+ public function filterByColumnName(array $values)
+ {
+ $this->query->beginOr();
+
+ foreach ($values as $project) {
+ $this->query->ilike(Board::TABLE.'.title', $project);
+ }
+
+ $this->query->closeOr();
+ }
+
+ /**
* Filter by swimlane
*
* @access public
@@ -382,7 +429,6 @@ class TaskFilter extends Base
*/
public function filterByDueDate($date)
{
- $this->query->neq(Task::TABLE.'.date_due', '');
$this->query->neq(Task::TABLE.'.date_due', 0);
$this->query->notNull(Task::TABLE.'.date_due');
return $this->filterWithOperator(Task::TABLE.'.date_due', $date, true);
@@ -452,7 +498,7 @@ class TaskFilter extends Base
*/
public function findAll()
{
- return $this->query->findAll();
+ return $this->query->asc(Task::TABLE.'.id')->findAll();
}
/**