1 package OpenILS::Application::Trigger::Reactor;
2 use strict; use warnings;
5 use DateTime::Format::ISO8601;
6 use OpenSRF::Utils qw/:datetime/;
7 use OpenSRF::Utils::Logger qw(:logger);
8 use OpenILS::Application::AppUtils;
9 my $U = 'OpenILS::Application::AppUtils';
11 sub fourty_two { return 42 }
12 sub NOOP_True { return 1 }
13 sub NOOP_False { return 0 }
18 # helper functions inserted into the TT environment
21 # turns a date into something TT can understand
24 $date = DateTime::Format::ISO8601->new->parse_datetime(clense_ISO8601($date));
26 "%0.2d:%0.2d:%0.2d %0.2d-%0.2d-%0.4d",
36 # escapes a string for inclusion in an XML document. escapes &, <, and > characters
39 $str =~ s/&/&/sog;
45 # returns the calculated user locale
46 get_user_locale => sub {
48 return $U->get_user_locale($user_id);
51 # returns the calculated copy price
52 get_copy_price => sub {
54 return $U->get_copy_price($copy_id);
57 # returns the org unit setting value
58 get_org_setting => sub {
59 my($org_id, $setting) = @_;
60 return $U->ou_ancestor_setting_value($org_id, $setting);
65 # processes templates. Returns template output on success, undef on error
69 return undef unless $env->{template};
72 my $tt = Template->new;
73 $env->{helpers} = $_TT_helpers;
75 $tt->process(\$env->{template}, $env, \$output) or
76 $logger->error("Error processing Trigger template: " . $tt->error);