archive_tags.php3 3.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
include("showstuff.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Experiment Tags");

#
# Only known and logged in users can end experiments.
#
18 19 20
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
21 22 23 24 25 26

# Show just the last N records unless request is different.
if (!isset($records) || !strcmp($records, "")) {
    $records = 100;
}

27 28 29
# An experiment idx.
if (! isset($exptidx) || $exptidx == "") {
    USERERROR("Must supply an experiment index!", 1);
30
}
31 32
if (!TBvalid_integer($exptidx)) {
    USERERROR("Invalid characters in $exptidx!", 1);
33 34 35
}

#
36 37
# We get an index. Must map that to a pid/gid to do a group level permission
# check, since it might not be an current experiment.
38
#
39 40 41 42 43
unset($pid);
unset($eid);
unset($gid);
if (TBExptidx2PidEid($exptidx, $pid, $eid, $gid) < 0) {
    USERERROR("No such experiment index $exptidx!", 1);
44 45
}

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
if (!$isadmin &&
    !TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO)) {
    USERERROR("You do not have permission to view tags for ".
	      "archive in $pid/$gid ($exptidx)!", 1);
}

if (TBCurrentExperiment($exptidx)) {
    echo "<center><font size=+1>".
	"Experiment <b>".
	"<a href='showproject.php3?pid=$pid'>$pid</a>/".
        "<a href='showexp.php3?pid=$pid&eid=$eid'>$eid</a> ".
        "(<a href='showstats.php3?showby=expt&exptidx=$exptidx'>$exptidx</a>) ".
        "</b></font>\n";
        "</center><br>";
}
else {
    echo "<center><font size=+1>".
	"Experiment ".
        "<a href='showstats.php3?showby=expt&exptidx=$exptidx'>$exptidx</a> ".
        "</b></font>\n";
        "</center><br>";
67 68 69 70 71 72 73 74
}

echo "<br>\n";

#
# We need the archive index so we can find its view.
#
$query_result =
75 76
    DBQueryFatal("select s.archive_idx from experiment_stats as s ".
		 "where s.exptidx='$exptidx'");
77
if (mysql_num_rows($query_result) == 0) {
78
    TBERROR("Could not get archive index for experiment $exptidx", 1);
79 80 81 82 83 84 85 86
}
$row   = mysql_fetch_array($query_result);
$archive_idx = $row["archive_idx"];
		    
#
# Grab all the (commit/user) tags.
#
$query_result =
87 88 89 90 91
    DBQueryFatal("select *,FROM_UNIXTIME(date_created) as date_created ".
		 "  from archive_tags ".
		 "where archive_idx='$archive_idx' and view='$exptidx' and ".
		 "      (tagtype='user' or tagtype='commit') ".
		 "order by date_created desc");
92 93 94 95 96 97 98 99

if (mysql_num_rows($query_result) == 0) {
    USERERROR("No tags for experiment $pid/$eid", 1);
}

echo "<table align=center border=1>
      <tr>";
echo "  <th>Run</th>";
100
echo "  <th>Tag (Click to visit archive)</th>";
101 102 103 104 105 106 107 108 109 110 111
echo "  <th>Date</th>";
echo "  <th>Description</th>";
echo "</tr>\n";

while ($row = mysql_fetch_assoc($query_result)) {
    $archive_tag = $row["tag"];
    $date_tagged = $row["date_created"];
    $description = $row["description"];

    echo "<tr>";
    echo "  <td align=center>
112
                <a href=beginexp_html.php3?copyid=$exptidx:$archive_tag>
113 114
                    <img border=0 alt=Run src=greenball.gif></a></td>";
    echo "  <td>".
115 116
	     "<a href='archive_view.php3/$exptidx/history/".
		    "$archive_tag/?exptidx=$exptidx'>$archive_tag</a>".
117 118 119 120 121 122 123 124 125 126 127 128 129
	 "  </td>";
    
    echo "  <td>$date_tagged</td>";
    echo "  <td>$description</td>";
    echo "</tr>\n";
}
echo "</table>\n";

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