From: Paul Poulain Date: Thu, 28 May 2009 16:32:14 +0000 (+0200) Subject: fix for 2997 : superlibrarian's ability to edit item/patron home branch affected... X-Git-Tag: n_acq_a_porter~26^2~170 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=6924e7d6b43634933e3c4219d16258f8411346c3;p=koha.git fix for 2997 : superlibrarian's ability to edit item/patron home branch affected if all other privileges are selected 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 --- diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 36d9ad4bbd..e72620f8a0 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -2233,7 +2233,7 @@ sub PrepareItemrecordDisplay { "branches" ) { if ( ( C4::Context->preference("IndependantBranches") ) - && ( C4::Context->userenv->{flags} != 1 ) ) + && ( C4::Context->userenv->{flags} % 2 != 1 ) ) { my $sth = $dbh->prepare( diff --git a/C4/Circulation.pm b/C4/Circulation.pm index fe2840947e..99df5ccecd 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -790,7 +790,7 @@ sub CanBookBeIssued { } 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} ); } diff --git a/C4/Items.pm b/C4/Items.pm index 571646268f..f47f9c88b9 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1254,7 +1254,7 @@ sub GetItemsInfo { $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}); } } diff --git a/C4/Members.pm b/C4/Members.pm index af329394bf..4f872485cc 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -184,7 +184,7 @@ sub SearchMember { $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"); } } @@ -197,7 +197,7 @@ sub SearchMember { $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"); } } @@ -1908,7 +1908,7 @@ sub GetBorrowersWhoHaveNotBorrowedSince { 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} : ""); @@ -1960,7 +1960,7 @@ sub GetBorrowersWhoHaveNeverBorrowed { 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} : ""); @@ -2010,7 +2010,7 @@ sub GetBorrowersWithIssuesHistoryOlderThan { 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} : ""); diff --git a/C4/Serials.pm b/C4/Serials.pm index 40ac9e5138..96908bf3f3 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -549,7 +549,7 @@ sub GetSubscriptionsFromBiblionumber { $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' ) { @@ -704,7 +704,7 @@ sub GetSubscriptions { $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; diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index c358d7ac24..17325401ea 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -118,7 +118,7 @@ sub SearchSuggestion { 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 ='')"; } @@ -237,7 +237,7 @@ sub GetSuggestionByStatus { 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 ='')"; } @@ -287,7 +287,7 @@ sub CountSuggestion { 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 diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 76e850b04c..8067a26873 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -168,7 +168,7 @@ sub build_authorized_values_list ($$$$$$$) { #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; diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index f2f192236b..a7595e7130 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -256,7 +256,7 @@ my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM auth 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. @@ -293,11 +293,6 @@ foreach my $tag (sort keys %{$tagslib}) { } $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); diff --git a/circ/overdue.pl b/circ/overdue.pl index 6c2a00a57c..60ae04c909 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -88,7 +88,7 @@ while (my ($itemtype, $description) =$req->fetchrow) { } 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); diff --git a/members/deletemem.pl b/members/deletemem.pl index e41157b386..99b779de56 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -57,7 +57,7 @@ if ($bor->{category_type} eq "S") { } 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"); diff --git a/members/memberentry.pl b/members/memberentry.pl index 2c97a570c0..c259dfd599 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -246,7 +246,7 @@ if ($op eq 'save' || $op eq 'insert'){ } } 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"; @@ -364,7 +364,7 @@ if ($nok or !$nodouble){ } 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; @@ -508,7 +508,7 @@ my %select_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); my $branches=GetBranches($onlymine); diff --git a/members/moremember.pl b/members/moremember.pl index 610bceb4dd..00b1be4301 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -190,7 +190,7 @@ else { #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; @@ -200,10 +200,10 @@ $bor{'borrowernumber'} = $borrowernumber; 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}; diff --git a/reserve/request.pl b/reserve/request.pl index 6812d786f8..60f7ea4077 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -383,7 +383,7 @@ foreach my $biblionumber (@biblionumbers) { 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} ); } } diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index 6cf13233fe..9fd55d12f7 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -130,7 +130,7 @@ if ($op eq 'mod' || $op eq 'dup' || $op eq 'modsubscription') { 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; diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl index 46ee3f8fd0..aa3179d012 100755 --- a/serials/subscription-detail.pl +++ b/serials/subscription-detail.pl @@ -72,12 +72,6 @@ $subs->{histstartdate} = format_date($subs->{histstartdate}); $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}); @@ -90,7 +84,7 @@ $template->param( 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, diff --git a/suggestion/acceptorreject.pl b/suggestion/acceptorreject.pl index 6147b34fb1..12e2f136fa 100755 --- a/suggestion/acceptorreject.pl +++ b/suggestion/acceptorreject.pl @@ -106,7 +106,7 @@ my $suggestions; my $branchcode; my $userenv = C4::Context->userenv; if ($userenv) { - unless ($userenv->{flags} == 1){ + unless ($userenv->{flags} % 2 == 1){ $branchcode=$userenv->{branch}; } } diff --git a/tools/export.pl b/tools/export.pl index 8cb495f033..f60fcd6e4c 100755 --- a/tools/export.pl +++ b/tools/export.pl @@ -47,7 +47,7 @@ my ($template, $loggedinuser, $cookie) 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") || ''; diff --git a/tools/holidays.pl b/tools/holidays.pl index 93808f0e1f..047f226216 100755 --- a/tools/holidays.pl +++ b/tools/holidays.pl @@ -57,7 +57,7 @@ my $branch= $input->param('branch') || C4::Context->userenv->{'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'};