Improved robustness and reload protection.

This commit is contained in:
Martin Kamerbeek 2010-07-07 12:21:16 +02:00
parent a858e8fb44
commit 913b4710e9
2 changed files with 23 additions and 4 deletions

View file

@ -21,7 +21,15 @@ sub handler {
my $func = 'www_' . ( $form->get('func') || 'view' );
my $id = $form->get('id');
my $object = WebGUI::Pluggable::instanciate( $class, 'new', [ $session, $id ] );
my $object = eval { WebGUI::Pluggable::instanciate( $class, 'new', [ $session, $id ] ) };
if ( $@ || !$object ) {
my $ac = WebGUI::AdminConsole->new( $session );
my $output = "Unable to instanciate object of class [$class] with id [$id] because: $@";
return $ac->render( $output, 'Error' );
};
return $object->$func if $object->can( $func );
return;

View file

@ -376,6 +376,16 @@ sub www_cancel {
return;
}
#----------------------------------------------------------------------------
sub redirectToManager {
my $self = shift;
my ( $http, $url ) = $self->session->quick( qw{http url} );
$http->setRedirect( $url->page('newsletter=manage') );
return 'redirect';
}
#----------------------------------------------------------------------------
sub www_delete {
my $self = shift;
@ -385,7 +395,7 @@ sub www_delete {
$self->delete;
return WebGUI::Mailing::Admin->new($session)->www_view;
return $self->redirectToManager;
}
#----------------------------------------------------------------------------
@ -581,7 +591,9 @@ sub www_editSave {
#### TODO: Add error checking and required fields?
$self->update( { configuration => $configuration } );
return WebGUI::Mailing::Admin->new( $session )->www_view;
my $url = $session->url;
return $self->redirectToManager;
}
#----------------------------------------------------------------------------
@ -753,7 +765,6 @@ sub www_sendTestEmailsConfirm {
$i18n->get( 'send test mails' )
);
}
1;