function imagepicker_user_autocomplete in Image Picker 6.2
Same name and namespace in other branches
- 5.2 imagepicker.module \imagepicker_user_autocomplete()
- 7 imagepicker.admin.inc \imagepicker_user_autocomplete()
Retrieve a pipe delimited string of autocomplete suggestions for existing users
1 string reference to 'imagepicker_user_autocomplete'
- imagepicker_menu in ./
imagepicker.module - Implementation of hook_menu().
File
- ./
imagepicker.admin.inc, line 2089 - admin settings functions
Code
function imagepicker_user_autocomplete($string = '') {
$matches = array();
if ($string) {
if (arg(3) == 'import' or arg(3) == 'orphans') {
$result = db_query_range("SELECT u.uid, u.name FROM {users} u WHERE LOWER(u.name) LIKE LOWER('%s%%')", $string, 0, 10);
}
else {
$result = db_query_range("SELECT DISTINCT u.name FROM {users} u, {imagepicker} i WHERE LOWER(u.name) LIKE LOWER('%s%%') AND u.uid=i.uid", $string, 0, 10);
}
while ($account = db_fetch_object($result)) {
if (arg(3) == 'import' or arg(3) == 'orphans') {
$user = user_load(array(
'uid' => $account->uid,
));
if (user_access('use imagepicker', $user)) {
$matches[$account->name] = check_plain($account->name);
}
}
else {
$matches[$account->name] = check_plain($account->name);
}
}
}
print drupal_to_js($matches);
exit;
}