summaryrefslogtreecommitdiff
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
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.
-rw-r--r--modules/blog.module2
-rw-r--r--modules/blog/blog.module2
-rw-r--r--modules/comment.module5
-rw-r--r--modules/comment/comment.module5
-rw-r--r--modules/profile.module6
-rw-r--r--modules/profile/profile.module6
-rw-r--r--modules/system.module3
-rw-r--r--modules/system/system.module3
-rw-r--r--modules/tracker.module3
-rw-r--r--modules/tracker/tracker.module3
-rw-r--r--modules/user.module37
-rw-r--r--modules/user/user.module37
12 files changed, 80 insertions, 32 deletions
diff --git a/modules/blog.module b/modules/blog.module
index 9b18115d4..bd1c00fe7 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -38,7 +38,7 @@ function blog_access($op, $node) {
function blog_user($type, &$edit, &$user) {
if ($type == 'view' && user_access("maintain personal blog", $user)) {
- return form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name)))));
+ return array(t('History') => form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name))))));
}
}
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index 9b18115d4..bd1c00fe7 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -38,7 +38,7 @@ function blog_access($op, $node) {
function blog_user($type, &$edit, &$user) {
if ($type == 'view' && user_access("maintain personal blog", $user)) {
- return form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name)))));
+ return array(t('History') => form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name))))));
}
}
diff --git a/modules/comment.module b/modules/comment.module
index b7676eaaf..03f6144bd 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -138,11 +138,6 @@ function comment_settings() {
function comment_user($type, $edit, &$user) {
switch ($type) {
- case "view":
- if ($user->signature) {
- return form_item(t("Signature"), check_output($user->signature));
- }
- break;
case "edit":
// when user tries to edit his own data
return array(t('Personal information') => form_textarea(t("Signature"), "signature", $user->signature, 64, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". filter_tips_short()));
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index b7676eaaf..03f6144bd 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -138,11 +138,6 @@ function comment_settings() {
function comment_user($type, $edit, &$user) {
switch ($type) {
- case "view":
- if ($user->signature) {
- return form_item(t("Signature"), check_output($user->signature));
- }
- break;
case "edit":
// when user tries to edit his own data
return array(t('Personal information') => form_textarea(t("Signature"), "signature", $user->signature, 64, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". filter_tips_short()));
diff --git a/modules/profile.module b/modules/profile.module
index 4efc5b656..7dae35895 100644
--- a/modules/profile.module
+++ b/modules/profile.module
@@ -129,15 +129,15 @@ function profile_view_profile($user) {
while ($field = db_fetch_object($result)) {
if ($value = profile_view_field($user, $field)) {
if ($field->type == 'checkbox') {
- $output .= "<p>$value</p>";
+ $fields[$field->category] .= "<p>$value</p>";
}
else {
- $output .= form_item($field->title, check_output($value));
+ $fields[$field->category] .= form_item($field->title, check_output($value));
}
}
}
- return $output;
+ return $fields;
}
function profile_edit_profile($edit, $user) {
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 4efc5b656..7dae35895 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -129,15 +129,15 @@ function profile_view_profile($user) {
while ($field = db_fetch_object($result)) {
if ($value = profile_view_field($user, $field)) {
if ($field->type == 'checkbox') {
- $output .= "<p>$value</p>";
+ $fields[$field->category] .= "<p>$value</p>";
}
else {
- $output .= form_item($field->title, check_output($value));
+ $fields[$field->category] .= form_item($field->title, check_output($value));
}
}
}
- return $output;
+ return $fields;
}
function profile_edit_profile($edit, $user) {
diff --git a/modules/system.module b/modules/system.module
index ae588c7dd..1c5e7b95f 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -95,6 +95,9 @@ function system_user($type, $edit, &$user) {
$data[t('Locale settings')] = form_select(t("Time zone"), "timezone", $edit["timezone"], $zones, t("Select what time you currently have and your time zone settings will be set appropriate."));
return $data;
}
+ else if ($type == 'view') {
+ // do nothing
+ }
else {
return $edit;
}
diff --git a/modules/system/system.module b/modules/system/system.module
index ae588c7dd..1c5e7b95f 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -95,6 +95,9 @@ function system_user($type, $edit, &$user) {
$data[t('Locale settings')] = form_select(t("Time zone"), "timezone", $edit["timezone"], $zones, t("Select what time you currently have and your time zone settings will be set appropriate."));
return $data;
}
+ else if ($type == 'view') {
+ // do nothing
+ }
else {
return $edit;
}
diff --git a/modules/tracker.module b/modules/tracker.module
index fbf587ff6..a700f13dc 100644
--- a/modules/tracker.module
+++ b/modules/tracker.module
@@ -76,7 +76,8 @@ function tracker_page() {
function tracker_user($type, &$edit, &$user) {
if ($type == 'view' && user_access("access content")) {
- return form_item(t("Recent posts"), l(t("recent posts"), "tracker/$user->uid"));
+ return array(t('History') => form_item(t("Recent posts"), l(t("recent posts"), "tracker/$user->uid")));
+ return $fields;
}
}
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index fbf587ff6..a700f13dc 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -76,7 +76,8 @@ function tracker_page() {
function tracker_user($type, &$edit, &$user) {
if ($type == 'view' && user_access("access content")) {
- return form_item(t("Recent posts"), l(t("recent posts"), "tracker/$user->uid"));
+ return array(t('History') => form_item(t("Recent posts"), l(t("recent posts"), "tracker/$user->uid")));
+ return $fields;
}
}
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 = "<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();
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();