use LSE::Database::Connection ; use LSE::Collections; use LSE::Config; use CGI ; use strict ; use warnings ; my $q = new CGI ; print $q->header ; my $dbh = getConnection() ; #Check to make sure th e current user has the right priveleges my $current_user = $dbh->quote($ENV{REMOTE_USER}) ; my $sth = $dbh->prepare("select * from users where userid = $current_user") ; $sth->execute ; my $current_user_info = $sth->fetchrow_hashref ; #If not an administrator don't allow to view page if ($current_user_info->{gid} ne 'admin') { print "Error: you aren't authorized to view this page" ; exit ; } if($q->param('delcol') and $q->param('delcolname') and $q->param('deluserid')) { my $colname = $q->param('delcolname'); my $userid = $q->param('deluserid'); print "

Deleting collection $userid-$colname

\n"; LSE::Collections::deleteCollection($userid,$colname); } my @table_cols = ('userid', 'name','scount','dcount','description','started', 'finished','ready','delete','newindex','oldindex') ; print "\n" ; print "
\n"; print "\n"; print ""; foreach my $col (@table_cols) { print "" ; } print "\n"; my $config = getQueryConfig(); if($q->param('action') and $q->param('action') eq 'Delete Index') { print "
";
	my $s_indexid = $dbh->quote($q->param('indexid'));
	print "Deleting index ID $s_indexid (this may take a while)";
	my ($location) = $dbh->selectrow_array("select location from collection_indices where indexid = $s_indexid");
	$dbh->do("delete from collection_indices where indexid = $s_indexid");
	if(-d $location) {
		print "Deleting index files from disk..\n";
		system('rm','-vrf','$location');
	}
	print "
"; } if($q->param('action') and $q->param('action') eq 'Create Index') { my $icmd = $config->{$q->param('indextype')}{indexingcommand}; if(!$icmd) { print "

Error: Invalid Index Type

\n"; exit; } print "Creating index in the background\n"; $SIG{CHLD} = 'IGNORE'; defined (my $kid = fork) or die "Cannot fork: $!\n"; if (!$kid) { system("nice","nohup",$icmd,$q->param('userid'),$q->param('colname'),$q->param('annottype')); CORE::exit(0); } } #Begin ordinary work for the list my $cmd = "select c.*, sum(scount) as scount, sum(dcount) as dcount from col_queries cq natural join collections c group by c.name,c.description,c.ready,c.started,c.finished,c.userid order by c.userid,c.name"; if (defined $q->param('sort')) { my $sortval = $q->param('sort'); $cmd = "$cmd order by $sortval" ; #if the sort parameter is defined, then check to see #if the reverse parameter is defined if (defined $q->param('reverse') && $q->param('reverse') eq 'true' ) { $cmd = "$cmd desc" ; } #include this print for degubing purposes #print $cmd ; } # Get list of index types that can be built my @indexable_types = (); foreach my $key (keys(%$config)) { if(exists $config->{$key}{indexingcommand}) { push(@indexable_types,$key); } } $sth = $dbh->prepare($cmd) ; $sth->execute; while ( my $row = $sth->fetchrow_hashref ) { print "\n" ; foreach my $col (@table_cols) { my $s_userid = $dbh->quote($row->{userid}); my $s_name = $dbh->quote($row->{name}); print "\n"; } print "\n" ; } #end while print "
LSE Annotators List
$col
\n"; #display information in table form. if ( defined $row->{$col} ) { print "$row->{$col}" ; } elsif($col eq 'delete') { print qq(
); print qq(); print qq(); print qq(); print qq(
); } elsif($col eq 'newindex') { print qq(
); print qq(); print qq(); print qq(); print qq("; print qq(); print "
\n"; } elsif($col eq 'oldindex') { my $indices = $dbh->selectall_arrayref("select annot_type, index_type, location, indexid from collection_indices where name = $s_name and userid = $s_userid"); if(@$indices) { print ""; print "\n"; foreach my $index (@$indices) { print qq(
Annotation TypeIndex TypeLocation
$index->[0]$index->[1]$index->[2]); print qq(
); print qq(); print qq(
); } print "
"; } } print "
" ;