summaryrefslogtreecommitdiff
path: root/modules/profile
diff options
context:
space:
mode:
Diffstat (limited to 'modules/profile')
-rw-r--r--modules/profile/profile.module22
-rw-r--r--modules/profile/profile.pages.inc15
2 files changed, 17 insertions, 20 deletions
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index e915a97ad..e4d3ab08f 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -203,13 +203,6 @@ function profile_block_view($delta = '') {
}
/**
- * Implementation of hook_user_load().
- */
-function profile_user_load(&$edit, &$user, $category = NULL) {
- return profile_load_profile($user);
-}
-
-/**
* Implementation of hook_user_register().
*/
function profile_user_register(&$edit, &$user, $category = NULL) {
@@ -270,11 +263,14 @@ function profile_user_cancel(&$edit, &$account, $method) {
}
}
-function profile_load_profile(&$user) {
- $result = db_query('SELECT f.name, f.type, v.value FROM {profile_field} f INNER JOIN {profile_value} v ON f.fid = v.fid WHERE uid = %d', $user->uid);
- while ($field = db_fetch_object($result)) {
- if (empty($user->{$field->name})) {
- $user->{$field->name} = _profile_field_serialize($field->type) ? unserialize($field->value) : $field->value;
+/**
+ * Implementation of hook_user_load().
+ */
+function profile_user_load($users) {
+ $result = db_query('SELECT f.name, f.type, v.uid, v.value FROM {profile_field} f INNER JOIN {profile_value} v ON f.fid = v.fid WHERE uid IN (:uids)', array(':uids' => array_keys($users)));
+ foreach ($result as $record) {
+ if (empty($users[$record->uid]->{$record->name})) {
+ $users[$record->uid]->{$record->name} = _profile_field_serialize($record->type) ? unserialize($record->value) : $record->value;
}
}
}
@@ -341,7 +337,7 @@ function profile_view_field($user, $field) {
function profile_view_profile(&$user) {
- profile_load_profile($user);
+ $user = user_load($user->uid);
// Show private fields to administrators and people viewing their own account.
if (user_access('administer users') || $GLOBALS['user']->uid == $user->uid) {
diff --git a/modules/profile/profile.pages.inc b/modules/profile/profile.pages.inc
index 9cb761a28..e1e01d9e0 100644
--- a/modules/profile/profile.pages.inc
+++ b/modules/profile/profile.pages.inc
@@ -55,11 +55,13 @@ function profile_browse() {
}
// Extract the affected users:
- $result = pager_query("SELECT u.uid, u.access FROM {users} u INNER JOIN {profile_value} v ON u.uid = v.uid WHERE v.fid = %d AND $query AND u.access != 0 AND u.status != 0 ORDER BY u.access DESC", 20, 0, NULL, $arguments);
+ $result = pager_query("SELECT u.uid, u.access FROM {users} u INNER JOIN {profile_value} v ON u.uid = v.uid WHERE v.fid = %d AND $query AND u.access != 0 AND u.status != 0 ORDER BY u.access DESC", 20, 0, NULL, $arguments)->fetchAllAssoc('uid');
+
+ // Load the users.
+ $users = user_load_multiple(array_keys($result));
$content = '';
- while ($account = db_fetch_object($result)) {
- $account = user_load(array('uid' => $account->uid));
+ foreach ($users as $account) {
$profile = _profile_update_user_fields($fields, $account);
$content .= theme('profile_listing', $account, $profile);
}
@@ -88,11 +90,10 @@ function profile_browse() {
}
// Extract the affected users:
- $result = pager_query('SELECT uid, access FROM {users} WHERE uid > 0 AND status != 0 AND access != 0 ORDER BY access DESC', 20, 0, NULL);
-
+ $result = pager_query('SELECT uid, access FROM {users} WHERE uid > 0 AND status != 0 AND access != 0 ORDER BY access DESC', 20, 0, NULL)->fetchAllAssoc('uid');
+ $users = user_load_multiple(array_keys($result));
$content = '';
- while ($account = db_fetch_object($result)) {
- $account = user_load(array('uid' => $account->uid));
+ foreach ($users as $account) {
$profile = _profile_update_user_fields($fields, $account);
$content .= theme('profile_listing', $account, $profile);
}