Skip to content

Commit

Permalink
Merge pull request #1467 from ushahidi/develop
Browse files Browse the repository at this point in the history
Release v3.6.1
  • Loading branch information
willdoran committed Oct 28, 2016
2 parents 0ee3a2a + ad7d84d commit 88c982e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
19 changes: 18 additions & 1 deletion application/classes/Ushahidi/Repository/Post.php
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
29 changes: 29 additions & 0 deletions application/classes/Ushahidi/Validator/Media/Update.php
@@ -0,0 +1,29 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');

/**
* Ushahidi Media Validator
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi\Application
* @copyright 2014 Ushahidi
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
*/

use Ushahidi\Core\Entity;
use Ushahidi\Core\Tool\Validator;

class Ushahidi_Validator_Media_Update extends Ushahidi_Validator_Media_Create
{
protected function getRules()
{
return [
'user_id' => [
['digit'],
],
'caption' => [
// alphas, numbers, punctuation, and spaces
['regex', [':value', '/^[\pL\pN\pP ]++$/uD']],
]
];
}
}

0 comments on commit 88c982e

Please sign in to comment.