added a batch/streaming version of the uber-hold retrieval call
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 18 Nov 2009 21:02:42 +0000 (21:02 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 18 Nov 2009 21:02:42 +0000 (21:02 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14957 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm

index 1ec30c6..b8d08d7 100644 (file)
@@ -960,7 +960,7 @@ sub retrieve_hold_queue_status_impl {
     return {
         total_holds => scalar(@$q_holds),
         queue_position => $qpos,
-        potential_copies => $num_potentials,
+        potential_copies => $num_potentials->{count},
         status => _hold_status($e, $hold),
         estimated_wait => int($estimated_wait)
     };
@@ -1908,7 +1908,26 @@ sub uber_hold {
        my($self, $client, $auth, $hold_id) = @_;
        my $e = new_editor(authtoken=>$auth);
        $e->checkauth or return $e->event;
-       $e->allowed('VIEW_HOLD') or return $e->event;
+    return uber_hold_impl($e, $hold_id);
+}
+
+__PACKAGE__->register_method(
+       method => 'batch_uber_hold',
+    authoritative => 1,
+    stream => 1,
+       api_name => 'open-ils.circ.hold.details.batch.retrieve'
+);
+
+sub batch_uber_hold {
+       my($self, $client, $auth, $hold_ids) = @_;
+       my $e = new_editor(authtoken=>$auth);
+       $e->checkauth or return $e->event;
+    $client->respond(uber_hold_impl($e, $_)) for @$hold_ids;
+    return undef;
+}
+
+sub uber_hold_impl {
+    my($e, $hold_id) = @_;
 
        my $resp = {};
 
@@ -1922,6 +1941,11 @@ sub uber_hold {
                ]
        ) or return $e->event;
 
+    if($hold->usr->id ne $e->requestor->id) {
+        # A user is allowed to see his/her own holds
+           $e->allowed('VIEW_HOLD') or return $e->event;
+    }
+
        my $user = $hold->usr;
        $hold->usr($user->id);