summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/user/user.module2
-rw-r--r--modules/user/user.pages.inc34
2 files changed, 29 insertions, 7 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 1af5f6de9..7661c37e3 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -40,7 +40,7 @@ function user_theme() {
'template' => 'user-picture',
),
'user_profile' => array(
- 'arguments' => array('account' => NULL),
+ 'arguments' => array('elements' => NULL),
'template' => 'user-profile',
'file' => 'user.pages.inc',
),
diff --git a/modules/user/user.pages.inc b/modules/user/user.pages.inc
index a4909f846..f5d684e6b 100644
--- a/modules/user/user.pages.inc
+++ b/modules/user/user.pages.inc
@@ -148,15 +148,35 @@ function user_logout() {
/**
* Menu callback; Displays a user or user profile page.
+ *
+ * The $page['content'] array for user profile pages contains:
+ *
+ * - $page['content']['Profile Category']:
+ * Profile categories keyed by their human-readable names.
+ * - $page['content']['Profile Category']['profile_machine_name']:
+ * Profile fields keyed by their machine-readable names.
+ * - $page['content']['user_picture']:
+ * User's rendered picture.
+ * - $page['content']['summary']:
+ * Contains the default "History" profile data for a user.
+ * - $page['content']['#account']:
+ * The user account of the profile being viewed.
+ *
+ * To theme user profiles, copy modules/user/user-profile.tpl.php
+ * to your theme directory, and edit it as instructed in that file's comments.
*/
function user_view($account) {
drupal_set_title($account->name);
// Retrieve all profile fields and attach to $account->content.
user_build_content($account);
+
+ $build = $account->content;
+ $build += array(
+ '#theme' => 'user_profile',
+ '#account' => $account,
+ );
- // To theme user profiles, copy modules/user/user_profile.tpl.php
- // to your theme directory, and edit it as instructed in that file's comments.
- return theme('user_profile', $account);
+ return drupal_get_page($build);
}
/**
@@ -168,12 +188,14 @@ function user_view($account) {
* @see user-picture.tpl.php
*/
function template_preprocess_user_profile(&$variables) {
+ $account = $variables['elements']['#account'];
+
$variables['profile'] = array();
// Sort sections by weight
- uasort($variables['account']->content, 'element_sort');
+ uasort($account->content, 'element_sort');
// Provide keyed variables so themers can print each section independently.
- foreach (element_children($variables['account']->content) as $key) {
- $variables['profile'][$key] = drupal_render($variables['account']->content[$key]);
+ foreach (element_children($account->content) as $key) {
+ $variables['profile'][$key] = drupal_render($account->content[$key]);
}
// Collect all profiles to make it easier to print all items at once.
$variables['user_profile'] = implode($variables['profile']);