Index: user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.785 diff -u -r1.785 user.module --- user.module 22 May 2007 05:52:17 -0000 1.785 +++ user.module 24 May 2007 17:50:17 -0000 @@ -481,12 +481,21 @@ } case 'search': if (user_access('access user profiles')) { + $admin = user_access('administer users'); $find = array(); // Replace wildcards with MySQL/PostgreSQL wildcards. $keys = preg_replace('!\*+!', '%', $keys); - $result = pager_query("SELECT uid, name FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys); + if ($admin) { // search on email as well as username + $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); + } else { // search on just username + $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, array('absolute' => TRUE))); + if ($admin) { // Display e-mail address of matching accounts as well as username + $find[] = array('title' => $account->name . '( ' . $account->mail . ')', 'link' => url('user/'. $account->uid, array('absolute' => TRUE))); + } else { // Just display username of accounts + $find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, array('absolute' => TRUE))); + } } return $find; }