function mail_debugger_user_callback_autocomplete_mail in Mail Debugger 7.3
Autocomplete the mail for a user.
Parameters
type $query:
Return value
type
1 string reference to 'mail_debugger_user_callback_autocomplete_mail'
- mail_debugger_common_menu in modules/
common/ mail_debugger_common.module - Implement hook_menu();
File
- modules/
common/ includes/ user.mail_debugger.inc, line 89
Code
function mail_debugger_user_callback_autocomplete_mail($query = '') {
if (empty($query)) {
return;
}
$result = db_select('users', 'u')
->fields('u', array(
'mail',
'name',
'uid',
))
->condition('u.mail', db_like($query) . '%', 'LIKE')
->condition('status', 1)
->range(0, 10)
->execute()
->fetchAll();
$complete = array();
foreach ($result as $obj) {
$account = user_load($obj->uid);
if (count($account->roles) > 1) {
$roles = $account->roles;
unset($roles[2]);
$roles_str = implode(', ', $roles);
$complete[$obj->mail] = $obj->mail . ' (' . $obj->name . ' - ' . $roles_str . ')';
}
else {
$complete[$obj->mail] = $obj->mail . ' (' . $obj->name . ')';
}
}
drupal_json_output($complete);
}