[Koha-patches] [PATCH 04/78] fix for 2997 : superlibrarian's ability to edit item/patron home branch affected if all other privileges are selected
paul.poulain at biblibre.com
paul.poulain at biblibre.com
Thu May 28 18:32:14 CEST 2009
From: Paul Poulain <paul.poulain at biblibre.com>
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.
---
C4/Biblio.pm | 2 +-
C4/Circulation.pm | 2 +-
C4/Items.pm | 2 +-
C4/Members.pm | 10 +++++-----
C4/Serials.pm | 4 ++--
C4/Suggestions.pm | 6 +++---
cataloguing/addbiblio.pl | 2 +-
cataloguing/additem.pl | 7 +------
circ/overdue.pl | 2 +-
members/deletemem.pl | 2 +-
members/memberentry.pl | 6 +++---
members/moremember.pl | 6 +++---
reserve/request.pl | 2 +-
serials/subscription-add.pl | 2 +-
serials/subscription-detail.pl | 8 +-------
suggestion/acceptorreject.pl | 2 +-
tools/export.pl | 2 +-
tools/holidays.pl | 2 +-
18 files changed, 29 insertions(+), 40 deletions(-)
diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 27a2795..50e6b54 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -2231,7 +2231,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 a3486f9..bb87ed7 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 5716462..f47f9c8 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 3c26ebb..7e2d5bd 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -185,7 +185,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");
}
}
@@ -198,7 +198,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");
}
}
@@ -1909,7 +1909,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}
: "");
@@ -1961,7 +1961,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}
: "");
@@ -2011,7 +2011,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 5dfd727..5ce7806 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 c358d7a..1732540 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 76e850b..8067a26 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 f2f1922..a7595e7 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 6c2a00a..60ae04c 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 e41157b..99b779d 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 2c97a57..c259dfd 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 610bceb..00b1be4 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 496962f..aed2aea 100755
--- a/reserve/request.pl
+++ b/reserve/request.pl
@@ -382,7 +382,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 dba37ad..62c1d90 100755
--- a/serials/subscription-add.pl
+++ b/serials/subscription-add.pl
@@ -139,7 +139,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 46ee3f8..aa3179d 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 6147b34..12e2f13 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 8cb495f..f60fcd6 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 c92e521..ddfdd80 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'};
--
1.6.0.4
More information about the Koha-patches
mailing list