Added a method to check to see if a profile category has protected fields.

Use that method to see prevent the category from being deleted in the ProfileSettings operation.
Change the delete profile confirmation message to match what it does, which is delete all
the fields in the category.
This commit is contained in:
Colin Kuskie 2008-06-27 20:57:54 +00:00
parent e51d02e3d8
commit bc9ddbf163
4 changed files with 39 additions and 17 deletions

View file

@ -95,36 +95,36 @@ sub canView {
=head2 www_deleteProfileCategoryConfirm ( $session )
Deletes the profile category in form variable C<cid>, 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<fid>, 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 )

View file

@ -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 ( )

View file

@ -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' => {