From 1e852d226bb0784c403614d1a5c73775bc26d795 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 13 Mar 2006 16:29:04 +0000 Subject: [PATCH] added method to create and retrieve hold notifications git-svn-id: svn://svn.open-ils.org/ILS/trunk@3343 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Circ/Holds.pm | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 25bc1f00a0..f77307441a 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -500,6 +500,68 @@ sub hold_pull_list { $reqr->home_ou, $limit, $offset ); # XXX change to workstation } +__PACKAGE__->register_method ( + method => 'fetch_hold_notify', + api_name => 'open-ils.circ.hold_notification.retrieve_by_hold', + signature => q/ + Returns a list of hold notification objects based on hold id. + @param authtoken The loggin session key + @param holdid The id of the hold whose notifications we want to retrieve + @return An array of hold notification objects, event on error. + / +); + +sub fetch_hold_notify { + my( $self, $conn, $authtoken, $holdid ) = @_; + my( $requestor, $evt ) = $U->checkses($authtoken); + return $evt if $evt; + my ($hold, $patron); + ($hold, $evt) = $U->fetch_hold($holdid); + return $evt if $evt; + ($patron, $evt) = $U->fetch_user($hold->usr); + return $evt if $evt; + + $evt = $U->check_perms($requestor->id, $patron->home_ou, 'VIEW_HOLD_NOTIFICATION'); + return $evt if $evt; + + $logger->info("User ".$requestor->id." fetching hold notifications for hold $holdid"); + return $U->storagereq( + 'open-ils.storage.direct.action.hold_notification.search.hold.atomic', $holdid ); +} + + +__PACKAGE__->register_method ( + method => 'create_hold_notify', + api_name => 'open-ils.circ.hold_notification.create', + signature => q/ + Creates a new hold notification object + @param authtoken The login session key + @param notification The hold notification object to create + @return ID of the new object on success, Event on error + / +); +sub create_hold_notify { + my( $self, $conn, $authtoken, $notification ) = @_; + my( $requestor, $evt ) = $U->checkses($authtoken); + return $evt if $evt; + my ($hold, $patron); + ($hold, $evt) = $U->fetch_hold($notification->hold); + return $evt if $evt; + ($patron, $evt) = $U->fetch_user($hold->usr); + return $evt if $evt; + + $evt = $U->check_perms($requestor->id, $patron->home_ou, 'CREATE_HOLD_NOTIFICATION'); + return $evt if $evt; + + # Set the proper notifier + $notification->notify_staff($requestor->id); + my $id = $U->storagereq( + 'open-ils.storage.direct.action.hold_notification.create', $notification ); + return $U->DB_UPDATE_FAILED($notification) unless $id; + $logger->info("User ".$requestor->id." successfully created new hold notification $id"); + return $id; +} + 1; -- 2.43.2