Skip to content

Commit

Permalink
Allow ?status[]=all as a post filter
Browse files Browse the repository at this point in the history
We already accept ?status=all but not in a array form. This breaks
on the client, but is also just inconsistent.

Refs #1484
  • Loading branch information
rjmackay committed Nov 8, 2016
1 parent 88c982e commit 9809c05
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions application/classes/Ushahidi/Repository/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,17 @@ protected function setSearchConditions(SearchData $search)
$query = $this->search_query;
$table = $this->getTable();

$status = $search->getFilter('status', 'published');
if ($status !== 'all')
{
if (!is_array($status)) {
$status = explode(',', $status);
}

// Filter by status
$status = $search->getFilter('status', ['published']);
//
if (!is_array($status)) {
$status = explode(',', $status);
}
// If array contains 'all' don't bother filtering
if (!in_array('all', $status)) {
$query->where("$table.status", 'IN', $status);
}
// End filter by status

foreach (['type', 'locale', 'slug'] as $key)
{
Expand Down

0 comments on commit 9809c05

Please sign in to comment.