summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/user/user.module29
1 files changed, 17 insertions, 12 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 6f9354971..ff1869f10 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -874,7 +874,7 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
// Replace wildcards with MySQL/PostgreSQL wildcards.
$keys = preg_replace('!\*+!', '%', $keys);
$query = db_select('users')->extend('PagerDefault');
- $query->fields('users', array('name', 'uid'));
+ $query->fields('users', array('uid'));
if (user_access('administer users')) {
// Administrators can also search in the otherwise private email field.
$query->fields('users', array('mail'));
@@ -885,20 +885,25 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
else {
$query->condition('name', '%' . db_like($keys) . '%', 'LIKE');
}
- $result = $query
+ $uids = $query
->limit(15)
- ->execute();
- if (user_access('administer users')) {
- foreach ($result as $account) {
- $find[] = array('title' => $account->name . ' (' . $account->mail . ')', 'link' => url('user/' . $account->uid, array('absolute' => TRUE)));
- }
- }
- else {
- foreach ($result as $account) {
- $find[] = array('title' => $account->name, 'link' => url('user/' . $account->uid, array('absolute' => TRUE)));
+ ->execute()
+ ->fetchCol();
+ $accounts = user_load_multiple($uids);
+
+ $results = array();
+ foreach ($accounts as $account) {
+ $result = array(
+ 'title' => format_username($account),
+ 'link' => url('user/' . $account->uid, array('absolute' => TRUE)),
+ );
+ if (user_access('administer users')) {
+ $result['title'] .= ' (' . $account->mail . ')';
}
+ $results[] = $result;
}
- return $find;
+
+ return $results;
}
/**