summaryrefslogtreecommitdiff
path: root/app/Filter
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-04-10 12:13:42 -0400
committerFrederic Guillot <fred@kanboard.net>2016-04-10 12:13:42 -0400
commit2eadfb22912d94e76a479b694070735fbb0298f1 (patch)
tree4280c1bc33851da2188f4bc0aa49310a5923e021 /app/Filter
parent7b74f55a285d2785f83be148abdeab95e2b4a7c6 (diff)
Refactor ProjectActivity model to use Filter and Formatter interface
Diffstat (limited to 'app/Filter')
-rw-r--r--app/Filter/ProjectActivityProjectIdFilter.php38
-rw-r--r--app/Filter/ProjectActivityProjectIdsFilter.php43
-rw-r--r--app/Filter/ProjectActivityTaskIdFilter.php38
-rw-r--r--app/Filter/ProjectActivityTaskTitleFilter.php38
4 files changed, 157 insertions, 0 deletions
diff --git a/app/Filter/ProjectActivityProjectIdFilter.php b/app/Filter/ProjectActivityProjectIdFilter.php
new file mode 100644
index 00000000..bb4d8bd1
--- /dev/null
+++ b/app/Filter/ProjectActivityProjectIdFilter.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\Filter\FilterInterface;
+use Kanboard\Model\ProjectActivity;
+
+/**
+ * Filter activity events by projectId
+ *
+ * @package filter
+ * @author Frederic Guillot
+ */
+class ProjectActivityProjectIdFilter extends BaseFilter implements FilterInterface
+{
+ /**
+ * Get search attribute
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getAttributes()
+ {
+ return array('project_id');
+ }
+
+ /**
+ * Apply filter
+ *
+ * @access public
+ * @return FilterInterface
+ */
+ public function apply()
+ {
+ $this->query->eq(ProjectActivity::TABLE.'.project_id', $this->value);
+ return $this;
+ }
+}
diff --git a/app/Filter/ProjectActivityProjectIdsFilter.php b/app/Filter/ProjectActivityProjectIdsFilter.php
new file mode 100644
index 00000000..4d7c9028
--- /dev/null
+++ b/app/Filter/ProjectActivityProjectIdsFilter.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\Filter\FilterInterface;
+use Kanboard\Model\ProjectActivity;
+
+/**
+ * Filter activity events by projectIds
+ *
+ * @package filter
+ * @author Frederic Guillot
+ */
+class ProjectActivityProjectIdsFilter extends BaseFilter implements FilterInterface
+{
+ /**
+ * Get search attribute
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getAttributes()
+ {
+ return array('project_ids');
+ }
+
+ /**
+ * Apply filter
+ *
+ * @access public
+ * @return FilterInterface
+ */
+ public function apply()
+ {
+ if (empty($this->value)) {
+ $this->query->eq(ProjectActivity::TABLE.'.project_id', 0);
+ } else {
+ $this->query->in(ProjectActivity::TABLE.'.project_id', $this->value);
+ }
+
+ return $this;
+ }
+}
diff --git a/app/Filter/ProjectActivityTaskIdFilter.php b/app/Filter/ProjectActivityTaskIdFilter.php
new file mode 100644
index 00000000..e99efe09
--- /dev/null
+++ b/app/Filter/ProjectActivityTaskIdFilter.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\Filter\FilterInterface;
+use Kanboard\Model\ProjectActivity;
+
+/**
+ * Filter activity events by taskId
+ *
+ * @package filter
+ * @author Frederic Guillot
+ */
+class ProjectActivityTaskIdFilter extends BaseFilter implements FilterInterface
+{
+ /**
+ * Get search attribute
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getAttributes()
+ {
+ return array('task_id');
+ }
+
+ /**
+ * Apply filter
+ *
+ * @access public
+ * @return FilterInterface
+ */
+ public function apply()
+ {
+ $this->query->eq(ProjectActivity::TABLE.'.task_id', $this->value);
+ return $this;
+ }
+}
diff --git a/app/Filter/ProjectActivityTaskTitleFilter.php b/app/Filter/ProjectActivityTaskTitleFilter.php
new file mode 100644
index 00000000..ed3f36d6
--- /dev/null
+++ b/app/Filter/ProjectActivityTaskTitleFilter.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\Filter\FilterInterface;
+use Kanboard\Model\Task;
+
+/**
+ * Filter activity events by task title
+ *
+ * @package filter
+ * @author Frederic Guillot
+ */
+class ProjectActivityTaskTitleFilter extends BaseFilter implements FilterInterface
+{
+ /**
+ * Get search attribute
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getAttributes()
+ {
+ return array('title');
+ }
+
+ /**
+ * Apply filter
+ *
+ * @access public
+ * @return FilterInterface
+ */
+ public function apply()
+ {
+ $this->query->ilike(Task::TABLE.'.title', '%'.$this->value.'%');
+ return $this;
+ }
+}