LP 1694058: Add backend code to allow multiple hold placement.
authorJason Stephenson <jason@sigio.com>
Wed, 9 Aug 2017 01:23:44 +0000 (21:23 -0400)
committerKathy Lussier <klussier@masslnc.org>
Wed, 21 Feb 2018 21:56:11 +0000 (16:56 -0500)
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 <jason@sigio.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/perlmods/lib/OpenILS/Const.pm

index c46ad21..350fde2 100644 (file)
@@ -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;
index c568d89..7c5fb7b 100644 (file)
@@ -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';