summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Filter/TaskTagFilter.php74
-rw-r--r--app/Model/TaskTagModel.php20
-rw-r--r--app/ServiceProvider/FilterProvider.php4
3 files changed, 88 insertions, 10 deletions
diff --git a/app/Filter/TaskTagFilter.php b/app/Filter/TaskTagFilter.php
new file mode 100644
index 00000000..01b6f625
--- /dev/null
+++ b/app/Filter/TaskTagFilter.php
@@ -0,0 +1,74 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\Filter\FilterInterface;
+use Kanboard\Model\TagModel;
+use Kanboard\Model\TaskModel;
+use Kanboard\Model\TaskTagModel;
+use PicoDb\Database;
+
+/**
+ * Class TaskTagFilter
+ *
+ * @package Kanboard\Filter
+ * @author Frederic Guillot
+ */
+class TaskTagFilter extends BaseFilter implements FilterInterface
+{
+ /**
+ * Database object
+ *
+ * @access private
+ * @var Database
+ */
+ private $db;
+
+ /**
+ * Get search attribute
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getAttributes()
+ {
+ return array('tag');
+ }
+
+ /**
+ * Set database object
+ *
+ * @access public
+ * @param Database $db
+ * @return $this
+ */
+ public function setDatabase(Database $db)
+ {
+ $this->db = $db;
+ return $this;
+ }
+
+ /**
+ * Apply filter
+ *
+ * @access public
+ * @return FilterInterface
+ */
+ public function apply()
+ {
+ $task_ids = $this->db
+ ->table(TagModel::TABLE)
+ ->ilike(TagModel::TABLE.'.name', $this->value)
+ ->asc(TagModel::TABLE.'.project_id')
+ ->join(TaskTagModel::TABLE, 'tag_id', 'id')
+ ->findAllByColumn(TaskTagModel::TABLE.'.task_id');
+
+ if (empty($task_ids)) {
+ $task_ids = array(-1);
+ }
+
+ $this->query->in(TaskModel::TABLE.'.id', $task_ids);
+
+ return $this;
+ }
+}
diff --git a/app/Model/TaskTagModel.php b/app/Model/TaskTagModel.php
index 3dd1dd88..91dfd224 100644
--- a/app/Model/TaskTagModel.php
+++ b/app/Model/TaskTagModel.php
@@ -74,9 +74,9 @@ class TaskTagModel extends Base
* Add or update a list of tags to a task
*
* @access public
- * @param integer $project_id
- * @param integer $task_id
- * @param string[] $tags
+ * @param integer $project_id
+ * @param integer $task_id
+ * @param string[] $tags
* @return boolean
*/
public function save($project_id, $task_id, array $tags)
@@ -123,10 +123,10 @@ class TaskTagModel extends Base
* Associate missing tags
*
* @access protected
- * @param integer $project_id
- * @param integer $task_id
- * @param array $task_tags
- * @param array $tags
+ * @param integer $project_id
+ * @param integer $task_id
+ * @param array $task_tags
+ * @param string[] $tags
* @return bool
*/
protected function associateTags($project_id, $task_id, $task_tags, $tags)
@@ -146,9 +146,9 @@ class TaskTagModel extends Base
* Dissociate removed tags
*
* @access protected
- * @param integer $task_id
- * @param array $task_tags
- * @param array $tags
+ * @param integer $task_id
+ * @param array $task_tags
+ * @param string[] $tags
* @return bool
*/
protected function dissociateTags($task_id, $task_tags, $tags)
diff --git a/app/ServiceProvider/FilterProvider.php b/app/ServiceProvider/FilterProvider.php
index cdef9ed8..20281a09 100644
--- a/app/ServiceProvider/FilterProvider.php
+++ b/app/ServiceProvider/FilterProvider.php
@@ -26,6 +26,7 @@ use Kanboard\Filter\TaskReferenceFilter;
use Kanboard\Filter\TaskStatusFilter;
use Kanboard\Filter\TaskSubtaskAssigneeFilter;
use Kanboard\Filter\TaskSwimlaneFilter;
+use Kanboard\Filter\TaskTagFilter;
use Kanboard\Filter\TaskTitleFilter;
use Kanboard\Model\ProjectModel;
use Kanboard\Model\ProjectGroupRoleModel;
@@ -163,6 +164,9 @@ class FilterProvider implements ServiceProviderInterface
->setDatabase($c['db'])
)
->withFilter(new TaskSwimlaneFilter())
+ ->withFilter(TaskTagFilter::getInstance()
+ ->setDatabase($c['db'])
+ )
->withFilter(new TaskTitleFilter(), true)
;