POD for 2 more files
This commit is contained in:
parent
0b02edaea5
commit
dc204428f6
2 changed files with 229 additions and 11 deletions
|
|
@ -24,6 +24,26 @@ use WebGUI::ProfileField;
|
|||
use WebGUI::ProfileCategory;
|
||||
use WebGUI::Operation::Shared;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Operation::Profile
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Operational handler for viewing, editing and validating user profile data.
|
||||
|
||||
=head2 getRequiredProfileFields ( $session )
|
||||
|
||||
Returns an array of hashes for required profile fields. This array is ready
|
||||
to be used as template variables in the WebGUI template system.
|
||||
|
||||
=head3 $session
|
||||
|
||||
The current WebGUI session variable.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Builds Extra form requirements for anonymous registration.
|
||||
sub getRequiredProfileFields {
|
||||
|
|
@ -41,12 +61,14 @@ sub getRequiredProfileFields {
|
|||
#-------------------------------------------------------------------
|
||||
=head2 isDuplicateEmail ( )
|
||||
|
||||
Checks the value of the email address passed in to see if it is duplicated in the system. Returns true of false. Will return false if the email address passed in is
|
||||
same as the email address of the current user.
|
||||
|
||||
Checks the value of the email address passed in to see if it is
|
||||
duplicated in the system. Returns true of false. Will return false
|
||||
if the email address passed in is same as the email address of the
|
||||
current user.
|
||||
|
||||
=head3 email
|
||||
|
||||
email address to check for duplication
|
||||
|
||||
email address to check for duplication
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -58,16 +80,56 @@ sub isDuplicateEmail {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 saveProfileFields ( $session, $u, $profile )
|
||||
|
||||
Saves profile data to a user's profile. Does not validate any of the data.
|
||||
|
||||
=head3 $session
|
||||
|
||||
WebGUI session variable
|
||||
|
||||
=head3 $user
|
||||
|
||||
User object. Profile data will be placed in this user's profile.
|
||||
|
||||
=head4 $profile
|
||||
|
||||
Hash ref of profile data to save.
|
||||
|
||||
=cut
|
||||
|
||||
sub saveProfileFields {
|
||||
my $session = shift;
|
||||
my $u = shift;
|
||||
my $profile = shift;
|
||||
|
||||
foreach my $fieldName (keys %{$profile}) {
|
||||
$u->profileField($fieldName,${$profile}{$fieldName});
|
||||
}
|
||||
my $u = shift;
|
||||
my $profile = shift;
|
||||
|
||||
foreach my $fieldName (keys %{$profile}) {
|
||||
$u->profileField($fieldName,${$profile}{$fieldName});
|
||||
}
|
||||
}
|
||||
|
||||
=head2 validateProfileData ( $session )
|
||||
|
||||
Validates profile data from the session form variables. Returns processed data, warnings
|
||||
and errors.
|
||||
|
||||
There are two levels of validation:
|
||||
|
||||
=over 4
|
||||
|
||||
=item 1
|
||||
|
||||
If the profile field is required, and the form field is blank, returns an error.
|
||||
|
||||
=item 2
|
||||
|
||||
If the profile field label is "email", then checks for a duplicate email and returns a
|
||||
warning if it is a duplicate.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub validateProfileData {
|
||||
my $session = shift;
|
||||
|
|
@ -91,6 +153,21 @@ sub validateProfileData {
|
|||
return (\%data, $error, $warning);
|
||||
}
|
||||
|
||||
=head2 www_editProfile ( $session )
|
||||
|
||||
Provide a form where user profile data can be entered or edited. The subroutine
|
||||
makes a large set of template variables which are passed to a template for presentation
|
||||
and styling. The default template is PBtmpl0000000000000051 and is not user
|
||||
selectable.
|
||||
|
||||
Calls www_editProfileSave on submission.
|
||||
|
||||
=head3 $session
|
||||
|
||||
=head3 $error
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editProfile {
|
||||
my $session = shift;
|
||||
|
|
@ -129,6 +206,19 @@ sub www_editProfile {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
=head2 www_editProfileSave ( $session )
|
||||
|
||||
Validates all data submitted by www_editProfile. If errors or warnings are present,
|
||||
they are concatenated and sent back to www_editProfile for display and to let the user
|
||||
correct their mistakes.
|
||||
|
||||
If no mistakes are present, saves the data to the user's profile, updates the session user
|
||||
object.
|
||||
|
||||
Returns the user to WebGUI::Operation::Auth::www_auth when done.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editProfileSave {
|
||||
my $session = shift;
|
||||
my ($profile, $fieldName, $error, $u, $warning);
|
||||
|
|
@ -147,6 +237,16 @@ sub www_editProfileSave {
|
|||
return WebGUI::Operation::Auth::www_auth($session);
|
||||
}
|
||||
|
||||
=head2 www_viewProfile ( $session )
|
||||
|
||||
View the profile data for a user by the userId specified by the form variable C<uid>.
|
||||
Validates that the user requesting the profile data is allowed to see it.
|
||||
Similarly to www_editProfile, this method is templated. The default template
|
||||
is PBtmpl0000000000000052. The template is not user selectable.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewProfile {
|
||||
my $session = shift;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,43 @@ use WebGUI::Form::FieldType;
|
|||
use WebGUI::ProfileField;
|
||||
use WebGUI::ProfileCategory;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Operation::ProfileSettings
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Operation handler for configuring the user profile system in WebGUI.
|
||||
You are allowed to create categories of profile settings and manage
|
||||
them (delete, reorder, edit) as well as adding new fields to the
|
||||
profile and managing them.
|
||||
|
||||
Only users in group Admin (3) are allowed to call subroutines in this package.
|
||||
|
||||
=head2 _submenu ( $session, $workarea, $title, $help )
|
||||
|
||||
Utility routine for creating the AdminConsole for DatabaseLink functions.
|
||||
|
||||
=head3 $session
|
||||
|
||||
The current WebGUI session variable.
|
||||
|
||||
=head3 $workarea
|
||||
|
||||
The content to display to the user.
|
||||
|
||||
=head3 $title
|
||||
|
||||
The title of the Admin Console. This should be an entry in the i18n
|
||||
table in the WebGUI namespace.
|
||||
|
||||
=head3 $help
|
||||
|
||||
An entry in the Help system in the WebGUI namespace. This will be shown
|
||||
as a link to the user.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _submenu {
|
||||
my $session = shift;
|
||||
|
|
@ -46,6 +83,14 @@ sub _submenu {
|
|||
return $ac->render($workarea, $title);
|
||||
}
|
||||
|
||||
=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.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteProfileCategoryConfirm {
|
||||
my $session = shift;
|
||||
|
|
@ -56,6 +101,14 @@ sub www_deleteProfileCategoryConfirm {
|
|||
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.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteProfileFieldConfirm {
|
||||
my $session = shift;
|
||||
|
|
@ -66,6 +119,13 @@ sub www_deleteProfileFieldConfirm {
|
|||
return www_editProfileSettings($session);
|
||||
}
|
||||
|
||||
=head2 www_editProfileCategory ( $session )
|
||||
|
||||
Add or edit a profile category specified in form variable C<cid>. Calls www_editProfileCategorySave when done.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editProfileCategory {
|
||||
my $session = shift;
|
||||
|
|
@ -116,6 +176,14 @@ sub www_editProfileCategory {
|
|||
return _submenu($session,$f->print,'468','user profile category add/edit','WebGUIProfile');
|
||||
}
|
||||
|
||||
=head2 www_editProfileCategorySave ( $session )
|
||||
|
||||
Saves the data submitted by www_editProfileCategorySave and/or creates a new category.
|
||||
Returns the user to www_editProfileSettings when done.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editProfileCategorySave {
|
||||
my $session = shift;
|
||||
|
|
@ -133,6 +201,12 @@ sub www_editProfileCategorySave {
|
|||
return www_editProfileSettings($session);
|
||||
}
|
||||
|
||||
=head2 www_editProfileField ( $session )
|
||||
|
||||
Add or edit a profile field specified in form variable C<fid>. Calls www_editProfileFieldSave when done.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editProfileField {
|
||||
my $session = shift;
|
||||
|
|
@ -235,6 +309,13 @@ sub www_editProfileField {
|
|||
return _submenu($session,$f->print,'471','profile settings edit',"WebGUIProfile");
|
||||
}
|
||||
|
||||
=head2 www_editProfileFieldSave ( $session )
|
||||
|
||||
Saves the data submitted by www_editProfileFieldSave and/or creates a new field.
|
||||
Returns the user to www_editProfileSettings when done.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editProfileFieldSave {
|
||||
my $session = shift;
|
||||
|
|
@ -260,6 +341,12 @@ sub www_editProfileFieldSave {
|
|||
return www_editProfileSettings($session);
|
||||
}
|
||||
|
||||
=head2 www_editProfileSettings ( $session )
|
||||
|
||||
Allows profile categories and fields to be managed (added, edited, deleted or moved).
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editProfileSettings {
|
||||
my $session = shift;
|
||||
|
|
@ -285,6 +372,14 @@ sub www_editProfileSettings {
|
|||
return _submenu($session,$output,undef,"profile settings edit",'WebGUIProfile');
|
||||
}
|
||||
|
||||
=head2 www_moveProfileCategoryDown ( $session )
|
||||
|
||||
Moves the profile category specified by form variable C<cid> down one notch.
|
||||
Returns the user to www_editProfileSettings.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveProfileCategoryDown {
|
||||
my $session = shift;
|
||||
|
|
@ -293,6 +388,13 @@ sub www_moveProfileCategoryDown {
|
|||
return www_editProfileSettings($session);
|
||||
}
|
||||
|
||||
=head2 www_moveProfileCategoryUp ( $session )
|
||||
|
||||
Moves the profile category specified by form variable C<cid> up one notch.
|
||||
Returns the user to www_editProfileSettings.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveProfileCategoryUp {
|
||||
my $session = shift;
|
||||
|
|
@ -301,6 +403,14 @@ sub www_moveProfileCategoryUp {
|
|||
return www_editProfileSettings($session);
|
||||
}
|
||||
|
||||
=head2 www_moveProfileFieldDown ( $session )
|
||||
|
||||
Moves the profile field specified by form variable C<cid> down one notch.
|
||||
This will not move the field into another category.
|
||||
Returns the user to www_editProfileSettings.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveProfileFieldDown {
|
||||
my $session = shift;
|
||||
|
|
@ -309,6 +419,14 @@ sub www_moveProfileFieldDown {
|
|||
return www_editProfileSettings($session);
|
||||
}
|
||||
|
||||
=head2 www_moveProfileFieldUp ( $session )
|
||||
|
||||
Moves the profile field specified by form variable C<cid> up one notch.
|
||||
This will not move the field into another category.
|
||||
Returns the user to www_editProfileSettings.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_moveProfileFieldUp {
|
||||
my $session = shift;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue