Commit 900196b4 authored by Leigh Stoller's avatar Leigh Stoller

Fun with Silly Sorting. Some people would call them "views" but I just

call 'em tuits (okay, I have no idea what a tuit is).
parent f0241d51
......@@ -14,37 +14,52 @@ LOGGEDINORDIE($uid);
$isadmin = ISADMIN($uid);
$altclause = "";
$altview = 0;
if (isset($alternate_view) && $alternate_view) {
echo "<b><a href='showexp_list.php3'>
if (! isset($showactive))
$showactive = 0;
if (! isset($sortby))
$sortby = "normal";
if ($showactive) {
echo "<b><a href='showexp_list.php3?showactive=0&sortby=$sortby'>
Show All Experiments</a>
</b><br><br>\n";
$altclause = "e.state='$TB_EXPTSTATE_ACTIVE'";
$altview = 1;
}
else {
echo "<b><a href='showexp_list.php3?alternate_view=1'>
echo "<b><a href='showexp_list.php3?showactive=1&sortby=$sortby'>
Show Active Experiments Only</a>
</b><br><br>\n";
}
if (! strcmp($sortby, "normal") ||
! strcmp($sortby, "pid"))
$order = "e.pid,e.eid";
elseif (! strcmp($sortby, "eid"))
$order = "e.eid,e.expt_head_uid";
elseif (! strcmp($sortby, "uid"))
$order = "e.expt_head_uid,e.pid,e.eid";
elseif (! strcmp($sortby, "name"))
$order = "e.expt_name";
else
$order = "e.pid,e.eid";
#
# 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) {
if ($altview)
if ($showactive)
$altclause = "where ($altclause)";
$experiments_result =
DBQueryFatal("select pid,eid,expt_head_uid,expt_name, ".
"date_format(expt_swapped,\"%Y-%m-%d\") as d ".
"from experiments as e $altclause ".
"order by pid,eid,expt_name");
"order by $order");
}
else {
if ($altview)
if ($showactive)
$altclause = "and ($altclause)";
$experiments_result =
......@@ -53,7 +68,7 @@ else {
"from experiments as e ".
"left join group_membership as g on g.pid=e.pid ".
"where g.uid='$uid' $altclause ".
"order by e.pid,eid,expt_name");
"order by $order");
}
if (! mysql_num_rows($experiments_result)) {
USERERROR("There are no experiments running in any of the projects ".
......@@ -68,15 +83,23 @@ if (mysql_num_rows($experiments_result)) {
echo "<table border=2 cols=0
cellpadding=0 cellspacing=2 align=center>
<tr>
<td width=8%>PID</td>
<td width=8%>EID</td>
<td width=8%>
<a href='showexp_list.php3?showactive=$showactive&sortby=pid'>
PID</td>
<td width=8%>
<a href='showexp_list.php3?showactive=$showactive&sortby=eid'>
EID</td>
<td width=3%>PCs</td>\n";
if ($isadmin)
echo "<td width=17% align=center>Last Login</td>\n";
echo " <td width=60%>Name</td>
<td width=4%>Head UID</td>
echo " <td width=60%>
<a href='showexp_list.php3?showactive=$showactive&sortby=name'>
Name</td>
<td width=4%>
<a href='showexp_list.php3?showactive=$showactive&sortby=uid'>
Head UID</td>
</tr>\n";
$total_pcs = 0;
......
......@@ -19,17 +19,30 @@ LOGGEDINORDIE($uid);
#
$isadmin = ISADMIN($uid);
if (! isset($sortby))
$sortby = "normal";
if (! strcmp($sortby, "normal") ||
! strcmp($sortby, "name"))
$order = "i.imagename";
elseif (! strcmp($sortby, "pid"))
$order = "i.pid";
elseif (! strcmp($sortby, "desc"))
$order = "i.description";
else
$order = "i.imagename";
#
# Get the list.
#
if ($isadmin) {
$query_result = DBQueryFatal("SELECT * FROM images order by imageid");
$query_result = DBQueryFatal("SELECT * FROM images as i order by $order");
}
else {
$query_result =
DBQueryFatal("select distinct i.* from images as i ".
"left join group_membership as g on g.pid=i.pid ".
"where g.uid='$uid' or i.shared order by i.imageid");
"where g.uid='$uid' or i.shared order by $order");
}
if (mysql_num_rows($query_result) == 0) {
......@@ -56,9 +69,12 @@ echo "<table border=2 cellpadding=0 cellspacing=2
align='center'>\n";
echo "<tr>
<td>Image</td>
<td>PID</td>
<td>Description</td>
<td><a href='showimageid_list.php3?&sortby=name'>
Image</td>
<td><a href='showimageid_list.php3?&sortby=pid'>
PID</td>
<td><a href='showimageid_list.php3?&sortby=desc'>
Description</td>
</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
......
......@@ -19,19 +19,32 @@ LOGGEDINORDIE($uid);
#
$isadmin = ISADMIN($uid);
if (! isset($sortby))
$sortby = "normal";
if (! strcmp($sortby, "normal") ||
! strcmp($sortby, "name"))
$order = "o.osname";
elseif (! strcmp($sortby, "pid"))
$order = "o.pid";
elseif (! strcmp($sortby, "desc"))
$order = "o.description";
else
$order = "o.osname";
#
# Get the project list.
#
if ($isadmin) {
$query_result =
DBQueryFatal("SELECT * FROM os_info order by pid,osname");
DBQueryFatal("SELECT * FROM os_info as o order by $order");
}
else {
$query_result =
DBQueryFatal("select distinct o.* from os_info as o ".
"left join group_membership as g on g.pid=o.pid ".
"where g.uid='$uid' or o.shared=1 ".
"order by o.pid,o.osname");
"order by $order");
}
if (mysql_num_rows($query_result) == 0) {
......@@ -70,9 +83,12 @@ echo "<br>
<table border=2 cellpadding=0 cellspacing=2 align='center'>\n";
echo "<tr>
<td>Name</td>
<td>PID</td>
<td>Description</td>
<td><a href='showosid_list.php3?&sortby=name'>
Name</td>
<td><a href='showosid_list.php3?&sortby=pid'>
PID</td>
<td><a href='showosid_list.php3?&sortby=desc'>
Description</td>
</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
......
......@@ -20,24 +20,36 @@ LOGGEDINORDIE($uid);
#
$isadmin = ISADMIN($uid);
if (!isset($splitview) || !$isadmin)
$splitview = 0;
if (!isset($sortby))
$sortby = "name";
if ($isadmin) {
if (! $alternate_view) {
echo "<b><a href='showproject_list.php3?alternate_view=1'>
Alternate View</a>
if (! $splitview) {
echo "<b><a href='showproject_list.php3?splitview=1&sortby=$sortby'>
Split View</a>
</b><br>\n";
}
else {
echo "<b><a href='showproject_list.php3'>
echo "<b><a href='showproject_list.php3?sortby=$sortby'>
Normal View</a>
</b><br>\n";
}
}
else {
$alternate_view = 0;
}
if (! strcmp($sortby, "name"))
$order = "p.name";
elseif (! strcmp($sortby, "pid"))
$order = "p.pid";
elseif (! strcmp($sortby, "uid"))
$order = "p.head_uid";
else
$order = "p.name";
if ($isadmin) {
$query_result = DBQueryFatal("SELECT * FROM projects order by pid");
$query_result =
DBQueryFatal("SELECT * FROM projects as p order by $order");
#
# Process the query results for active projects so I can generate a
......@@ -74,17 +86,21 @@ if ($isadmin) {
function GENPLIST ($query_result)
{
global $isadmin;
global $isadmin, $splitview;
echo "<table width='100%' border=2
cellpadding=2 cellspacing=0 align=center>
<tr>
<td>PID</td>
<td>(Approved?) Description</td>
<td>Leader</td>
<td align=center>Days<br>Idle</td>
<td align=center colspan=2>Expts<br>Cr, Run</td>
<td align=center>Nodes</td>\n";
<td><a href='showproject_list.php3?splitview=$splitview&sortby=pid'>
PID</td>
<td>(Approved?)
<a href='showproject_list.php3?splitview=$splitview&sortby=name'>
Description</td>
<td><a href='showproject_list.php3?splitview=$splitview&sortby=uid'>
Leader</td>
<td align=center>Days<br>Idle</td>
<td align=center colspan=2>Expts<br>Cr, Run</td>
<td align=center>Nodes</td>\n";
#
# Admin users get other fields.
......@@ -170,7 +186,7 @@ if (! $isadmin) {
DBQueryFatal("SELECT * FROM projects as p ".
"left join group_membership as g on ".
" p.pid=g.pid and g.pid=g.gid ".
"where g.uid='$uid' and g.trust!='none'");
"where g.uid='$uid' and g.trust!='none' order by $order");
if (mysql_num_rows($query_result) == 0) {
USERERROR("You are not a member of any projects!", 1);
......@@ -179,10 +195,10 @@ if (! $isadmin) {
GENPLIST($query_result);
}
else {
if ($alternate_view) {
if ($splitview) {
$query_result =
DBQueryFatal("select * FROM projects ".
"where expt_count>0 order by name");
DBQueryFatal("select * FROM projects as p ".
"where expt_count>0 order by $order");
if (mysql_num_rows($query_result)) {
echo "<center>
......@@ -192,8 +208,8 @@ else {
}
$query_result =
DBQueryFatal("select * FROM projects ".
"where expt_count=0 order by name");
DBQueryFatal("select * FROM projects as p ".
"where expt_count=0 order by $order");
if (mysql_num_rows($query_result)) {
echo "<br><center>
......
......@@ -22,30 +22,39 @@ $isadmin = ISADMIN($uid);
if (! $isadmin) {
USERERROR("You do not have permission to view the user list!", 1);
}
if (isset($alternate_view) && $alternate_view) {
echo "<b><a href='showuser_list.php3'>
Show All Users</a>
if (!isset($showactive))
$showactive = 0;
if (!isset($sortbyname))
$sortbyname = 0;
if (!$showactive) {
echo "<b><a href='showuser_list.php3?showactive=1&sortbyname=$sortbyname'>
Show Logged in Users</a>
</b><br><br>\n";
}
else {
echo "<b><a href='showuser_list.php3?alternate_view=1'>
Show Logged in Users</a>
echo "<b><a href='showuser_list.php3?showactive=0&sortbyname=$sortbyname'>
Show All Users</a>
</b><br><br>\n";
$alternate_view = 0;
}
if (!$sortbyname) {
$order = "u.uid";
$sortbyname = 0;
}
else {
$order = "u.usr_name";
}
if ($alternate_view) {
if ($showactive) {
$query_result =
DBQueryFatal("select u.* from login as l ".
"left join users as u on u.uid=l.uid ".
"where timeout>=unix_timestamp() ".
"order by u.uid");
"order by $order");
}
else {
$query_result =
DBQueryFatal("SELECT u.* FROM users as u order by u.uid");
DBQueryFatal("SELECT u.* FROM users as u order by $order");
}
if (mysql_num_rows($query_result) == 0) {
......@@ -63,8 +72,10 @@ echo "<table width=\"100%\" border=2 cellpadding=1 cellspacing=0
echo "<tr>
<td>&nbsp</td>
<td>UID</td>
<td>Name</td>
<td><a href='showuser_list.php3?showactive=$showactive&sortbyname=0'>
UID</td>
<td><a href='showuser_list.php3?showactive=$showactive&sortbyname=1'>
Name</td>
<td>Projects</td>
<td>Web<br>Idle</td>
<td>Users<br>Idle</td>\n";
......@@ -76,6 +87,7 @@ if ($isadmin) {
echo "<td align=center>Modify</td>\n";
echo "<td align=center>Delete</td>\n";
}
echo "</tr>\n";
while ($row = mysql_fetch_array($query_result)) {
......
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