Possibility to set custom template parameters (#449)

This commit is contained in:
Clément Oudot 2012-03-09 12:41:17 +00:00
parent 0221cecc89
commit ff86ca2a1a
4 changed files with 40 additions and 5 deletions

View File

@ -118,6 +118,11 @@ localStorageOptions={ \
# Old menu HTML code
# Enable it if you use old templates
;useOldMenuItems=1
# Override error codes
;error_0 = You are well authenticated!
# Custom template parameters
# For example to use <TMPL_VAR NAME="myparam">
;tpl_myparam = test
# LOG
# By default, all is logged in Apache file. To log user actions by

View File

@ -115,6 +115,13 @@ if ( $portal->{mail_token}
);
}
# Custom template parameters
if ( my $customParams = $portal->getCustomTemplateParameters() ) {
foreach ( keys %$customParams ) {
$template->param( $_, $customParams->{$_} );
}
}
print $portal->header('text/html; charset=utf8');
print $template->output;

View File

@ -325,6 +325,11 @@ sub display {
ANTIFRAME => $self->{portalAntiFrame},
);
## Custom template params
if ( my $customParams = $self->getCustomTemplateParameters() ) {
%templateParams = ( %templateParams, %$customParams );
}
return ( "$skin_dir/$skin/$skinfile", %templateParams );
}

View File

@ -2422,8 +2422,7 @@ sub issuerForAuthUser {
unless ( $self->safe->reval($rule) ) {
$self->lmLog(
"User $user was not allowed to use IssuerDB $issuerDBtype",
'warn'
);
'warn' );
return PE_OK;
}
@ -2433,9 +2432,7 @@ sub issuerForAuthUser {
$self->lmLog( "No rule found for IssuerDB $issuerDBtype", 'debug' );
}
$self->lmLog(
"User $user allowed to use IssuerDB $issuerDBtype",
'debug' );
$self->lmLog( "User $user allowed to use IssuerDB $issuerDBtype", 'debug' );
# Register IssuerDB module in session
$self->addSessionValue( '_issuerDB', $issuerDBtype, $self->{id} );
@ -2553,6 +2550,27 @@ sub autoPost {
return PE_REDIRECT;
}
## @method HASHREF getCustomTemplateParameters()
# Find custom templates parameters
# @return Custom parameters
sub getCustomTemplateParameters {
my $self = shift;
my $customTplParams = {};
foreach ( keys %$self ) {
next unless ( $_ =~ /^tpl_(.+)$/ );
my $tplParam = $1;
my $tplValue = $self->{ "tpl_" . $tplParam };
$self->lmLog( "Set custom template parameter $tplParam with $tplValue",
'debug' );
$customTplParams->{$tplParam} = $tplValue;
}
return $customTplParams;
}
1;
__END__