Bugzilla – Attachment 115127 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.49 KB, created by
Arthur Suzuki
on 2021-01-14 04:54:07 UTC
(
hide
)
Description:
Bug 25408: Add "opacitemholds" checks in CanBookBeReserved & CanItemBeReserved
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2021-01-14 04:54:07 UTC
Size:
3.49 KB
patch
obsolete
>From ba3a2fe79fd5505b8c925f383d28ed9cceaedac5 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 > >The rule "opacitemholds" seemed not to be controlled in some cases. >This patch adds a control for this issuingrule in such a way it is checked across all interfaces (staff, opac, api) > >To test: >0 - Apply patches >1 - Set rule to "Don't allow" item specific holds on opac >2 - Attempt to place hold on staff side >3 - Hold is still allowed >4 - Attempt to place hold from opac or api >5 - Hold is not allowed >6 - Change rule to 'force' >7 - Item-level hold can be placed in all interfaces >8 - Record-level hold cannot be placed in all interfaces > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > C4/Reserves.pm | 25 +++++++++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index a658646407..327499dcd3 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -320,6 +320,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; > > # Check that patron have not checked out this biblio (if AllowHoldsOnPatronsPossessions set) > if ( !C4::Context->preference('AllowHoldsOnPatronsPossessions') >@@ -335,9 +337,13 @@ 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 { status => 'OK' } if $canReserve->{status} eq 'recordHoldsOnly'; > } > return $canReserve; > } >@@ -442,10 +448,11 @@ sub CanItemBeReserved { > categorycode => $borrower->{'categorycode'}, > itemtype => $item->effective_itemtype, > branchcode => $branchcode, >- rules => ['holds_per_record','holds_per_day'] >+ rules => ['holds_per_record','holds_per_day','opacitemholds'] > }); > my $holds_per_record = $rights->{holds_per_record} // 1; > my $holds_per_day = $rights->{holds_per_day}; >+ my $opacitemholds = $rights->{opacitemholds} // 'Y'; > > my $search_params = { > borrowernumber => $borrowernumber, >@@ -454,6 +461,16 @@ sub CanItemBeReserved { > $search_params->{found} = undef if $params->{ignore_found_holds}; > > my $holds = Koha::Holds->search($search_params); >+ >+ $item = Koha::Items->find( $itemnumber ); >+ >+ $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 }; >@@ -574,7 +591,11 @@ sub CanItemBeReserved { > } > } > >- return { status => 'OK' }; >+ if ( $opacitemholds eq "N" ) { >+ return { status => "recordHoldsOnly", right => $rights }; >+ } >+ >+ return { status => 'OK', rights => $rights }; > } > > =head2 CanReserveBeCanceledFromOpac >-- >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
|
165442
|
165443
|
165444
|
165445