X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=PciIds%2FHtml%2FChanges.pm;h=57473544d65015e33f36402dbb3d2d146a8173dd;hb=5342f8673c7aedc4d43f2fad44729e1b1d626b41;hp=a23d50dfd70ccc6aafebb68d734640110faedd60;hpb=b4d2a8f2c63d013bd0477acc3fa4549d9e8c0d0e;p=pciids.git diff --git a/PciIds/Html/Changes.pm b/PciIds/Html/Changes.pm index a23d50d..5747354 100644 --- a/PciIds/Html/Changes.pm +++ b/PciIds/Html/Changes.pm @@ -15,10 +15,9 @@ sub genNewItemForm( $$$$$$ ) { return NOT_FOUND unless( $ok ); my $prettyAddr = encode( $address->pretty() ); genHtmlHead( $req, "$prettyAddr - add new item", undef ); - print "

$prettyAddr - add new item

\n"; - genLocMenu( $req, $args, [ logItem( $auth ), $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'newitem' ], [ 'ID syntax', 'help', $address->helpName() ] ] ); + genCustomHead( $req, $args, $address, "$prettyAddr - add new item", [ $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Help', 'help', 'newitem' ], [ 'ID syntax', 'help', $address->helpName() ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); print "
$error
\n" if( defined $error ); - print "
\n"; + print "hostname().$req->uri().buildExcept( 'action', $args ).'?action=newitem' : '' )."'>\n
"; genFormEx( [ [ 'input', 'Id:', 'text', 'id', 'maxlength="50"' ], [ 'input', 'Name:', 'text', 'name', 'maxlength="200"' ], [ 'input', 'Note*:', 'text', 'note', 'maxlength="1024"' ], @@ -64,15 +63,13 @@ sub newItemSubmit( $$$$ ) { my( $result, $comName ) = $tables->submitItem( $data, $auth ); if( $result eq 'exists' ) { genHtmlHead( $req, 'ID collision', undef ); - print '

ID collision

'; my $addr = PciIds::Address::new( $req->uri() ); - genCustomMenu( $req, $addr, $args, [ logItem( $auth ), [ 'Add other item', 'newitem' ], $addr->canDiscuss() ? [ 'Discuss', 'newhistory' ] : () ] ); - genPath( $req, $data->{'address'}, 1 ); + genCustomHead( $req, $args, $addr, 'ID collision', [ [ 'Add other item', 'newitem' ], $addr->canDiscuss() ? [ 'Discuss', 'newhistory' ] : () ], [ logItem( $auth ) ] ); print '

Sorry, this ID already exists.'; genHtmlTail(); return OK; } elsif( $result ) { - die "Failed to submit new item: $result\n"; + return genNewItemForm( $req, $args, $auth, $tables, $result, $data ); } notify( $tables, $data->{'address'}->get(), $comName, 2, 0 ); tulog( $auth->{'authid'}, "Item created ".$data->{'address'}->get()." ".logEscape( $data->{'name'} )." ".logEscape( $data->{'note'} )." ".logEscape( $data->{'discussion'} )." $comName" ); @@ -88,17 +85,15 @@ sub genNewHistoryForm( $$$$$$ ) { return NOT_FOUND unless( $ok ); my $prettyAddr = encode( $address->pretty() ); genHtmlHead( $req, "$prettyAddr - discuss", undef ); - print "

$prettyAddr - discuss

\n"; - genLocMenu( $req, $args, [ logItem( $auth ), $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), [ 'Notifications', 'notifications' ], [ 'Help', 'help', 'newhistory' ] ] ); + genCustomHead( $req, $args, $address, "$prettyAddr - discuss", [ $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), [ 'Help', 'help', 'newhistory' ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); print "
$error
\n" if( defined $error ); - print "\n
"; + print "hostname().$req->uri().buildExcept( 'action', $args ).'?action=newhistory' : '' )."'>\n
"; genFormEx( [ [ 'textarea', 'Text:', undef, 'text', 'rows="5" cols="50"' ], - [ 'input', 'Name*:', 'text', 'name', 'maxlength="200"' ], - [ 'input', 'Note*:', 'text', 'note', 'maxlength="1024"' ], + [ 'input', 'Request deletion', 'checkbox', 'delete', 'value="delete"' ], + [ 'input', 'Name:', 'text', 'name', 'maxlength="200"' ], + [ 'input', 'Note:', 'text', 'note', 'maxlength="1024"' ], [ 'input', '', 'submit', 'submit', 'value="Submit"' ] ], $values ); print '
'; - print '

Items marked with * are optional, use them only if you want to change the name and note.'; - print '

If you specify note, you must include name too.'; genHtmlTail(); return OK; } @@ -123,10 +118,22 @@ sub newHistorySubmit( $$$$ ) { 'text' => sub { my( $expl ) = @_; return 'Text can not be longer than 1024 characters' if ( length $expl > 1024 ); - return 'You must provide the text of comment' unless( length $expl ); + return undef; + }, + 'delete' => sub { + my( $delete ) = @_; + return ( undef, '0' ) unless defined $delete; + return undef if $delete eq 'delete'; + return 'Invalid form value'; return undef; } }, [ sub { my( $data ) = @_; + return 'You must provide either name, text or request a deletion' if( ! length $data->{'name'} && ! length $data->{'text'} && ! $data->{'delete'} ); + return undef; + }, sub { my( $data ) = @_; + return 'You can not set name and request deletion at the same time' if( length $data->{'name'} && $data->{'delete'} ); + return undef; + }, sub { my( $data ) = @_; return 'You must provide name too' if( ( length $data->{'note'} ) && ( ! length $data->{'name'} ) ); return undef; }, sub { return $address->canDiscuss() ? undef : 'You can not discuss this item'; } ] );