Bugzilla – Attachment 105990 Details for
Bug 25408
CanBookBeReserved & CanItemBeReserved should check "opacitemholds" policy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25408: Add "opacitemholds" checks in CanBookBeReserved & CanItemBeReserved
Bug-25408-Add-opacitemholds-checks-in-CanBookBeRes.patch (text/plain), 3.41 KB, created by
Arthur Suzuki
on 2020-06-17 22:11:00 UTC
(
hide
)
Description:
Bug 25408: Add "opacitemholds" checks in CanBookBeReserved & CanItemBeReserved
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2020-06-17 22:11:00 UTC
Size:
3.41 KB
patch
obsolete
>From f0fef7a2c791d2cf10521bf059516464dfb6beb6 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Thu, 7 May 2020 12:33:46 +0200 >Subject: [PATCH] Bug 25408: Add "opacitemholds" checks in CanBookBeReserved & > CanItemBeReserved > >test plan: >1) apply tests patch >2) run tests >3) verify not green >4) apply patch >5) run tests (again) >6) success: green :) >--- > C4/Reserves.pm | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index d328773b01..28776858dd 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -310,6 +310,8 @@ See CanItemBeReserved() for possible return values. > > sub CanBookBeReserved{ > my ($borrowernumber, $biblionumber, $pickup_branchcode) = @_; >+ my $patron = Koha::Patrons->find( $borrowernumber ); >+ my $borrower = $patron->unblessed; > > my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); > #get items linked via host records >@@ -319,7 +321,13 @@ sub CanBookBeReserved{ > } > > my $canReserve = { status => '' }; >+ my ($rights,$item); >+ > foreach my $itemnumber (@itemnumbers) { >+ $item = Koha::Items->find($itemnumber); >+ $rights = GetHoldRule( $borrower->{'categorycode'}, $item->{'itype'}, $pickup_branchcode ); >+ return { 'status' => 'RecordHoldNotAllowed' } if $rights->{opacitemholds} eq 'F'; >+ > $canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode ); > return { status => 'OK' } if $canReserve->{status} eq 'OK'; > } >@@ -353,6 +361,10 @@ sub CanItemBeReserved { > my $allowedreserves = 0; # Total number of holds allowed across all records > my $holds_per_record = 1; # Total number of holds allowed for this one given record > my $holds_per_day; # Default to unlimited >+ my $opacitemholds = 'Y'; # Itemlevel holds default to allowed >+ >+ # Get calling context >+ my $caller = (caller(1))[3]; > > # we retrieve borrowers and items informations # > # item->{itype} will come for biblioitems if necessery >@@ -404,11 +416,18 @@ sub CanItemBeReserved { > $allowedreserves = $rights->{reservesallowed} // $allowedreserves; > $holds_per_record = $rights->{holds_per_record} // $holds_per_record; > $holds_per_day = $rights->{holds_per_day}; >+ $opacitemholds = $rights->{opacitemholds}; > } > else { > $ruleitemtype = undef; > } > >+ if ( $opacitemholds eq "N" and index($caller,"CanBookBeReserved") eq -1 ) { >+ return { status => "notReservable" }; >+ } >+ >+ $item = Koha::Items->find( $itemnumber ); >+ > my $holds = Koha::Holds->search( > { > borrowernumber => $borrowernumber, >@@ -2249,7 +2268,7 @@ sub GetHoldRule { > itemtype => $itemtype, > categorycode => $categorycode, > branchcode => $branchcode, >- rules => ['holds_per_record', 'holds_per_day'], >+ rules => ['holds_per_record', 'holds_per_day', 'opacitemholds'], > order_by => { > -desc => [ 'categorycode', 'itemtype', 'branchcode' ] > } >@@ -2257,6 +2276,7 @@ sub GetHoldRule { > ); > $rules->{holds_per_record} = $holds_per_x_rules->{holds_per_record}; > $rules->{holds_per_day} = $holds_per_x_rules->{holds_per_day}; >+ $rules->{opacitemholds} = $holds_per_x_rules->{opacitemholds}; > > return $rules; > } >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25408
:
104488
|
104496
|
105988
|
105989
|
105990
|
106413
|
106414
|
106521
|
106535
|
106536
|
106537
|
107777
|
107778
|
107779
|
107780
|
111681
|
111682
|
111693
|
111696
|
111716
|
111717
|
111718
|
111719
|
111720
|
111721
|
115125
|
115126
|
115127
|
115128
|
115129
|
115130
|
121524
|
121525
|
121526
|
121527
|
121528
|
121530
|
128505
|
130180
|
130181
|
132658
|
132660
|
132661
|
164680
|
164681
|
164682
|
164684
|
164685
|
164686
|
164693
|
164694
|
164878
|
164879
|
165111
|
165112