function support_autocomplete_assigned in Support Ticketing System 6
Same name and namespace in other branches
- 7 support.module \support_autocomplete_assigned()
Autocomplete usernames to assign to ticket.
1 string reference to 'support_autocomplete_assigned'
- support_menu in ./
support.module - Implementation of hook_menu().
File
- ./
support.module, line 409 - support.module
Code
function support_autocomplete_assigned($clid = 0, $string = '') {
$matches = array();
if ($string) {
if ($clid) {
$client = db_result(db_query('SELECT name FROM {support_client} WHERE clid = %d', $clid));
// retrieve all roles giving permission to access current tickets
$result = db_query("SELECT rid FROM {permission} WHERE perm LIKE '%%%s%%' OR perm LIKE '%%%s%%'", "access {$client} tickets", 'administer support');
}
$roles = array();
while ($role = db_fetch_object($result)) {
$roles[$role->rid] = $role->rid;
}
// also get people with administer support permissions
$result = db_query("SELECT rid FROM {permission} WHERE perm LIKE '%%%s%%'", 'administer support');
while ($role = db_fetch_object($result)) {
$roles[$role->rid] = $role->rid;
}
if (!empty($roles)) {
$role_sql = "SELECT u.name FROM {users} u LEFT JOIN {users_roles} r ON u.uid = r.uid WHERE r.rid IN (%s) AND u.status = 1 AND LOWER(name) LIKE LOWER('%s%%')";
if (variable_get('support_filter_uid1', FALSE)) {
$role_sql .= ' AND u.uid <> 1';
}
$result = db_query_range($role_sql, implode(', ', $roles), $string, 0, 10);
while ($user = db_fetch_object($result)) {
$matches[$user->name] = check_plain($user->name);
}
}
}
drupal_json($matches);
}