From ff0b39d968b3d6d5550310317247e3dc7e399011 Mon Sep 17 00:00:00 2001 From: Robbie Mackay Date: Mon, 17 Oct 2016 15:08:40 +1300 Subject: [PATCH 1/3] Add filters for post_date --- .../classes/Ushahidi/Repository/Post.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/application/classes/Ushahidi/Repository/Post.php b/application/classes/Ushahidi/Repository/Post.php index 65e90ef06f..1f25ed7eab 100644 --- a/application/classes/Ushahidi/Repository/Post.php +++ b/application/classes/Ushahidi/Repository/Post.php @@ -171,6 +171,7 @@ public function getSearchFields() 'parent', 'form', 'set', 'q', /* LIKE title, content */ 'created_before', 'created_after', 'updated_before', 'updated_after', + 'date_before', 'date_after', 'bbox', 'tags', 'values', 'current_stage', 'center_point', 'within_km', 'published_to', @@ -305,6 +306,22 @@ protected function setSearchConditions(SearchData $search) $query->where("$table.updated", '<=', $updated_before); } + if ($search->date_after) + { + $date_after = date_create($search->date_after, new DateTimeZone('UTC')); + // Convert to UTC (needed in case date came with a tz) + $date_after->setTimezone(new DateTimeZone('UTC')); + $query->where("$table.post_date", '>=', $date_after->format('Y-m-d H:i:s')); + } + + if ($search->date_before) + { + $date_before = date_create($search->date_before, new DateTimeZone('UTC')); + // Convert to UTC (needed in case date came with a tz) + $date_before->setTimezone(new DateTimeZone('UTC')); + $query->where("$table.post_date", '<=', $date_before->format('Y-m-d H:i:s')); + } + // Bounding box search // Create geometry from bbox (or create bbox from center & radius) $bounding_box = null; @@ -917,7 +934,7 @@ protected function updatePostTags($post_id, $tags) ->where('post_id', '=', $post_id) ->execute($this->db); } - else + else { // Load existing tags $existing = $this->getTagsForPost($post_id); From d2fcd012721633f9a122b66a0cb7bff7e7d0ed8a Mon Sep 17 00:00:00 2001 From: will Date: Thu, 20 Oct 2016 16:00:53 -0400 Subject: [PATCH 2/3] Fix validation --- .../classes/Ushahidi/Validator/Media/Update.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/application/classes/Ushahidi/Validator/Media/Update.php b/application/classes/Ushahidi/Validator/Media/Update.php index baadef9cbc..e811edde60 100644 --- a/application/classes/Ushahidi/Validator/Media/Update.php +++ b/application/classes/Ushahidi/Validator/Media/Update.php @@ -23,7 +23,19 @@ protected function getRules() 'caption' => [ // alphas, numbers, punctuation, and spaces ['regex', [':value', '/^[\pL\pN\pP ]++$/uD']], - ] + ], + 'mime' => [ + [[$this, 'validateMime'], [':validation', ':value']], + ], + 'o_size' => [ + [[$this, 'validateSize'], [':validation', ':value']], + ], + 'o_width' => [ + ['numeric'], + ], + 'o_height' => [ + ['numeric'], + ], ]; } } From f2f90d3e1a7a43df16d1fde2ccd967edc17a42a3 Mon Sep 17 00:00:00 2001 From: will Date: Tue, 25 Oct 2016 23:09:22 -0400 Subject: [PATCH 3/3] Change media update check --- .../Ushahidi/Validator/Media/Update.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/application/classes/Ushahidi/Validator/Media/Update.php b/application/classes/Ushahidi/Validator/Media/Update.php index e811edde60..f16ae8a846 100644 --- a/application/classes/Ushahidi/Validator/Media/Update.php +++ b/application/classes/Ushahidi/Validator/Media/Update.php @@ -1,4 +1,4 @@ - [ // alphas, numbers, punctuation, and spaces ['regex', [':value', '/^[\pL\pN\pP ]++$/uD']], - ], - 'mime' => [ - [[$this, 'validateMime'], [':validation', ':value']], - ], - 'o_size' => [ - [[$this, 'validateSize'], [':validation', ':value']], - ], - 'o_width' => [ - ['numeric'], - ], - 'o_height' => [ - ['numeric'], - ], + ] ]; } }