From 32979d75e157520dfa2f2ee923731b69479cf238 Mon Sep 17 00:00:00 2001 From: Frank Dillon Date: Tue, 18 Nov 2008 07:05:23 +0000 Subject: [PATCH] Replaced the account.options loop in the displayAccount auth methods with new macros for displaying deactivate account and back to site links. Another macro which allows text to be displayed according to whether the value passed in is empty or not was added to allow functionality similar to that which currently exists. --- docs/changelog/7.x.x.txt | 3 + docs/gotcha.txt | 6 +- ...efault_ldap_account_display_template.wgpkg | Bin 0 -> 1061 bytes ...ault_webgui_account_display_template.wgpkg | Bin 0 -> 1147 bytes .../root_import_macro_deactivateaccount.wgpkg | Bin 0 -> 1120 bytes docs/upgrades/upgrade_7.6.3-7.6.4.pl | 6 ++ lib/WebGUI/Account.pm | 71 +----------------- lib/WebGUI/Auth.pm | 3 - lib/WebGUI/Auth/LDAP.pm | 3 +- lib/WebGUI/Macro/BackToSite.pm | 37 +++++++++ lib/WebGUI/Macro/DeactivateAccount.pm | 62 +++++++++++++++ lib/WebGUI/Macro/HasValueText.pm | 58 ++++++++++++++ lib/WebGUI/Operation/Shared.pm | 8 +- 13 files changed, 175 insertions(+), 82 deletions(-) create mode 100644 docs/upgrades/packages-7.6.4/default_ldap_account_display_template.wgpkg create mode 100644 docs/upgrades/packages-7.6.4/default_webgui_account_display_template.wgpkg create mode 100644 docs/upgrades/packages-7.6.4/root_import_macro_deactivateaccount.wgpkg create mode 100644 lib/WebGUI/Macro/BackToSite.pm create mode 100644 lib/WebGUI/Macro/DeactivateAccount.pm create mode 100644 lib/WebGUI/Macro/HasValueText.pm 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 0000000000000000000000000000000000000000..acbf1f07a144970f515273d407d68ef7d25584dd GIT binary patch literal 1061 zcmV+=1ls!_iwFP!000001MOCAkK#5E=JWlEC{m?6X+=VSP}md+%HA!#eWAPTophy( zOk%*@V5hdj!d3U*J9ZKlbJ?EM9#TK7Kg3aHJTK2YGfuT~{N=iCtJ$nn)b8)?)^53# z8Z5Wrd%o*dteV$swJH{<9)G1mA`YP?F(Pypqwt~J=eOjL94wur-pj50@4o7&YkSZ7 z-g~Y3hhX$S#|#$zM&sG~H$2ZfsK4J-GypV@zm8S^>hVMW9v=RB1x;uR$v9eI+v-@q zsSmK!_WOyJCY&XhOM-<`&?mHtWyeU!vrWRd#8FR6X&T4+RIU+nj6m4ms-t$@-j_k= zN$t~4(pgNz5=Vxd;>VAKM(k0abq$%=QkDo(>Jx7yN9PztW3(t$V2>2@JAwHyDhVs) zvHlw2IZ9(WjU$vyQ5dq6%4tLdOoHuH;uY)={(eG82rP4(qrLSVCi)yd_pHOPytQXh+C4#80)Wr zQ;0$3Ng>a+y23&LFEUkqoXo94IA?rSeL#GLGWm>KPB+j` z#8&4AScIG;k}x{4bDjN2zxGv)(G16hIY&mtt9-JoJr9sXJDb)&8!c=U<^m^=7+#*T zaB>7PZIxm~*1L4_P_K0|BKNGiAV{-tvyQN=`*S2dpg6^2AnNP;UbG@~%od9npPmFU z>HZ)B2ey+prwYd6l#<+Eu*FVSD`k~EusFadlw=L;>}9MivkQQL#Q<4Lj^|K~`#xNK zV|Gg38GKGTdvfU7=OhU|9y8PEYk|r!y|= zVKve&Sw!Xprjcr(n&l}12> zYHUTjlGYawB)MV|!V7h6w2F!43e$9~I{aVySG7p>+_X^wvwwXsmi3goC7(0slg1wX!)=17+yvd=CphMIamy7iiG zUPv6Ti2%aG=*Y1zuRRQIXqJMGCNIR2Jr3zxm~9z^rj!B|MS{Z2d@q$tM-juxiD4j# zX~?&U92I`dDoeD;Z<_b+pO*rseRnqcHak~|8EtFsbY||I`GknvK z6qp~}-}-Jh;Hr6zdb{bjeZxCY0=hnrc5}PBIs0^7e|Poyef_dILMgt!{?*R^I=;O6 f@;&})UTnM|@Pfb#0xt-B3xU4@b9M+V01^NI9%>JO literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..6ab653d530f9b2ae73789ee33d1fa93829c2d80a GIT binary patch literal 1147 zcmV->1cdt^iwFP!000001MOCAZz4Ak=JWlE)k>A_q!d_QHi2v-<>ju>a=BC?$%oP) zvuhR?V{dFPgjV<8Z|q$-%q=?U0#!f6Qr5&Xo_S_GZ{^bASG8I_ZZ=CLz55%xvtHGb z2dmofYkt))IUa1yk^`)VU#V0`0JMZ6!bTK@(_)?9ql0msklHfcAd8K zr#^tCx4(`IH4!|)LJ=%AgSlZ?9G4=g-ajW?C>)&|DoZIfw{nh9UWIU0iP$zy?0(CHo`Y0}B;0uPuoy4LW6~Iab zHK!3Cqm-)Q0*~U93{e>Jl&N7vB-DcCP~jQuV8EtHNJ^}7sW%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*5X?q(Q+@>~IlzxQ)lK`~uHs)v62lFZYtg zkEvQE{s=Q7I?Ov`blgG=gG%wztIb@@9Yz8{sGQ+XQ3HX+Z_zkWri=UMoy%&q77JXh zc4_|+JMeNwy;z0iaPx?d=W(t{7c+J~rGt#Y#t8YtH9;DO_ziW*fIxJ{6M@alv@4cv zsWY0(`I+D(TrFi7u}GliB8F-iF~pxpa7zV@=AcxZ73s#<4}aw2E9M}>LYV>@3LwiT zD;Xw3_JO=4Iu}dolnB43&Qq$(>KZL8Cxx+X%eKpwp&DU0j!5b^(_CMpAEW~u&FR{y z5ied3L#v|bjeUnjfoP@nRG$PI&Ldh6+=g{;&!XvdV0TJq&biN??i5pTy4Ad3g!)*( zs(4lHy_@(`-Jam#9k&^V#;% zdqTcEUzZ~6(xKX(5nsgqJiIN*0o}CusqyXIw{4tC2OIlRVBId5eBTZQg00Q`S6bzN zvuqR&{I`!7_&xsnzXRScAYX$zQPbh?Z=c7XL@Uzkyf^7=3He@Owe)j~E_& z_^O@6wAPy-mgm?T^cM6ACrS?>_w=iFx~Yi(jy^p(MyJZz@kYQ~rh`oQcQzqj%ALx{ zZ(+M+S5v!X0-UW^%4Mb9-T)4O0GN9X4yZ&{GEBwCSk+BD_bY4&&;U0e88Rz?ovL50 zUbJtn(|?L1o6&Ftcdxn!>=;{LsqiJHPW*=ELLn4c(S4L=QUNKQbjgC zqSH(NjIwb8$SQLBaQWZ?auPDWk=MV?to>HxyrNyo%xBvDJmbA)?at}^_2pbe&i&G) mSyY8lXmZU(_CSOCIJ*yH927Vxa8TfP6!;Fpp@4`08UO&aNibai literal 0 HcmV?d00001 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,
  • %s
  • ,); +returns:
  • test
  • + +=head3 textIfNoValue + +Text to be displayed if the value is empty. + +=cut + +#------------------------------------------------------------------- +sub process { + my $session = shift; + my ($value, $valueText, $noValueText ) = @_; + $value =~ s/^\s//; + $value =~ s/\s$//; + if ($value eq "") { + return $noValueText; + } + return sprintf($valueText,$value); +} + + + +1; diff --git a/lib/WebGUI/Operation/Shared.pm b/lib/WebGUI/Operation/Shared.pm index 997f73c95..377b0497f 100644 --- a/lib/WebGUI/Operation/Shared.pm +++ b/lib/WebGUI/Operation/Shared.pm @@ -27,18 +27,14 @@ Shared routines for WebGUI Operations. TODO: DOCUMENT ME -DEPRECATED - USE WebGUI::Account->appendAccountOptions +DEPRECATED - USE Macros to display account options =cut #------------------------------------------------------------------- sub accountOptions { my $session = shift; - - my $vars = {}; - WebGUI::Account->appendAccountLinks($session,$vars); - - return $vars->{'account.options'}; + return ""; } =head2 secureEval ( $session, $code )