You are here

function mail_debugger_callback_autocomplete_mail in Mail Debugger 7.2

Autocomplete the mail for a user.

Parameters

type $query:

Return value

type

1 string reference to 'mail_debugger_callback_autocomplete_mail'
mail_debugger_menu in ./mail_debugger.module
Implement hook_menu()

File

includes/mail_debugger.callback.inc, line 315

Code

function mail_debugger_callback_autocomplete_mail($query = '') {
  if (empty($query)) {
    return;
  }
  $result = db_select('users', 'u')
    ->fields('u', array(
    'mail',
    'name',
  ))
    ->condition('u.mail', db_like($query) . '%', 'LIKE')
    ->condition('status', 1)
    ->range(0, 10)
    ->execute()
    ->fetchAll();
  $complete = array();
  foreach ($result as $obj) {
    $complete[$obj->mail] = $obj->mail . ' (' . $obj->name . ')';
  }
  drupal_json_output($complete);
}