]> mj.ucw.cz Git - pciids.git/commitdiff
Limit administration to current subtree
authorMichal Vaner <vorner@ucw.cz>
Mon, 1 Sep 2008 15:16:14 +0000 (17:16 +0200)
committerMichal Vaner <vorner@ucw.cz>
Mon, 1 Sep 2008 15:16:14 +0000 (17:16 +0200)
PciIds/DBQ.pm
PciIds/Html/Admin.pm

index 7b2de188e8cef621d651ea8cbaa2e4e75f534b90..40ab21878f4d1b87a8c09a2d3c8919a2f774e2ab 100644 (file)
@@ -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( $$ ) {
index e4daf442fab5e5ee0e7347f1f6a2b5be736b93e7..6ea280a674b3598477850c9f917b8f76ca4e1aa1 100644 (file)
@@ -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 "<h1>Administration ‒ pending events</h1>\n";
-       print "<div class='error'>".$error."</div>\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 "<div class='error'>$error</div>\n" if( defined $error );
        print "<form name='admin' id='admin' class='admin' method='POST' action=''>\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 ) ) {