summaryrefslogtreecommitdiff
path: root/app/Filter/TaskStatusFilter.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Filter/TaskStatusFilter.php')
-rw-r--r--app/Filter/TaskStatusFilter.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/Filter/TaskStatusFilter.php b/app/Filter/TaskStatusFilter.php
new file mode 100644
index 00000000..0ba4361e
--- /dev/null
+++ b/app/Filter/TaskStatusFilter.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\Filter\FilterInterface;
+use Kanboard\Model\Task;
+
+/**
+ * Filter tasks by status
+ *
+ * @package filter
+ * @author Frederic Guillot
+ */
+class TaskStatusFilter extends BaseFilter implements FilterInterface
+{
+ /**
+ * Get search attribute
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getAttributes()
+ {
+ return array('status');
+ }
+
+ /**
+ * Apply filter
+ *
+ * @access public
+ * @return FilterInterface
+ */
+ public function apply()
+ {
+ if ($this->value === 'open' || $this->value === 'closed') {
+ $this->query->eq(Task::TABLE.'.is_active', $this->value === 'open' ? Task::STATUS_OPEN : Task::STATUS_CLOSED);
+ } else {
+ $this->query->eq(Task::TABLE.'.is_active', $this->value);
+ }
+
+ return $this;
+ }
+}