function privatemsg_sql_autocomplete in Privatemsg 7
Same name and namespace in other branches
- 6.2 privatemsg.module \privatemsg_sql_autocomplete()
- 6 privatemsg.module \privatemsg_sql_autocomplete()
- 7.2 privatemsg.module \privatemsg_sql_autocomplete()
Looks up autocomplete suggestions for users.
Parameters
$search: The string that is being searched for.
$names: Array of names which are already selected and should be excluded.
See also
hook_query_privatemsg_autocomplete_alter()
Related topics
File
- ./
privatemsg.module, line 1204 - Allows users to send private messages to other users.
Code
function privatemsg_sql_autocomplete($search, $names) {
$query = db_select('users', 'u')
->fields('u', array(
'uid',
))
->condition('u.name', $search . '%', 'LIKE')
->condition('u.status', 0, '<>')
->where('NOT EXISTS (SELECT 1 FROM {pm_disable} pd WHERE pd.uid=u.uid)')
->orderBy('u.name', 'ASC')
->range(0, 10);
if (!empty($names)) {
$query
->condition('u.name', $names, 'NOT IN');
}
return $query;
}