From 517291c84a9f38197b1d920d500edf3ba16b34cb Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Mon, 1 Sep 2008 17:16:14 +0200 Subject: [PATCH] Limit administration to current subtree --- PciIds/DBQ.pm | 10 ++++++---- PciIds/Html/Admin.pm | 13 +++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/PciIds/DBQ.pm b/PciIds/DBQ.pm index 7b2de18..40ab218 100644 --- a/PciIds/DBQ.pm +++ b/PciIds/DBQ.pm @@ -37,9 +37,10 @@ sub new( $ ) { 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 1000',#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 = ?', @@ -212,8 +213,9 @@ sub submitHistory( $$$$ ) { return $self->last(); } -sub adminDump( $ ) { - return shift->query( 'admindump', [] ); +sub adminDump( $$ ) { + my( $self, $prefix ) = @_; + return $self->query( 'admindump', [ "$prefix%" ] ); } sub deleteHistory( $$ ) { diff --git a/PciIds/Html/Admin.pm b/PciIds/Html/Admin.pm index e4daf44..6ea280a 100644 --- a/PciIds/Html/Admin.pm +++ b/PciIds/Html/Admin.pm @@ -6,21 +6,26 @@ use PciIds::Html::Util; use PciIds::Html::Users; use PciIds::Html::Forms; use PciIds::Notifications; +use PciIds::Address; use PciIds::Log; use Apache2::Const qw(:common :http); sub genNewAdminForm( $$$$ ) { my( $req, $args, $tables, $error ) = @_; - genHtmlHead( $req, 'Administration ‒ pending events', undef ); - print "

Administration ‒ pending events

\n"; - print "
".$error."
\n" if( defined $error ); + my $address = PciIds::Address::new( $req->uri() ); + my $prefix = $address->get(); + $prefix = '' if( $args->{'global'} ); + my $caption = 'Administration ‒ pending events '.( $args->{'global'} ? '(Global)' : '('.encode( $address->pretty() ).')' ); + genHtmlHead( $req, $caption, undef ); + genCustomHead( $req, $args, $address, $caption, [ $address->canAddItem() ? [ 'Add item', 'newitem' ] : (), $address->canDiscuss() ? [ 'Discuss', 'newhistory' ] : (), [ 'Help', 'help', 'admin' ] ], [ [ 'Log out', 'logout' ] ] ); + print "
$error
\n" if( defined $error ); print "
\n"; my $lastId; my $started = 0; my $cnt = 0; my $hiscnt = 0; my $subcnt; - foreach( @{$tables->adminDump()} ) { + foreach( @{$tables->adminDump( $prefix )} ) { my( $locId, $actName, $actNote, $actHist, $actUser, $actDisc, $hist, $disc, $name, $note, $user ) = @{$_}; if( !defined( $lastId ) || ( $lastId ne $locId ) ) { -- 2.39.2