From c165eff05f534e5c20305764380899606fa0ac7d Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 4 Aug 2006 20:45:08 +0000 Subject: [PATCH] added slimmed down user note creater git-svn-id: svn://svn.open-ils.org/ILS/trunk@5309 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Collections.pm | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Collections.pm b/Open-ILS/src/perlmods/OpenILS/Application/Collections.pm index c1e70dab63..8e480611e8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Collections.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Collections.pm @@ -592,4 +592,67 @@ sub fetch_active { return \@active; } + +__PACKAGE__->register_method( + method => 'create_user_note', + api_name => 'open-ils.collections.patron_note.create', + api_level => 1, + argc => 4, + signature => { + desc => q/ Adds a note to a patron's account /, + params => [ + { name => 'auth', + desc => 'The authentication token', + type => 'string' }, + + { name => 'user_barcode', + desc => q/The patron's barcode/, + type => q/string/, + }, + { name => 'title', + desc => q/The title of the note/, + type => q/string/, + }, + + { name => 'note', + desc => q/The text of the note/, + type => q/string/, + }, + ], + + 'return' => { + desc => q/ + Returns '1' on success, event on error. + /, + type => 'object' + } + } +); + + +sub create_user_note { + my( $self, $conn, $auth, $user_barcode, $title, $note_txt ) = @_; + + my $e = new_editor(authtoken=>$auth, xact=>1); + return $e->event unless $e->checkauth; + return $e->event unless $e->allowed('UPDATE_USER'); + + return $e->event unless + my $card = $e->search_actor_card({barcode=>$user_barcode})->[0]; + + my $note = Fieldmapper::actor::usr_note->new; + $note->usr($card->usr); + $note->title($title); + $note->creator($e->requestor->id); + $note->create_date('now'); + $note->pub('f'); + $note->value($note_txt); + + $e->create_actor_usr_note($note) or return $e->event; + $e->commit; + return 1; +} + + + 1; -- 2.11.0