Bugzilla – Attachment 91591 Details for
Bug 11999
Add two checks in CanBookBeReserved and CanItemBeReserved
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11999: Add maxreserves check in CanBookBeReserved and CanItemBeReserved
Bug-11999-Add-maxreserves-check-in-CanBookBeReserv.patch (text/plain), 4.47 KB, created by
Arthur Suzuki
on 2019-07-18 14:48:52 UTC
(
hide
)
Description:
Bug 11999: Add maxreserves check in CanBookBeReserved and CanItemBeReserved
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2019-07-18 14:48:52 UTC
Size:
4.47 KB
patch
obsolete
>From ba4d32cc38b119b7153449ed3984156aa63f0c4f Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 26 Mar 2014 10:51:59 +0100 >Subject: [PATCH] Bug 11999: Add maxreserves check in CanBookBeReserved and > CanItemBeReserved > >- Check if borrower has reached the maximum number of holds allowed > (syspref maxreserves) > >The goal of this patch is to do these checks also when using ILS-DI >services HoldTitle and HoldItem > >Test plan: >---------- >Before patch: >1/ Set syspref maxreserves to 1 >2/ Place some holds through ILS-DI and note that you can place more than > 1 hold for a borrower > >Apply the patch >3/ Place some holds through ILS-DI, you shouldn't be able to place more > than 1 hold for a borrower >4/ Try to place holds on staff interface and OPAC. The behaviour must be > identical than before the patch. > >Maxreserves and alreadyreserved works on ILSDI >Maxreserves works also on staff and opac >Already reserves works also on staff and opac >tests on t/db_dependent/Reserves.t and t/db_dependent/Holds.t passe (using koha_ut db) > >Signed-off-by: Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com> >Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com> >--- > C4/Reserves.pm | 23 +++++++++++++++++++++-- > reserve/request.pl | 4 +++- > 2 files changed, 24 insertions(+), 3 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 5fc68f1359..bd888fd187 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -274,7 +274,17 @@ See CanItemBeReserved() for possible return values. > sub CanBookBeReserved{ > my ($borrowernumber, $biblionumber, $pickup_branchcode) = @_; > >+ my $patron = Koha::Patrons->find($borrowernumber); >+ my $holds = $patron->holds; >+ >+ # Check if borrower has reached the maximum number of holds allowed >+ my $maxreserves = C4::Context->preference('maxreserves'); >+ if ($maxreserves && $holds->count >= $maxreserves) { >+ return { status => 'tooManyReserves' }; >+ } >+ > my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); >+ > #get items linked via host records > my @hostitems = get_hostitemnumbers_of($biblionumber); > if (@hostitems){ >@@ -286,7 +296,8 @@ sub CanBookBeReserved{ > $canReserve = CanItemBeReserved( $borrowernumber, $itemnumber, $pickup_branchcode ); > return { status => 'OK' } if $canReserve->{status} eq 'OK'; > } >- return $canReserve; >+ >+ return { status => 'none_available' }; > } > > =head2 CanItemBeReserved >@@ -303,6 +314,7 @@ sub CanBookBeReserved{ > { status => libraryNotFound }, if given branchcode is not an existing library > { status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location > { status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode >+ { status => alreadyReserved }, if the borrower has already reserved this item. > > =cut > >@@ -336,6 +348,13 @@ sub CanItemBeReserved { > return { status =>'itemAlreadyOnHold' } > if Koha::Holds->search( { borrowernumber => $borrowernumber, itemnumber => $itemnumber } )->count(); > >+ # Check if borrower has reached the maximum number of holds allowed >+ my $maxreserves = C4::Context->preference('maxreserves'); >+ my $holds = Koha::Holds->search( { borrowernumber => $borrowernumber } ); >+ if ($maxreserves && $holds->count >= $maxreserves) { >+ return { status => 'tooManyReserves', limit => $maxreserves }; >+ } >+ > my $controlbranch = C4::Context->preference('ReservesControlBranch'); > > my $querycount = q{ >@@ -370,7 +389,7 @@ sub CanItemBeReserved { > $ruleitemtype = '*'; > } > >- my $holds = Koha::Holds->search( >+ $holds = Koha::Holds->search( > { > borrowernumber => $borrowernumber, > biblionumber => $item->biblionumber, >diff --git a/reserve/request.pl b/reserve/request.pl >index df9cae861d..5f775b3e73 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -240,7 +240,9 @@ foreach my $biblionumber (@biblionumbers) { > $exceeded_holds_per_record = 1; > $biblioloopiter{ $canReserve->{status} } = 1; > } >- elsif ( $canReserve->{status} eq 'ageRestricted' ) { >+ elsif ( grep { $canReserve->{status} eq $_ } >+ (qw(ageRestricted alreadyReserved none_available)) ) >+ { > $template->param( $canReserve->{status} => 1 ); > $biblioloopiter{ $canReserve->{status} } = 1; > } >-- >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 11999
:
26589
|
28986
|
31524
|
35697
|
36358
|
36404
|
36630
|
38397
|
41951
|
41952
|
44631
|
44632
|
46262
|
46263
|
50224
|
50225
|
58741
|
58742
|
58743
|
63593
|
63594
|
63595
|
66267
|
66268
|
66269
|
66270
|
88300
|
88301
|
88302
|
88303
|
90142
|
90143
|
90144
|
90146
|
90147
|
91046
|
91402
|
91403
|
91479
|
91481
|
91494
|
91580
|
91581
|
91582
|
91590
|
91591
|
91592
|
91593
|
99927
|
99928
|
106481
|
106494
|
111687
|
111688
|
111689
|
112871
|
112872
|
112873
|
112874
|
120776
|
120777
|
120778
|
120779
|
120780
|
121531
|
121612