X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=PciIds%2FHtml%2FChanges.pm;h=0230a8e11ee36ce89016e9263922a89c9d08f99a;hb=8b50236fc38dcfd1d084bad5e2689162f3e247b1;hp=7154b01fe249b3202621644557011dfe68a16a3e;hpb=d1db063d5f74737ed6b7197078c67533a5bf88a5;p=pciids.git diff --git a/PciIds/Html/Changes.pm b/PciIds/Html/Changes.pm index 7154b01..0230a8e 100644 --- a/PciIds/Html/Changes.pm +++ b/PciIds/Html/Changes.pm @@ -1,3 +1,21 @@ +# PciIds web database +# Copyright (C) 2008 Michal Vaner (vorner@ucw.cz) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# he Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + package PciIds::Html::Changes; use strict; use PciIds::Html::Users; @@ -13,19 +31,28 @@ sub genNewItemForm( $$$$$$ ) { my( $req, $args, $auth, $tables, $error, $values ) = @_; 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 ); - genCustomHead( $req, $args, $address, "$prettyAddr - add new item", [ $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Help', 'help', 'newitem' ], [ 'ID syntax', 'help', $address->helpName() ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); + genHtmlHead( $req, "Add new item", undef ); + genCustomHead( $req, $args, $address, "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 "
hostname().$req->uri().buildExcept( 'action', $args ).'?action=newitem' : '' )."'>\n"; - genFormEx( [ [ 'input', 'Id:', 'text', 'id', 'maxlength="'.$address->subIdSize().'"' ], + print "\n
"; + genFormEx( [ [ 'input', 'ID:', 'text', 'id', 'maxlength="'.$address->subIdSize().'"' ], [ 'input', 'Name:', 'text', 'name', 'maxlength="200"' ], - [ 'input', 'Note*:', 'text', 'note', 'maxlength="1024"' ], - [ 'textarea', 'Discussion*:', undef, 'discussion', 'rows="5" cols="50"' ], + [ 'input', 'Note:', 'text', 'note', 'maxlength="1024"' ], + [ 'textarea', 'Discussion:', undef, 'discussion', 'rows="5" cols="50"' ], + [ 'input', 'Subscribe:', 'checkbox', 'subscribe', 'value="subscribe" checked="checked"' ], [ 'input', '', 'submit', 'submit', 'value="Submit"' ] ], $values ); print '
'; - print '

Items marked with * are optional.'; - genHtmlTail(); + print ' +

+ Please enter only accurate information. Descriptions like "Unknown modem device" are only of a little use to anybody. + Real chip names and numbers are preferred over marketing names. In case you know both, enclose the marketing name in square brackets like in + "3c595 100BaseTX [Vortex]". Do not include names of superitems in the name (like vendor name in device name). + Check information specific to this ID type. +

+ If there is something you want to clarify about the item, you can use note (like the ID does not belong to people using it). + Discussion is for things more relevant to history of the item than the real device (like information source). + Both note and discussion is optional.'; + genHtmlFooter( 1, $req, $args ); return OK; } @@ -52,7 +79,8 @@ sub newItemSubmit( $$$$ ) { return 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; } + 'discussion' => sub { return ( length shift > 1024 ) ? 'Discussion can not be longer than 1024 characters' : undef; }, + 'subscribe' => undef }, [ sub { my( $data ) = @_; my $errstr; return undef unless( length $data->{'id'} );#No address, so let it for the first check @@ -64,14 +92,15 @@ sub newItemSubmit( $$$$ ) { if( $result eq 'exists' ) { genHtmlHead( $req, 'ID collision', undef ); my $addr = PciIds::Address::new( $req->uri() ); - genCustomHead( $req, $args, $addr, 'ID collision', [ [ 'Add other item', 'newitem' ], $addr->canDiscuss() ? [ 'Discuss', 'newhistory' ] : () ], [ logItem( $auth ) ] ); + genCustomHead( $req, $args, $addr, 'ID collision', [ [ 'Add other item', 'newitem' ], $addr->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), ], [ logItem( $auth ) ] ); print '

Sorry, this ID already exists.'; - genHtmlTail(); + genHtmlFooter( 0, undef, undef ); return OK; } elsif( $result ) { return genNewItemForm( $req, $args, $auth, $tables, $result, $data ); } - notify( $tables, $data->{'address'}->get(), $comName, 2, 0 ); + notify( $tables, $data->{'address'}->parent()->get(), $comName, 2, 0 );#Notify the parent (parent gets new items) + $tables->submitNotification( $auth->{'authid'}, $data->{'address'}->get(), { 'recursive' => 0, 'notification' => 0, 'way' => 0 } ) if( defined $data->{'subscribe'} && $data->{'subscribe'} eq 'subscribe' ); 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 { @@ -83,18 +112,32 @@ sub genNewHistoryForm( $$$$$$ ) { my( $req, $args, $tables, $auth, $error, $values ) = @_; my( $ok, $parent, $name, $note, $address ) = loadItem( $tables, $req->uri() ); return NOT_FOUND unless( $ok ); - my $prettyAddr = encode( $address->pretty() ); - genHtmlHead( $req, "$prettyAddr - discuss", undef ); - genCustomHead( $req, $args, $address, "$prettyAddr - discuss", [ $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), [ 'Help', 'help', 'newhistory' ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); + genHtmlHead( $req, "Discuss", undef ); + genCustomHead( $req, $args, $address, "Discuss", [ $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), [ 'Help', 'help', 'newhistory' ] ], [ logItem( $auth ), [ 'Notifications', 'notifications' ] ] ); print "

$error
\n" if( defined $error ); - print "
hostname().$req->uri().buildExcept( 'action', $args ).'?action=newhistory' : '' )."'>\n"; + print "\n
"; genFormEx( [ [ 'textarea', 'Text:', undef, 'text', 'rows="5" cols="50"' ], [ 'input', 'Request deletion', 'checkbox', 'delete', 'value="delete"' ], [ 'input', 'Name:', 'text', 'name', 'maxlength="200"' ], [ 'input', 'Note:', 'text', 'note', 'maxlength="1024"' ], + !$tables->notifExists( $auth->{'authid'}, $address->get() ) ? [ 'input', 'Subscribe:', 'checkbox', 'subscribe', "value='subscribe' checked='checked'" ] : (), [ 'input', '', 'submit', 'submit', 'value="Submit"' ] ], $values ); print '
'; - genHtmlTail(); + print ' +

+ Please enter only accurate information. Descriptions like "Unknown modem device" are only of a little use to anybody. + Real chip names and numbers are preferred over marketing names. In case you know both, enclose the marketing name in square brackets like in + "3c595 100BaseTX [Vortex]". Do not include names of superitems in the name (like vendor name in device name). + Check information specific to this ID type. +

+ You may provide just discussion, request deletion or enter a new name and note. + Note is for clarification of the device information, discussion is for reasons, why you change it and like that. +

+ You may add discussion note to name change or deletion request too. + You must provide at last name or discussion or deletion request. +

+ If you provide note, you must provide name too.'; + genHtmlFooter( 1, $req, $args ); return OK; } @@ -126,7 +169,8 @@ sub newHistorySubmit( $$$$ ) { return undef if $delete eq 'delete'; return 'Invalid form value'; return undef; - } + }, + 'subscribe' => 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; @@ -141,6 +185,7 @@ sub newHistorySubmit( $$$$ ) { my $hid = $tables->submitHistory( $data, $auth, $address ); tulog( $auth->{'authid'}, "Discussion 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 ); + $tables->submitNotification( $auth->{'authid'}, $address->get(), { 'recursive' => 0, 'notification' => 1, 'way' => 0 } ) if( defined $data->{'subscribe'} && $data->{'subscribe'} eq 'subscribe' ); return HTTPRedirect( $req, '/read/'.$address->get().'?action=list' ); } else { return notLoggedComplaint( $req, $args, $auth );