Add better feedback for schedule, test and cancel operations.

This commit is contained in:
Martin Kamerbeek 2010-06-02 18:09:55 +02:00
parent 6010aa947f
commit 62dd81a165
3 changed files with 83 additions and 17 deletions

View file

@ -247,6 +247,7 @@ sub queueEmails {
recipientEmail => undef, recipientEmail => undef,
isTest => 0, isTest => 0,
} ); } );
} }
return; return;
@ -272,6 +273,15 @@ sub queueScheduled {
return; return;
} }
#----------------------------------------------------------------------------
sub renderInConsole {
my $self = shift;
my $content = shift;
my $title = shift;
return WebGUI::Mailing::Admin->new($self->session)->getAdminConsole->render( $content, $title );
}
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
sub send { sub send {
my $self = shift; my $self = shift;
@ -321,17 +331,24 @@ sub sendQueuedEmails {
sub www_cancel { sub www_cancel {
my $self = shift; my $self = shift;
my $session = $self->session; my $session = $self->session;
my $admin = WebGUI::Mailing::Admin->new( $session );
my $i18n = WebGUI::International->new( $session, 'MailingManager' ); my $i18n = WebGUI::International->new( $session, 'MailingManager' );
return $admin->adminConsole->render( if ( $self->canCancel ) {
sprintf( $i18n->get( 'cannot cancel mailing' ), $self->getId ), $self->cancel;
$i18n->get( 'error' )
) unless $self->canCancel;
$self->cancel; return $self->renderInConsole(
$i18n->get('cancel mailing success'),
$i18n->get('cancel mailing'),
);
}
else {
return $self->renderInConsole(
$i18n->get('cancel mailing failure'),
$i18n->get('cancel mailing'),
);
}
return WebGUI::Mailing::Admin->new($session)->www_view; return;
} }
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -546,9 +563,7 @@ sub www_sendBatch {
extras => qq{onclick="window.location='$cancelUrl'" class="backwardButton"}, extras => qq{onclick="window.location='$cancelUrl'" class="backwardButton"},
); );
return WebGUI::Mailing::Admin->new($session)->getAdminConsole->render( $f->print, 'Send test emails' ); return $self->renderInConsole( $f->print, $i18n->get('schedule mailing') );
return WebGUI::Mailing::Admin->new($session)->getAdminConsole->render( $f->print, $i18n->get('schedule mailing') );
} }
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -579,6 +594,7 @@ sub www_sendBatchConfirm {
my $self = shift; my $self = shift;
my $session = $self->session; my $session = $self->session;
my $form = $session->form; my $form = $session->form;
my $i18n = WebGUI::International->new( $session, 'MailingManager' );
my $scheduled = $form->dateTime( 'sendDate' ); my $scheduled = $form->dateTime( 'sendDate' );
@ -589,7 +605,13 @@ sub www_sendBatchConfirm {
$self->schedule( $scheduled ); $self->schedule( $scheduled );
return WebGUI::Mailing::Admin->new( $session )->www_view; return $self->renderInConsole(
sprintf( $i18n->get('schedule mailing success'),
$session->datetime->epochToHuman( $scheduled ),
$session->url->page('newsletter=manage'),
),
$i18n->get( 'schedule mailing' )
);
} }
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -646,7 +668,7 @@ sub www_sendTestEmails {
extras => qq{onclick="window.location='$cancelUrl'" class="backwardButton"}, extras => qq{onclick="window.location='$cancelUrl'" class="backwardButton"},
); );
return WebGUI::Mailing::Admin->new($session)->getAdminConsole->render( $f->print, 'Send test emails' ); return $self->renderInConsole( $f->print, $i18n->get('send test mails') );
} }
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -654,13 +676,23 @@ sub www_sendTestEmailsConfirm {
my $self = shift; my $self = shift;
my $session = $self->session; my $session = $self->session;
my $form = $session->form; my $form = $session->form;
my $i18n = WebGUI::International->new( $session, 'MailingManager' );
my $to = $form->get( 'to' ); my $to = $form->get( 'to' );
my @userIds = $form->selectList( 'userIds' ); my @userIds = $form->selectList( 'userIds' );
$self->queueTestEmails( $to, \@userIds ); $self->queueTestEmails( $to, \@userIds );
return WebGUI::Mailing::Admin->new( $session )->www_view; return $self->renderInConsole(
sprintf( $i18n->get('send test mail success'),
scalar( @userIds ),
$to,
$session->url->page('newsletter=manage'),
),
$i18n->get( 'send test mails' )
);
} }
1; 1;

View file

@ -1,4 +1,4 @@
package WebGUI::i18n::English::MailingManager; package WebGUI::i18n::Dutch::MailingManager;
use strict; use strict;
@ -65,6 +65,23 @@ our $I18N = {
message => 'Afbreken', message => 'Afbreken',
}, },
'send test mail success' => {
message => qq{<p>Er zijn %i testemails klaargezet om verstuurd te worden naar %s.</p><p><a href="%s">Terug naar mailingbeheer.</a></p>},
},
'schedule mailing success' => {
message => qq{<p>Deze mailing is geplanned om verzonden te worden op %s.</p><p><a href="%s">Terug naar mailingbeheer.</a></p>},
},
'cancel mailing' => {
message => 'Mailing afbreken',
},
'cancel mailing success' => {
message => 'De mailing is afgebroken.',
},
'cancel mailing failure' => {
message => 'De mailing kan niet afgebroken worden. Dit kan voorkomen als de mailing geplanned stond om verzonden te worden vlak voor het moment waarop deze afgebroken werd.',
},
}; };
1; 1;

View file

@ -27,9 +27,6 @@ our $I18N = {
message => 'Bounce score', message => 'Bounce score',
}, },
'cannot cancel' => {
message => 'Cannot cancel mailing \'%s\'.',
},
'error' => { 'error' => {
message => 'An error occurred', message => 'An error occurred',
}, },
@ -65,6 +62,26 @@ our $I18N = {
message => 'Cancel', message => 'Cancel',
}, },
'send test mail' => {
message => 'Send test emails',
},
'send test mail success' => {
message => qq{<p>%i test emails have been queued for sending to %s.</p><p><a href="%s">Back to mailing manager.</a></p>},
},
'schedule mailing success' => {
message => qq{This mailing is successfully scheduled for distribution on %s.</p><p><a href="%s">Back to mailing manager.</a></p>},
},
'cancel mailing' => {
message => 'Cancel mailing',
},
'cancel mailing success' => {
message => 'The mailing has sucessfully been canceled.',
},
'cancel mailing failure' => {
message => 'The mailing could not be canceled. This can happen when the mailing has been scheduled just before it was canceled.',
},
}; };
1; 1;