Skip to content

Commit 9809c05

Browse files
committed
Allow ?status[]=all as a post filter
We already accept ?status=all but not in a array form. This breaks on the client, but is also just inconsistent. Refs #1484
1 parent 88c982e commit 9809c05

File tree

1 file changed

+9
-7
lines changed
  • application/classes/Ushahidi/Repository

1 file changed

+9
-7
lines changed

application/classes/Ushahidi/Repository/Post.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,17 @@ protected function setSearchConditions(SearchData $search)
211211
$query = $this->search_query;
212212
$table = $this->getTable();
213213

214-
$status = $search->getFilter('status', 'published');
215-
if ($status !== 'all')
216-
{
217-
if (!is_array($status)) {
218-
$status = explode(',', $status);
219-
}
220-
214+
// Filter by status
215+
$status = $search->getFilter('status', ['published']);
216+
//
217+
if (!is_array($status)) {
218+
$status = explode(',', $status);
219+
}
220+
// If array contains 'all' don't bother filtering
221+
if (!in_array('all', $status)) {
221222
$query->where("$table.status", 'IN', $status);
222223
}
224+
// End filter by status
223225

224226
foreach (['type', 'locale', 'slug'] as $key)
225227
{

0 commit comments

Comments
 (0)