rendered paste body--- - 2007-01-29 12:03:12.000000000 -0800
+++ /dev/fd/63 2007-01-29 12:03:12.000000000 -0800
@@ -453,7 +453,7 @@
* Implementation of hook_perm().
*/
function user_perm() {
- return array('administer access control', 'administer users', 'access user profiles', 'change own username');
+ return array('administer access control', 'administer users', 'access user profiles', 'change own username', 'user search includes email');
}
/**
@@ -482,7 +482,8 @@
$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);
+ $extend = user_access('user search includes email') ? " OR LOWER(mail) LIKE LOWER('%%%s%%')" : '';
+ $result = pager_query("SELECT * FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')$extend", 15, 0, NULL, $keys);
while ($account = db_fetch_object($result)) {
$find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid));
}