From: Galen Charlton Date: Wed, 18 Feb 2015 21:39:48 +0000 (+0000) Subject: LP#1410369: add open-ils.actor method for fetching user messages X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=03efadddeb549573c23ac15272a3e5251efad8ed;p=evergreen%2Fmasslnc.git LP#1410369: add open-ils.actor method for fetching user messages This patches adds open-ils.actor.message.retrieve as an authenticated, public-router visible method for fetching patron messages belong to the authenticated user. This method exists, at present, solely for the benefit of potential third-party API users; TPac itself uses pcrud. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index be97787a27..9b4658ac28 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -2656,6 +2656,39 @@ sub update_user_note { return 1; } +__PACKAGE__->register_method( + method => 'fetch_patron_messages', + api_name => 'open-ils.actor.message.retrieve', + authoritative => 1, + signature => q/ + Returns a list of notes for a given user, not + including ones marked deleted + @param authtoken The login session key + @param patronid patron ID + @param options hash containing optional limit and offset + / +); + +sub fetch_patron_messages { + my( $self, $conn, $auth, $patronid, $options ) = @_; + + $options ||= {}; + + my $e = new_editor(authtoken => $auth); + return $e->die_event unless $e->checkauth; + + if ($e->requestor->id ne $patronid) { + return $e->die_event unless $e->allowed('VIEW_USER'); + } + + my $select_clause = { usr => $patronid }; + my $options_clause = { order_by => { aum => 'create_date DESC' } }; + $options_clause->{'limit'} = $options->{'limit'} if $options->{'limit'}; + $options_clause->{'offset'} = $options->{'offset'} if $options->{'offset'}; + + my $aum = $e->search_actor_usr_message([ $select_clause, $options_clause ]); + return $aum; +} __PACKAGE__->register_method(