Bug 7245 Tables population with mandatory data for italian installation
[koha_gimpoz] / installer / InstallAuth.pm
index 26ba5a7..10cbea3 100644 (file)
@@ -103,25 +103,22 @@ InstallAuth - Authenticates Koha users for Install process
     authenticated page.
 
     More information on the C<gettemplate> sub can be found in the
-    Output.pm module.
+    Templates.pm module.
 
 =cut
 
 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 $tmplbase = $in->{template_name};
     $tmplbase=~ s/\.tmpl$/.tt/;
     my $filename = "$path/modules/" . $tmplbase;
     my $interface = 'intranet';
-    my $template = C4::Templates->new( $interface, $filename, $tmplbase);
+    my $template = C4::Templates->new( $interface, $filename, $tmplbase, $query);
     
-
     my ( $user, $cookie, $sessionID, $flags ) = checkauth(
         $in->{'query'},
         $in->{'authnotrequired'},
@@ -160,6 +157,17 @@ 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;
+    $opaclang =~ s/[^a-zA-Z_-]*//g;
+    my $path = C4::Context->config('intrahtdocs') . "/prog/$opaclang";
+    -d $path ? $opaclang : 'en';
+}
+
 =item checkauth
 
   ($userid, $cookie, $sessionID) = &checkauth($query, $noauth, $flagsrequired, $type);
@@ -359,7 +367,7 @@ sub checkauth {
     my $filename = "$path/modules/$template_name";
     $filename =~ s/\.tmpl$/.tt/;
     my $interface = 'intranet';
-    my $template = C4::Templates->new( $interface, $filename);
+    my $template = C4::Templates->new( $interface, $filename, '', $query);
     $template->param(
         INPUTS => \@inputs,