From bf1fd83d087d13561ddd8ade870413a9912c5329 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Tue, 7 Aug 2007 15:45:03 -0500 Subject: [PATCH] set the branch at login --- C4/Auth.pm | 30 +++-------------------- C4/Branch.pm | 3 ++- koha-tmpl/intranet-tmpl/prog/en/auth.tmpl | 11 ++------- 3 files changed, 8 insertions(+), 36 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 3ffbb3edd2..da70939d10 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -114,7 +114,6 @@ C4::Auth - Authenticates Koha users sub get_template_and_user { my $in = shift; - warn "GET Template"; my $template = gettemplate( $in->{'template_name'}, $in->{'type'}, $in->{'query'} ); my ( $user, $cookie, $sessionID, $flags ) = checkauth( @@ -217,7 +216,8 @@ sub get_template_and_user { } if ( $in->{'type'} eq "intranet" ) { $template->param( - intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetcolorstylesheet => + C4::Context->preference("intranetcolorstylesheet"), intranetstylesheet => C4::Context->preference("intranetstylesheet"), IntranetNav => C4::Context->preference("IntranetNav"), intranetuserjs => C4::Context->preference("intranetuserjs"), @@ -383,7 +383,7 @@ sub checkauth { # state variables my $loggedin = 0; my %info; - my ( $userid, $cookie, $sessionID, $flags ); + my ( $userid, $cookie, $sessionID, $flags, $envcookie ); my $logout = $query->param('logout.x'); if ( $userid = $ENV{'REMOTE_USER'} ) { @@ -545,14 +545,10 @@ sub checkauth { # new op dev : # launch a sequence to check if we have a ip for the branch, if we have one we replace the branchcode of the userenv by the branch bound in the ip. 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(); my @branchesloop; foreach my $br ( keys %$branches ) { + # now we work with the treatment of ip my $domain = $branches->{$br}->{'branchip'}; if ( $domain && $ip =~ /^$domain/ ) { @@ -591,17 +587,7 @@ sub checkauth { $session->param('ip',$session->remote_addr()); $session->param('lasttime',time()); } - if ($session){ - 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') - ); - } } - else { if ($userid) { $info{'invalid_username_or_password'} = 1; @@ -631,16 +617,8 @@ sub checkauth { my $value = $query->param($name); push @inputs, { name => $name, value => $value }; } - # get the branchloop, which we need for authetication - use C4::Branch; - my $branches = GetBranches(); - my @branch_loop; - for my $branch_hash (keys %$branches) { - push @branch_loop, {branchcode => "$branch_hash", branchname => $branches->{$branch_hash}->{'branchname'}, }; - } my $template = gettemplate( $template_name, $type, $query ); - $template->param(branchloop => \@branch_loop,); $template->param( INPUTS => \@inputs, suggestion => C4::Context->preference("suggestion"), diff --git a/C4/Branch.pm b/C4/Branch.pm index 79d4d54a4b..4a540be3f4 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -91,7 +91,8 @@ foreach my $thisbranch (keys %$branches) { =cut sub GetBranches { - my ($onlymine)=@_; + + my $onlymine=@_; # returns a reference to a hash of references to ALL branches... my %branches; my $dbh = C4::Context->dbh; diff --git a/koha-tmpl/intranet-tmpl/prog/en/auth.tmpl b/koha-tmpl/intranet-tmpl/prog/en/auth.tmpl index 69c6c4b511..b91d737dfe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/auth.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/auth.tmpl @@ -43,17 +43,10 @@

-

-

- - -

+

+