diff --git a/include/ajax.orgs.php b/include/ajax.orgs.php index f7be2b2d130e5672e71a88669b102cb2b96f74ee..1a1c8d19ca060a22e139135cae4d5af4965510f4 100644 --- a/include/ajax.orgs.php +++ b/include/ajax.orgs.php @@ -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; diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 6acae0719f35404ed9b43e871a238b53d92c6a22..c20abba7ec0120fbaceffca81f762c5e5eb0c650 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -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)); } diff --git a/include/ajax.users.php b/include/ajax.users.php index 22257675d152e6eed6e4916f5de17b0f7f5acb05..f8b9b78b4ea8a8d7dfc3c3d0a3c67352067e214b 100644 --- a/include/ajax.users.php +++ b/include/ajax.users.php @@ -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();