From 118674ec6477bb90d8c390221c463ec627e1ca6d Mon Sep 17 00:00:00 2001 From: hdl Date: Wed, 5 Apr 2006 15:06:58 +0000 Subject: [PATCH] Adding branchname to userenv. --- C4/Auth.pm | 14 ++++++++------ C4/Context.pm | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index c603b205c1..0cd19e1a41 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -317,6 +317,7 @@ sub checkauth { $hash{firstname}, $hash{surname}, $hash{branch}, + $hash{branchname}, $hash{flags}, $hash{emailaddress}, ); @@ -403,18 +404,18 @@ sub checkauth { } if ($return == 1){ my ($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress); - my $sth=$dbh->prepare("select borrowernumber,firstname,surname,flags,branchcode,emailaddress from borrowers where userid=?"); + my $sth=$dbh->prepare("select borrowernumber,firstname,surname,flags,borrowers.branchcode,branchname,emailaddress from borrowers,branches where borrowers.branchcode=branches.branchcode and userid=?"); $sth->execute($userid); - ($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow if ($sth->rows); + ($bornum,$firstname,$surname,$userflags,$branchcode,$branchname, $emailaddress) = $sth->fetchrow if ($sth->rows); # warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; unless ($sth->rows){ - my $sth=$dbh->prepare("select borrowernumber,firstname,surname,flags,branchcode,emailaddress from borrowers where cardnumber=?"); + my $sth=$dbh->prepare("select borrowernumber,firstname,surname,flags,borrowers.branchcode,branchname,emailaddress from borrowers,branches where borrowers.branchcode=branches.branchcode and cardnumber=?"); $sth->execute($cardnumber); - ($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow if ($sth->rows); + ($bornum,$firstname,$surname,$userflags,$branchcode, $branchname,$emailaddress) = $sth->fetchrow if ($sth->rows); # warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; unless ($sth->rows){ $sth->execute($userid); - ($bornum,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow if ($sth->rows); + ($bornum,$firstname,$surname,$userflags,$branchcode, $branchname, $emailaddress) = $sth->fetchrow if ($sth->rows); } # warn "$cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress"; } @@ -425,6 +426,7 @@ sub checkauth { $firstname, $surname, $branchcode, + $branchname, $userflags, $emailaddress, ); @@ -439,7 +441,7 @@ sub checkauth { C4::Context->config('user'), C4::Context->config('user'), C4::Context->config('user'), - "",1,C4::Context->preference('KohaAdminEmailAddress') + "","",1,C4::Context->preference('KohaAdminEmailAddress') ); $envcookie=$query->cookie(-name => 'userenv', -value => $hash, diff --git a/C4/Context.pm b/C4/Context.pm index f270d2655f..f56d0a9298 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -635,7 +635,7 @@ set_userenv is called in Auth.pm =cut #' sub set_userenv{ - my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $userflags, $emailaddress)= @_; + my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $userbranchname, $userflags, $emailaddress)= @_; my $var=$context->{"activeuser"}; my $cell = { "number" => $usernum, @@ -645,6 +645,7 @@ sub set_userenv{ # "surname" => $usersurname, #possibly a law problem "branch" => $userbranch, + "branchname" => $userbranchname, "flags" => $userflags, "emailaddress" => $emailaddress, }; -- 2.39.5