From c7083c8177f4ce291bece410e319636ceff84efc Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 13 Jun 2008 05:07:12 +0000 Subject: [PATCH] selectable templates for user profile view and edit --- docs/upgrades/upgrade_7.5.11-7.5.12.pl | 7 ++ lib/WebGUI/Help/WebGUIProfile.pm | 104 +++++++++++++++++++++++ lib/WebGUI/Operation/Profile.pm | 6 +- lib/WebGUI/Operation/Settings.pm | 16 ++++ lib/WebGUI/i18n/English/WebGUI.pm | 20 +++++ lib/WebGUI/i18n/English/WebGUIProfile.pm | 78 ++++++++++++++++- 6 files changed, 228 insertions(+), 3 deletions(-) create mode 100644 lib/WebGUI/Help/WebGUIProfile.pm diff --git a/docs/upgrades/upgrade_7.5.11-7.5.12.pl b/docs/upgrades/upgrade_7.5.11-7.5.12.pl index 81ab10af2..8655872a4 100644 --- a/docs/upgrades/upgrade_7.5.11-7.5.12.pl +++ b/docs/upgrades/upgrade_7.5.11-7.5.12.pl @@ -29,6 +29,7 @@ my $quiet; # this line required my $session = start(); # this line required # upgrade functions go here +addSelectableProfileTemplates($session); finish($session); # this line required @@ -42,6 +43,12 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +sub addSelectableProfileTemplates { + my $session = shift; + $session->setting->add('viewUserProfileTemplate', 'PBtmpl0000000000000052'); + $session->setting->add('editUserProfileTemplate', 'PBtmpl0000000000000051'); +} + # -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- diff --git a/lib/WebGUI/Help/WebGUIProfile.pm b/lib/WebGUI/Help/WebGUIProfile.pm new file mode 100644 index 000000000..147cecfa9 --- /dev/null +++ b/lib/WebGUI/Help/WebGUIProfile.pm @@ -0,0 +1,104 @@ +package WebGUI::Help::WebGUIProfile; + +use strict; + + +our $HELP = { + + 'view profile template' => { + title => 'view profile template title', + body => 'view profile template body', + fields => [], + variables => [ + { + name => 'displayTitle', + }, + { + name => 'profile.elements', + required => 1, + variables => [ + { + name => 'profile.category', + }, + { + name => 'profile.label', + }, + { + name => 'profile.value', + }, + + ], + }, + { + name => 'profile.accountOptions', + required => 1, + variables => [ + { + name => 'account.options', + required => 1, + }, + ], + }, + ], + related => [ + ], + }, + + 'edit profile template' => { + title => 'edit profile template title', + body => 'edit profile template body', + fields => [], + variables => [ + { + name => 'displayTitle', + }, + { + name => 'profile.message', + required => 1, + }, + { + name => 'profile.form.header', + required => 1, + }, + { + name => 'profile.form.footer', + required => 1, + }, + { + name => 'profile.form.hidden', + required => 1, + }, + { + name => 'profile.elements', + required => 1, + variables => [ + { + name => 'profile.category', + }, + { + name => 'profile.label', + }, + { + name => 'profile.value', + }, + + ], + }, + { + name => 'profile.accountOptions', + required => 1, + variables => [ + { + name => 'account.options', + required => 1, + }, + ], + }, + ], + related => [ + ], + }, + +}; + +1; ##All perl modules must return true diff --git a/lib/WebGUI/Operation/Profile.pm b/lib/WebGUI/Operation/Profile.pm index 6cf1278fd..c9dc731be 100644 --- a/lib/WebGUI/Operation/Profile.pm +++ b/lib/WebGUI/Operation/Profile.pm @@ -50,6 +50,8 @@ This method is deprecated, and should not be used in new code. Use the getRequiredFields method from WebGUI::ProfileField and specify the translation to template variables directly instead. +NOTE: You should use the getRequiredFields method in WebGUI::ProfileField instead. + =head3 session The current WebGUI session object. @@ -230,7 +232,7 @@ sub www_editProfile { $vars->{'profile.form.elements'} = \@array; $vars->{'profile.form.submit'} = WebGUI::Form::submit($session,{}); $vars->{'profile.accountOptions'} = WebGUI::Operation::Shared::accountOptions($session); - return $session->style->userStyle(WebGUI::Asset::Template->new($session,"PBtmpl0000000000000051")->process($vars)); + return $session->style->userStyle(WebGUI::Asset::Template->new($session, $session->setting->get('editUserProfileTemplate'))->process($vars)); } #------------------------------------------------------------------- @@ -319,7 +321,7 @@ sub www_viewProfile { }; } - return $session->style->userStyle(WebGUI::Asset::Template->new($session,"PBtmpl0000000000000052")->process($vars)); + return $session->style->userStyle(WebGUI::Asset::Template->new($session, $session->setting->get('viewUserProfileTemplate'))->process($vars)); } diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index ca0d890e8..25949ced5 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -480,6 +480,22 @@ sub definition { fieldType => 'HTMLArea', label => $i18n->get( 'showMessageOnLoginBody label' ), hoverHelp => $i18n->get( 'showMessageOnLoginBody description' ), + }; + push @fields, { + tab => "user", + name => 'viewUserProfileTemplate', + fieldType => 'Template', + namespace => 'Operation/Profile/View', + label => $i18n->get( 'user profile view template' ), + hoverHelp => $i18n->get( 'user profile view template description' ), + }; + push @fields, { + tab => "user", + name => 'editUserProfileTemplate', + fieldType => 'Template', + namespace => 'Operation/Profile/Edit', + label => $i18n->get( 'user profile edit template' ), + hoverHelp => $i18n->get( 'user profile edit template description' ), }; # auth settings my $options; diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 1d4dbc3ab..30b7aed65 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -3520,6 +3520,26 @@ LongTruncOk=1

lastUpdated => 1181969398, }, + 'user profile view template' => { + message => q|User Profile Viewing Template|, + lastUpdated => 1213323171, + }, + + 'user profile view template description' => { + message => q|The template used show the user their user profile.|, + lastUpdated => 1213323173, + }, + + 'user profile edit template' => { + message => q|User Profile Editing Template|, + lastUpdated => 1213323171, + }, + + 'user profile edit template description' => { + message => q|The template used show to build a form so the user can edit their template.|, + lastUpdated => 1213323173, + }, + 'send private message' => { message => q|Send Private Message|, lastUpdated => 1181019679, diff --git a/lib/WebGUI/i18n/English/WebGUIProfile.pm b/lib/WebGUI/i18n/English/WebGUIProfile.pm index cc99920c1..83641ff81 100644 --- a/lib/WebGUI/i18n/English/WebGUIProfile.pm +++ b/lib/WebGUI/i18n/English/WebGUIProfile.pm @@ -260,7 +260,83 @@ If you wish to set the Default Value for any other field. Create the field with 'requiredForPasswordRecovery hoverHelp' => { message => "Require users to enter this field for password recovery. Only users that enter all such fields correctly and uniquely to them will be able to perform password recovery.", lastUpdated => 1165401097 - }, + }, + + 'view profile template title' => { + message => 'View Profile Template', + lastUpdated => 1213326336, + }, + + 'view profile template body' => { + message => 'This template is used to show the user their User Profile.', + lastUpdated => 1213326336, + }, + + 'displayTitle' => { + message => q|An internationalized title containing the user's name.|, + lastUpdated => 1213326336, + }, + + 'profile.elements' => { + message => q|A loop containing all profile field elements.|, + lastUpdated => 1213326336, + }, + + 'profile.category' => { + message => q|The name of the current category. This variable will only exist for the first profile field in each category.|, + lastUpdated => 1213326336, + }, + + 'profile.label' => { + message => q|The label for this profile field.|, + lastUpdated => 1213326336, + }, + + 'profile.value' => { + message => q|The value of this profile field.|, + lastUpdated => 1213326336, + }, + + 'profile.accountOptions' => { + message => q|A loop containing options for other account actions, such as editing a profile, viewing a profile, changing your account, and so on.|, + lastUpdated => 1213326336, + }, + + 'account.options' => { + message => q|A link to an account option with label.|, + lastUpdated => 1213326336, + }, + + 'edit profile template title' => { + message => 'Edit Profile Template', + lastUpdated => 1213326336, + }, + + 'edit profile template body' => { + message => 'This template builds a form for the user to edit their User Profile.', + lastUpdated => 1213326336, + }, + + 'profile.message' => { + message => |Messages from the system, in case of errors or further work on the user's part.|, + lastUpdated => 1213326336, + }, + + 'profile.form.header' => { + message => |HTML code to begin the form|, + lastUpdated => 1213326336, + }, + + 'profile.form.footer' => { + message => |HTML code to end the form|, + lastUpdated => 1213326336, + }, + + 'profile.form.hidden' => { + message => |HTML code for directing the form's action|, + lastUpdated => 1213326336, + }, + }; 1;