[open-ils-commits] r9199 - branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Circ

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 2 16:37:08 EDT 2008


Author: erickson
Date: 2008-04-02 16:00:48 -0400 (Wed, 02 Apr 2008)
New Revision: 9199

Modified:
   branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Log:
added logic to run the hold targeter if a hold is un-frozen by the user

Modified: branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2008-04-02 19:52:09 UTC (rev 9198)
+++ branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm	2008-04-02 20:00:48 UTC (rev 9199)
@@ -517,6 +517,12 @@
     my $e = new_editor(authtoken=>$auth, xact=>1);
     return $e->die_event unless $e->checkauth;
 
+    my $orig_hold = $e->retrieve_action_hold_request($hold->id)
+        or return $e->die_event;
+
+    # don't allow the user to be changed
+    return OpenILS::Event->new('BAD_PARAMS') if $hold->usr != $orig_hold->usr;
+
     if($hold->usr ne $e->requestor->id) {
         # if the hold is for a different user, make sure the 
         # requestor has the appropriate permissions
@@ -525,12 +531,8 @@
         return $e->die_event unless $e->allowed('UPDATE_HOLD', $usr->home_ou);
     }
 
-    my $evt = $self->update_hold_if_frozen($e, $hold);
-    return $evt if $evt;
-
-    $e->update_action_hold_request($hold)
-        or return $e->die_event;
-
+    $self->update_hold_if_frozen($e, $hold, $orig_hold);
+    $e->update_action_hold_request($hold) or return $e->die_event;
     $e->commit;
     return $hold->id;
 }
@@ -538,17 +540,22 @@
 
 # if the hold is frozen, this method ensures that the hold is not "targeted", 
 # that is, it clears the current_copy and prev_check_time to essentiallly 
-# reset the hold
+# reset the hold.  If it is being activated, it runs the targeter in the background
 sub update_hold_if_frozen {
-    my($self, $e, $hold) = @_;
-    return undef if $hold->capture_time;
-    if($hold->frozen and ($hold->current_copy or $hold->prev_check_time)) {
-        $logger->info("clearing current_copy and check_time for frozen hold");
+    my($self, $e, $hold, $orig_hold) = @_;
+    return if $hold->capture_time;
+
+    if($U->is_true($hold->frozen)) {
+        $logger->info("clearing current_copy and check_time for frozen hold ".$hold->id);
         $hold->clear_current_copy;
         $hold->clear_prev_check_time;
-        $e->update_action_hold_request($hold) or return $e->die_event;
+
+    } else {
+        if($U->is_true($orig_hold->frozen)) {
+            $logger->info("Running targeter on activated hold ".$hold->id);
+	        $U->storagereq( 'open-ils.storage.action.hold_request.copy_targeter', undef, $hold->id );
+        }
     }
-    return undef;
 }
 
 



More information about the open-ils-commits mailing list