summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Filter/BaseDateRangeFilter.php54
-rw-r--r--app/Filter/TaskCreationDateRangeFilter.php38
-rw-r--r--app/Filter/TaskMovedDateRangeFilter.php38
-rw-r--r--app/ServiceProvider/FilterProvider.php8
-rw-r--r--vendor/composer/autoload_classmap.php3
-rw-r--r--vendor/composer/autoload_static.php3
6 files changed, 144 insertions, 0 deletions
diff --git a/app/Filter/BaseDateRangeFilter.php b/app/Filter/BaseDateRangeFilter.php
new file mode 100644
index 00000000..336f8c8e
--- /dev/null
+++ b/app/Filter/BaseDateRangeFilter.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\DateParser;
+
+/**
+ * Base date filter class
+ *
+ * @package filter
+ * @author Kamil Ściana
+ */
+abstract class BaseDateRangeFilter extends BaseFilter
+{
+ /**
+ * DateParser object
+ *
+ * @access protected
+ * @var DateParser
+ */
+ protected $dateParser;
+
+ /**
+ * Set DateParser object
+ *
+ * @access public
+ * @param DateParser $dateParser
+ * @return $this
+ */
+ public function setDateParser(DateParser $dateParser)
+ {
+ $this->dateParser = $dateParser;
+ return $this;
+ }
+
+ /**
+ * Apply a date filter
+ *
+ * @access protected
+ * @param string $field
+ */
+ protected function applyDateFilter($field)
+ {
+ $dates = explode('..', $this->value);
+
+ if(count($dates)=== 2){
+ $timestampFrom = $this->dateParser->getTimestamp($dates[0]);
+ $timestampTo = $this->dateParser->getTimestamp($dates[1]);
+
+ $this->query->gte($field, $timestampFrom);
+ $this->query->lte($field, $timestampTo + 86399);
+ }
+ }
+}
diff --git a/app/Filter/TaskCreationDateRangeFilter.php b/app/Filter/TaskCreationDateRangeFilter.php
new file mode 100644
index 00000000..7696af07
--- /dev/null
+++ b/app/Filter/TaskCreationDateRangeFilter.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\Filter\FilterInterface;
+use Kanboard\Model\TaskModel;
+
+/**
+ * Filter tasks by creation date
+ *
+ * @package filter
+ * @author Kamil Ściana
+ */
+class TaskCreationDateRangeFilter extends BaseDateRangeFilter implements FilterInterface
+{
+ /**
+ * Get search attribute
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getAttributes()
+ {
+ return array('createdRange');
+ }
+
+ /**
+ * Apply filter
+ *
+ * @access public
+ * @return FilterInterface
+ */
+ public function apply()
+ {
+ $this->applyDateFilter(TaskModel::TABLE.'.date_creation');
+ return $this;
+ }
+}
diff --git a/app/Filter/TaskMovedDateRangeFilter.php b/app/Filter/TaskMovedDateRangeFilter.php
new file mode 100644
index 00000000..b5b826b0
--- /dev/null
+++ b/app/Filter/TaskMovedDateRangeFilter.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Kanboard\Filter;
+
+use Kanboard\Core\Filter\FilterInterface;
+use Kanboard\Model\TaskModel;
+
+/**
+ * Filter tasks by creation date
+ *
+ * @package filter
+ * @author Kamil Ściana
+ */
+class TaskMovedDateRangeFilter extends BaseDateRangeFilter implements FilterInterface
+{
+ /**
+ * Get search attribute
+ *
+ * @access public
+ * @return string[]
+ */
+ public function getAttributes()
+ {
+ return array('movedRange');
+ }
+
+ /**
+ * Apply filter
+ *
+ * @access public
+ * @return FilterInterface
+ */
+ public function apply()
+ {
+ $this->applyDateFilter(TaskModel::TABLE.'.date_moved');
+ return $this;
+ }
+}
diff --git a/app/ServiceProvider/FilterProvider.php b/app/ServiceProvider/FilterProvider.php
index 11a29e69..c61d2284 100644
--- a/app/ServiceProvider/FilterProvider.php
+++ b/app/ServiceProvider/FilterProvider.php
@@ -16,6 +16,7 @@ use Kanboard\Filter\TaskColumnFilter;
use Kanboard\Filter\TaskCommentFilter;
use Kanboard\Filter\TaskCompletionDateFilter;
use Kanboard\Filter\TaskCreationDateFilter;
+use Kanboard\Filter\TaskCreationDateRangeFilter;
use Kanboard\Filter\TaskCreatorFilter;
use Kanboard\Filter\TaskDescriptionFilter;
use Kanboard\Filter\TaskDueDateFilter;
@@ -24,6 +25,7 @@ use Kanboard\Filter\TaskIdFilter;
use Kanboard\Filter\TaskLinkFilter;
use Kanboard\Filter\TaskModificationDateFilter;
use Kanboard\Filter\TaskMovedDateFilter;
+use Kanboard\Filter\TaskMovedDateRangeFilter;
use Kanboard\Filter\TaskPriorityFilter;
use Kanboard\Filter\TaskProjectFilter;
use Kanboard\Filter\TaskReferenceFilter;
@@ -148,6 +150,9 @@ class FilterProvider implements ServiceProviderInterface
->withFilter(TaskCreationDateFilter::getInstance()
->setDateParser($c['dateParser'])
)
+ ->withFilter(TaskCreationDateRangeFilter::getInstance()
+ ->setDateParser($c['dateParser'])
+ )
->withFilter(TaskCreatorFilter::getInstance()
->setCurrentUserId($c['userSession']->getId())
)
@@ -171,6 +176,9 @@ class FilterProvider implements ServiceProviderInterface
->withFilter(TaskMovedDateFilter::getInstance()
->setDateParser($c['dateParser'])
)
+ ->withFilter(TaskMovedDateRangeFilter::getInstance()
+ ->setDateParser($c['dateParser'])
+ )
->withFilter(new TaskProjectFilter())
->withFilter(new TaskReferenceFilter())
->withFilter(new TaskScoreFilter())
diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
index 07f96725..780def81 100644
--- a/vendor/composer/autoload_classmap.php
+++ b/vendor/composer/autoload_classmap.php
@@ -425,6 +425,7 @@ return array(
'Kanboard\\ExternalLink\\WebLinkProvider' => $baseDir . '/app/ExternalLink/WebLinkProvider.php',
'Kanboard\\Filter\\BaseComparisonFilter' => $baseDir . '/app/Filter/BaseComparisonFilter.php',
'Kanboard\\Filter\\BaseDateFilter' => $baseDir . '/app/Filter/BaseDateFilter.php',
+ 'Kanboard\\Filter\\BaseDateRangeFilter' => $baseDir . '/app/Filter/BaseDateRangeFilter.php',
'Kanboard\\Filter\\BaseFilter' => $baseDir . '/app/Filter/BaseFilter.php',
'Kanboard\\Filter\\ProjectActivityCreationDateFilter' => $baseDir . '/app/Filter/ProjectActivityCreationDateFilter.php',
'Kanboard\\Filter\\ProjectActivityCreatorFilter' => $baseDir . '/app/Filter/ProjectActivityCreatorFilter.php',
@@ -448,6 +449,7 @@ return array(
'Kanboard\\Filter\\TaskCommentFilter' => $baseDir . '/app/Filter/TaskCommentFilter.php',
'Kanboard\\Filter\\TaskCompletionDateFilter' => $baseDir . '/app/Filter/TaskCompletionDateFilter.php',
'Kanboard\\Filter\\TaskCreationDateFilter' => $baseDir . '/app/Filter/TaskCreationDateFilter.php',
+ 'Kanboard\\Filter\\TaskCreationDateRangeFilter' => $baseDir . '/app/Filter/TaskCreationDateRangeFilter.php',
'Kanboard\\Filter\\TaskCreatorFilter' => $baseDir . '/app/Filter/TaskCreatorFilter.php',
'Kanboard\\Filter\\TaskDescriptionFilter' => $baseDir . '/app/Filter/TaskDescriptionFilter.php',
'Kanboard\\Filter\\TaskDueDateFilter' => $baseDir . '/app/Filter/TaskDueDateFilter.php',
@@ -457,6 +459,7 @@ return array(
'Kanboard\\Filter\\TaskLinkFilter' => $baseDir . '/app/Filter/TaskLinkFilter.php',
'Kanboard\\Filter\\TaskModificationDateFilter' => $baseDir . '/app/Filter/TaskModificationDateFilter.php',
'Kanboard\\Filter\\TaskMovedDateFilter' => $baseDir . '/app/Filter/TaskMovedDateFilter.php',
+ 'Kanboard\\Filter\\TaskMovedDateRangeFilter' => $baseDir . '/app/Filter/TaskMovedDateRangeFilter.php',
'Kanboard\\Filter\\TaskPriorityFilter' => $baseDir . '/app/Filter/TaskPriorityFilter.php',
'Kanboard\\Filter\\TaskProjectFilter' => $baseDir . '/app/Filter/TaskProjectFilter.php',
'Kanboard\\Filter\\TaskProjectsFilter' => $baseDir . '/app/Filter/TaskProjectsFilter.php',
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 8cf48666..0d496e8a 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -536,6 +536,7 @@ class ComposerStaticInitbdc3716ceecc7570f8ff9a8407f0ca0e
'Kanboard\\ExternalLink\\WebLinkProvider' => __DIR__ . '/../..' . '/app/ExternalLink/WebLinkProvider.php',
'Kanboard\\Filter\\BaseComparisonFilter' => __DIR__ . '/../..' . '/app/Filter/BaseComparisonFilter.php',
'Kanboard\\Filter\\BaseDateFilter' => __DIR__ . '/../..' . '/app/Filter/BaseDateFilter.php',
+ 'Kanboard\\Filter\\BaseDateRangeFilter' => __DIR__ . '/../..' . '/app/Filter/BaseDateRangeFilter.php',
'Kanboard\\Filter\\BaseFilter' => __DIR__ . '/../..' . '/app/Filter/BaseFilter.php',
'Kanboard\\Filter\\ProjectActivityCreationDateFilter' => __DIR__ . '/../..' . '/app/Filter/ProjectActivityCreationDateFilter.php',
'Kanboard\\Filter\\ProjectActivityCreatorFilter' => __DIR__ . '/../..' . '/app/Filter/ProjectActivityCreatorFilter.php',
@@ -559,6 +560,7 @@ class ComposerStaticInitbdc3716ceecc7570f8ff9a8407f0ca0e
'Kanboard\\Filter\\TaskCommentFilter' => __DIR__ . '/../..' . '/app/Filter/TaskCommentFilter.php',
'Kanboard\\Filter\\TaskCompletionDateFilter' => __DIR__ . '/../..' . '/app/Filter/TaskCompletionDateFilter.php',
'Kanboard\\Filter\\TaskCreationDateFilter' => __DIR__ . '/../..' . '/app/Filter/TaskCreationDateFilter.php',
+ 'Kanboard\\Filter\\TaskCreationDateRangeFilter' => __DIR__ . '/../..' . '/app/Filter/TaskCreationDateRangeFilter.php',
'Kanboard\\Filter\\TaskCreatorFilter' => __DIR__ . '/../..' . '/app/Filter/TaskCreatorFilter.php',
'Kanboard\\Filter\\TaskDescriptionFilter' => __DIR__ . '/../..' . '/app/Filter/TaskDescriptionFilter.php',
'Kanboard\\Filter\\TaskDueDateFilter' => __DIR__ . '/../..' . '/app/Filter/TaskDueDateFilter.php',
@@ -568,6 +570,7 @@ class ComposerStaticInitbdc3716ceecc7570f8ff9a8407f0ca0e
'Kanboard\\Filter\\TaskLinkFilter' => __DIR__ . '/../..' . '/app/Filter/TaskLinkFilter.php',
'Kanboard\\Filter\\TaskModificationDateFilter' => __DIR__ . '/../..' . '/app/Filter/TaskModificationDateFilter.php',
'Kanboard\\Filter\\TaskMovedDateFilter' => __DIR__ . '/../..' . '/app/Filter/TaskMovedDateFilter.php',
+ 'Kanboard\\Filter\\TaskMovedDateRangeFilter' => __DIR__ . '/../..' . '/app/Filter/TaskMovedDateRangeFilter.php',
'Kanboard\\Filter\\TaskPriorityFilter' => __DIR__ . '/../..' . '/app/Filter/TaskPriorityFilter.php',
'Kanboard\\Filter\\TaskProjectFilter' => __DIR__ . '/../..' . '/app/Filter/TaskProjectFilter.php',
'Kanboard\\Filter\\TaskProjectsFilter' => __DIR__ . '/../..' . '/app/Filter/TaskProjectsFilter.php',