- Fixes bug #1336 and #1473.

4.2.x
Dries Buytaert 2003-04-29 20:31:21 +00:00
parent db04650411
commit 5ce6e015d0
2 changed files with 14 additions and 12 deletions

View File

@ -52,11 +52,11 @@ function profile_settings() {
$profile_register_fields = variable_get("profile_register_fields", array());
$output = "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= "<tr><th>field</th><th>public</th><th>private</th><th>required</th><th>show in registration form</th></tr>\n";
$output .= "<tr><th>field</th><th>enable</th><th>public</th><th>required</th><th>show in registration form</th></tr>\n";
foreach ($profile_fields as $key => $field) {
$output .= "<tr><td>$field[1]</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields)) ."</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_private_fields][", $key, in_array($key, $profile_private_fields)) ."</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields)) ."</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_required_fields][", $key, in_array($key, $profile_required_fields)) ."</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_register_fields][", $key, in_array($key, $profile_register_fields)) ."</td>";
$output .= "</tr>\n";
@ -135,15 +135,16 @@ function _profile_form($edit, $mode) {
}
function _profile_validate($edit, $mode) {
global $profile_fields, $user, $HTTP_POST_VARS;
$req_fields = _profile_active_fields($mode);
$enabled_fields = _profile_active_fields($mode);
if (in_array("birthday", $req_fields) && ($birth_error = _profile_validate_birth($edit))) {
if (in_array("birthday", $enabled_fields) && ($birth_error = _profile_validate_birth($edit))) {
$error .= $birth_error."<br />";
}
if (in_array("avatar", $req_fields) && ($avatar_error = _profile_validate_avatar($edit))) {
if (in_array("avatar", $enabled_fields) && ($avatar_error = _profile_validate_avatar($edit))) {
$error .= $avatar_error."<br />";
}
@ -156,7 +157,7 @@ function _profile_validate($edit, $mode) {
// now check for required fields
foreach(_profile_active_fields("required") as $required) {
if (in_array($required, $req_fields)) {
if (in_array($required, $enabled_fields)) {
if (!$edit["profile_".$required]) {
$error .= t("This required field is missing: %a", array("%a" => $profile_fields[$required][1]))."<br />";
}

View File

@ -52,11 +52,11 @@ function profile_settings() {
$profile_register_fields = variable_get("profile_register_fields", array());
$output = "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
$output .= "<tr><th>field</th><th>public</th><th>private</th><th>required</th><th>show in registration form</th></tr>\n";
$output .= "<tr><th>field</th><th>enable</th><th>public</th><th>required</th><th>show in registration form</th></tr>\n";
foreach ($profile_fields as $key => $field) {
$output .= "<tr><td>$field[1]</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields)) ."</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_private_fields][", $key, in_array($key, $profile_private_fields)) ."</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_public_fields][", $key, in_array($key, $profile_public_fields)) ."</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_required_fields][", $key, in_array($key, $profile_required_fields)) ."</td>";
$output .= "<td align=\"center\">". form_checkbox("", "profile_register_fields][", $key, in_array($key, $profile_register_fields)) ."</td>";
$output .= "</tr>\n";
@ -135,15 +135,16 @@ function _profile_form($edit, $mode) {
}
function _profile_validate($edit, $mode) {
global $profile_fields, $user, $HTTP_POST_VARS;
$req_fields = _profile_active_fields($mode);
$enabled_fields = _profile_active_fields($mode);
if (in_array("birthday", $req_fields) && ($birth_error = _profile_validate_birth($edit))) {
if (in_array("birthday", $enabled_fields) && ($birth_error = _profile_validate_birth($edit))) {
$error .= $birth_error."<br />";
}
if (in_array("avatar", $req_fields) && ($avatar_error = _profile_validate_avatar($edit))) {
if (in_array("avatar", $enabled_fields) && ($avatar_error = _profile_validate_avatar($edit))) {
$error .= $avatar_error."<br />";
}
@ -156,7 +157,7 @@ function _profile_validate($edit, $mode) {
// now check for required fields
foreach(_profile_active_fields("required") as $required) {
if (in_array($required, $req_fields)) {
if (in_array($required, $enabled_fields)) {
if (!$edit["profile_".$required]) {
$error .= t("This required field is missing: %a", array("%a" => $profile_fields[$required][1]))."<br />";
}