]> mj.ucw.cz Git - pciids.git/blobdiff - PciIds/Html/Handler.pm
Help index
[pciids.git] / PciIds / Html / Handler.pm
index dd996ffd5b27ee674ec6e6bbdb525c8fd941e090..879086a26c4632175eb5127fc8eab119edbff926 100644 (file)
@@ -10,7 +10,7 @@ use PciIds::Html::Debug;
 use PciIds::Html::Changes;
 use PciIds::Html::Admin;
 use PciIds::Html::Notifications;
-use PciIds::Notifications;
+use PciIds::Html::Help;
 use Apache2::Const qw(:common :http);
 
 $ENV{'PATH'} = '';
@@ -23,7 +23,7 @@ my %handlers = (
                '' => \&PciIds::Html::List::list,
                #Database changes
                'newitem' => \&PciIds::Html::Changes::newItemForm,
-               'newcomment' => \&PciIds::Html::Changes::newCommentForm,
+               'newhistory' => \&PciIds::Html::Changes::newHistoryForm,
                #Registering users
                'register' => \&PciIds::Html::Users::registerForm,
                'register-confirm' => \&PciIds::Html::Users::confirmForm,
@@ -39,11 +39,12 @@ my %handlers = (
                #Some debug
                'test' => \&PciIds::Html::Debug::test,
                #Notifications
-               'notifications' => \&PciIds::Html::Notifications::notifForm
+               'notifications' => \&PciIds::Html::Notifications::notifForm,
+               'help' => \&PciIds::Html::Help::getHelp
        },
        'POST' => {
                'newitem' => \&PciIds::Html::Changes::newItemSubmit,
-               'newcomment' => \&PciIds::Html::Changes::newCommentSubmit,
+               'newhistory' => \&PciIds::Html::Changes::newHistorySubmit,
                'register' => \&PciIds::Html::Users::registerSubmit,
                'register-confirm' => \&PciIds::Html::Users::confirmSubmit,
                'login' => \&PciIds::Html::Users::loginSubmit,
@@ -57,9 +58,9 @@ my %handlers = (
 
 sub handler( $$ ) {
        my( $req, $hasSSL ) = @_;
-       return HTTPRedirect( $req, $req->uri()."index.html" ) if( $req->uri() eq '/' );
-       return DECLINED if( $req->uri() =~ /^\/((static)\/|robots.txt|index.html)/ );
        my $args = parseArgs( $req->args() );
+       return HTTPRedirect( $req, $req->uri()."index.html" ) if( $req->uri() eq '/' && ( !defined $args->{'action'} || $args->{'action'} ne 'help' ) );
+       return DECLINED if( $req->uri() =~ /^\/((static)\/|robots.txt|index.html)/ );
        my $action = $args->{'action'};
        $action = '' unless( defined $action );
        my $method = $handlers{$req->method()};
@@ -68,8 +69,15 @@ sub handler( $$ ) {
        return HTTP_BAD_REQUEST unless( defined $sub );#I do not know this action for given method
        my $auth = checkLogin( $req, $tables );#Check if logged in
        $auth->{'ssl'} = $hasSSL;
-       my $result = &{$sub}( $req, $args, $tables, $auth );#Just do the right thing
-       $tables->commit();
+       my( $result );
+       eval {
+               $result = &{$sub}( $req, $args, $tables, $auth );#Just do the right thing
+               $tables->commit();
+       };
+       if( $@ ) {
+               $tables->rollback();
+               die $@;
+       }
        return $result;
 }