Bugzilla – Attachment 107778 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.88 KB, created by
Arthur Suzuki
on 2020-08-04 14:45:27 UTC
(
hide
)
Description:
Bug 25408: Add "opacitemholds" checks in CanBookBeReserved & CanItemBeReserved
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2020-08-04 14:45:27 UTC
Size:
3.88 KB
patch
obsolete
>From 8beb93da3bf559feddd32a654b1d5349f887aa62 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 :) > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > C4/Reserves.pm | 26 ++++++++++++++++++++++++-- > 1 file changed, 24 insertions(+), 2 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 950d29f587..30de970146 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -315,6 +315,8 @@ See CanItemBeReserved() for possible return values. > > sub CanBookBeReserved{ > my ($borrowernumber, $biblionumber, $pickup_branchcode, $params) = @_; >+ 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 >@@ -324,8 +326,11 @@ sub CanBookBeReserved{ > } > > my $canReserve = { status => '' }; >+ my ($rights,$item); >+ > foreach my $itemnumber (@itemnumbers) { > $canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode, $params ); >+ return { status => 'RecordHoldNotAllowed' } if $canReserve->{rights}->{opacitemholds} eq 'F'; > return { status => 'OK' } if $canReserve->{status} eq 'OK'; > } > return $canReserve; >@@ -362,6 +367,7 @@ 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 > > # we retrieve borrowers and items informations # > # item->{itype} will come for biblioitems if necessery >@@ -413,6 +419,7 @@ 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; >@@ -425,6 +432,20 @@ sub CanItemBeReserved { > $search_params->{found} = undef if $params->{ignore_found_holds}; > > my $holds = Koha::Holds->search($search_params); >+ >+ if ( $opacitemholds eq "N" ) { >+ return { status => "notReservable" }; >+ } >+ >+ $item = Koha::Items->find( $itemnumber ); >+ >+ my $holds = Koha::Holds->search( >+ { >+ borrowernumber => $borrowernumber, >+ biblionumber => $item->biblionumber, >+ } >+ ); >+ > if ( defined $holds_per_record && $holds_per_record ne '' > && $holds->count() >= $holds_per_record ) { > return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record }; >@@ -545,7 +566,7 @@ sub CanItemBeReserved { > } > } > >- return { status => 'OK' }; >+ return { status => 'OK', rights => $rights }; > } > > =head2 CanReserveBeCanceledFromOpac >@@ -2250,7 +2271,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' ] > } >@@ -2258,6 +2279,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.11.0
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