From 1438791250621e5f089b2b1ed9292862d6c4fbcd Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Tue, 8 Aug 2017 21:23:44 -0400 Subject: [PATCH] LP 1694058: Add backend code to allow multiple hold placement. We add a constant for the circ.holds.max_duplicate_holds setting. We modify Holds.pm to check if we're placing a title or metarecord hold, that we have the CREATE_DUPLICATE_HOLDS permission, and that we haven't placed more than the maximum allowed number of duplicate holds before returning the HOLD_EXISTS event. Signed-off-by: Jason Stephenson Signed-off-by: Kathy Lussier --- .../src/perlmods/lib/OpenILS/Application/Circ/Holds.pm | 10 +++++++++- Open-ILS/src/perlmods/lib/OpenILS/Const.pm | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index c46ad21c21..350fde2229 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -294,7 +294,15 @@ sub create_hold { $sargs->{holdable_formats} = $hold->holdable_formats if $t eq 'M'; my $existing = $e->search_action_hold_request($sargs); - push( @events, OpenILS::Event->new('HOLD_EXISTS')) if @$existing; + if (@$existing) { + # See if the requestor has the CREATE_DUPLICATE_HOLDS perm. + my $can_dup = $e->allowed('CREATE_DUPLICATE_HOLDS', $recipient->home_ou); + # How many are allowed. + my $num_dups = $U->ou_ancestor_setting_value($recipient->home_ou, OILS_SETTING_MAX_DUPLICATE_HOLDS, $e) || 0; + push( @events, OpenILS::Event->new('HOLD_EXISTS')) + unless (($t eq 'T' || $t eq 'M') && $can_dup && scalar(@$existing) < $num_dups); + # Note: We check for @$existing < $num_dups because we're adding a hold with this call. + } my $checked_out = hold_item_is_checked_out($e, $recipient->id, $hold->hold_type, $hold->target); push( @events, OpenILS::Event->new('HOLD_ITEM_CHECKED_OUT')) if $checked_out; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Const.pm b/Open-ILS/src/perlmods/lib/OpenILS/Const.pm index c568d89e1e..7c5fb7b2dc 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Const.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Const.pm @@ -96,6 +96,7 @@ econst OILS_SETTING_RESTORE_OVERDUE_ON_LOST_RETURN => 'circ.restore_overdue econst OILS_SETTING_LOST_IMMEDIATELY_AVAILABLE => 'circ.lost_immediately_available'; econst OILS_SETTING_BLOCK_HOLD_FOR_EXPIRED_PATRON => 'circ.holds.expired_patron_block'; econst OILS_SETTING_GENERATE_OVERDUE_ON_LOST_RETURN => 'circ.lost.generate_overdue_on_checkin'; +econst OILS_SETTING_MAX_DUPLICATE_HOLDS => 'circ.holds.max_duplicate_holds'; -- 2.43.2