Commit ec134951 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Rework show/end experiment as per Jay request. Instead of a form with

option list, use a plain list instead. Simplify the DB queries now
that I'm a joining fool, and put in a proper confirmation step for
ending an experiment. Yippie.
parent 492e5bfa
......@@ -28,16 +28,6 @@ $exp_eid = strstr($exp_pideid, "\$\$");
$exp_eid = substr($exp_eid, 2);
$exp_pid = substr($exp_pideid, 0, strpos($exp_pideid, "\$\$", 0));
#
# Stop now if the Confirm box was not Depressed
#
if (!isset($confirm) ||
strcmp($confirm, "yes")) {
USERERROR("The \"Confirm\" button was not depressed! If you really ".
"want to end experiment '$exp_eid' in project '$exp_pid', ".
"please go back and try again.", 1);
}
#
# Check to make sure thats this is a valid PID/EID tuple.
#
......@@ -60,6 +50,38 @@ if (mysql_num_rows($query_result) == 0) {
"Experiment: $exp_eid.", 1);
}
#
# We run this twice. The first time we are checking for a confirmation
# by putting up a form. The next time through the confirmation will be
# set. Or, the user can hit the cancel button, in which case we should
# probably redirect the browser back up a level.
#
if ($canceled) {
echo "<center><h2><br>
Experiment termination canceled!
</h2></center>\n";
PAGEFOOTER();
return;
}
if (!$confirmed) {
echo "<center><h2><br>
Are you <b>REALLY</b>
sure you want to terminate Experiment '$exp_eid?'
</h2>\n";
echo "<form action=\"endexp.php3\" method=\"post\">";
echo "<input type=hidden name=exp_pideid value=\"$exp_pideid\">\n";
echo "<b><input type=submit name=confirmed value=Confirm></b>\n";
echo "<b><input type=submit name=canceled value=Cancel></b>\n";
echo "</form>\n";
echo "</center>\n";
PAGEFOOTER();
return;
}
#
# We need the unix gid for the project for running the scripts below.
#
......
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Terminate Experiment Form");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Show a menu of all experiments for all projects that this uid
# is a member of.
#
$projmemb_result = mysql_db_query($TBDBNAME,
"SELECT * FROM proj_memb WHERE uid=\"$uid\"");
if (mysql_num_rows($projmemb_result) == 0) {
USERERROR("You are not a member of any Projects, so you cannot ".
"show any experiment information", 1);
}
#
# Lets see if the user is even part of any experiements before
# presenting a bogus option list.
#
$experiments = "";
while ($projrow = mysql_fetch_array($projmemb_result)) {
$pid = $projrow[pid];
$exp_result = mysql_db_query($TBDBNAME,
"SELECT eid FROM experiments WHERE pid=\"$pid\"");
while ($exprow = mysql_fetch_array($exp_result)) {
$eid = $exprow[eid];
$experiments = "$experiments " .
"<option value=\"$pid\$\$$eid\">$pid/$eid</option>\n";
}
}
if (strcmp($experiments, "") == 0) {
USERERROR("There are no experiments running in any of the projects ".
"you are a member of.", 1);
}
?>
<center>
<h1>Terminate Experiment Selection</h1>
<h2>Select an experiment from the list below.<br>
These are the experiments in the projects
you are a member of.</h2>
<table align="center" border="1">
<?php
echo "<form action=\"endexp.php3\" method=\"post\">";
echo "<tr>
<td align='center'>Project/Experiment</td>
</tr>\n";
echo "<tr></tr>";
echo "<tr></tr>";
#
# Suck the current info out of the database and display a list of
# experiments as an option list.
#
echo "<tr>";
echo " <td align=\"center\"><select name=\"exp_pideid\">";
echo " $experiments";
echo " </select>";
echo " </td>
</tr>\n";
?>
<tr>
<td height=25></td>
</tr>
<tr>
<td align="center" height=50>
<em>Do you really want to do this?<br>
(Depress the Confirm button)</em></td>
</tr>
<tr>
<td heght=25 align="center">
<input type="checkbox" name="confirm" value="yes"></td>
</tr>
<tr>
<td height=25></td>
</tr>
<tr>
<td align="center">
<b><input type="submit" value="Submit"></b></td>
</tr>
</form>
</table>
</center>
<?php
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Terminate Experiment List");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
#
# Lets see if the user is even part of any experiements
#
$query_result = mysql_db_query($TBDBNAME,
"select e.pid,eid,expt_name from experiments as e ".
"left join proj_memb as p on p.pid=e.pid where p.uid='$uid'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("There are no experiments running in any of the projects ".
"you are a member of.", 1);
}
?>
<center>
<h1>Terminate Experiment Selection</h1>
<h2>Select an experiment from the list below.<br>
These are the experiments in the projects
you are a member of.</h2>
<table width="100%" border=2 cellpadding=0 cellspacing=2 align=center>
<tr>
<td>PID</td>
<td>EID</td>
<td align=center>Name</td>
<td align=center>Terminate</td>
</tr>
<?php
while ($row = mysql_fetch_array($query_result)) {
$pid = $row[pid];
$eid = $row[eid];
$name = $row[expt_name];
echo "<tr>
<td><A href='showproject.php3?pid=$pid'>$pid</A></td>
<td><A href='showexp.php3?exp_pideid=$pid\$\$$eid'>$eid</A></td>
<td>$name</td>
<td align=center><A href='endexp.php3?exp_pideid=$pid\$\$$eid'>
<img alt=\"o\" src=\"redball.gif\"></A></td>
</tr>\n";
}
echo "</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
......@@ -109,9 +109,9 @@ if (isset($uid)) {
Project Information</A><p>\n";
echo "<p><A href='beginexp_form.php3'>
Begin an Experiment</A>\n";
echo "<p><A href='endexp_form.php3'>
echo "<p><A href='endexp_list.php3'>
End an Experiment</A>\n";
echo "<p><A href='showexp_form.php3'>
echo "<p><A href='showexp_list.php3'>
Experiment Information</A>\n";
echo "<p><A href='modusr_form.php3'>
Update user information</A>\n";
......
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Show Experiment Information Form");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Show a menu of all experiments for all projects that this uid
# is a member of. Or, if an admin type person, show them all!
#
if ($isadmin) {
$projmemb_result = mysql_db_query($TBDBNAME,
"SELECT DISTINCT pid FROM proj_memb");
if (mysql_num_rows($projmemb_result) == 0) {
USERERROR("There are no experiments to ".
"show any experiment information", 1);
}
}
else {
$projmemb_result = mysql_db_query($TBDBNAME,
"SELECT pid FROM proj_memb WHERE uid=\"$uid\"");
if (mysql_num_rows($projmemb_result) == 0) {
USERERROR("You are not a member of any Projects, so you cannot ".
"show any experiment information", 1);
}
}
#
# Lets see if the user is even part of any experiements before
# presenting a bogus option list.
#
$experiments = "";
while ($projrow = mysql_fetch_array($projmemb_result)) {
$pid = $projrow[pid];
$exp_result = mysql_db_query($TBDBNAME,
"SELECT eid FROM experiments WHERE pid=\"$pid\"");
while ($exprow = mysql_fetch_array($exp_result)) {
$eid = $exprow[eid];
$experiments = "$experiments " .
"<option value=\"$pid\$\$$eid\">$pid/$eid</option>\n";
}
}
if (strcmp($experiments, "") == 0) {
USERERROR("There are no experiments running in any of the projects ".
"you are a member of.", 1);
}
?>
<center>
<h1>Experiment Information Selection</h1>
<h2>Select an experiment from the list below.<br>
These are the experiments in the projects
you are a member of.</h2>
<table align="center" border="1">
<?php
echo "<form action=\"showexp.php3\" method=\"post\">";
echo "<tr>
<td align='center'>Project/Experiment</td>
</tr>\n";
echo "<tr></tr>";
echo "<tr></tr>";
#
# Suck the current info out of the database and display a list of
# experiments as an option list.
#
echo "<tr>";
echo " <td><select name=\"exp_pideid\">";
echo " $experiments";
echo " </select>";
echo " </td>
</tr>\n";
?>
<td align="center">
<b><input type="submit" value="Submit"></b></td></tr>
</form>
</table>
</center>
<?php
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
<?php
include("defs.php3");
#
# Standard Testbed Header
#
PAGEHEADER("Show Experiment Information Form");
#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
#
# Show a menu of all experiments for all projects that this uid
# is a member of. Or, if an admin type person, show them all!
#
if ($isadmin) {
$query_result = mysql_db_query($TBDBNAME,
"select pid,eid,expt_name from experiments");
}
else {
$query_result = mysql_db_query($TBDBNAME,
"select e.pid,eid,expt_name from experiments as e ".
"left join proj_memb as p on p.pid=e.pid where p.uid='$uid'");
}
if (mysql_num_rows($query_result) == 0) {
USERERROR("There are no experiments to ".
"show any experiment information", 1);
}
?>
<center>
<h1>Experiment Information Selection</h1>
<h2>Select an experiment from the list below.<br>
These are the experiments in the projects
you are a member of.</h2>
<table width="100%" border=2 cellpadding=0 cellspacing=2 align=center>
<tr>
<td>PID</td>
<td>EID</td>
<td>Name</td>
</tr>
<?php
while ($row = mysql_fetch_array($query_result)) {
$pid = $row[pid];
$eid = $row[eid];
$name = $row[expt_name];
echo "<tr>
<td><A href='showproject.php3?pid=$pid'>$pid</A></td>
<td><A href='showexp.php3?exp_pideid=$pid\$\$$eid'>$eid</A></td>
<td>$name</td>
</tr>\n";
}
echo "</table>\n";
#
# Standard Testbed Footer
#
PAGEFOOTER();
?>
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