X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=PciIds%2FDBQ.pm;h=c6de46c4bc0f6aeb01007b8de4976420cd56123b;hb=d8d36960220afc6ea41b26c98c9cb3aba5a05bab;hp=7b2de188e8cef621d651ea8cbaa2e4e75f534b90;hpb=cd3e762ec2244149e284b2677cd208a2a29f872e;p=pciids.git diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index 7b2de18..c6de46c 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -31,15 +31,16 @@ 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 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" + 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 15',#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 = ?', @@ -93,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( $$$$ ) { @@ -212,8 +225,9 @@ sub submitHistory( $$$$ ) { return $self->last(); } -sub adminDump( $ ) { - return shift->query( 'admindump', [] ); +sub adminDump( $$ ) { + my( $self, $prefix ) = @_; + return $self->query( 'admindump', [ "$prefix%" ] ); } sub deleteHistory( $$ ) {