You are here

function privatemsg_filter_sql_tags_autocomplete in Privatemsg 7.2

Same name and namespace in other branches
  1. 6.2 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_sql_tags_autocomplete()
  2. 6 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_sql_tags_autocomplete()
  3. 7 privatemsg_filter/privatemsg_filter.module \privatemsg_filter_sql_tags_autocomplete()

Query definition to get autocomplete suggestions for tags

Parameters

$search: String fragment to use for tag suggestions.

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

File

privatemsg_filter/privatemsg_filter.module, line 947
Allows users to tag private messages and to filter based upon those tags.

Code

function privatemsg_filter_sql_tags_autocomplete($search, $tags) {
  $query = db_select('pm_tags', 'pmt')
    ->fields('pmt', array(
    'tag',
  ))
    ->condition('pmt.tag', $search . '%%', 'LIKE')
    ->orderBy('pmt.tag', 'ASC')
    ->range(0, 10);
  if (!empty($tags)) {
    $query
      ->condition('pmt.tag', $tags, 'NOT IN');
  }
  return $query;
}