archive_view.php3 4.49 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2006-2012 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24
#
include("defs.php3");
25
include_once("template_defs.php");
26 27 28 29

#
# Only known and logged in users can look at experiments.
#
30 31 32
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
33 34

#
35
# Verify page arguments.
36
#
37 38
$optargs = OptionalPageArguments("index",      PAGEARG_INTEGER,
				 "experiment", PAGEARG_EXPERIMENT,
39 40
				 "template",   PAGEARG_TEMPLATE,
				 "instance",   PAGEARG_INSTANCE,
41 42
				 "records",    PAGEARG_INTEGER,
				 "tag",        PAGEARG_STRING);
43

44
#
45 46 47 48 49 50 51 52
# Standard Testbed Header now that we know what to say.
#
PAGEHEADER((isset($instance) || isset($template) ?
	    "Template Datastore" : "Experiment Archive"));

#
# An instance might be a current or historical. If its a template, use
# the underlying experiment of the template.
53
#
54 55 56 57
if (isset($instance)) {
    if (($foo = $instance->GetExperiment()))
	$experiment = $foo;
    else
58 59 60 61 62
	$index = $instance->exptidx();
    $template   = $instance->GetTemplate();
    $urlarg     = "instance";
    $urlval     = $instance->exptidx();
    echo $instance->PageHeader();    
Leigh Stoller's avatar
Leigh Stoller committed
63
}
64 65
elseif (isset($template)) {
    $experiment = $template->GetExperiment();
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
    $export_url = CreateURL("template_export", $template);
    $urlarg     = "template";
    $urlval     = $template->guid() . "/" . $template->vers();
    echo $template->PageHeader();
}
elseif (isset($index)) {
    $experiment = Experiment::Lookup($index);
    $urlarg     = "index";
    $urlval     = $index;
    echo $experiment->PageHeader();
}
else {
    $export_url = CreateURL("template_export", $experiment);
    $urlarg     = "experiment";
    $urlval     = $experiment->idx();
    echo $experiment->PageHeader();
82
}
83

84
#
85 86
# If we got a current experiment, great. Otherwise we have to lookup
# data for a historical experiment.
87
#
88
if (isset($experiment) && $experiment) {
89 90 91
    # Need these below.
    $pid = $experiment->pid();
    $eid = $experiment->eid();
Leigh Stoller's avatar
Leigh Stoller committed
92
    $exptidx = $experiment->idx();
93 94 95 96 97 98 99

    # Permission
    if (!$isadmin &&
	!$experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
	USERERROR("You do not have permission to view tags for ".
		  "archive in $pid/$eid!", 1);
    }
100
}
101 102
elseif (isset($index)) {
    $stats = ExperimentStats::Lookup($index);
103
    if (!$stats) {
104
	PAGEARGERROR("Invalid experiment index: $index");
105 106 107 108 109
    }

    # Need these below.
    $pid = $stats->pid();
    $eid = $stats->eid();
110
    $exptidx = $index;
111

112 113 114 115 116 117 118 119 120
    # Permission
    if (!$isadmin &&
	!$stats->AccessCheck($this_user, $TB_PROJECT_READINFO)) {
	USERERROR("You do not have permission to view tags for ".
		  "archive in $pid/$eid!", 1);
    }
}
else {
    PAGEARGERROR("Must provide a current or former experiment index");
121
}
122

123
$url = preg_replace("/archive_view\.php3/", "archive_list.php",
124
		    $_SERVER['REQUEST_URI']);
125

126
# This is how you get forms to align side by side across the page.
127
$style = 'style="float:left; width:50%;"';
128

129
echo "<center>\n";
130

Leigh Stoller's avatar
Leigh Stoller committed
131
#
132
# Buttons to export and to view the tags.
Leigh Stoller's avatar
Leigh Stoller committed
133
#
134 135 136
echo "<form action='template_export.php' $style method=get>\n";
echo "<b><input type=hidden name=$urlarg value='$urlval'></b>";
if (isset($tag)) {
137
    $tag = CleanString($tag);
138
    echo "<b><input type=hidden name=tag value='$tag'></b>";
139
}
140 141
echo "<b><input type=submit name=submit value='Export'></b>";
echo "</form>";
142

143 144 145
echo "<form action='archive_tags.php3' $style method=get>";
echo "<b><input type=hidden name=$urlarg value='$urlval'></b>";
echo "<b><input type=submit name=submit value='Show Tags'></b>";
146
echo "</form>";
147

148 149
echo "<div><iframe src='$url' class='outputframe' ".
	"id='outputframe' name='outputframe'></iframe></div>\n";
Leigh Stoller's avatar
Leigh Stoller committed
150
echo "</center><br>\n";
151

152 153 154 155
echo "<script type='text/javascript' language='javascript'>\n";
echo "SetupOutputArea('outputframe', false);\n"; 
echo "</script>\n";

156 157 158 159 160
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>