Add returnUrl to to process mutation template.

This commit is contained in:
Martin Kamerbeek 2010-06-09 12:23:23 +02:00
parent fdd2542fb2
commit 6c0e8b8e47
2 changed files with 22 additions and 1 deletions

View file

@ -8,6 +8,7 @@ use Carp;
use WebGUI::Asset::Template;
use WebGUI::Macro;
use Tie::IxHash;
use URI;
#----------------------------------------------------------------------------
sub definition {
@ -226,6 +227,21 @@ sub getSubscriptionGroup {
return $group;
}
#----------------------------------------------------------------------------
sub getReturnUrl {
my $self = shift;
my $referer = $self->session->env->get('HTTP_REFERER');
return unless $referer;
# Get path and strip leading and trailing slash if it exists.
my ( $path ) = URI->new( $referer )->path =~ m{ ^/ (.*?) /?$ }xms;
return $referer if WebGUI::Asset->urlExists( $self->session, $path );
return;
}
#----------------------------------------------------------------------------
sub getEmailVars {
my $self = shift;
@ -498,7 +514,12 @@ sub www_processSubscription {
return $self->processStyle( $i18n->get( 'anonnymous not allowed' ) );
}
return $self->processStyle( $self->processTemplate( {}, $self->get('confirmationRequiredTemplateId') ) );
my $var = {
assetUrl => $self->getUrl,
returnUrl => $self->getReturnUrl,
};
return $self->processStyle( $self->processTemplate( $var, $self->get('confirmationRequiredTemplateId') ) );
}
#----------------------------------------------------------------------------