Commit c535422a authored by Yadd's avatar Yadd

customParameters for templates (#595)

parent 4cde65c8
......@@ -13,7 +13,9 @@ sub display {
my ( $self, $req ) = @_;
my $skin_dir = $self->conf->{templatesDir};
my ( $skinfile, %templateParams );
my $skinfile;
my %templateParams =
( %{ $self->customParameters }, %{ $req->customParameters } );
# 0. Display error page
if ( my $http_error = $req->param('lmError') ) {
......
......@@ -59,6 +59,9 @@ has beforeLogout => (
default => sub { [] }
);
# Custom template parameters
has customParameters => ( is => 'rw', default => sub { {} } );
sub init {
my ( $self, $args ) = @_;
$args ||= {};
......@@ -70,6 +73,11 @@ sub init {
%$args
}
);
foreach my $k ( keys $self->localConfig ) {
if ( $k =~ /tpl_(.*)/ ) {
$self->customParameters->{$1} = $self->localConfig->{$k};
}
}
Lemonldap::NG::Handler::Main::Reload->onReload( $self, 'reloadConf' );
return 0 unless ( $self->SUPER::init($args) );
return 0 if ( $self->error );
......@@ -173,7 +181,7 @@ sub reloadConf {
if ( my $td = $self->conf->{trustedDomains} ) {
$td =~ s/^\s*(.*?)\s*/$1/;
foreach ( split( /\s+/, $td ) ) {
next unless($td);
next unless ($td);
s#^\.#([^/]+\.)?#;
$self->lmLog( "Domain $_ added in trusted domains", 'debug' );
s/\./\\./g;
......@@ -183,7 +191,8 @@ sub reloadConf {
# - $domainlabel.$td
# $domainlabel is build looking RFC2396
# (see Regexp::Common::URI::RFC2396)
$_ =~ s/\*\\\./(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9]\\.)*/g;
$_ =~
s/\*\\\./(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9]\\.)*/g;
$re->add("$_");
}
}
......
......@@ -44,6 +44,9 @@ has respCookies => ( is => 'rw' );
# Template to display (if not defined, login or menu)
has template => ( is => 'rw' );
# Custom template parameters
has customParameters => ( is => 'rw', default => sub { {} } );
# Boolean to indicate that response must be a redirection
has mustRedirect => ( is => 'rw' );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment