Possibility to set custom template parameters (#449)
This commit is contained in:
parent
0221cecc89
commit
ff86ca2a1a
|
@ -118,6 +118,11 @@ localStorageOptions={ \
|
||||||
# Old menu HTML code
|
# Old menu HTML code
|
||||||
# Enable it if you use old templates
|
# Enable it if you use old templates
|
||||||
;useOldMenuItems=1
|
;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
|
# LOG
|
||||||
# By default, all is logged in Apache file. To log user actions by
|
# By default, all is logged in Apache file. To log user actions by
|
||||||
|
|
|
@ -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 $portal->header('text/html; charset=utf8');
|
||||||
print $template->output;
|
print $template->output;
|
||||||
|
|
||||||
|
|
|
@ -325,6 +325,11 @@ sub display {
|
||||||
ANTIFRAME => $self->{portalAntiFrame},
|
ANTIFRAME => $self->{portalAntiFrame},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
## Custom template params
|
||||||
|
if ( my $customParams = $self->getCustomTemplateParameters() ) {
|
||||||
|
%templateParams = ( %templateParams, %$customParams );
|
||||||
|
}
|
||||||
|
|
||||||
return ( "$skin_dir/$skin/$skinfile", %templateParams );
|
return ( "$skin_dir/$skin/$skinfile", %templateParams );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2422,8 +2422,7 @@ sub issuerForAuthUser {
|
||||||
unless ( $self->safe->reval($rule) ) {
|
unless ( $self->safe->reval($rule) ) {
|
||||||
$self->lmLog(
|
$self->lmLog(
|
||||||
"User $user was not allowed to use IssuerDB $issuerDBtype",
|
"User $user was not allowed to use IssuerDB $issuerDBtype",
|
||||||
'warn'
|
'warn' );
|
||||||
);
|
|
||||||
|
|
||||||
return PE_OK;
|
return PE_OK;
|
||||||
}
|
}
|
||||||
|
@ -2433,9 +2432,7 @@ sub issuerForAuthUser {
|
||||||
$self->lmLog( "No rule found for IssuerDB $issuerDBtype", 'debug' );
|
$self->lmLog( "No rule found for IssuerDB $issuerDBtype", 'debug' );
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->lmLog(
|
$self->lmLog( "User $user allowed to use IssuerDB $issuerDBtype", 'debug' );
|
||||||
"User $user allowed to use IssuerDB $issuerDBtype",
|
|
||||||
'debug' );
|
|
||||||
|
|
||||||
# Register IssuerDB module in session
|
# Register IssuerDB module in session
|
||||||
$self->addSessionValue( '_issuerDB', $issuerDBtype, $self->{id} );
|
$self->addSessionValue( '_issuerDB', $issuerDBtype, $self->{id} );
|
||||||
|
@ -2553,6 +2550,27 @@ sub autoPost {
|
||||||
return PE_REDIRECT;
|
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;
|
1;
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
|
Loading…
Reference in New Issue
Block a user