]> mj.ucw.cz Git - pciids.git/commitdiff
Allow sending deletion requests
authorMichal Vaner <vorner@ucw.cz>
Sat, 30 Aug 2008 17:44:18 +0000 (19:44 +0200)
committerMichal Vaner <vorner@ucw.cz>
Sat, 30 Aug 2008 17:44:18 +0000 (19:44 +0200)
PciIds/DBQ.pm
PciIds/Html/Changes.pm
PciIds/Html/List.pm

index 219bc08d5b83d35d5ccc941ddb8b89b304232f0b..b671ea26eef4fe01caf8b22c159553bfe23d676f 100644 (file)
@@ -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();
 }
 
index a23d50dfd70ccc6aafebb68d734640110faedd60..c03af9e046b1c35d7d88cf6efbd35f5c5f398943 100644 (file)
@@ -93,12 +93,11 @@ sub genNewHistoryForm( $$$$$$ ) {
        print "<div class='error'>$error</div>\n" if( defined $error );
        print "<form name='newhistory' id='newhistory' method='POST' action=''>\n<table>";
        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 '</table></form>';
-       print '<p>Items marked with * are optional, use them only if you want to change the name and note.';
-       print '<p>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'; } ] );
index 040d35abeb1311c83bd078368726a64e50ae6f4a..e8b9a29054a32e1227d0eb7bc5b1cb75fd70e256 100644 (file)
@@ -27,7 +27,7 @@ sub list( $$$$ ) {
        print '<h1>'.encode( $id ).'</h1>';
        genMenu( $req, $address, $args, $auth, [ [ 'Help', 'help', 'list' ], $address->helpName() ? [ 'ID syntax', 'help', $address->helpName() ] : () ] );
        genPath( $req, $address, 0 );
-       print htmlDiv( 'name', '<p>'.encode( $name ) ) if( defined( $name ) );
+       print htmlDiv( 'name', '<p>'.encode( $name ) ) if defined( $name );
        print htmlDiv( 'note', '<p>'.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 "<div class='$type'>\n";
                print "<p class='itemname'>Name: ".encode( $name )."\n" if( defined( $name ) && ( $name ne '' ) );
+               print "<p class='itemname'>Deletion request\n" if( defined $name && $name eq '' );
                print "<p class='itemnote'>Note: ".encode( $note )."\n" if( defined( $note ) && ( $note ne '' ) );
                if( defined( $text ) && ( $text ne '' ) ) {
                        $text = encode( $text );