Index: user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.745.2.1
diff -u -r1.745.2.1 user.module
--- user.module	29 Jan 2007 19:08:46 -0000	1.745.2.1
+++ user.module	24 May 2007 17:43:46 -0000
@@ -430,13 +430,22 @@
         return t('Users');
       }
     case 'search':
-      if (user_access('access user profiles')) {
+        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 * 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, NULL, NULL, 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, NULL, NULL, TRUE));        	        		
+        	} else { // Just display username of accounts
+        		$find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, NULL, NULL, TRUE));        	
+        	}
         }
         return $find;
       }
