summaryrefslogtreecommitdiff
path: root/modules/user
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-03-21 14:28:15 +0000
committerDries Buytaert <dries@buytaert.net>2004-03-21 14:28:15 +0000
commit754f2ac26a2dbe81fcaa2886d4a8f5030b8e6cda (patch)
treec0300113f97cbc055fe177e75542e11c0c0ff400 /modules/user
parentf43cd3bb3399bf13109945b5d259e5fe934a81f7 (diff)
downloadbrdo-754f2ac26a2dbe81fcaa2886d4a8f5030b8e6cda.tar.gz
brdo-754f2ac26a2dbe81fcaa2886d4a8f5030b8e6cda.tar.bz2
- 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.
Diffstat (limited to 'modules/user')
-rw-r--r--modules/user/user.module37
1 files changed, 31 insertions, 6 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index 9fd0a971f..7d2b33380 100644
--- a/modules/user/user.module
+++ b/modules/user/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 = "<div class=\"profile\">\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 .= "<h2>$category</h2>$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();