From 39fbd09f6121c5dc9014c52bc47b8e74c31461aa Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 11 Dec 2012 11:57:42 -0500 Subject: [PATCH] Additional action/trigger helper functions Added to the 'helpers' environment for action/trigger templates * get_org_unit -- get org object from id * escape_csv -- escapes strings ia csv values * get_user_setting Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../OpenILS/Application/Trigger/Reactor.pm | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm index 62ca21b7d0..7be19932ad 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm @@ -98,6 +98,12 @@ $_TT_helpers = { return $U->get_copy_price(new_editor(xact=>1), $copy_id); }, + get_org_unit => sub { + my $org_id = shift; + return $org_id if ref $org_id; + return new_editor()->retrieve_actor_org_unit($org_id); + }, + # given a copy, returns the title and author in a hash get_copy_bib_basics => sub { my $copy_id = shift; @@ -165,6 +171,14 @@ $_TT_helpers = { return $U->ou_ancestor_setting_value($org_id, $setting); }, + get_user_setting => sub { + my ($user_id, $setting) = @_; + my $val = new_editor()->search_actor_user_setting( + {usr => $user_id, name => $setting})->[0]; + return undef unless $val; + return OpenSRF::Utils::JSON->JSON2perl($val->value); + }, + # This basically greps/maps out ths isbn string values, but also promotes the first isbn-13 to the # front of the line (so that the EDI translator takes it as primary) if there is one. get_li_isbns => sub { @@ -372,6 +386,13 @@ $_TT_helpers = { my $unapi = new_editor()->json_query($query); return undef unless @$unapi; return $_TT_helpers->{xml_doc}->($unapi->[0]->{'unapi.bre'}); + }, + + # escapes quotes in csv string values + escape_csv => sub { + my $string = shift; + $string =~ s/"/""/og; + return $string; } }; -- 2.43.2