Before this patch, we used to test for flags == 1, which was wrong when patron had all privileges.
This patch just adds a %2 to check that patron has superlibrarian privilege, and maybe something else we don't care.
I think I fixed it everywhere except in acquisition, that will be addressed by BibLibre new acquisition module.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
"branches" )
{
if ( ( C4::Context->preference("IndependantBranches") )
- && ( C4::Context->userenv->{flags} != 1 ) )
+ && ( C4::Context->userenv->{flags} % 2 != 1 ) )
{
my $sth =
$dbh->prepare(
}
if ( C4::Context->preference("IndependantBranches") ) {
my $userenv = C4::Context->userenv;
- if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
+ if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
$issuingimpossible{NOTSAMEBRANCH} = 1
if ( $item->{C4::Context->preference("HomeOrHoldingBranch")} ne $userenv->{branch} );
}
$datedue = $idata->{'date_due'};
if (C4::Context->preference("IndependantBranches")){
my $userenv = C4::Context->userenv;
- if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
+ if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
$data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch});
}
}
$query .= ($category_type ? " AND category_type = ".$dbh->quote($category_type) : "");
$query .= " WHERE (surname LIKE ? OR cardnumber like ?) ";
if (C4::Context->preference("IndependantBranches") && !$showallbranches){
- if (C4::Context->userenv && C4::Context->userenv->{flags}!=1 && C4::Context->userenv->{'branch'}){
+ if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){
$query.=" AND borrowers.branchcode =".$dbh->quote(C4::Context->userenv->{'branch'}) unless (C4::Context->userenv->{'branch'} eq "insecure");
}
}
$count = @data;
$query .= " WHERE ";
if (C4::Context->preference("IndependantBranches") && !$showallbranches){
- if (C4::Context->userenv && C4::Context->userenv->{flags}!=1 && C4::Context->userenv->{'branch'}){
+ if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){
$query.=" borrowers.branchcode =".$dbh->quote(C4::Context->userenv->{'branch'})." AND " unless (C4::Context->userenv->{'branch'} eq "insecure");
}
}
my $filterbranch = shift ||
((C4::Context->preference('IndependantBranches')
&& C4::Context->userenv
- && C4::Context->userenv->{flags}!=1
+ && C4::Context->userenv->{flags} % 2 !=1
&& C4::Context->userenv->{branch})
? C4::Context->userenv->{branch}
: "");
my $filterbranch = shift ||
((C4::Context->preference('IndependantBranches')
&& C4::Context->userenv
- && C4::Context->userenv->{flags}!=1
+ && C4::Context->userenv->{flags} % 2 !=1
&& C4::Context->userenv->{branch})
? C4::Context->userenv->{branch}
: "");
my $filterbranch = shift ||
((C4::Context->preference('IndependantBranches')
&& C4::Context->userenv
- && C4::Context->userenv->{flags}!=1
+ && C4::Context->userenv->{flags} % 2 !=1
&& C4::Context->userenv->{branch})
? C4::Context->userenv->{branch}
: "");
$subs->{ "status" . $subs->{'status'} } = 1;
$subs->{'cannotedit'}=(C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags} !=1 &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch} && $subs->{branchcode} &&
(C4::Context->userenv->{branch} ne $subs->{branchcode}));
if ( $subs->{enddate} eq '0000-00-00' ) {
$line->{toggle} = 1 if $odd == 1;
$line->{'cannotedit'}=(C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags} !=1 &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch} && $line->{branchcode} &&
(C4::Context->userenv->{branch} ne $line->{branchcode}));
push @results, $line;
if (C4::Context->preference("IndependantBranches") || $branchcode) {
my $userenv = C4::Context->userenv;
if ($userenv) {
- unless ($userenv->{flags} == 1){
+ unless ($userenv->{flags} % 2 == 1){
push @sql_params,$userenv->{branch};
$query .= " and (U1.branchcode = ? or U1.branchcode ='')";
}
if (C4::Context->preference("IndependantBranches") || $branchcode) {
my $userenv = C4::Context->userenv;
if ($userenv) {
- unless ($userenv->{flags} == 1){
+ unless ($userenv->{flags} % 2 == 1){
push @sql_params,$userenv->{branch};
$query .= " and (U1.branchcode = ? or U1.branchcode ='')";
}
my $sth;
if (C4::Context->preference("IndependantBranches")){
my $userenv = C4::Context->userenv;
- if ($userenv->{flags} == 1){
+ if ($userenv->{flags} % 2 == 1){
my $query = qq |
SELECT count(*)
FROM suggestions
#Use GetBranches($onlymine)
my $onlymine=C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags}!=1 &&
+ C4::Context->userenv->{flags} % 2 == 0 &&
C4::Context->userenv->{branch};
my $branches = GetBranches($onlymine);
my @branchloop;
my $onlymine = C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags}!=1 &&
+ C4::Context->userenv->{flags} % 2 == 0 &&
C4::Context->userenv->{branch};
my $branches = GetBranches($onlymine); # build once ahead of time, instead of multiple times later.
}
$subfield_data{visibility} = "display:none;" if (($tagslib->{$tag}->{$subfield}->{hidden} > 4) || ($tagslib->{$tag}->{$subfield}->{hidden} < -4));
# testing branch value if IndependantBranches.
- # my $test = (C4::Context->preference("IndependantBranches")) &&
- # ($tag eq $branchtagfield) && ($subfield eq $branchtagsubfield) &&
- # (C4::Context->userenv->{flags} != 1) && ($value) && ($value ne C4::Context->userenv->{branch}) ;
- # $test and print $input->redirect(".pl?biblionumber=$biblionumber") and exit;
- # search for itemcallnumber if applicable
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
if (!$value && $tagslib->{$tag}->{$subfield}->{kohafield} eq 'items.itemcallnumber' && $pref_itemcallnumber) {
my $CNtag = substr($pref_itemcallnumber, 0, 3);
}
my $onlymine=C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags}!=1 &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch};
$branchfilter = C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter);
}
if (C4::Context->preference("IndependantBranches")) {
- unless ($userenv->{flags} == 1){
+ unless ($userenv->{flags} % 2 == 1){
unless ($userenv->{'branch'} eq $bor->{'branchcode'}){
# warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'};
print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$member&error=CANT_DELETE_OTHERLIBRARY");
}
}
if (C4::Context->preference("IndependantBranches")) {
- if ($userenv && $userenv->{flags} != 1){
+ if ($userenv && $userenv->{flags} % 2 != 1){
$debug and print STDERR " $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch};
unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){
push @errors, "ERROR_branch";
}
if (C4::Context->preference("IndependantBranches")) {
my $userenv = C4::Context->userenv;
- if ($userenv->{flags} != 1 && $data{branchcode}){
+ if ($userenv->{flags} % 2 != 1 && $data{branchcode}){
unless ($userenv->{branch} eq $data{'branchcode'}){
print $input->redirect("/cgi-bin/koha/members/members-home.pl");
exit;
my $onlymine=(C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags} !=1 &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch}?1:0);
my $branches=GetBranches($onlymine);
#Independant branches management
my $unvalidlibrarian =
( ( C4::Context->preference("IndependantBranches") )
- && ( C4::Context->userenv->{flags} != 1 )
+ && ( C4::Context->userenv->{flags} % 2 != 1 )
&& ( $data->{'branchcode'} ne C4::Context->userenv->{branch} ) );
my %bor;
my $samebranch;
if ( C4::Context->preference("IndependantBranches") ) {
my $userenv = C4::Context->userenv;
- unless ( $userenv->{flags} == 1 ) {
+ unless ( $userenv->{flags} % 2 == 1 ) {
$samebranch = ( $data->{'branchcode'} eq $userenv->{branch} );
}
- $samebranch = 1 if ( $userenv->{flags} == 1 );
+ $samebranch = 1 if ( $userenv->{flags} % 2 == 1 );
}
my $branchdetail = GetBranchDetail( $data->{'branchcode'});
$data->{'branchname'} = $branchdetail->{branchname};
if (! C4::Context->preference("canreservefromotherbranches")){
# cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
my $userenv = C4::Context->userenv;
- if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
+ if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) {
$item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
}
}
my $onlymine=C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags}!=1 &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch};
my $branches = GetBranches($onlymine);
my @branchloop;
$subs->{enddate} = format_date($subs->{enddate});
$subs->{histenddate} = format_date($subs->{histenddate});
$subs->{abouttoexpire} = abouttoexpire($subs->{subscriptionid});
-# Done in Serials.pm
-# $subs->{'donotedit'}=(C4::Context->preference('IndependantBranches') &&
-# C4::Context->userenv &&
-# C4::Context->userenv->{flags} !=1 &&
-# C4::Context->userenv->{branch} && $subs->{branchcode} &&
-# (C4::Context->userenv->{branch} ne $subs->{branchcode}));
$template->param($subs);
$template->param(biblionumber_for_new_subscription => $subs->{bibnum});
hemisphere => $hemisphere,
cannotedit =>(C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags} !=1 &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch} && $subs->{branchcode} &&
(C4::Context->userenv->{branch} ne $subs->{branchcode})),
"periodicity".($subs->{periodicity}?$subs->{periodicity}:'0') => 1,
my $branchcode;
my $userenv = C4::Context->userenv;
if ($userenv) {
- unless ($userenv->{flags} == 1){
+ unless ($userenv->{flags} % 2 == 1){
$branchcode=$userenv->{branch};
}
}
my $limit_ind_branch=(C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags} !=1 &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch}?1:0);
my $branches = GetBranches($limit_ind_branch);
my $branch = $query->param("branch") || '';
# Set all the branches.
my $onlymine=(C4::Context->preference('IndependantBranches') &&
C4::Context->userenv &&
- C4::Context->userenv->{flags} !=1 &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch}?1:0);
if ( $onlymine ) {
$branch = C4::Context->userenv->{'branch'};