From 5234c9964c954a68ad431cde06012ec662f56bd6 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 12 Jul 2005 20:03:54 +0000 Subject: [PATCH] added hold update and cancel code.. git-svn-id: svn://svn.open-ils.org/ILS/trunk@1156 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Circ/Holds.pm | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 1024a0374b..6edd5a4c8e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -189,6 +189,75 @@ sub retrieve_holds { } +__PACKAGE__->register_method( + method => "cancel_hold", + api_name => "open-ils.circ.hold.cancel", + notes => <<" NOTE"); + Cancels the specified hold. The login session + is the requestor and if the requestor is different from the usr field + on the hold, the requestor must have CANCEL_HOLDS permissions. + NOTE + +sub cancel_hold { + my($self, $client, $login_session, $hold) = @_; + + my $user = $apputils->check_user_session($login_session); + + if($user->id ne $hold->usr) { + if($apputils->check_user_perms($user->id, $user->home_ou, "CANCEL_HOLDS")) { + return OpenILS::Perm->new("CANCEL_HOLDS"); + } + } + + use Data::Dumper; + warn "Cancelling hold: " . Dumper($hold) . "\n"; + + my $session = OpenSRF::AppSession->create("open-ils.storage"); + my $req = $session->request( + "open-ils.storage.direct.action.hold_request.delete", + $hold ); + my $h = $req->gather(1); + + warn "[$h] returned from hold_request delete\n"; + $session->disconnect(); + return $h; +} + + +__PACKAGE__->register_method( + method => "update_hold", + api_name => "open-ils.circ.hold.update", + notes => <<" NOTE"); + Updates the specified hold. The login session + is the requestor and if the requestor is different from the usr field + on the hold, the requestor must have UPDATE_HOLDS permissions. + NOTE + +sub update_hold { + my($self, $client, $login_session, $hold) = @_; + + my $user = $apputils->check_user_session($login_session); + + if($user->id ne $hold->usr) { + if($apputils->check_user_perms($user->id, $user->home_ou, "UPDATE_HOLDS")) { + return OpenILS::Perm->new("UPDATE_HOLDS"); + } + } + + use Data::Dumper; + warn "Updating hold: " . Dumper($hold) . "\n"; + + my $session = OpenSRF::AppSession->create("open-ils.storage"); + my $req = $session->request( + "open-ils.storage.direct.action.hold_request.update", $hold ); + my $h = $req->gather(1); + + warn "[$h] returned from hold_request update\n"; + $session->disconnect(); + return $h; +} + + 1; -- 2.43.2