You are here

function hook_privatemsg_sql_autocomplete_alter in Privatemsg 6

Same name and namespace in other branches
  1. 6.2 privatemsg.api.php \hook_privatemsg_sql_autocomplete_alter()

Query to search for autocomplete usernames.

Parameters

$fragments: Query fragments

$search: Search for that username

$names: Names that are already in the list and are excluded

Related topics

1 function implements hook_privatemsg_sql_autocomplete_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

privatemsg_filter_privatemsg_sql_autocomplete_alter in privatemsg_filter/privatemsg_filter.module
Limit the user autocomplete for the filter widget.

File

./privatemsg.api.php, line 124
Privatemsg API Documentation

Code

function hook_privatemsg_sql_autocomplete_alter(&$fragments, $search, $names) {
  global $user;

  // Extend the query that searches for usernames
  // $fragments is explained in the api documentation in detail
  // The query is already set up, it's searching for usernames which start with
  // $search and are not $names (may be empty)
  // the main table is {user} a
  // for example, add a join on a table where the user connections are stored
  // and specify that only users connected with the current user should be
  // loaded.
  $fragments['inner_join'] = 'INNER JOIN {my_table} m ON (m.user1 = u.uid AND m.user2 = %d)';
  $fragments['query_args'][] = $user->uid;
}