Show AdminAnnotation.pl syntax highlighted
#!/usr/bin/perl
#use strict "vars";
use vars qw(
$GV
$GVportal
$PRM
@modes
$DBH
$zeroPos
$UCAcgiPATH
$IMAGEDIR
$GENSCAN_speciesModel
);
do 'UCAconf.pl';
do 'functions.pl';
$PRM->{USERid} = &{$GV->{getUserIdFunction}};
$PRM->{owner} = param('owner') ? param('owner') : $PRM->{USERid}; # ?
if(!$PRM->{USERid}){
## Request user login for annotation creation
bailOut("You must login first before using this tool. $GV->{dbTitle}");
}
my $isAdmin = getUserGroup($PRM->{USERid});
if ($isAdmin){ # only display page for admins
my $geneId = param('mode'); # geneId to checkout
my $uid = param('uid'); # uid to return
if ($geneId){
$openV = param('openV');
#check out annotation
$sql = "insert into admin_session (USERid,uid,checked_out_date,dbName) VALUES ('$PRM->{USERid}','$geneId',now(),'$GV->{dbTitle}')";
$GV->{LDBH}->do($sql);
}
my $ownedRef = getAdminOwnership();
if ($$ownedRef{$uid} eq $PRM->{USERid}){
$sql = "update admin_session set returned = 1 where uid = $uid and USERid = '$PRM->{USERid}'";
$GV->{LDBH}->do($sql);
$ownedRef = getAdminOwnership(); # new ownership
}
# %statusHash = (
# 'aREVIEW' => [],
# 'ACCEPTED' => [],
# 'REJECTED' => []
# );
$sql = "select uid,geneId,modDate,status,USERid,chr from user_gene_annotation where status != 'SAVED' order by status, modDate desc";
$UCAref = $GV->{DBH}->selectall_arrayref($sql);
for (my $i=0;$i<scalar(@$UCAref);$i++){
my ($uid,$geneId,$modDate,$status,$owner,$chr) = @{$UCAref->[$i]};
my $UCAtablerow = "<td>$owner</td><td>$modDate</td><td>$chr</td><td>$$ownedRef{$uid}";
if (!$$ownedRef{$uid}){
push(@{$statusHash{$status}},"<tr><td class='myLink'><a target=\"_blank\" onClick=\"checkout('$uid');\">$geneId </a></td><td>$owner</td><td>$modDate</td><td>$chr</td><td>$$ownedRef{$uid}</td></tr>\n");
}elsif ($$ownedRef{$uid} eq $PRM->{USERid}){
push(@{$statusHash{$status}},"<tr><td class='myLink'><a target=\"_blank\" onClick=\"checkout('$uid');\">$geneId </a></td><td>$owner</td><td>$modDate</td><td>$chr</td><td>$$ownedRef{$uid}<br><a href='${rootPATH}${CGIPATH}AnnotationTool.pl?uid=$uid' target='_blank'>Administrate Annotation</a><br><a href='${rootPATH}${CGIPATH}AdminAnnotation.pl?uid=$uid&return=1'>Return Annotation</a></td></tr>\n");
}else{
push(@{$statusHash{$status}},"<tr class='checked'><td>$geneId</td><td>$owner</td><td>$modDate</td><td>$chr</td><td>$$ownedRef{$uid}</td></tr>\n");
}
}
my $page = "<span class=mainT><font style='font-weight:bold;font-size:24px'>User Contributed Annotation System<br>
Administration Tool - Check Out List</font><br>
<font style='font-weight:bold;font-size:14px'> $specieName ($GV->{dbTitle})</font><br><br>
<br><br>
<br></span><br>";
$page .= "Click on an Annotation ID to check it out for administration. This will grant you exclusive permission to administrate the annotation for 30 minutes. To administrate a checked out annotation, use the Administration Tool which opens in a new window open clicking the annotation ID if your browser accepts popups, or click on the link 'Administrate Annotation'.<br><br>";
my $status = '';
foreach $status (sort {return $b cmp $a} keys %statusHash){
$page .= "\n<table border=0 cellspacing=0 cellpadding=0 class='statusTBL'><tr><td class='statusHDR'>$status -- " . scalar(@{$statusHash{$status}}) . " annotations</td>" .
"<td class='button' onclick=\"hide_show(-1,'${status}TBL');\" onmousedown='md(this);' onmouseup='mu(this);' ><img id='${status}TBL_HSbimg' src=\"$GV->{IMAGEDIR}hide.png\"></td>" .
"<td class='button' onclick=\"expand_collapse(-1,'${status}TBL');\" onmousedown='md(this);' onmouseup='mu(this);' ><img id='${status}TBL_ECbimg' src=\"$GV->{IMAGEDIR}expand.png\"></td></tr></table>\n";
$page .= "<div id='${status}TBL' class='UCAlist'>\n<table class=mainT border=1><tr class='headRow'><td>Annotation ID</td><td>Owner</td><td>Last Modified</td><td>Chromosome</td><td>Checked out by Admin?</td></tr>\n" . join("\n", @{$statusHash{$status}}) . "</table></div>\n";
}
print header();
$HTML_head = <<END_OF_HEAD;
<html>
<head>
<title>UCA Administration Annotation Check Out Page</title>
<style>
.myLink a {background:white; color:black; text-decoration:none;}
.myLink a:hover {background:#f4a30c; cursor:pointer;}
.button {height:16px; width:16px; text-align:center; background:#DCDCDC;border:2px outset grey;}
.mainT {font-family:Arial;font-size:11px;padding:5;}
.checked {font-family:Arial;font-size:11px;background-color:lightyellow}
.headRow {font-family:Arial;font-size:14px;font-weight:bold}
.statusTBL {font-family:Arial;font-size:14px;background-color:lightblue;padding:0px;margin:10px 0px 0px 0px;}
.statusHDR {font-weight:bold; padding-left:4px; width:495px; border-right:1px outset grey; }
.UCAlist { width:540px; overflow:auto; height:400px;}
</style>
<script>
function checkout(id){
Sname = id;
illChar = new RegExp("[-_\s\.]","g");
Sname = Sname.replace(illChar,"");
document.forms.tFrm.mode.value = id;
document.forms.tFrm.openV.value = 1;
document.forms.tFrm.submit();
return;
}
function openANN(){
if (document.forms.tFrm.openV.value == 1){
document.forms.tFrm.openV.value = 0;
window.open("AnnotationTool.pl?uid=" + '$geneId', 'UCA' + '$geneId', 'resizable=yes,screenX=100,screenY=100,top=100,left=100,toolbar=no,status=yes,scrollbars=yes,location=yes,menubar=no,directories=no,width=800,height=600');
}
}
function md(obj){
obj.style.borderStyle = "inset";
}
function mu(obj){
obj.style.borderStyle = 'outset';
}
function hide_show(viz,obj){
if(viz < 0){
viz = (document.getElementById(obj).style.display == "none")?1:0;
}
if(viz){
document.getElementById(obj).style.display = "block";
document.getElementById(obj + '_HSbimg').src = "$GV->{IMAGEDIR}hide.png";
}else{
document.getElementById(obj).style.display = "none";
document.getElementById(obj + '_HSbimg').src = "$GV->{IMAGEDIR}show.png";
}
return;
}
function expand_collapse(state,obj){
if(state < 0){
state = (document.getElementById(obj).style.height == "auto")?0:1;
}
if(state){
document.getElementById(obj).style.height = "auto";
document.getElementById(obj + '_ECbimg').src = "$GV->{IMAGEDIR}collapse.png";
}else{
document.getElementById(obj).style.height = "400px";
document.getElementById(obj + '_ECbimg').src = "$GV->{IMAGEDIR}expand.png";
}
hide_show(0,obj); // cycle object visability to correctly redraw in mozilla
hide_show(1,obj); // Make sure object is visable!
return;
}
</script>
</head>
<body onLoad="openANN();"><form name='tFrm' method=post><input type=hidden name=mode value="">$mode
END_OF_HEAD
print $HTML_head;
print $page;
print "<input type=submit value='Reload Page'><br><input type=hidden name='openV' value=$openV>";
print "</form></body></html>";
}else{
print header();
print "Action not allowed.";
}
See more files for this project here