plugging in TT; a bit of documentation in the ABOUT() sub. I suggest this as convention
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Feb 2009 05:33:31 +0000 (05:33 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Feb 2009 05:33:31 +0000 (05:33 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12295 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor/StaticEmail.pm

index 634dc70..556afc8 100644 (file)
@@ -9,13 +9,29 @@ use base 'OpenILS::Application::Trigger::Reactor';
 my $log = 'OpenSRF::Utils::Logger';
 
 my $default_template = <<TT;
-To: [%- env.params.recipient -%]
-From: [%- env.params.sender -%]
-Subject: [%- env.params.subject -%]
+To: [%- params.recipient -%]
+From: [%- params.sender -%]
+Subject: [%- params.subject -%]
 
-[% env.params.body %]
+[% params.body %]
 TT
 
+sub ABOUT {
+    return <<ABOUT;
+
+The StagicEmail Reactor Module sends an email to the address specified by the
+"recipient" parameter.  This is the only required parameter (in fact the
+template is not even required), though sender, subject and body parameters are
+also accepted and used by the default template.
+
+The default template looks like:
+-------
+$default_template
+-------
+
+ABOUT
+}
+
 sub handler {
     my $self = shift;
     my $env = shift;
@@ -25,17 +41,19 @@ sub handler {
     $$env{params}{sender} ||= $conf->config_value('email_notify', 'sender_address');
     $$env{params}{subject} ||= 'Test subject -- StaticEmail Reactor';
     $$env{params}{body} ||= 'Test body -- StaticEmail Reactor';
+    $$env{template} ||= $default_template;
 
     $$env{params}{recipient} or return 0;
 
+    my $text = $self->run_TT($env);
+    return 0 if (!$text);
+
     $logger->info("StaticEmail Reactor: sending email to ".
         $$env{params}{recipient}." via SMTP server $smtp");
 
     my $sender = Email::Send->new({mailer => 'SMTP'});
     $sender->mailer_args([Host => $smtp]);
 
-    my $TT = $$env{template} || $default_template;
-    my $text = ''; # XXX TemplateToolkit stuff goes here...
 
     my $stat;
     my $err;