query($query); } $users = array(); // Count real items returned $count = 0; if ($DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $users[$data["id"]] = formatUserName($data["id"], $data["name"], $data["realname"], $data["firstname"]); $logins[$data["id"]] = $data["name"]; } } if (!function_exists('dpuser_cmp')) { function dpuser_cmp($a, $b) { return strcasecmp($a, $b); } } $datas = array(); // Display first if empty search if ($_REQUEST['page'] == 1 && empty($_REQUEST['searchText'])) { if (($one_item < 0) || ($one_item == 0)) { if ($_REQUEST['all'] == 0) { array_push($datas, array('id' => 0, 'text' => Dropdown::EMPTY_VALUE)); } else if ($_REQUEST['all'] == 1) { array_push($datas, array('id' => 0, 'text' => __('All'))); } } } if (count($users)) { foreach ($users as $ID => $output) { $title = sprintf('%1$s - %2$s', $output, $logins[$ID]); array_push($datas, array('id' => $ID, 'text' => $output, 'title' => $title)); $count++; } } if (($one_item >= 0) && isset($datas[0])) { echo json_encode($datas[0]); } else { $ret['results'] = $datas; $ret['count'] = $count; echo json_encode($ret); }