From 0ea3ad56c750ff262b404ce48983349bff66fe8f Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Sat, 30 Aug 2008 19:44:18 +0200 Subject: [PATCH] Allow sending deletion requests --- PciIds/DBQ.pm | 7 ++++++- PciIds/Html/Changes.pm | 21 ++++++++++++++++----- PciIds/Html/List.pm | 3 ++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index 219bc08..b671ea2 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -199,7 +199,12 @@ sub submitItem( $$$ ) { sub submitHistory( $$$$ ) { my( $self, $data, $auth, $address ) = @_; - $self->command( 'newhistory', [ $address->get(), $auth->{'authid'}, $data->{'text'}, $data->{'name'}, $data->{'note'} ], 1 ); + if( $data->{'delete'} ) { + $self->command( 'newhistory', [ $address->get(), $auth->{'authid'}, $data->{'text'}, '', $data->{'note'} ], 1 ); + } else { + $data->{'name'} = undef if defined $data->{'name'} && $data->{'name'} eq ''; + $self->command( 'newhistory', [ $address->get(), $auth->{'authid'}, $data->{'text'}, $data->{'name'}, $data->{'note'} ], 1 ); + } return $self->last(); } diff --git a/PciIds/Html/Changes.pm b/PciIds/Html/Changes.pm index a23d50d..c03af9e 100644 --- a/PciIds/Html/Changes.pm +++ b/PciIds/Html/Changes.pm @@ -93,12 +93,11 @@ sub genNewHistoryForm( $$$$$$ ) { print "
$error
\n" if( defined $error ); print "
\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 +122,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'; } ] ); diff --git a/PciIds/Html/List.pm b/PciIds/Html/List.pm index 040d35a..e8b9a29 100644 --- a/PciIds/Html/List.pm +++ b/PciIds/Html/List.pm @@ -27,7 +27,7 @@ sub list( $$$$ ) { print '

'.encode( $id ).'

'; genMenu( $req, $address, $args, $auth, [ [ 'Help', 'help', 'list' ], $address->helpName() ? [ 'ID syntax', 'help', $address->helpName() ] : () ] ); genPath( $req, $address, 0 ); - print htmlDiv( 'name', '

'.encode( $name ) ) if( defined( $name ) ); + print htmlDiv( 'name', '

'.encode( $name ) ) if defined( $name ); print htmlDiv( 'note', '

'.encode( $note ) ) if( defined( $note ) ); my $diss = 0; my $history; @@ -41,6 +41,7 @@ sub list( $$$$ ) { $type = 'main-history' if( defined( $mid ) && ( $id == $mid ) ); print "

\n"; print "

Name: ".encode( $name )."\n" if( defined( $name ) && ( $name ne '' ) ); + print "

Deletion request\n" if( defined $name && $name eq '' ); print "

Note: ".encode( $note )."\n" if( defined( $note ) && ( $note ne '' ) ); if( defined( $text ) && ( $text ne '' ) ) { $text = encode( $text ); -- 2.39.2