@@ -, +, @@ --- C4/Acquisition.pm | 15 ++++++--------- 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, 38 insertions(+), 38 deletions(-) --- a/C4/Acquisition.pm +++ a/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,11 +1892,10 @@ 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}; + push @query_params, C4::Context->userenv->{branch}; } } $strsth .= " ORDER BY aqbasket.basketno"; @@ -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,10 +2306,9 @@ 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}; + push @query_params, C4::Context->userenv->{branch}; } } $query .= " ORDER BY id"; --- a/C4/Branch.pm +++ a/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" --- a/C4/Items.pm +++ a/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'} ) ) { --- a/acqui/basket.pl +++ a/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 '' ) --- a/acqui/neworderempty.pl +++ a/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 ) { --- a/cataloguing/additem.pl +++ a/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. --- a/circ/ysearch.pl +++ a/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); --- a/suggestion/suggestion.pl +++ a/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; --- a/tools/export.pl +++ a/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'}; } --