showosid_list.php3 1.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?php
include("defs.php3");

#
# Standard Testbed Header
#
PAGEHEADER("OSID List");

#
#
# Only known and logged in users allowed.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Admin users can see all OSIDs, while normal users can only see
# ones in their projects or ones that are globally available.
#
$isadmin = ISADMIN($uid);

#
# Get the project list.
#
if ($isadmin) {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
26 27
    $query_result =
	DBQueryFatal("SELECT * FROM os_info order by osid");
28 29
}
else {
Leigh B. Stoller's avatar
Leigh B. Stoller committed
30 31 32 33 34
    $query_result =
	DBQueryFatal("select distinct o.* from os_info as o ".
		     "left join group_membership as g on ".
		     " o.pid IS NULL or g.pid=o.pid ".
		     "where g.uid='$uid' order by o.osid");
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
}

if (mysql_num_rows($query_result) == 0) {
	if ($isadmin) {
	    USERERROR("There are no OSIDs!", 1);
	}
	else {
	    USERERROR("There are no OSIDs in any of your projects!", 1);
	}
}

echo "<table border=2 cellpadding=0 cellspacing=2
       align='center'>\n";

echo "<tr>
          <td>OSID</td>
          <td>PID</td>
          <td>Description</td>
      </tr>\n";

while ($row = mysql_fetch_array($query_result)) {
    $osid    = $row[osid];
    $descrip = $row[description];
    $pid     = $row[pid];

    if (! $pid) {
	$pid = "&nbsp";
    }

    echo "<tr>
              <td><A href='showosinfo.php3?osid=$osid'>$osid</A></td>
              <td>$pid</td>
              <td>$descrip</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>