From 1c883df7d9318dd97a9771132f7dd511f31b355a Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Fri, 29 Aug 2008 21:33:19 +0200 Subject: [PATCH] New terminology, part 4 -- user editation --- PciIds/DBQ.pm | 4 ++-- PciIds/Html/Changes.pm | 44 +++++++++++++++++++++--------------------- PciIds/Html/Handler.pm | 4 ++-- PciIds/Html/Util.pm | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index 63b201c..219bc08 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -187,7 +187,7 @@ sub submitItem( $$$ ) { return( 'exists', undef ) if( defined( $self->item( $addr->get(), 0 ) ) ); eval { $self->command( 'newitem', [ $addr->get(), $addr->parent()->get() ] ); - $self->command( 'newhistory', [ $addr->get(), $auth->{'authid'}, $data->{'text'}, $data->{'name'}, $data->{'description'} ] ); + $self->command( 'newhistory', [ $addr->get(), $auth->{'authid'}, $data->{'discussion'}, $data->{'name'}, $data->{'note'} ] ); }; if( $@ ) { @@ -199,7 +199,7 @@ sub submitItem( $$$ ) { sub submitHistory( $$$$ ) { my( $self, $data, $auth, $address ) = @_; - $self->command( 'newhistory', [ $address->get(), $auth->{'authid'}, $data->{'text'}, $data->{'name'}, $data->{'description'} ], 1 ); + $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 e444f06..0dfbc97 100644 --- a/PciIds/Html/Changes.pm +++ b/PciIds/Html/Changes.pm @@ -10,7 +10,7 @@ use Apache2::Const qw(:common :http); sub genNewItemForm( $$$$$ ) { my( $req, $args, $tables, $error, $values ) = @_; - my( $ok, $parent, $name, $description, $address ) = loadItem( $tables, $req->uri() ); + my( $ok, $parent, $name, $note, $address ) = loadItem( $tables, $req->uri() ); return NOT_FOUND unless( $ok ); my $prettyAddr = encode( $address->pretty() ); genHtmlHead( $req, "$prettyAddr - add new item", undef ); @@ -19,8 +19,8 @@ sub genNewItemForm( $$$$$ ) { print "
\n"; genFormEx( [ [ 'input', 'Id:', 'text', 'id', 'maxlength="50"' ], [ 'input', 'Name:', 'text', 'name', 'maxlength="200"' ], - [ 'input', 'Description*:', 'text', 'description', 'maxlength="1024"' ], - [ 'textarea', 'Text*:', undef, 'text', 'rows="5" cols="50"' ], + [ 'input', 'Note*:', 'text', 'note', 'maxlength="1024"' ], + [ 'textarea', 'Discussion*:', undef, 'discussion', 'rows="5" cols="50"' ], [ 'input', '', 'submit', 'submit', 'value="Submit"' ] ], $values ); print '
'; print '

Items marked with * are optional.'; @@ -40,7 +40,7 @@ sub newItemForm( $$$$ ) { sub newItemSubmit( $$$$ ) { my( $req, $args, $tables, $auth ) = @_; if( defined $auth->{'authid'} ) { - my( $pok, $parent, $pname, $pdescription, $paddress ) = loadItem( $tables, $req->uri() ); + my( $pok, $parent, $pname, $pnote, $paddress ) = loadItem( $tables, $req->uri() ); return NOT_FOUND unless( $pok ); my( $data, $error ) = getForm( { 'id' => sub{ return ( length shift ) ? undef : 'Please, provide the ID'; }, #Checked at the bottom and added as address @@ -50,8 +50,8 @@ sub newItemSubmit( $$$$ ) { return 'Lenght limit of the name is 200 characters' if( length $name > 200 ); return undef; }, - 'description' => sub { return ( length shift > 1024 ) ? 'Description can not be longer than 1024 characters' : undef; }, - 'text' => sub { return ( length shift > 1024 ) ? 'Text can not be longer than 1024 characters' : undef; } + 'note' => sub { return ( length shift > 1024 ) ? 'Note can not be longer than 1024 characters' : undef; }, + 'discussion' => sub { return ( length shift > 1024 ) ? 'Discussion can not be longer than 1024 characters' : undef; } }, [ sub { my( $data ) = @_; my $errstr; return undef unless( length $data->{'id'} );#No address, so let it for the first check @@ -70,50 +70,50 @@ sub newItemSubmit( $$$$ ) { die "Failed to submit new item: $result\n"; } notify( $tables, $data->{'address'}->get(), $comName, 2, 0 ); - tulog( $auth->{'authid'}, "Item created ".$data->{'address'}->get()." ".logEscape( $data->{'name'} )." ".logEscape( $data->{'description'} )." ".logEscape( $data->{'text'} )." $comName" ); + tulog( $auth->{'authid'}, "Item created ".$data->{'address'}->get()." ".logEscape( $data->{'name'} )." ".logEscape( $data->{'note'} )." ".logEscape( $data->{'discussion'} )." $comName" ); return HTTPRedirect( $req, '/read/'.$data->{'address'}->get().'?action=list' ); } else { return notLoggedComplaint( $req, $args, $auth ); } } -sub genNewCommentForm( $$$$$ ) { +sub genNewHistoryForm( $$$$$ ) { my( $req, $args, $tables, $error, $values ) = @_; - my( $ok, $parent, $name, $description, $address ) = loadItem( $tables, $req->uri() ); + my( $ok, $parent, $name, $note, $address ) = loadItem( $tables, $req->uri() ); return NOT_FOUND unless( $ok ); my $prettyAddr = encode( $address->pretty() ); - genHtmlHead( $req, "$prettyAddr - add a comment to discussion", undef ); - print "

$prettyAddr - add a comment to discussion

\n"; + genHtmlHead( $req, "$prettyAddr - discuss", undef ); + print "

$prettyAddr - discuss

\n"; print "
$error
\n" if( defined $error ); - print "
\n"; + print "\n
"; genFormEx( [ [ 'textarea', 'Text:', undef, 'text', 'rows="5" cols="50"' ], [ 'input', 'Name*:', 'text', 'name', 'maxlength="200"' ], - [ 'input', 'Description*:', 'text', 'description', 'maxlength="1024"' ], + [ '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 description.'; - print '

If you specify description must include name too.'; + 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; } -sub newCommentForm( $$$$ ) { +sub newHistoryForm( $$$$ ) { my( $req, $args, $tables, $auth ) = @_; if( defined $auth->{'authid'} ) { - return genNewCommentForm( $req, $args, $tables, undef, {} ); + return genNewHistoryForm( $req, $args, $tables, undef, {} ); } else { return notLoggedComplaint( $req, $args, $auth ); } } -sub newCommentSubmit( $$$$ ) { +sub newHistorySubmit( $$$$ ) { my( $req, $args, $tables, $auth ) = @_; if( defined $auth->{'authid'} ) { - my( $ok, $parent, $name, $description, $address ) = loadItem( $tables, $req->uri() ); + my( $ok, $parent, $name, $note, $address ) = loadItem( $tables, $req->uri() ); return NOT_FOUND unless( $ok ); my( $data, $error ) = getForm( { 'name' => sub { return ( length shift > 200 ) ? 'Lenght limit of the name is 200 characters' : undef; }, - 'description' => sub { return ( length shift > 1024 ) ? 'Description can not be longer than 1024 characters' : undef; }, + 'note' => sub { return ( length shift > 1024 ) ? 'Note can not be longer than 1024 characters' : undef; }, 'text' => sub { my( $expl ) = @_; return 'Text can not be longer than 1024 characters' if ( length $expl > 1024 ); @@ -121,10 +121,10 @@ sub newCommentSubmit( $$$$ ) { return undef; } }, [ sub { my( $data ) = @_; - return 'You must provide name too' if( ( length $data->{'description'} ) && ( ! length $data->{'name'} ) ); + return 'You must provide name too' if( ( length $data->{'note'} ) && ( ! length $data->{'name'} ) ); return undef; }, sub { return $address->canAddComment() ? undef : 'You can not discuss this item'; } ] ); - return genNewCommentForm( $req, $args, $tables, $error, $data ) if( defined $error ); + return genNewHistoryForm( $req, $args, $tables, $error, $data ) if( defined $error ); my $hid = $tables->submitHistory( $data, $auth, $address ); tulog( $auth->{'authid'}, "Comment created $hid ".$address->get()." ".logEscape( $data->{'name'} )." ".logEscape( $data->{'description'} )." ".logEscape( $data->{'text'} ) ); notify( $tables, $address->get(), $hid, ( defined $name && ( $name ne '' ) ) ? 1 : 0, 1 ); diff --git a/PciIds/Html/Handler.pm b/PciIds/Html/Handler.pm index da7c10f..4392baf 100644 --- a/PciIds/Html/Handler.pm +++ b/PciIds/Html/Handler.pm @@ -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, @@ -43,7 +43,7 @@ my %handlers = ( }, '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, diff --git a/PciIds/Html/Util.pm b/PciIds/Html/Util.pm index 790421d..e54b8a7 100644 --- a/PciIds/Html/Util.pm +++ b/PciIds/Html/Util.pm @@ -61,7 +61,7 @@ sub genMenu( $$$ ) { push @list, [ 'Log in', 'login' ]; } push @list, [ 'Add item', 'newitem' ] if( $address->canAddItem() ); - push @list, [ 'Discuss', 'newcomment' ] if( $address->canAddComment() ); + push @list, [ 'Discuss', 'newhistory' ] if( $address->canAddComment() ); push @list, [ 'Administrate', 'admin' ] if( hasRight( $auth->{'accrights'}, 'validate' ) ); push @list, [ 'Profile', 'profile' ] if defined $auth->{'authid'}; push @list, [ 'Notifications', 'notifications' ] if defined $auth->{'authid'}; -- 2.39.2