From aff6b5d5d0d3d6417fd67b9ae07ba5b15ef88cf0 Mon Sep 17 00:00:00 2001 From: Martin Kamerbeek Date: Thu, 6 May 2010 18:05:18 +0200 Subject: [PATCH] Add mailing send workflow activity. --- .../Workflow/Activity/SendQueuedMailings.pm | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 lib/WebGUI/Workflow/Activity/SendQueuedMailings.pm diff --git a/lib/WebGUI/Workflow/Activity/SendQueuedMailings.pm b/lib/WebGUI/Workflow/Activity/SendQueuedMailings.pm new file mode 100644 index 0000000..078cfd1 --- /dev/null +++ b/lib/WebGUI/Workflow/Activity/SendQueuedMailings.pm @@ -0,0 +1,66 @@ +package WebGUI::Workflow::Activity::SendQueuedMailings; + +use base 'WebGUI::Workflow::Activity'; + +#------------------------------------------------------------------- + +=head2 definition ( session, definition ) + +See WebGUI::Workflow::Activity::definition() for details. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift; + + push( @{ $definition }, { + name => 'Send queued newsletter mailings', +# properties => { +# someField => { +# fieldType=>"integer", +# label=>"Some Field", +# defaultValue=>0, +# hoverHelp=>"Hover help for some field." +# }, +# } + } ); + + return $class->SUPER::definition( $session, $definition ); +} + + +#------------------------------------------------------------------- + +=head2 execute ( [ object ] ) + +See WebGUI::Workflow::Activity::execute() for details. + +=cut + +sub execute { + my $self = shift; + my $object = shift; + my $instance = shift; + my $session = $self->session; + + my $maxTime = time + $self->getTTL; + + # For now only process test mails. + my $it = WebGUI::Mailing::Email->getQueuedTestEmails( $session ); + + while ( my $email = $it->() ) { + return $self->WAITING(1) if time >= $maxTime; + + $email->send; + } + + return $self->COMPLETE; +} + + + +1; + +#vim:ft=perl