From 754f2ac26a2dbe81fcaa2886d4a8f5030b8e6cda Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 21 Mar 2004 14:28:15 +0000 Subject: - More profile module improvements: + Updated the _user() hook's "$type == 'view'" case to match the "$type == 'edit'" case. That is, both have to return an associtive array of the format array('category' => 'fields'). + Updated the profile pages to group fields by category. Made possible thanks to the above change. + Moved logic out of the theme_ functions. --- modules/user.module | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'modules/user.module') diff --git a/modules/user.module b/modules/user.module index 9fd0a971f..7d2b33380 100644 --- a/modules/user.module +++ b/modules/user.module @@ -333,6 +333,12 @@ function user_search($keys) { return array(t("Matching users"), $find); } +function user_user($type, &$edit, &$user) { + if ($type == 'view') { + return array(t('History') => form_item(t('Member for'), format_interval(time() - $account->created))); + } +} + function user_block($op = "list", $delta = 0) { global $user; @@ -478,12 +484,12 @@ function theme_user_picture($account) { } } -function theme_user_profile($account) { +function theme_user_profile($account, $fields) { $output = "
\n"; $output .= theme('user_picture', $account); - $output .= form_item(t('Name'), $account->name); - $output .= implode("\n", module_invoke_all('user', 'view', '', $account)); - $output .= form_item(t('Member for'), format_interval(time() - $account->created)); + foreach ($fields as $category => $value) { + $output .= "

$category

$value"; + } if (user_access("administer users")) { $output .= form_item(t("Administration"), l(t("edit account"), "admin/user/edit/$account->uid")); @@ -1077,7 +1083,16 @@ function user_view($uid = 0) { if ($uid == 0) { if ($user->uid) { - print theme('page', theme('user_profile', $user), $user->name); + // Retrieve and merge all profile fields: + $fields = array(); + foreach (module_list() as $module) { + if ($data = module_invoke($module, 'user', 'view', '', $user)) { + foreach ($data as $category => $content) { + $fields[$category] .= $content; + } + } + } + print theme('page', theme('user_profile', $user, $fields), $user->name); } else { $output = user_login(); @@ -1091,7 +1106,17 @@ function user_view($uid = 0) { } else { if ($account = user_load(array('uid' => $uid, "status" => 1))) { - print theme('page', theme('user_profile', $account), $account->name); + // Retrieve and merge all profile fields: + $fields = array(); + foreach (module_list() as $module) { + if ($data = module_invoke($module, 'user', 'view', '', $account)) { + foreach ($data as $category => $content) { + $fields[$category] .= $content; + } + } + } + + print theme('page', theme('user_profile', $account, $fields), $account->name); } else { drupal_not_found(); -- cgit v1.2.3