From: Michal Vaner Date: Mon, 13 Oct 2008 21:08:30 +0000 (+0200) Subject: Count of pending events in admin interface X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;ds=sidebyside;h=93ac596833fc6df9ee6ebe7326fd2c6e6447203b;p=pciids.git Count of pending events in admin interface --- diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index bf7134d..2740de5 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -119,7 +119,8 @@ sub new( $ ) { 'hasChildren' => 'SELECT DISTINCT 1 FROM locations WHERE parent = ?', 'hasMain' => 'SELECT DISTINCT 1 FROM locations WHERE id = ? AND mainhistory IS NOT NULL', 'notif-exists' => 'SELECT DISTINCT 1 FROM notifications WHERE user = ? AND ( location = ? OR ( recursive = 1 AND type <= 1 AND SUBSTR( ?, 1, LENGTH( location ) ) = location ) )', - 'itemname' => 'SELECT name FROM locations WHERE id = ?' + 'itemname' => 'SELECT name FROM locations WHERE id = ?', + 'admincount' => 'SELECT COUNT( DISTINCT location ) FROM history WHERE seen = 0 AND location LIKE ?' } ); } @@ -394,4 +395,9 @@ sub itemName( $$ ) { return defined $result ? $result : ''; } +sub adminCount( $$ ) { + my( $tables, $prefix ) = @_; + return $tables->query( 'admincount', [ "$prefix%" ] )->[0]->[0]; +} + 1; diff --git a/PciIds/Html/Admin.pm b/PciIds/Html/Admin.pm index 056d353..0f8c159 100644 --- a/PciIds/Html/Admin.pm +++ b/PciIds/Html/Admin.pm @@ -116,6 +116,7 @@ sub genNewAdminForm( $$$$$ ) { my $moreButt = 'admin?limit='.( $limit ? int( $limit * 2 ) : 160 ).buildExcept( 'action', $args ); $moreButt .= '?global='.$glob if defined $glob; genCustomHead( $req, $args, $address, $caption, [ $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), $glob ? [ 'Local', 'admin'.buildExcept( 'action', $args ) ] : [ 'Global', 'admin?global=1'.buildExcept( 'action', $args ) ], [ 'More items', $moreButt ], [ 'Help', 'help', 'admin' ] ], [ [ 'Log out', 'logout' ] ] ); + print "

Pending events: ".$tables->adminCount( $glob ? '' : $address->get() ); print "

$error
\n" if( defined $error ); print "
\n"; my $lastId;