- my $ip = $ENV{'REMOTE_ADDR'};
- # if they specify at login, use that
- if ($query->param('branch')) {
- $branchcode = $query->param('branch');
- $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
- my $domain = $branches->{$br}->{'branchip'};
- if ( $domain && $ip =~ /^$domain/ ) {
- $branchcode = $branches->{$br}->{'branchcode'};
-
- # new op dev : add the branchprinter and branchname in the cookie
- $branchprinter = $branches->{$br}->{'branchprinter'};
- $branchname = $branches->{$br}->{'branchname'};
- }
- }
- $session->param('number',$borrowernumber);
- $session->param('id',$userid);
- $session->param('cardnumber',$cardnumber);
- $session->param('firstname',$firstname);
- $session->param('surname',$surname);
- $session->param('branch',$branchcode);
- $session->param('branchname',$branchname);
- $session->param('flags',$userflags);
- $session->param('emailaddress',$emailaddress);
- $session->param('ip',$session->remote_addr());
- $session->param('lasttime',time());
- $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map {$session->param($_)} qw(cardnumber firstname surname branch) ;
- }
- elsif ( $return == 2 ) {
- #We suppose the user is the superlibrarian
- $borrowernumber = 0;
- $session->param('number',0);
- $session->param('id',C4::Context->config('user'));
- $session->param('cardnumber',C4::Context->config('user'));
- $session->param('firstname',C4::Context->config('user'));
- $session->param('surname',C4::Context->config('user'));
- $session->param('branch','NO_LIBRARY_SET');
- $session->param('branchname','NO_LIBRARY_SET');
- $session->param('flags',1);
- $session->param('emailaddress', C4::Context->preference('KohaAdminEmailAddress'));
- $session->param('ip',$session->remote_addr());
- $session->param('lasttime',time());
- }
- C4::Context::set_userenv(
- $session->param('number'), $session->param('id'),
- $session->param('cardnumber'), $session->param('firstname'),
- $session->param('surname'), $session->param('branch'),
- $session->param('branchname'), $session->param('flags'),
- $session->param('emailaddress'), $session->param('branchprinter')
- );
-
- # Grab borrower's shelves and public shelves and add them to the session
- # $row_count determines how many records are returned from the db query
- # and the number of lists to be displayed of each type in the 'Lists' button drop down
- my $row_count = 10; # FIXME:This probably should be a syspref
- my ($total, $totshelves, $barshelves, $pubshelves);
- ($barshelves, $totshelves) = C4::VirtualShelves::GetRecentShelves(1, $row_count, $borrowernumber);
- $total->{'bartotal'} = $totshelves;
- ($pubshelves, $totshelves) = C4::VirtualShelves::GetRecentShelves(2, $row_count, undef);
- $total->{'pubtotal'} = $totshelves;
- $session->param('barshelves', $barshelves);
- $session->param('pubshelves', $pubshelves);
- $session->param('totshelves', $total);
-
- C4::Context::set_shelves_userenv('bar',$barshelves);
- C4::Context::set_shelves_userenv('pub',$pubshelves);
- C4::Context::set_shelves_userenv('tot',$total);
- }
+ my $ip = $ENV{'REMOTE_ADDR'};
+ # if they specify at login, use that
+ if ($query->param('branch')) {
+ $branchcode = $query->param('branch');
+ $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
+ my $domain = $branches->{$br}->{'branchip'};
+ if ( $domain && $ip =~ /^$domain/ ) {
+ $branchcode = $branches->{$br}->{'branchcode'};
+
+ # new op dev : add the branchprinter and branchname in the cookie
+ $branchprinter = $branches->{$br}->{'branchprinter'};
+ $branchname = $branches->{$br}->{'branchname'};
+ }
+ }
+ $session->param('number',$borrowernumber);
+ $session->param('id',$userid);
+ $session->param('cardnumber',$cardnumber);
+ $session->param('firstname',$firstname);
+ $session->param('surname',$surname);
+ $session->param('branch',$branchcode);
+ $session->param('branchname',$branchname);
+ $session->param('flags',$userflags);
+ $session->param('emailaddress',$emailaddress);
+ $session->param('ip',$session->remote_addr());
+ $session->param('lasttime',time());
+ $debug and printf STDERR "AUTH_4: (%s)\t%s %s - %s\n", map {$session->param($_)} qw(cardnumber firstname surname branch) ;
+ }
+ elsif ( $return == 2 ) {
+ #We suppose the user is the superlibrarian
+ $borrowernumber = 0;
+ $session->param('number',0);
+ $session->param('id',C4::Context->config('user'));
+ $session->param('cardnumber',C4::Context->config('user'));
+ $session->param('firstname',C4::Context->config('user'));
+ $session->param('surname',C4::Context->config('user'));
+ $session->param('branch','NO_LIBRARY_SET');
+ $session->param('branchname','NO_LIBRARY_SET');
+ $session->param('flags',1);
+ $session->param('emailaddress', C4::Context->preference('KohaAdminEmailAddress'));
+ $session->param('ip',$session->remote_addr());
+ $session->param('lasttime',time());
+ }
+ C4::Context::set_userenv(
+ $session->param('number'), $session->param('id'),
+ $session->param('cardnumber'), $session->param('firstname'),
+ $session->param('surname'), $session->param('branch'),
+ $session->param('branchname'), $session->param('flags'),
+ $session->param('emailaddress'), $session->param('branchprinter')
+ );
+
+ # Grab borrower's shelves and public shelves and add them to the session
+ # $row_count determines how many records are returned from the db query
+ # and the number of lists to be displayed of each type in the 'Lists' button drop down
+ my $row_count = 10; # FIXME:This probably should be a syspref
+ my ($total, $totshelves, $barshelves, $pubshelves);
+ ($barshelves, $totshelves) = C4::VirtualShelves::GetRecentShelves(1, $row_count, $borrowernumber);
+ $total->{'bartotal'} = $totshelves;
+ ($pubshelves, $totshelves) = C4::VirtualShelves::GetRecentShelves(2, $row_count, undef);
+ $total->{'pubtotal'} = $totshelves;
+ $session->param('barshelves', $barshelves);
+ $session->param('pubshelves', $pubshelves);
+ $session->param('totshelves', $total);
+
+ C4::Context::set_shelves_userenv('bar',$barshelves);
+ C4::Context::set_shelves_userenv('pub',$pubshelves);
+ C4::Context::set_shelves_userenv('tot',$total);
+ }