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.
This commit is contained in:
parent
d91bc5754d
commit
32979d75e1
13 changed files with 175 additions and 82 deletions
37
lib/WebGUI/Macro/BackToSite.pm
Normal file
37
lib/WebGUI/Macro/BackToSite.pm
Normal file
|
|
@ -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;
|
||||
62
lib/WebGUI/Macro/DeactivateAccount.pm
Normal file
62
lib/WebGUI/Macro/DeactivateAccount.pm
Normal file
|
|
@ -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;
|
||||
|
||||
|
||||
58
lib/WebGUI/Macro/HasValueText.pm
Normal file
58
lib/WebGUI/Macro/HasValueText.pm
Normal file
|
|
@ -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,<li>%s</li>,);
|
||||
returns: <li>test</li>
|
||||
|
||||
=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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue