From ac1f580a4048637e86229cd81334eda8ed3025d5 Mon Sep 17 00:00:00 2001 From: hdl Date: Thu, 1 Sep 2005 12:26:19 +0000 Subject: [PATCH] Fixing Bug when no user logged in --- C4/Acquisition.pm | 10 +++++----- C4/Context.pm | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 60c13c4489..3d56c46817 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -403,7 +403,7 @@ quantityreceived is NULL) and datecancellationprinted is NULL "; if (C4::Context->preference("IndependantBranches")) { my $userenv = C4::Context->userenv; - unless ($userenv->{flags} == 1){ + if (($userenv)&&($userenv->{flags} != 1)){ $strsth .= " and (borrowers.branchcode = '".$userenv->{branch}."' or borrowers.branchcode ='')"; } } @@ -500,7 +500,7 @@ quantityreceived is NULL) and datecancellationprinted is NULL "; if (C4::Context->preference("IndependantBranches")) { my $userenv = C4::Context->userenv; - unless ($userenv->{flags} == 1){ + if (($userenv) &&($userenv->{flags} != 1)){ $strsth .= " and (borrowers.branchcode = '".$userenv->{branch}."' or borrowers.branchcode ='')"; } } @@ -589,7 +589,7 @@ sub getlateorders { AND ((datereceived = '' OR datereceived is null) OR (aqorders.quantityreceived < aqorders.quantity) ) "; $strsth .= " AND aqbasket.booksellerid = $supplierid " if ($supplierid); $strsth .= " AND borrowers.branchcode like \'".$branch."\'" if ($branch); - $strsth .= " AND borrowers.branchcode like \'".C4::Context->userenv->{branch}."\'" if (C4::Context->preference("IndependantBranches") && C4::Context->userenv->{flags}!=1); + $strsth .= " AND borrowers.branchcode like \'".C4::Context->userenv->{branch}."\'" if (C4::Context->preference("IndependantBranches") && C4::Context->userenv && C4::Context->userenv->{flags}!=1); $strsth .= " ORDER BY latesince,basketno,borrowers.branchcode, supplier"; } else { $strsth ="SELECT aqbasket.basketno, @@ -740,7 +740,7 @@ sub histsearch { $query .= " and creationdate<".$dbh->quote($to_placed_on) if $to_placed_on; if (C4::Context->preference("IndependantBranches")) { my $userenv = C4::Context->userenv; - unless ($userenv->{flags} == 1){ + if (($userenv) &&($userenv->{flags} != 1)){ $query .= " and (borrowers.branchcode = '".$userenv->{branch}."' or borrowers.branchcode ='')"; } } @@ -1002,7 +1002,7 @@ table of the Koha database. sub branches { my $dbh = C4::Context->dbh; my $sth; - if (C4::Context->preference("IndependantBranches") && (C4::Context->userenv->{flags}!=1)){ + if (C4::Context->preference("IndependantBranches") && (C4::Context->userenv) && (C4::Context->userenv->{flags} != 1)){ my $strsth ="Select * from branches "; $strsth.= " WHERE branchcode = ".$dbh->quote(C4::Context->userenv->{branch}); $strsth.= " order by branchname"; diff --git a/C4/Context.pm b/C4/Context.pm index 73e81c7764..f270d2655f 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -617,6 +617,7 @@ sub userenv { my $var = $context->{"activeuser"}; return $context->{"userenv"}->{$var} if (defined $context->{"userenv"}->{$var}); + return 0; warn "NO CONTEXT for $var"; } -- 2.39.5