Commit d2b002e1 authored by Leigh Stoller's avatar Leigh Stoller

Add Show History link to show experiment page.

parent a382994d
......@@ -1234,6 +1234,20 @@ function TBExptState($pid, $eid)
return $state;
}
function TBExptIndex($pid, $eid)
{
$query_result =
DBQueryFatal("select idx from experiments ".
"where eid='$eid' and pid='$pid'");
if (mysql_num_rows($query_result) == 0) {
return -1;
}
$row = mysql_fetch_array($query_result);
$idx = $row[idx];
return $idx;
}
function TBUidNodeLastLogin($uid)
{
$query_result =
......
......@@ -48,8 +48,7 @@ if (! TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view experiment $exp_eid!", 1);
}
$expindex = TBExptIndex($exp_pid, $exp_eid);
$expstate = TBExptState($exp_pid, $exp_eid);
echo "<font size=+2>Experiment <b>".
......@@ -113,6 +112,10 @@ if (TBExptAccessCheck($uid, $exp_pid, $exp_eid, $TB_EXPT_MODIFY)) {
}
# History
WRITESUBMENUBUTTON("Show History",
"showstats.php3?showby=expt&which=$expindex");
if (ISADMIN($uid)) {
if (strcmp($expstate, $TB_EXPTSTATE_ACTIVE) == 0) {
SUBMENUSECTION("Beta-Test Options");
......
......@@ -90,6 +90,35 @@ elseif ($showby == "project") {
$wclause = "where s.pid='$which'";
$records = 400;
}
elseif ($showby == "expt") {
if (!$which) {
USERERROR("Must supply an experiment to view!", 1);
}
#
# We get an index. Must map that to a pid/eid to do the permission
# check, and note that it might not be an current experiment. Not
# sure I like this so I am not going to permit it for mere users
# just yet.
#
if (!$isadmin) {
$query_result =
DBQueryFatal("select pid,eid from experiments where idx='$which'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("No such experiment index $which!", 1);
}
$row = mysql_fetch_array($query_result);
$pid = $row[pid];
$eid = $row[eid];
if (! TBExptAccessCheck($uid, $pid, $eid, $TB_EXPT_READINFO)) {
USERERROR("You do not have permission to view stats for ".
"experiment $which!", 1);
}
}
$wclause = "where t.exptidx='$which'";
$records = 100;
}
elseif ($showby == "all") {
if ($which) {
if (! TBProjAccessCheck($uid, $which, $which, $TB_PROJECT_READINFO)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment