diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4e9d9a2c1..70bfcb343 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -3,6 +3,7 @@ - fixed: Reverted change to RichEdit that caused IE6 to stop working - fixed: Subscription: Price not displaying - fixed: Flat Discount Coupon: Add to Cart button seems broken + - fixed: Deleting unProtected user profile fields 7.5.14 - fixed: RSS feeds report modified date instead of create date diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index a6930c456..3cefda478 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -95,36 +95,36 @@ sub canView { =head2 www_deleteProfileCategoryConfirm ( $session ) Deletes the profile category in form variable C, unless the category is -protected, in which case it returns $session->privilege->vitalComponent. -Othewise, it returns the user to www_editProfileSettings. +protected, or it contains protected fields, in which case it returns $session->privilege->vitalComponent. +Otherwise, it returns the user to www_editProfileSettings. =cut sub www_deleteProfileCategoryConfirm { - my $session = shift; - return $session->privilege->adminOnly() unless canView($session); - my $category = WebGUI::ProfileCategory->new($session,$session->form->process("cid")); - return WebGUI::AdminConsole->new($session,"userProfiling")->render($session->privilege->vitalComponent()) if ($category->isProtected); - $category->delete; - return www_editProfileSettings($session); + my $session = shift; + return $session->privilege->adminOnly() unless canView($session); + my $category = WebGUI::ProfileCategory->new($session,$session->form->process("cid")); + return WebGUI::AdminConsole->new($session,"userProfiling")->render($session->privilege->vitalComponent()) if ($category->isProtected or $category->hasProtected); + $category->delete; + return www_editProfileSettings($session); } =head2 www_deleteProfileFieldConfirm ( $session ) Deletes the profile field in form variable C, unless the field is protected, in which case it returns $session->privilege->vitalComponent. -Othewise, it returns the user to www_editProfileSettings. +Otherwise, it returns the user to www_editProfileSettings. =cut #------------------------------------------------------------------- sub www_deleteProfileFieldConfirm { - my $session = shift; - return $session->privilege->adminOnly() unless canView($session); - my $field = WebGUI::ProfileField->new($session,$session->form->process("fid")); - return WebGUI::AdminConsole->new($session,"userProfiling")->render($session->privilege->vitalComponent()) if ($field->isProtected); - $field->delete; - return www_editProfileSettings($session); + my $session = shift; + return $session->privilege->adminOnly() unless canView($session); + my $field = WebGUI::ProfileField->new($session,$session->form->process("fid")); + return WebGUI::AdminConsole->new($session,"userProfiling")->render($session->privilege->vitalComponent()) if ($field->isProtected); + $field->delete; + return www_editProfileSettings($session); } =head2 www_editProfileCategory ( $session ) diff --git a/lib/WebGUI/ProfileCategory.pm b/lib/WebGUI/ProfileCategory.pm index 6e3bae9ee..b2bd2d67f 100644 --- a/lib/WebGUI/ProfileCategory.pm +++ b/lib/WebGUI/ProfileCategory.pm @@ -177,6 +177,27 @@ sub getLabel { return WebGUI::Operation::Shared::secureEval($self->session,$self->get("label")); } +#------------------------------------------------------------------- + +=head2 hasProtected ( ) + +Returns a boolean indicating whether any of the category's fields are protected. + +=cut + +sub hasProtected { + my $self = shift; + my $protected=0; + FIELD: foreach my $field (@{ $self->getFields }) { + if ($field->isProtected) { + $protected=1; + last FIELD; + } + } + return $protected; +} + + #------------------------------------------------------------------- =head2 isEditable ( ) diff --git a/lib/WebGUI/i18n/English/WebGUIProfile.pm b/lib/WebGUI/i18n/English/WebGUIProfile.pm index 0598ac2e1..38d7e7524 100644 --- a/lib/WebGUI/i18n/English/WebGUIProfile.pm +++ b/lib/WebGUI/i18n/English/WebGUIProfile.pm @@ -123,8 +123,8 @@ If you wish to set the Default Value for any other field. Create the field with }, '466' => { - message => q|Are you certain you wish to delete this category and move all of its fields to the Miscellaneous category?|, - lastUpdated => 1031514049 + message => q|Are you certain you wish to delete this category and all of its fields?|, + lastUpdated => 1214599497, }, '470 description' => {