You are here

function privatemsg_roles_sql_autocomplete_roles in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 privatemsg_roles/privatemsg_roles.module \privatemsg_roles_sql_autocomplete_roles()
  2. 7 privatemsg_roles/privatemsg_roles.module \privatemsg_roles_sql_autocomplete_roles()

Query definition to search for username autocomplete suggestions.

Parameters

$fragments: Query fragments array.

$search: Which search string is currently searched for.

$names: Array of names not to be used as suggestions.

File

privatemsg_roles/privatemsg_roles.module, line 185
Allows to send messages to all members of a role.

Code

function privatemsg_roles_sql_autocomplete_roles($search, $names) {
  $query = db_select('role', 'role')
    ->fields('role')
    ->condition('role.name', $search . '%', 'LIKE')
    ->condition('role.rid', DRUPAL_ANONYMOUS_RID, '<>')
    ->orderBy('role.name', 'ASC');
  if (!empty($names)) {
    $query
      ->condition('role.name', $names, 'NOT IN');
  }
  return $query;
}