From 2605a206109e18a68b549db59b3c3b69978ccd9b Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 5 Aug 2005 14:43:44 +0000 Subject: [PATCH] adding emailaddress to user context. Now, we can use userenv->{emailaddress} to get the librarian email address everywhere. --- C4/Auth.pm | 12 +++++++----- C4/Context.pm | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index a4e64a73c3..338df98045 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -303,7 +303,8 @@ sub checkauth { $hash{firstname}, $hash{surname}, $hash{branch}, - $hash{flags} + $hash{flags}, + $hash{emailaddress}, ); } my ($ip , $lasttime); @@ -388,11 +389,11 @@ sub checkauth { } if ($return == 1){ my $sth=$dbh->prepare( - "select cardnumber,borrowernumber,userid,firstname,surname,flags,branchcode + "select cardnumber,borrowernumber,userid,firstname,surname,flags,branchcode,emailaddress from borrowers where userid=?" ); $sth->execute($userid); - my ($cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode) = $sth->fetchrow; + my ($cardnumber,$bornum,$userid,$firstname,$surname,$userflags,$branchcode,$emailaddress) = $sth->fetchrow; my $hash = C4::Context::set_userenv( $bornum, $userid, @@ -400,7 +401,8 @@ sub checkauth { $firstname, $surname, $branchcode, - $userflags + $userflags, + $emailaddress, ); $envcookie=$query->cookie(-name => 'userenv', -value => $hash, @@ -412,7 +414,7 @@ sub checkauth { C4::Context->config('user'), C4::Context->config('user'), C4::Context->config('user'), - "",1 + "",1,'nobody@nowhere_koha.com' ); $envcookie=$query->cookie(-name => 'userenv', -value => $hash, diff --git a/C4/Context.pm b/C4/Context.pm index b51f1f40d9..3fc51f6047 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -632,6 +632,7 @@ sub userenv { my $var = $context->{"activeuser"}; return $context->{"userenv"}->{$var} if (defined $context->{"userenv"}->{$var}); + warn "NO CONTEXT for $var"; } =item userenv @@ -648,7 +649,7 @@ set_userenv is called in Auth.pm =cut #' sub set_userenv{ - my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $userflags)= @_; + my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $userflags, $emailaddress)= @_; my $var=$context->{"activeuser"}; my $cell = { "number" => $usernum, @@ -657,7 +658,8 @@ sub set_userenv{ "firstname" => $userfirstname, "surname" => $usersurname, "branch" => $userbranch, - "flags" => $userflags + "flags" => $userflags, + "emailaddress" => $emailaddress, }; $context->{userenv}->{$var} = $cell; return $cell; -- 2.39.5