You are here

function _mail_debugger_load_users in Mail Debugger 7

Load uid, username and mail from the users table

Return value

array

1 call to _mail_debugger_load_users()
mail_debugger_callback in includes/mail_debugger.callback.inc
Callback for drupal_get_form

File

includes/mail_debugger.callback.inc, line 7

Code

function _mail_debugger_load_users() {
  $options =& drupal_static(__FUNCTION__);
  if (!is_array($options)) {

    // load the users to prepopulate the user select dropdown
    $options = array();
    $users = db_select('users', 'u')
      ->fields('u')
      ->orderBy('created', 'DESC')
      ->range(0, 50)
      ->execute()
      ->fetchAllAssoc('uid');
    foreach ($users as $uid => $account) {
      if (!valid_email_address($account->mail)) {
        continue;
      }
      $options[$uid] = t('!name (!mail)', array(
        '!name' => format_username($account),
        '!mail' => $account->mail,
      ));
    }
  }
  return $options;
}