Adding noItemTypeImages syspref to Auth.pm; Beginning the process of adding support...
[koha_fer] / C4 / Auth.pm
index 590ea3f..996117b 100755 (executable)
@@ -154,7 +154,7 @@ sub get_template_and_user {
         $template->param( "USER_INFO" => \@bordat );
 
         my @flagroots = qw(circulate catalogue parameters borrowers permissions reserveforothers borrow
-                            editcatalogue updatecharge management tools editauthorities serials reports);
+                            editcatalogue updatecharges management tools editauthorities serials reports);
         # We are going to use the $flags returned by checkauth
         # to create the template's parameters that will indicate
         # which menus the user can access.
@@ -167,7 +167,7 @@ sub get_template_and_user {
             $template->param( CAN_user_reserveforothers => 1 );
             $template->param( CAN_user_borrow           => 1 );
             $template->param( CAN_user_editcatalogue    => 1 );
-            $template->param( CAN_user_updatecharge     => 1 );
+            $template->param( CAN_user_updatecharges     => 1 );
             $template->param( CAN_user_acquisition      => 1 );
             $template->param( CAN_user_management       => 1 );
             $template->param( CAN_user_tools            => 1 ); 
@@ -268,6 +268,7 @@ sub get_template_and_user {
                        'item-level_itypes' => C4::Context->preference('item-level_itypes'),
                        canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'),
                        intranetreadinghistory => C4::Context->preference("intranetreadinghistory"),
+                       noItemTypeImages => C4::Context->preference("noItemTypeImages"),
         );
     }
     else {
@@ -456,7 +457,7 @@ sub checkauth {
         );
         $loggedin = 1;
     }
-    elsif ( $sessionID = $query->cookie("CGISESSID")) {     # assignment, not comparison (?)
+    elsif ( $sessionID = $query->cookie("CGISESSID")) {     # assignment, not comparison 
         my $session = get_session($sessionID);
         C4::Context->_new_userenv($sessionID);
         if ($session){
@@ -535,7 +536,7 @@ sub checkauth {
             _session_log(sprintf "%20s from %16s logged in  at %30s.\n", $userid,$ENV{'REMOTE_ADDR'},localtime);
             $cookie = $query->cookie(CGISESSID => $sessionID);
             if ( $flags = haspermission( $dbh, $userid, $flagsrequired ) ) {
-                $loggedin = 1;
+                               $loggedin = 1;
             }
             else {
                 $info{'nopermission'} = 1;
@@ -590,6 +591,15 @@ sub checkauth {
                     $branchname = GetBranchName($branchcode);
                 }
                 my $branches = GetBranches();
+                if (C4::Context->boolean_preference('IndependantBranches') && C4::Context->boolean_preference('Autolocation')){
+                                   # we have to check they are coming from the right ip range
+                                       my $domain = $branches->{$branchcode}->{'branchip'};
+                                       if ($ip !~ /^$domain/){
+                                               $loggedin=0;
+                                               $info{'wrongip'} = 1;
+                                       }
+                               }
+
                 my @branchesloop;
                 foreach my $br ( keys %$branches ) {
                     #     now we work with the treatment of ip
@@ -644,6 +654,7 @@ sub checkauth {
                 $info{'invalid_username_or_password'} = 1;
                 C4::Context->_unset_userenv($sessionID);
             }
+
         }
     }
     my $insecure = C4::Context->boolean_preference('insecure');
@@ -706,7 +717,9 @@ sub checkauth {
         IndependantBranches     => C4::Context->preference("IndependantBranches"),
         AutoLocation       => C4::Context->preference("AutoLocation"),
         yuipath            => C4::Context->preference("yuipath"),
+               wrongip            => $info{'wrongip'}
     );
+    
     $template->param( loginprompt => 1 ) unless $info{'nopermission'};
 
     my $self_url = $query->url( -absolute => 1 );