From 2cbc47a871efc60ae663ecfedf59ec77dda718f4 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 9 Jul 2013 11:48:23 +0200 Subject: [PATCH] Bug 2394: Use syspref canreservefromotherbranches in CanItemBeReserved If IndependentBranches is ON, patrons are not allowed to place hold requests on items whose owning library is different from the patron's home library, *unless* the canreservefromotherbranches system preference is also ON. The patch implements the intended behavior; without it, IndependentBranches and canreservefromotherbranches were not consulted during the item holdability check. To test: [1] Have IndependentBranches ON and canreservefromotherbranches OFF. Make sure that the circulation rules are set up to permit patrons to place hold requests in general. [2] In the OPAC, log in as a patron from library A, and try placing a hold on an item from library B. The patron will be able to place the request. [3] Cancel the request. [4] Apply the patch. [5] Try placing the same hold request. This time, the request should be forbidden. [6] Turn on canreservefromotherbranches. [7] Try placing the hold request. This time, it should go through. [8] Cancel the request. [9] Turn off IndependentBranches. [10] Try placing the hold request and verify that it is permitted. [10] Signed-off-by: Srdjan Signed-off-by: Kyle M Hall Signed-off-by: Galen Charlton --- C4/Reserves.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 1f89127eec..0291def3aa 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -510,11 +510,22 @@ sub CanItemBeReserved{ } # we check if it's ok or not - if( $reservecount < $allowedreserves ){ - return 1; - }else{ + if( $reservecount >= $allowedreserves ){ return 0; } + + # If reservecount is ok, we check item branch if IndependentBranches is ON + # and canreservefromotherbranches is OFF + if ( C4::Context->preference('IndependentBranches') + and !C4::Context->preference('canreservefromotherbranches') ) + { + my $itembranch = $item->{homebranch}; + if ($itembranch ne $borrower->{branchcode}) { + return 0; + } + } + + return 1; } #-------------------------------------------------------------------------------- =head2 GetReserveCount -- 2.39.5