function photos_access_multiple_users_autocomplete in Album Photos 7.3
Autocomplete multiple comma-separated usernames.
1 string reference to 'photos_access_multiple_users_autocomplete'
- photos_access_menu in photos_access/
photos_access.module - Implements hook_menu().
File
- photos_access/
photos_access.module, line 57
Code
function photos_access_multiple_users_autocomplete($string = '') {
$array = drupal_explode_tags($string);
$last_string = trim(array_pop($array));
$matches = array();
if ($last_string != '') {
$result = db_select('users')
->fields('users', array(
'name',
))
->condition('name', db_like($last_string) . '%', 'LIKE')
->range(0, 10)
->execute();
$prefix = count($array) ? implode(', ', $array) . ', ' : '';
foreach ($result as $user) {
$n = $user->name;
$matches[$prefix . $n] = $user->name;
}
}
drupal_json_output($matches);
}