Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.745.2.35 diff -u -r1.745.2.35 user.module --- modules/user/user.module 8 Oct 2008 20:10:26 -0000 1.745.2.35 +++ modules/user/user.module 21 Jan 2009 02:34:13 -0000 @@ -452,9 +452,18 @@ $find = array(); // Replace wildcards with MySQL/PostgreSQL wildcards. $keys = preg_replace('!\*+!', '%', $keys); - $result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys); - while ($account = db_fetch_object($result)) { - $find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, NULL, NULL, TRUE)); + if (user_access('administer users')) { + // Administrators can also search in the otherwise private email field. + $result = pager_query("SELECT name, uid, mail FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%') OR LOWER(mail) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys, $keys); + while ($account = db_fetch_object($result)) { + $find[] = array('title' => $account->name .' ('. $account->mail .')', 'link' => url('user/'. $account->uid, NULL, NULL, TRUE)); + } + } + else { + $result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys); + while ($account = db_fetch_object($result)) { + $find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, NULL, NULL, TRUE)); + } } return $find; } @@ -782,7 +791,7 @@ if (module_exists('search')) { $items[] = array('path' => 'admin/user/search', 'title' => t('Search users'), - 'description' => t('Search users by name.'), + 'description' => t('Search users by name or e-mail address.'), 'callback' => 'user_admin', 'callback arguments' => array('search'), 'access' => $admin_access, 'type' => MENU_NORMAL_ITEM); } @@ -2412,7 +2421,7 @@
  • Authenticated user: this role is automatically granted to all logged in users.
  • ', array('@permissions' => url('admin/user/access'))); case 'admin/user/search': - return '

    '. t('Enter a simple pattern ("*" may be used as a wildcard match) to search for a username. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda".') .'

    '; + return '

    '. t('Enter a simple pattern ("*" may be used as a wildcard match) to search for a username or e-mail address. For example, one may search for "br" and Drupal might return "brian", "brad", and "brenda@example.com".') .'

    '; case 'user/help#user': $site = variable_get('site_name', 'Drupal');