From 3fdf486e28964a41ee3348b30ee58a767294d276 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 7 Apr 2011 14:10:40 +0200 Subject: [PATCH] 5660 Webinstaller should check if KohaOpacLanguage exists in staff Content-Type: text/plain; charset="utf-8" Rebased on April 11. --- installer/InstallAuth.pm | 23 +++++++++++++++++------ 1 files changed, 17 insertions(+), 6 deletions(-) diff --git a/installer/InstallAuth.pm b/installer/InstallAuth.pm index 81c38fb..447c1e6 100644 --- a/installer/InstallAuth.pm +++ b/installer/InstallAuth.pm @@ -110,17 +110,13 @@ InstallAuth - Authenticates Koha users for Install process sub get_template_and_user { my $in = shift; my $query = $in->{'query'}; - my $language = $query->cookie('KohaOpacLanguage'); - my $path = - C4::Context->config('intrahtdocs') . "/prog/" - . ( $language ? $language : "en" ); - + my $language =_get_template_language($query->cookie('KohaOpacLanguage')); + my $path = C4::Context->config('intrahtdocs'). "/prog/". $language; my $filename = "$path/modules/" . $in->{template_name}; $filename =~ s/\.tmpl$/.tt/; my $interface = 'intranet'; my $template = C4::Templates->new( $interface, $filename); - my ( $user, $cookie, $sessionID, $flags ) = checkauth( $in->{'query'}, $in->{'authnotrequired'}, @@ -159,6 +155,21 @@ sub get_template_and_user { return ( $template, $borrowernumber, $cookie ); } +sub _get_template_language { + #verify if opac language exists in staff (bug 5660) + #conditions are 1) dir exists and 2) enabled in prefs + my ($opaclang)= @_; + return 'en' unless $opaclang; + my $path= C4::Context->config('intrahtdocs')."/prog/$opaclang"; + my $pref= ','.C4::Context->preference('language').','; + if(-d $path) { + if($pref =~ /,$opaclang,/ ) { + return $opaclang; + } + } + return 'en'; +} + =item checkauth ($userid, $cookie, $sessionID) = &checkauth($query, $noauth, $flagsrequired, $type); -- 1.6.0.6