diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 9b6a1e062..f77bdec95 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -5,6 +5,9 @@ - New Inbox Account module added providing a better interface into WebGUI's various messaging systems - New Friends Account module added providing a better interface into WebGUI's friends system - The Display Account and My Purchases interfaces have been added to the new Account system + - Added a new macro which returns the self deactivation link if the setting is enabled. + - Added a new macro which returns the back to site link + - Added a new macro which allows users to test to see if a value is not empty and set the display text accordingly. not be imported, only the surveys themselves. - Made syndicated content asset use cache. - Added Cashier/Point of Sale mode for the Shop. diff --git a/docs/gotcha.txt b/docs/gotcha.txt index c1678bec0..88f99a2c3 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -16,7 +16,11 @@ save you many hours of grief. custom templates prior to upgrading as you will need to modify them for the new system. - * The Survey system has been completely updated. Please make sure you + * The Auth display account template no longer has the account.options loop + available. This loop has been replaced entirely by macros to provide more + flexibility. Any custom templates will need to be updated accordingly. + + * The Survey system has been completely updated. Please make sure you create full backups of your survey results and export them as needed. Results will not be imported into the new Survey system. Your old surveys will be imported into the new survey system. diff --git a/docs/upgrades/packages-7.6.4/default_ldap_account_display_template.wgpkg b/docs/upgrades/packages-7.6.4/default_ldap_account_display_template.wgpkg new file mode 100644 index 000000000..acbf1f07a Binary files /dev/null and b/docs/upgrades/packages-7.6.4/default_ldap_account_display_template.wgpkg differ diff --git a/docs/upgrades/packages-7.6.4/default_webgui_account_display_template.wgpkg b/docs/upgrades/packages-7.6.4/default_webgui_account_display_template.wgpkg new file mode 100644 index 000000000..6ab653d53 Binary files /dev/null and b/docs/upgrades/packages-7.6.4/default_webgui_account_display_template.wgpkg differ diff --git a/docs/upgrades/packages-7.6.4/root_import_macro_deactivateaccount.wgpkg b/docs/upgrades/packages-7.6.4/root_import_macro_deactivateaccount.wgpkg new file mode 100644 index 000000000..7c6796667 Binary files /dev/null and b/docs/upgrades/packages-7.6.4/root_import_macro_deactivateaccount.wgpkg differ diff --git a/docs/upgrades/upgrade_7.6.3-7.6.4.pl b/docs/upgrades/upgrade_7.6.3-7.6.4.pl index 37b595f93..ad51e6c68 100644 --- a/docs/upgrades/upgrade_7.6.3-7.6.4.pl +++ b/docs/upgrades/upgrade_7.6.3-7.6.4.pl @@ -383,6 +383,12 @@ sub upgradeAccount { } $session->config->set( "contentHandlers", \@newHandlers ); } + + #Add new macros to the config file + $session->config->addToHash("macros","BackToSite","BackToSite"); + $session->config->addToHash("macros","HasValueText","HasValueText"); + $session->config->addToHash("macros","DeactivateAccount","DeactivateAccount"); + #Add the settings for the profile module $setting->add("profileStyleTemplateId",""); #Use the userStyle by default diff --git a/lib/WebGUI/Account.pm b/lib/WebGUI/Account.pm index 24d0fad51..8da4c087a 100644 --- a/lib/WebGUI/Account.pm +++ b/lib/WebGUI/Account.pm @@ -33,76 +33,7 @@ readonly session => my %session; readonly module => my %module; public method => my %method; public uid => my %uid; -public store => my %store; #This is an all purpose hash to store stuff in: $store{id $self}->{something} = "something" - -#------------------------------------------------------------------- - -=head2 appendAccountLinks ( session , var) - - Class method which appends common links to preform various account tasks - -=head3 session - - WebGUI::Session object - -=head3 var - - hash ref to append template variables to - -=cut - -sub appendAccountLinks { - my $class = shift; - my $session = shift; - my $var = shift; - - return unless $var; - - my $i18n = WebGUI::International->new($session); - my $format = q{%s}; - my @array = (); - - #Turn Admin On - if ($session->user->isInGroup(12)) { - if ($session->var->isAdminOn) { - $var->{'admin_mode_url' } = $session->url->page('op=switchOffAdmin'); - $var->{'admin_mode_text'} = $i18n->get(12); - } - else { - $var->{'admin_mode_url' } = $session->url->page('op=switchOnAdmin'); - $var->{'admin_mode_text'} = $i18n->get(63); - } - push(@array,{ - 'options.display' => sprintf($format,$var->{'admin_mode_url'},$var->{'admin_mode_text'}) - }); - } - - #Logout - $var->{'logout_url' } = $session->url->page('op=auth;method=logout'); - $var->{'logout_text'} = $i18n->get(64); - push(@array,{ - 'options.display' => sprintf($format,$var->{'logout_url'},$var->{'logout_text'}) - }); - - #Deactivate Account - if ($session->setting->get("selfDeactivation") && !$session->user->isAdmin){ - $var->{'self_deactivation_url' } = $session->url->page('op=auth;method=deactivateAccount'); - $var->{'self_deactivation_text'} = $i18n->get(65); - push(@array,{ - 'options.display' => sprintf($format,$var->{'self_deactivation_url' },$var->{'self_deactivation_text'}) - }); - } - - #Return to site - $var->{'return_to_site_url' } = $session->url->getBackToSiteURL; - $var->{'return_to_site_link'} = $i18n->get(493); - push(@array,{ - 'options.display' => sprintf($format,$var->{'return_to_site_url'},$var->{'return_to_site_link'}) - }); - - $var->{'account.options'} = \@array; -} - +public store => my %store; #This is an all purpose hash to store stuff in: $self->store->{something} = "something" #------------------------------------------------------------------- diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index e3e102210..9a32809fd 100755 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -482,9 +482,6 @@ sub displayAccount { } $vars->{'account.form.submit'} = WebGUI::Form::submit($self->session,{}); $vars->{'account.form.footer'} = WebGUI::Form::formFooter($self->session,); - - #Appends 'account.options' loop along with some new links - WebGUI::Account->appendAccountLinks($self->session,$vars); ########### ACCOUNT SHUNT #The following is a shunt which allows the displayAccount page to be displayed in the diff --git a/lib/WebGUI/Auth/LDAP.pm b/lib/WebGUI/Auth/LDAP.pm index e9c651238..809149983 100644 --- a/lib/WebGUI/Auth/LDAP.pm +++ b/lib/WebGUI/Auth/LDAP.pm @@ -355,8 +355,7 @@ sub displayAccount { $vars->{'account.form.karma'} = $self->session->user->profileField("karma"); $vars->{'account.form.karma.label'} = $i18n->get(537); } - WebGUI::Account->appendAccountLinks($self->session,$vars); - + ########### ACCOUNT SHUNT #The following is a shunt which allows the displayAccount page to be displayed in the #Account system. This shunt will be replaced in WebGUI 8 when the API can be broken diff --git a/lib/WebGUI/Macro/BackToSite.pm b/lib/WebGUI/Macro/BackToSite.pm new file mode 100644 index 000000000..50aac21d3 --- /dev/null +++ b/lib/WebGUI/Macro/BackToSite.pm @@ -0,0 +1,37 @@ +package WebGUI::Macro::BackToSite; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2008 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; + +=head1 NAME + +Package WebGUI::Macro::BackToSite + +=head1 DESCRIPTION + +Tries to return a URL to take the user back to the last page they were at before +using an operation or other function. This will always include the gateway +url from the config file. + +=head2 process + +=cut + +#------------------------------------------------------------------- +sub process { + my $session = shift; + return $session->url->getBackToSiteURL; +} + + + +1; diff --git a/lib/WebGUI/Macro/DeactivateAccount.pm b/lib/WebGUI/Macro/DeactivateAccount.pm new file mode 100644 index 000000000..0f616ad6f --- /dev/null +++ b/lib/WebGUI/Macro/DeactivateAccount.pm @@ -0,0 +1,62 @@ +package WebGUI::Macro::DeactivateAccount; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2008 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; +use WebGUI::International; +use WebGUI::Asset::Template; + +=head1 NAME + +Package WebGUI::Macro::DeactivateAccount + +=head1 DESCRIPTION + +Macro for displaying a url to the user for deactivating their account, if +the setting is turned on. + +=head2 process ( [deactivateText, template ] ) + +process takes two optional parameters for customizing the content and layout +of the self deactivation link. + +=head3 deactivateText + +The text displayed to the user for this link. If this is blank an internationalized default is used. + +=head3 template + +The url for a template from the Macro/DeactivateAccount namespace to use for formatting the link. + +=cut + +#------------------------------------------------------------------- +sub process { + my $session = shift; + my ($deactivateText, $templateName) = @_; + + return "" unless ($session->setting->get("selfDeactivation") && !$session->user->isAdmin); + + my $i18n = WebGUI::International->new($session); + my $var = {}; + + $var->{'self_deactivation_url' } = $session->url->page('op=auth;method=deactivateAccount'); + $var->{'self_deactivation_text'} = $deactivateText || $i18n->get(65); + + my $template = $templateName ? WebGUI::Asset::Template->newByUrl($session, $templateName) + : WebGUI::Asset::Template->new($session, "CocyDcs-NqmKtPy0Bs_vUA") + ; + return $template->process($var); +} + +1; + + diff --git a/lib/WebGUI/Macro/HasValueText.pm b/lib/WebGUI/Macro/HasValueText.pm new file mode 100644 index 000000000..80a4ecf73 --- /dev/null +++ b/lib/WebGUI/Macro/HasValueText.pm @@ -0,0 +1,58 @@ +package WebGUI::Macro::HasValueText; + +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2008 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use strict; + +=head1 NAME + +Package WebGUI::Macro::HasValueText + +=head1 DESCRIPTION + +Macro for displaying text based on whether or not the value entered it empty. + +=head2 process ( value, textIfValue, textIfNotValule ) + +Either the textIfValue or textIfNotValue fields can be empty + +=head3 value + +The value to test to see if it's empty. + +=head3 textIfValue + +The text to be displayed if the value is not empty. Use %s to represent the value itself. + +ex: ^HasValueText(test,