From 244e1791e7127031de318821dd551e76b65ec0fc Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Fri, 29 Aug 2008 20:48:55 +0200 Subject: [PATCH 1/1] New terminology, part 2 -- DBQ function names --- PciIds/DBQ.pm | 24 ++++++++++++------------ PciIds/Html/Admin.pm | 6 +++--- PciIds/Html/Changes.pm | 2 +- scripts/importil.pl | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index 7d4e6ef..63b201c 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -28,7 +28,7 @@ sub new( $ ) { 'setlastlog' => 'UPDATE users SET logtime = now(), lastlog = ? WHERE id = ?', 'rights' => 'SELECT rightId FROM rights WHERE userId = ?', 'newitem' => 'INSERT INTO locations (id, parent) VALUES(?, ?)', - 'newcomment' => 'INSERT INTO history (location, owner, discussion, nodename, nodenote) VALUES(?, ?, ?, ?, ?)', + 'newhistory' => 'INSERT INTO history (location, owner, discussion, nodename, nodenote) VALUES(?, ?, ?, ?, ?)', 'history' => 'SELECT history.id, history.discussion, history.time, history.nodename, history.nodenote, history.seen, users.login FROM history LEFT OUTER JOIN users ON history.owner = users.id WHERE history.location = ? ORDER BY history.time', 'admindump' => 'SELECT locations.id, locations.name, locations.note, locations.mainhistory, musers.login, main.discussion, @@ -39,11 +39,11 @@ sub new( $ ) { LEFT OUTER JOIN history AS main ON locations.mainhistory = main.id LEFT OUTER JOIN users AS musers ON main.owner = musers.id WHERE history.seen = "0" ORDER BY locations.id, history.id - LIMIT 15',#Dumps new comments with their senders and corresponding main comments and names + LIMIT 15',#Dumps new discussion submits with their senders and corresponding main history and names 'delete-hist' => 'DELETE FROM history WHERE id = ?', 'mark-checked' => 'UPDATE history SET seen = 1 WHERE id = ?', 'delete-item' => 'DELETE FROM locations WHERE id = ?', - 'set-maincomment' => 'UPDATE locations SET + 'set-mainhist' => 'UPDATE locations SET mainhistory = ?, name = ( SELECT nodename FROM history WHERE id = ? ), note = ( SELECT nodenote FROM history WHERE id = ? ) @@ -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( 'newcomment', [ $addr->get(), $auth->{'authid'}, $data->{'text'}, $data->{'name'}, $data->{'description'} ] ); + $self->command( 'newhistory', [ $addr->get(), $auth->{'authid'}, $data->{'text'}, $data->{'name'}, $data->{'description'} ] ); }; if( $@ ) { @@ -197,9 +197,9 @@ sub submitItem( $$$ ) { return( '', $self->last() ); } -sub submitComment( $$$$ ) { +sub submitHistory( $$$$ ) { my( $self, $data, $auth, $address ) = @_; - $self->command( 'newcomment', [ $address->get(), $auth->{'authid'}, $data->{'text'}, $data->{'name'}, $data->{'description'} ], 1 ); + $self->command( 'newhistory', [ $address->get(), $auth->{'authid'}, $data->{'text'}, $data->{'name'}, $data->{'description'} ], 1 ); return $self->last(); } @@ -222,9 +222,9 @@ sub deleteItem( $$ ) { $self->command( 'delete-item', [ $id ] ); } -sub setMainComment( $$$ ) { - my( $self, $location, $comment ) = @_; - $self->command( 'set-maincomment', [ $comment, $comment, $comment, $location ] ); +sub setMainHistory( $$$ ) { + my( $self, $location, $history ) = @_; + $self->command( 'set-mainhist', [ $history, $history, $history, $location ] ); } sub resetInfo( $$ ) { @@ -285,9 +285,9 @@ sub submitNotification( $$$$ ) { } sub pushNotifications( $$$$$ ) { - my( $self, $location, $comment, $priority, $reason ) = @_; - $self->command( 'notify', [ $comment, 0, $reason, 0, $priority, $location, $location ] ); - $self->command( 'notify', [ $comment, 1, $reason, 1, $priority, $location, $location ] ); + my( $self, $location, $history, $priority, $reason ) = @_; + $self->command( 'notify', [ $history, 0, $reason, 0, $priority, $location, $location ] ); + $self->command( 'notify', [ $history, 1, $reason, 1, $priority, $location, $location ] ); $self->command( 'newtime-mail', [ $priority, $location, $location ] ); $self->command( 'newtime-xmpp', [ $priority, $location, $location ] ); } diff --git a/PciIds/Html/Admin.pm b/PciIds/Html/Admin.pm index e945bd7..d5773eb 100644 --- a/PciIds/Html/Admin.pm +++ b/PciIds/Html/Admin.pm @@ -134,13 +134,13 @@ sub submitAdminForm( $$$$ ) { } if( ( defined( $name ) && ( length $name >= 3 ) ) || ( defined( $text ) && ( $text ne '' ) ) ) { #Submited comment my $addr = PciIds::Address::new( $loc ); - my $comId = $tables->submitComment( { 'name' => $name, 'description' => $description, 'explanation' => $text }, $auth, $addr ); + my $comId = $tables->submitHistory( { 'name' => $name, 'description' => $description, 'explanation' => $text }, $auth, $addr ); my $main = defined $name && ( $name ne '' ); notify( $tables, $addr->get(), $comId, $main ? 2 : 0, $main ? 2 : 1 ); $tables->markChecked( $comId ); tulog( $authid, "Comment created (admin) $comId $loc ".logEscape( $name )." ".logEscape( $description )." ".logEscape( $text ) ); if( defined( $name ) && ( length $name >= 3 ) ) { - $tables->setMainComment( $loc, $comId ); + $tables->setMainHistory( $loc, $comId ); tulog( $authid, "Item main comment changed $loc $comId" ); $action = 'keep'; } @@ -155,7 +155,7 @@ sub submitAdminForm( $$$$ ) { } #Ignore if it was already deleted by superitem } elsif( my( $setId ) = ( $action =~ /set-(.*)/ ) ) { next if( $deleted{$setId} ); - $tables->setMainComment( $loc, $setId ); + $tables->setMainHistory( $loc, $setId ); notify( $tables, $loc, $setId, 2, 2 ); tulog( $authid, "Item main comment changed $loc $setId" ); markAllChecked( $tables, $i, \%deleted, $authid ); diff --git a/PciIds/Html/Changes.pm b/PciIds/Html/Changes.pm index d31c916..e444f06 100644 --- a/PciIds/Html/Changes.pm +++ b/PciIds/Html/Changes.pm @@ -125,7 +125,7 @@ sub newCommentSubmit( $$$$ ) { return undef; }, sub { return $address->canAddComment() ? undef : 'You can not discuss this item'; } ] ); return genNewCommentForm( $req, $args, $tables, $error, $data ) if( defined $error ); - my $hid = $tables->submitComment( $data, $auth, $address ); + 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 ); return HTTPRedirect( $req, '/read/'.$address->get().'?action=list' ); diff --git a/scripts/importil.pl b/scripts/importil.pl index add02d1..7e0fe4b 100755 --- a/scripts/importil.pl +++ b/scripts/importil.pl @@ -82,7 +82,7 @@ sub markAllSeen() { } sub setMain( $ ) { - $db->setMainComment( $addr->get(), shift ); + $db->setMainHistory( $addr->get(), shift ); } print "Importing\n"; -- 2.39.2