From 415fa243aadee297e6f3eda36e8aa116f8cf16ee Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Thu, 12 Dec 2013 08:19:37 -0500
Subject: [PATCH] Bug 10277 [Followup] - Replace all remaining userenv checks with IsSuperLibrarian()
---
C4/Acquisition.pm | 11 ++++-------
C4/Branch.pm | 10 +++++-----
C4/Items.pm | 2 +-
acqui/basket.pl | 4 ++--
acqui/neworderempty.pl | 9 +++++----
cataloguing/additem.pl | 9 +++++----
circ/ysearch.pl | 14 +++++++-------
suggestion/suggestion.pl | 9 +++++----
tools/export.pl | 4 ++--
9 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index dc090b8..cbbb6fb 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -1696,7 +1696,7 @@ sub SearchOrders {
my $userenv = C4::Context->userenv;
if ( C4::Context->preference("IndependentBranches") ) {
- if ( ( $userenv ) and ( $userenv->{flags} != 1 ) ) {
+ unless ( C4::Context->IsSuperLibrarian() ) {
$query .= q{
AND (
borrowers.branchcode = ?
@@ -1892,8 +1892,7 @@ sub GetParcel {
my @query_params = ( $supplierid, $code, $datereceived );
if ( C4::Context->preference("IndependentBranches") ) {
- my $userenv = C4::Context->userenv;
- if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
+ unless ( C4::Context->IsSuperLibrarian() ) {
$strsth .= " and (borrowers.branchcode = ?
or borrowers.branchcode = '')";
push @query_params, $userenv->{branch};
@@ -2111,8 +2110,7 @@ sub GetLateOrders {
$from .= ' AND ADDDATE(aqbasket.closedate, INTERVAL aqbooksellers.deliverytime DAY) <= CAST(now() AS date)';
}
if (C4::Context->preference("IndependentBranches")
- && C4::Context->userenv
- && C4::Context->userenv->{flags} != 1 ) {
+ && !C4::Context->IsSuperLibrarian() ) {
$from .= ' AND borrowers.branchcode LIKE ? ';
push @query_params, C4::Context->userenv->{branch};
}
@@ -2308,8 +2306,7 @@ sub GetHistory {
}
if ( C4::Context->preference("IndependentBranches") ) {
- my $userenv = C4::Context->userenv;
- if ( $userenv && ($userenv->{flags} || 0) != 1 ) {
+ unless ( C4::Context->IsSuperLibrarian() ) {
$query .= " AND (borrowers.branchcode = ? OR borrowers.branchcode ='' ) ";
push @query_params, $userenv->{branch};
}
diff --git a/C4/Branch.pm b/C4/Branch.pm
index bdc01dc..7513cdd 100644
--- a/C4/Branch.pm
+++ b/C4/Branch.pm
@@ -146,11 +146,11 @@ sub GetBranches {
}
sub onlymine {
- return
- C4::Context->preference('IndependentBranches') &&
- C4::Context->userenv &&
- C4::Context->userenv->{flags} %2 != 1 &&
- C4::Context->userenv->{branch} ;
+ return
+ C4::Context->preference('IndependentBranches')
+ && C4::Context->userenv
+ && !C4::Context->IsSuperLibrarian()
+ && C4::Context->userenv->{branch};
}
# always returns a string for OK comparison via "eq" or "ne"
diff --git a/C4/Items.pm b/C4/Items.pm
index 1d8fb0b..cc50d42 100644
--- a/C4/Items.pm
+++ b/C4/Items.pm
@@ -2240,7 +2240,7 @@ sub DelItemCheck {
if ($onloan){
$error = "book_on_loan"
}
- elsif ( !( C4::Context->userenv->{flags} & 1 )
+ elsif ( !C4::Context->IsSuperLibrarian()
and C4::Context->preference("IndependentBranches")
and ( C4::Context->userenv->{branch} ne $item->{'homebranch'} ) )
{
diff --git a/acqui/basket.pl b/acqui/basket.pl
index 6833eb6..e546948 100755
--- a/acqui/basket.pl
+++ b/acqui/basket.pl
@@ -154,7 +154,7 @@ if ( $op eq 'delete_confirm' ) {
$template->param( delete_confirm => 1 );
if ( C4::Context->preference("IndependentBranches") ) {
my $userenv = C4::Context->userenv;
- unless ( $userenv->{flags} == 1 ) {
+ unless ( C4::Context->IsSuperLibrarian() ) {
my $validtest = ( $basket->{creationdate} eq '' )
|| ( $userenv->{branch} eq $basket->{branch} )
|| ( $userenv->{branch} eq '' )
@@ -257,7 +257,7 @@ if ( $op eq 'delete_confirm' ) {
# get librarian branch...
if ( C4::Context->preference("IndependentBranches") ) {
my $userenv = C4::Context->userenv;
- unless ( $userenv->{flags} == 1 ) {
+ unless ( C4::Context->IsSuperLibrarian() ) {
my $validtest = ( $basket->{creationdate} eq '' )
|| ( $userenv->{branch} eq $basket->{branch} )
|| ( $userenv->{branch} eq '' )
diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl
index 9c9eed3..9fdf032 100755
--- a/acqui/neworderempty.pl
+++ b/acqui/neworderempty.pl
@@ -229,10 +229,11 @@ for my $curr ( @rates ) {
}
# build branches list
-my $onlymine=C4::Context->preference('IndependentBranches') &&
- C4::Context->userenv &&
- C4::Context->userenv->{flags}!=1 &&
- C4::Context->userenv->{branch};
+my $onlymine =
+ C4::Context->preference('IndependentBranches')
+ && C4::Context->userenv
+ && !C4::Context->IsSuperLibrarian()
+ && C4::Context->userenv->{branch};
my $branches = GetBranches($onlymine);
my @branchloop;
foreach my $thisbranch ( sort {$branches->{$a}->{'branchname'} cmp $branches->{$b}->{'branchname'}} keys %$branches ) {
diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index c1eb2e2..5c63aa3 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -756,10 +756,11 @@ my $i=0;
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
-my $onlymine = C4::Context->preference('IndependentBranches') &&
- C4::Context->userenv &&
- C4::Context->userenv->{flags}!=1 &&
- C4::Context->userenv->{branch};
+my $onlymine =
+ C4::Context->preference('IndependentBranches')
+ && C4::Context->userenv
+ && !C4::Context->IsSuperLibrarian()
+ && C4::Context->userenv->{branch};
my $branch = $input->param('branch') || C4::Context->userenv->{branch};
my $branches = GetBranchesLoop($branch,$onlymine); # build once ahead of time, instead of multiple times later.
diff --git a/circ/ysearch.pl b/circ/ysearch.pl
index 7429c06..8973902 100755
--- a/circ/ysearch.pl
+++ b/circ/ysearch.pl
@@ -51,13 +51,13 @@ my $sql = q(
OR firstname LIKE ?
OR cardnumber LIKE ? )
);
-if (C4::Context->preference("IndependentBranches")){
- if ( C4::Context->userenv
- && (C4::Context->userenv->{flags} % 2) !=1
- && C4::Context->userenv->{'branch'}
- ){
- $sql .= " AND borrowers.branchcode =" . $dbh->quote(C4::Context->userenv->{'branch'});
- }
+if ( C4::Context->preference("IndependentBranches")
+ && C4::Context->userenv
+ && !C4::Context->IsSuperLibrarian()
+ && C4::Context->userenv->{'branch'} )
+{
+ $sql .= " AND borrowers.branchcode ="
+ . $dbh->quote( C4::Context->userenv->{'branch'} );
}
$sql .= q( ORDER BY surname, firstname LIMIT 10);
diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl
index 7d50447..c0327ad 100755
--- a/suggestion/suggestion.pl
+++ b/suggestion/suggestion.pl
@@ -288,10 +288,11 @@ if(defined($returnsuggested) and $returnsuggested ne "noone")
#branch display management
my $branchfilter = ($displayby ne "branchcode") ? $input->param('branchcode') : '';
-my $onlymine=C4::Context->preference('IndependentBranches') &&
- C4::Context->userenv &&
- C4::Context->userenv->{flags}!=1 &&
- C4::Context->userenv->{branch};
+my $onlymine =
+ C4::Context->preference('IndependentBranches')
+ && C4::Context->userenv
+ && !C4::Context->IsSuperLibrarian()
+ && C4::Context->userenv->{branch};
my $branches = GetBranches($onlymine);
my @branchloop;
diff --git a/tools/export.pl b/tools/export.pl
index a516a6b..9bbed0b 100755
--- a/tools/export.pl
+++ b/tools/export.pl
@@ -120,13 +120,13 @@ my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
my $limit_ind_branch =
( C4::Context->preference('IndependentBranches')
&& C4::Context->userenv
- && !( C4::Context->userenv->{flags} & 1 )
+ && !C4::Context->IsSuperLibrarian()
&& C4::Context->userenv->{branch} ) ? 1 : 0;
my $branch = $query->param("branch") || '';
if ( C4::Context->preference("IndependentBranches")
&& C4::Context->userenv
- && !( C4::Context->userenv->{flags} & 1 ) )
+ && !C4::Context->IsSuperLibrarian() )
{
$branch = C4::Context->userenv->{'branch'};
}
--
1.7.2.5