summaryrefslogtreecommitdiff
path: root/app/Model/TaskFilter.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/TaskFilter.php')
-rw-r--r--app/Model/TaskFilter.php43
1 files changed, 42 insertions, 1 deletions
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php
index 137a7a8e..1883298d 100644
--- a/app/Model/TaskFilter.php
+++ b/app/Model/TaskFilter.php
@@ -30,6 +30,7 @@ class TaskFilter extends Base
'T_COLUMN' => 'filterByColumnName',
'T_REFERENCE' => 'filterByReference',
'T_SWIMLANE' => 'filterBySwimlaneName',
+ 'T_LINK' => 'filterByLinkName',
);
/**
@@ -108,6 +109,22 @@ class TaskFilter extends Base
}
/**
+ * Create a new link query
+ *
+ * @access public
+ * @return \PicoDb\Table
+ */
+ public function createLinkQuery()
+ {
+ return $this->db->table(TaskLink::TABLE)
+ ->columns(
+ TaskLink::TABLE.'.task_id',
+ Link::TABLE.'.label'
+ )
+ ->join(Link::TABLE, 'id', 'link_id', TaskLink::TABLE);
+ }
+
+ /**
* Clone the filter
*
* @access public
@@ -452,7 +469,7 @@ class TaskFilter extends Base
$this->query->beginOr();
foreach ($values as $project) {
- $this->query->ilike(Board::TABLE.'.title', $project);
+ $this->query->ilike(Column::TABLE.'.title', $project);
}
$this->query->closeOr();
@@ -507,6 +524,30 @@ class TaskFilter extends Base
}
/**
+ * Filter by link
+ *
+ * @access public
+ * @param array $values List of links
+ * @return TaskFilter
+ */
+ public function filterByLinkName(array $values)
+ {
+ $this->query->beginOr();
+
+ $link_query = $this->createLinkQuery()->in(Link::TABLE.'.label', $values);
+ $matching_task_ids = $link_query->findAllByColumn('task_id');
+ if (empty($matching_task_ids)) {
+ $this->query->eq(Task::TABLE.'.id', 0);
+ } else {
+ $this->query->in(Task::TABLE.'.id', $matching_task_ids);
+ }
+
+ $this->query->closeOr();
+
+ return $this;
+ }
+
+ /**
* Filter by due date
*
* @access public