Skip to content
Snippets Groups Projects
Commit a9787174 authored by Peter Rotich's avatar Peter Rotich
Browse files

Return empty JSON array on empty query

parent 4a0f4b40
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,10 @@ class OrgsAjaxAPI extends AjaxController {
if(!isset($_REQUEST['q'])) {
Http::response(400, 'Query argument is required');
}
}
if (!$_REQUEST['q'])
return $this->json_encode(array());
$q = $_REQUEST['q'];
$limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']:25;
......
......@@ -26,14 +26,17 @@ class TicketsAjaxAPI extends AjaxController {
function lookup() {
global $thisstaff;
$limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']:25;
$tickets=array();
// Bail out of query is empty
if (!$_REQUEST['q'])
return $this->json_encode($tickets);
$visibility = Q::any(array(
'staff_id' => $thisstaff->getId(),
'team_id__in' => $thisstaff->teams->values_flat('team_id'),
));
if (!$thisstaff->showAssignedOnly() && ($depts=$thisstaff->getDepts())) {
$visibility->add(array('dept_id__in' => $depts));
}
......
......@@ -29,6 +29,10 @@ class UsersAjaxAPI extends AjaxController {
Http::response(400, __('Query argument is required'));
}
$matches = array();
if (!$_REQUEST['q'])
return $this->json_encode($matches);
$q = $_REQUEST['q'];
$limit = isset($_REQUEST['limit']) ? (int) $_REQUEST['limit']:25;
$users=array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment