X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=PciIds%2FDBQ.pm;h=c6de46c4bc0f6aeb01007b8de4976420cd56123b;hb=d8d36960220afc6ea41b26c98c9cb3aba5a05bab;hp=40ab21878f4d1b87a8c09a2d3c8919a2f774e2ab;hpb=517291c84a9f38197b1d920d500edf3ba16b34cb;p=pciids.git diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index 40ab218..c6de46c 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -31,8 +31,8 @@ sub new( $ ) { '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, users.email 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, - history.id, history.discussion, history.nodename, history.nodenote, users.login + locations.id, locations.name, locations.note, locations.mainhistory, musers.email, main.discussion, + history.id, history.discussion, history.nodename, history.nodenote, users.email FROM locations INNER JOIN history ON history.location = locations.id LEFT OUTER JOIN users ON history.owner = users.id @@ -40,7 +40,7 @@ sub new( $ ) { LEFT OUTER JOIN users AS musers ON main.owner = musers.id WHERE history.seen = "0" AND locations.id LIKE ? ORDER BY locations.id, history.id - LIMIT 1000',#Dumps new discussion submits with their senders and corresponding main history and names + LIMIT 100',#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 = ?', @@ -94,10 +94,22 @@ sub new( $ ) { 'dropnotifsmail' => 'DELETE FROM pending WHERE notification = 0 AND EXISTS ( SELECT 1 FROM users WHERE users.id = pending.user AND nextmail <= ? )', 'time' => 'SELECT NOW()', 'searchname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? ORDER BY l.id', - 'searchlocalname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? AND l.id LIKE ? ORDER BY l.id' + 'searchlocalname' => 'SELECT l.id, l.name, p.name FROM locations AS l JOIN locations AS p ON l.parent = p.id WHERE l.name LIKE ? AND l.id LIKE ? ORDER BY l.id', + 'hasChildren' => 'SELECT DISTINCT 1 FROM locations WHERE parent = ?', + 'hasMain' => 'SELECT DISTINCT 1 FROM locations WHERE id = ? AND mainhistory IS NOT NULL' } ); } +sub hasChildren( $$ ) { + my( $self, $parent ) = @_; + return scalar @{$self->query( 'hasChildren', [ $parent ] )}; +} + +sub hasMain( $$ ) { + my( $self, $id ) = @_; + return scalar @{$self->query( 'hasMain', [ $id ] )}; +} + my %sorts = ( 'id' => 1, 'rid' => 1, 'name' => 1, 'rname' => 1 ); sub nodes( $$$$ ) {