Implement cancel functionality.

This commit is contained in:
Martin Kamerbeek 2010-05-20 15:49:26 +02:00
parent 55934b11f5
commit ddaaebe6a0
2 changed files with 30 additions and 0 deletions

View file

@ -8,6 +8,24 @@ use WebGUI::Mailing::Admin;
use base 'WebGUI::Crud';
sub canCancel {
my $self = shift;
return 1 if $self->get('state') eq 'scheduled';
return 0;
}
sub cancel {
my $self = shift;
$self->update( {
state => 'idle',
sendDate => undef,
} );
return;
}
sub crud_definition {
my $class = shift;
my $session = shift;
@ -162,6 +180,17 @@ sub sendQueuedEmails {
return 1;
}
sub www_cancel {
my $self = shift;
my $session = $self->session;
return 'Cannot cancel mailing ['.$self->getId.']' unless $self->canCancel;
$self->cancel;
return WebGUI::Mailing::Admin->new($session)->www_view;
}
sub www_delete {
my $self = shift;
my $session = $self->session;

View file

@ -129,6 +129,7 @@ sub www_view {
editUrl => $url->page('newsletter=mailing;func=edit;id='.$mailing->getId ),
deleteUrl => $url->page('newsletter=mailing;func=delete;id='.$mailing->getId ),
previewUrl => $url->page('newsletter=mailing;func=previewEmail;id='.$mailing->getId ),
cancelUrl => $url->page('newsletter=mailing;func=cancel;id='.$mailing->getId ),
};
};