summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-02-07 16:18:46 +0000
committerDries Buytaert <dries@buytaert.net>2004-02-07 16:18:46 +0000
commit5a8129e0fbf762c9dc6891d574dac386e959c262 (patch)
tree85a91e174d293a75656f8c1f5159d729c2cf6fc3
parent8c909397d7af99b6898255a93d13a03d0eafb2aa (diff)
downloadbrdo-5a8129e0fbf762c9dc6891d574dac386e959c262.tar.gz
brdo-5a8129e0fbf762c9dc6891d574dac386e959c262.tar.bz2
- First batch of profile module improvements:
+ Tidied up the profile configuration page: grouped form elements. + Tidied up the block configuration settings: removed hard-coded table. + Changed the profile API to return the preferred group name, and changed the user module to group settings. Modules implementing the _user hook will need to be udpated. + Removed register_form and register_validate for now.
-rw-r--r--modules/block.module12
-rw-r--r--modules/block/block.module12
-rw-r--r--modules/comment.module2
-rw-r--r--modules/comment/comment.module2
-rw-r--r--modules/locale.module3
-rw-r--r--modules/locale/locale.module3
-rw-r--r--modules/profile.module25
-rw-r--r--modules/profile/profile.module25
-rw-r--r--modules/system.module7
-rw-r--r--modules/system/system.module7
-rw-r--r--modules/user.module66
-rw-r--r--modules/user/user.module66
12 files changed, 80 insertions, 150 deletions
diff --git a/modules/block.module b/modules/block.module
index 4b2738e07..d18c84b15 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -323,26 +323,18 @@ function block_admin() {
function block_user($type, &$edit, &$user) {
switch ($type) {
- case "register_form":
- $result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
-
- while ($block = db_fetch_object($result)) {
- $form .= form_hidden("block][$block->module][$block->delta", $block->status);
- }
-
- return $form;
case "edit_form":
$result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
if ($data[$block->delta]["info"]) {
- $form .= "<tr><td>". $data[$block->delta]["info"] ."</td><td>". form_checkbox(NULL, "block][$block->module][$block->delta", 1, $user->block[$block->module][$block->delta]) ."</td></tr>\n";
+ $form .= form_checkbox($data[$block->delta]['info'], "block][$block->module][$block->delta", 1, $user->block[$block->module][$block->delta]);
}
}
if (isset($form)) {
- return form_item(t("Block configuration"), "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">". $form ."</table>", t("Enable the blocks you would like to see displayed in the side bars."));
+ return array(t('Block configuration') => $form);
}
break;
diff --git a/modules/block/block.module b/modules/block/block.module
index 4b2738e07..d18c84b15 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -323,26 +323,18 @@ function block_admin() {
function block_user($type, &$edit, &$user) {
switch ($type) {
- case "register_form":
- $result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
-
- while ($block = db_fetch_object($result)) {
- $form .= form_hidden("block][$block->module][$block->delta", $block->status);
- }
-
- return $form;
case "edit_form":
$result = db_query("SELECT * FROM {blocks} WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
if ($data[$block->delta]["info"]) {
- $form .= "<tr><td>". $data[$block->delta]["info"] ."</td><td>". form_checkbox(NULL, "block][$block->module][$block->delta", 1, $user->block[$block->module][$block->delta]) ."</td></tr>\n";
+ $form .= form_checkbox($data[$block->delta]['info'], "block][$block->module][$block->delta", 1, $user->block[$block->module][$block->delta]);
}
}
if (isset($form)) {
- return form_item(t("Block configuration"), "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\">". $form ."</table>", t("Enable the blocks you would like to see displayed in the side bars."));
+ return array(t('Block configuration') => $form);
}
break;
diff --git a/modules/comment.module b/modules/comment.module
index 1a6f45b50..9dfee0ef1 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -146,7 +146,7 @@ function comment_user($type, $edit, &$user) {
break;
case "edit_form":
// when user tries to edit his own data
- return form_textarea(t("Signature"), "signature", $user->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". filter_tips_short());
+ return array(t('Personal information') => form_textarea(t("Signature"), "signature", $user->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". filter_tips_short()));
case "edit_validate":
// validate user data editing
return array("signature" => $edit["signature"]);
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 1a6f45b50..9dfee0ef1 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -146,7 +146,7 @@ function comment_user($type, $edit, &$user) {
break;
case "edit_form":
// when user tries to edit his own data
- return form_textarea(t("Signature"), "signature", $user->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". filter_tips_short());
+ return array(t('Personal information') => form_textarea(t("Signature"), "signature", $user->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."<br />". filter_tips_short()));
case "edit_validate":
// validate user data editing
return array("signature" => $edit["signature"]);
diff --git a/modules/locale.module b/modules/locale.module
index efc4f576b..e5fa717e3 100644
--- a/modules/locale.module
+++ b/modules/locale.module
@@ -75,9 +75,8 @@ function locale_link($type) {
function locale_user($type, &$edit, &$user) {
global $languages;
if ($type == "edit_form" && count($languages) > 1) {
- $output = form_radios(t("Language"), 'language', $user->language, $languages, t("Selecting a different language will change the language of the site."));
+ return array(t('Locale settings') => form_radios(t("Language"), 'language', $user->language, $languages, t("Selecting a different language will change the language of the site.")));
}
- return $output;
}
function locale_delete($lid) {
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index efc4f576b..e5fa717e3 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -75,9 +75,8 @@ function locale_link($type) {
function locale_user($type, &$edit, &$user) {
global $languages;
if ($type == "edit_form" && count($languages) > 1) {
- $output = form_radios(t("Language"), 'language', $user->language, $languages, t("Selecting a different language will change the language of the site."));
+ return array(t('Locale settings') => form_radios(t("Language"), 'language', $user->language, $languages, t("Selecting a different language will change the language of the site.")));
}
- return $output;
}
function locale_delete($lid) {
diff --git a/modules/profile.module b/modules/profile.module
index adf8af224..d74b75e12 100644
--- a/modules/profile.module
+++ b/modules/profile.module
@@ -45,7 +45,7 @@ function profile_help($section) {
$output = t("Support for configurable user profiles.");
break;
case 'admin/system/modules/profile':
- $output = t("When a user creates an account you can ask for some extra information, as well as letting the user have a small picture, called an avatar.<br />Notes:<ul><li>In order for a user to enter information you <strong>must</strong> check \"enable\".</li><li>In order for other people too see the entered information you must make it \"public\".</li><li>If an item is \"public\", but not enabled, the user can never give it a value and it will never be seen. Public does <strong>not</strong> imply \"enable\".</li><li>If an item is enabled, but not shown in the registration form the user will have to <a href=\"%edit\">edit their account</a> to place information in the field.</ul>", array("%edit" => url("user/edit")));
+ $output = t("When a user creates an account you can ask for some extra information, as well as letting the user have a small picture, called an avatar.<br />Notes:<ul><li>In order for a user to enter information you <strong>must</strong> check \"enable\".</li><li>In order for other people too see the entered information you must make it \"public\".</li><li>If an item is \"public\", but not enabled, the user can never give it a value and it will never be seen. Public does <strong>not</strong> imply \"enable\".</li></ul>", array("%edit" => url("user/edit")));
break;
}
return $output;
@@ -53,6 +53,7 @@ function profile_help($section) {
function profile_settings() {
global $profile_fields;
+
if (!$profile_fields) {
_profile_init();
}
@@ -64,23 +65,23 @@ function profile_settings() {
$profile_public_fields = variable_get("profile_public_fields", array());
$profile_private_fields = variable_get("profile_private_fields", array());
$profile_required_fields = variable_get("profile_required_fields", array());
- $profile_register_fields = variable_get("profile_register_fields", array());
- $header = array(t("field"), t("enable"), t("public"), t("required"), t("show in registration form"));
+ $header = array(t("field"), t("enable"), t("public"), t("required"));
$i = 0;
foreach ($profile_fields as $key => $field) {
$row[$i][] = $field[1];
$row[$i][] = form_checkbox("", "profile_private_fields][", $key, in_array($key, $profile_private_fields));
$row[$i][] = form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields));
$row[$i][] = form_checkbox("", "profile_required_fields][", $key, in_array($key, $profile_required_fields));
- $row[$i][] = form_checkbox("", "profile_register_fields][", $key, in_array($key, $profile_register_fields));
$i++;
}
- $output .= theme("table", $header, $row);
+
+ $avatar = form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "avatars"), 30, 255, t("Subdirectory in the directory '%dir' where avatars will be stored.", array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)) . $error['profile_avatar_path']);
+ $avatar .= form_textfield(t("Avatar maximum dimensions"), "profile_avatar_dimensions", variable_get("profile_avatar_dimensions", "85x85"), 10, 10, t("Maximum dimensions for avatars."));
+ $avatar .= form_textfield(t("Avatar maximum file size"), "profile_avatar_file_size", variable_get("profile_avatar_file_size", "30"), 10, 10, t("Maximum file size for avatars, in kB."));
- $output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "avatars"), 30, 255, t("Subdirectory in the directory '%dir' where avatars will be stored.", array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)) . $error['profile_avatar_path']);
- $output .= form_textfield(t("Avatar maximum dimensions"), "profile_avatar_dimensions", variable_get("profile_avatar_dimensions", "85x85"), 10, 10, t("Maximum dimensions for avatars."));
- $output .= form_textfield(t("Avatar maximum file size"), "profile_avatar_file_size", variable_get("profile_avatar_file_size", "30"), 10, 10, t("Maximum file size for avatars, in kB."));
+ $output = theme("table", $header, $row);
+ $output .= form_group(t('Avatars'), $avatar);
return $output;
}
@@ -92,12 +93,6 @@ function profile_user($type, $edit, &$user) {
}
switch ($type) {
- case "register_form":
- // first registration form (to add something to just email and nick)
- return _profile_form($edit, "register");
- case "register_validate":
- // validate first registration form
- return _profile_validate($edit, "required", $user);
case "edit_form":
// when user tries to edit his own data
return _profile_form(object2array($user), "private");
@@ -143,7 +138,7 @@ function _profile_form($edit, $mode) {
$output .= form_file($profile_fields["avatar"][1], "profile_avatar", 64, $profile_fields["avatar"][2]);
}
- return $output;
+ return array(t('Personal information') => $output);
}
function _profile_validate($edit, $mode, $user) {
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index adf8af224..d74b75e12 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -45,7 +45,7 @@ function profile_help($section) {
$output = t("Support for configurable user profiles.");
break;
case 'admin/system/modules/profile':
- $output = t("When a user creates an account you can ask for some extra information, as well as letting the user have a small picture, called an avatar.<br />Notes:<ul><li>In order for a user to enter information you <strong>must</strong> check \"enable\".</li><li>In order for other people too see the entered information you must make it \"public\".</li><li>If an item is \"public\", but not enabled, the user can never give it a value and it will never be seen. Public does <strong>not</strong> imply \"enable\".</li><li>If an item is enabled, but not shown in the registration form the user will have to <a href=\"%edit\">edit their account</a> to place information in the field.</ul>", array("%edit" => url("user/edit")));
+ $output = t("When a user creates an account you can ask for some extra information, as well as letting the user have a small picture, called an avatar.<br />Notes:<ul><li>In order for a user to enter information you <strong>must</strong> check \"enable\".</li><li>In order for other people too see the entered information you must make it \"public\".</li><li>If an item is \"public\", but not enabled, the user can never give it a value and it will never be seen. Public does <strong>not</strong> imply \"enable\".</li></ul>", array("%edit" => url("user/edit")));
break;
}
return $output;
@@ -53,6 +53,7 @@ function profile_help($section) {
function profile_settings() {
global $profile_fields;
+
if (!$profile_fields) {
_profile_init();
}
@@ -64,23 +65,23 @@ function profile_settings() {
$profile_public_fields = variable_get("profile_public_fields", array());
$profile_private_fields = variable_get("profile_private_fields", array());
$profile_required_fields = variable_get("profile_required_fields", array());
- $profile_register_fields = variable_get("profile_register_fields", array());
- $header = array(t("field"), t("enable"), t("public"), t("required"), t("show in registration form"));
+ $header = array(t("field"), t("enable"), t("public"), t("required"));
$i = 0;
foreach ($profile_fields as $key => $field) {
$row[$i][] = $field[1];
$row[$i][] = form_checkbox("", "profile_private_fields][", $key, in_array($key, $profile_private_fields));
$row[$i][] = form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields));
$row[$i][] = form_checkbox("", "profile_required_fields][", $key, in_array($key, $profile_required_fields));
- $row[$i][] = form_checkbox("", "profile_register_fields][", $key, in_array($key, $profile_register_fields));
$i++;
}
- $output .= theme("table", $header, $row);
+
+ $avatar = form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "avatars"), 30, 255, t("Subdirectory in the directory '%dir' where avatars will be stored.", array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)) . $error['profile_avatar_path']);
+ $avatar .= form_textfield(t("Avatar maximum dimensions"), "profile_avatar_dimensions", variable_get("profile_avatar_dimensions", "85x85"), 10, 10, t("Maximum dimensions for avatars."));
+ $avatar .= form_textfield(t("Avatar maximum file size"), "profile_avatar_file_size", variable_get("profile_avatar_file_size", "30"), 10, 10, t("Maximum file size for avatars, in kB."));
- $output .= form_textfield(t("Avatar image path"), "profile_avatar_path", variable_get("profile_avatar_path", "avatars"), 30, 255, t("Subdirectory in the directory '%dir' where avatars will be stored.", array('%dir' => variable_get('file_directory_path', 'files') . FILE_SEPARATOR)) . $error['profile_avatar_path']);
- $output .= form_textfield(t("Avatar maximum dimensions"), "profile_avatar_dimensions", variable_get("profile_avatar_dimensions", "85x85"), 10, 10, t("Maximum dimensions for avatars."));
- $output .= form_textfield(t("Avatar maximum file size"), "profile_avatar_file_size", variable_get("profile_avatar_file_size", "30"), 10, 10, t("Maximum file size for avatars, in kB."));
+ $output = theme("table", $header, $row);
+ $output .= form_group(t('Avatars'), $avatar);
return $output;
}
@@ -92,12 +93,6 @@ function profile_user($type, $edit, &$user) {
}
switch ($type) {
- case "register_form":
- // first registration form (to add something to just email and nick)
- return _profile_form($edit, "register");
- case "register_validate":
- // validate first registration form
- return _profile_validate($edit, "required", $user);
case "edit_form":
// when user tries to edit his own data
return _profile_form(object2array($user), "private");
@@ -143,7 +138,7 @@ function _profile_form($edit, $mode) {
$output .= form_file($profile_fields["avatar"][1], "profile_avatar", 64, $profile_fields["avatar"][2]);
}
- return $output;
+ return array(t('Personal information') => $output);
}
function _profile_validate($edit, $mode, $user) {
diff --git a/modules/system.module b/modules/system.module
index bdef196cd..ea5e703b8 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -83,17 +83,18 @@ function system_user($type, &$edit, $user) {
foreach ($themes as $key => $value) {
$options .= "<option value=\"$key\"". (($edit["theme"] == $key) ? " selected=\"selected\"" : "") .">$key - $value->description</option>\n";
}
- $output .= form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
+ $data[t('Theme settings')] = form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
}
+
$zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
foreach ($zonelist as $offset) {
$zone = $offset * 3600;
$zones["$zone"] = date(variable_get("date_format_long", "l, F dS, Y - g:ia"), time() - date("Z") + $zone) . sprintf(" (GMT %s%02d:%02d)\n", ($offset >= 0) ? "+" : "-", floor(abs($offset)), (abs($offset) * 60) % 60);
}
- $output .= 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."));
+ $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 $output;
+ return $data;
}
function system_view_general() {
diff --git a/modules/system/system.module b/modules/system/system.module
index bdef196cd..ea5e703b8 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -83,17 +83,18 @@ function system_user($type, &$edit, $user) {
foreach ($themes as $key => $value) {
$options .= "<option value=\"$key\"". (($edit["theme"] == $key) ? " selected=\"selected\"" : "") .">$key - $value->description</option>\n";
}
- $output .= form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
+ $data[t('Theme settings')] = form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
}
+
$zonelist = array(-11, -10, -9.5, -9, -8, -7, -6, -5, -4, -3.5, -3, -2, -1, 0, 1, 2, 3, 3.5, 4, 5, 5.5, 5.75, 6, 6.5, 7, 8, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 14);
foreach ($zonelist as $offset) {
$zone = $offset * 3600;
$zones["$zone"] = date(variable_get("date_format_long", "l, F dS, Y - g:ia"), time() - date("Z") + $zone) . sprintf(" (GMT %s%02d:%02d)\n", ($offset >= 0) ? "+" : "-", floor(abs($offset)), (abs($offset) * 60) % 60);
}
- $output .= 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."));
+ $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 $output;
+ return $data;
}
function system_view_general() {
diff --git a/modules/user.module b/modules/user.module
index 91cccf78d..a46fe3809 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -789,23 +789,6 @@ function user_register($edit = array()) {
else if (variable_get("user_register", 1) == 0) {
$error = t("Public registrations have been disabled by the site administrator.");
}
- else {
- foreach (module_list() as $module) {
- if (module_hook($module, 'user')) {
- $result = module_invoke($module, 'user', "register_validate", $edit, $user);
- if (is_array($result)) {
- $data = array_merge($data, $result);
- }
- elseif (is_string($result)) {
- $error = $result;
- break;
- }
- }
- }
- if (!$error) {
- $success = 1;
- }
- }
}
if ($success) {
@@ -869,11 +852,6 @@ function user_register($edit = array()) {
}
$output .= form_textfield(t("Username"), 'name', $edit['name'], 30, 64, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $edit['mail'], 30, 64, t("A password and instructions will be sent to this e-mail address, so make sure it is accurate."));
- foreach (module_list() as $module) {
- if (module_hook($module, 'user')) {
- $output .= module_invoke($module, 'user', "register_form", $edit, $user);
- }
- }
$output .= form_submit(t("Create new account"));
$items[] = l(t("Request new password"), "user/password");
$items[] = l(t("Log in"), "user/login");
@@ -969,12 +947,11 @@ function user_edit($edit = array()) {
$edit = object2array($user);
}
- $output .= form_textfield(t("Username"), 'name', $edit['name'], 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
+ $output = form_textfield(t("Username"), 'name', $edit['name'], 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $edit['mail'], 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."));
-
- $output .= implode("\n", module_invoke_all('user', "edit_form", $edit, $user));
-
$output .= form_item(t("Password"), "<input type=\"password\" name=\"edit[pass1]\" size=\"12\" maxlength=\"24\" /> <input type=\"password\" name=\"edit[pass2]\" size=\"12\" maxlength=\"24\" />", t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password."));
+ $output = form_group(t('Account information'), $output);
+ $output .= _user_settings();
$output .= form_submit(t("Save user information"));
$output = form($output, "post", 0, array("enctype" => "multipart/form-data"));
@@ -987,6 +964,24 @@ function user_edit($edit = array()) {
return $output;
}
+function _user_settings($style = 'edit_form') {
+
+ foreach (module_list() as $module) {
+ if ($data = module_invoke($module, 'user', $style, $edit, $user)) {
+ foreach ($data as $title => $form) {
+ $groups[$title] .= $form;
+ }
+ }
+ }
+
+ $output = '';
+ foreach ($groups as $title => $form) {
+ $output .= form_group($title, $form);
+ }
+
+ return $output;
+}
+
function user_view($uid = 0) {
global $user;
@@ -1697,24 +1692,7 @@ function user_help($section = "admin/help#user") {
function julia_user(\$type, \$edit, &\$user) {
// What type of registration action are we taking?
switch (\$type) {
- case t(\"register_form\"):
- // Add two items to the resigtration form.
- \$output .= form_item(\"Privacy Policy\", \"Julia would never sell your user information. She is just a nice \".
- \"old French chef who lives near me in Cambridge, Massachussetts USA.\");
- \$output .= form_checkbox(\"Accept <i>Julia's Kitchen</i> privacy policy.\",
- julia_accept, 1, \$edit[\"julia_accept\"]);
- return \$output;
- case t(\"register_validate\"):
- // The user has filled out the form and checked the \"accept\" box.
- if (\$edit[\"julia_accept\"] == \"1\") {
- // on success return the values you want to store
- return array(\"julia_accept\" => 1);
- }
- else {
- // on error return an error message
- return \"You must accept the Julia's Kitchen privacy policy to register.\";
- }
- case t(\"view_public\"):
+ case t(\"view_public\"):
// when others look at user data
return form_item(\"Favorite Ingredient\", \$user->julia_favingredient);
case t(\"view_private\"):
diff --git a/modules/user/user.module b/modules/user/user.module
index 91cccf78d..a46fe3809 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -789,23 +789,6 @@ function user_register($edit = array()) {
else if (variable_get("user_register", 1) == 0) {
$error = t("Public registrations have been disabled by the site administrator.");
}
- else {
- foreach (module_list() as $module) {
- if (module_hook($module, 'user')) {
- $result = module_invoke($module, 'user', "register_validate", $edit, $user);
- if (is_array($result)) {
- $data = array_merge($data, $result);
- }
- elseif (is_string($result)) {
- $error = $result;
- break;
- }
- }
- }
- if (!$error) {
- $success = 1;
- }
- }
}
if ($success) {
@@ -869,11 +852,6 @@ function user_register($edit = array()) {
}
$output .= form_textfield(t("Username"), 'name', $edit['name'], 30, 64, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $edit['mail'], 30, 64, t("A password and instructions will be sent to this e-mail address, so make sure it is accurate."));
- foreach (module_list() as $module) {
- if (module_hook($module, 'user')) {
- $output .= module_invoke($module, 'user', "register_form", $edit, $user);
- }
- }
$output .= form_submit(t("Create new account"));
$items[] = l(t("Request new password"), "user/password");
$items[] = l(t("Log in"), "user/login");
@@ -969,12 +947,11 @@ function user_edit($edit = array()) {
$edit = object2array($user);
}
- $output .= form_textfield(t("Username"), 'name', $edit['name'], 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
+ $output = form_textfield(t("Username"), 'name', $edit['name'], 30, 55, t("Your full name or your preferred username: only letters, numbers and spaces are allowed."));
$output .= form_textfield(t("E-mail address"), "mail", $edit['mail'], 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail."));
-
- $output .= implode("\n", module_invoke_all('user', "edit_form", $edit, $user));
-
$output .= form_item(t("Password"), "<input type=\"password\" name=\"edit[pass1]\" size=\"12\" maxlength=\"24\" /> <input type=\"password\" name=\"edit[pass2]\" size=\"12\" maxlength=\"24\" />", t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password."));
+ $output = form_group(t('Account information'), $output);
+ $output .= _user_settings();
$output .= form_submit(t("Save user information"));
$output = form($output, "post", 0, array("enctype" => "multipart/form-data"));
@@ -987,6 +964,24 @@ function user_edit($edit = array()) {
return $output;
}
+function _user_settings($style = 'edit_form') {
+
+ foreach (module_list() as $module) {
+ if ($data = module_invoke($module, 'user', $style, $edit, $user)) {
+ foreach ($data as $title => $form) {
+ $groups[$title] .= $form;
+ }
+ }
+ }
+
+ $output = '';
+ foreach ($groups as $title => $form) {
+ $output .= form_group($title, $form);
+ }
+
+ return $output;
+}
+
function user_view($uid = 0) {
global $user;
@@ -1697,24 +1692,7 @@ function user_help($section = "admin/help#user") {
function julia_user(\$type, \$edit, &\$user) {
// What type of registration action are we taking?
switch (\$type) {
- case t(\"register_form\"):
- // Add two items to the resigtration form.
- \$output .= form_item(\"Privacy Policy\", \"Julia would never sell your user information. She is just a nice \".
- \"old French chef who lives near me in Cambridge, Massachussetts USA.\");
- \$output .= form_checkbox(\"Accept <i>Julia's Kitchen</i> privacy policy.\",
- julia_accept, 1, \$edit[\"julia_accept\"]);
- return \$output;
- case t(\"register_validate\"):
- // The user has filled out the form and checked the \"accept\" box.
- if (\$edit[\"julia_accept\"] == \"1\") {
- // on success return the values you want to store
- return array(\"julia_accept\" => 1);
- }
- else {
- // on error return an error message
- return \"You must accept the Julia's Kitchen privacy policy to register.\";
- }
- case t(\"view_public\"):
+ case t(\"view_public\"):
// when others look at user data
return form_item(\"Favorite Ingredient\", \$user->julia_favingredient);
case t(\"view_private\"):