/** * Returns the list of users, faster than using query method for Users module * * @param array $args arguments used to construct query, see query() for example * * @return array list of users returned */ function get_user_array($args) { global $json; $json = getJSONobj(); $response = array(); if (showFullName()) { // utils.php, if system is configured to show full name $user_array = getUserArrayFromFullName($args['conditions'][0]['value'], true); } else { $user_array = get_user_array(false, "Active", '', false, $args['conditions'][0]['value'], ' AND portal_only=0 ', false); } $response['totalCount'] = count($user_array); $response['fields'] = array(); $i = 0; foreach ($user_array as $id => $name) { array_push($response['fields'], array('id' => (string) $id, 'user_name' => $name, 'module' => 'Users')); $i++; } return $json->encodeReal($response); }
/** * Returns user array * * @param string $condition * @return array */ protected function getUserArray($condition) { return showFullName() ? getUserArrayFromFullName($condition, true) : get_user_array(false, 'Active', '', false, $condition, ' AND portal_only=0 ', false); }
/** * retrieves Users matching passed criteria */ function json_get_user_array($request_id, &$params) { global $json; $args = $params[0]; //decode condition parameter values.. if (is_array($args['conditions'])) { foreach ($args['conditions'] as $key => $condition) { if (!empty($condition['value'])) { $args['conditions'][$key]['value'] = $json->decode($condition['value']); } } } $response = array(); $response['id'] = $request_id; $response['result'] = array(); $response['result']['list'] = array(); if (showFullName()) { $user_array = getUserArrayFromFullName($args['conditions'][0]['value']); } else { $user_array = get_user_array(false, "Active", $focus->assigned_user_id, false, $args['conditions'][0]['value']); } foreach ($user_array as $id => $name) { array_push($response['result']['list'], array('fields' => array('id' => $id, 'user_name' => $name), 'module' => 'Users')); } print $json->encode($response); exit; }