archive_view.php3 3.77 KB
Newer Older
1 2 3
<?php
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2006, 2007 University of Utah and the Flux Group.
5 6 7
# All rights reserved.
#
include("defs.php3");
8
include_once("template_defs.php");
9 10 11 12

#
# Only known and logged in users can look at experiments.
#
13 14 15
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
16 17

#
18
# Verify page arguments.
19
#
20 21
$optargs = OptionalPageArguments("index",      PAGEARG_INTEGER,
				 "experiment", PAGEARG_EXPERIMENT,
22 23
				 "template",   PAGEARG_TEMPLATE,
				 "instance",   PAGEARG_INSTANCE,
24 25
				 "records",    PAGEARG_INTEGER,
				 "tag",        PAGEARG_STRING);
26

27
#
28 29 30 31 32 33 34 35
# 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.
36
#
37 38 39 40
if (isset($instance)) {
    if (($foo = $instance->GetExperiment()))
	$experiment = $foo;
    else
41 42 43 44 45
	$index = $instance->exptidx();
    $template   = $instance->GetTemplate();
    $urlarg     = "instance";
    $urlval     = $instance->exptidx();
    echo $instance->PageHeader();    
Leigh B. Stoller's avatar
Leigh B. Stoller committed
46
}
47 48
elseif (isset($template)) {
    $experiment = $template->GetExperiment();
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    $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();
65
}
66

67
#
68 69
# If we got a current experiment, great. Otherwise we have to lookup
# data for a historical experiment.
70
#
71
if (isset($experiment) && $experiment) {
72 73 74
    # Need these below.
    $pid = $experiment->pid();
    $eid = $experiment->eid();
Leigh B. Stoller's avatar
Leigh B. Stoller committed
75
    $exptidx = $experiment->idx();
76 77 78 79 80 81 82

    # 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);
    }
83
}
84 85
elseif (isset($index)) {
    $stats = ExperimentStats::Lookup($index);
86
    if (!$stats) {
87
	PAGEARGERROR("Invalid experiment index: $index");
88 89 90 91 92
    }

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

95 96 97 98 99 100 101 102 103
    # 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");
104
}
105

106
$url = preg_replace("/archive_view\.php3/", "archive_list.php",
107
		    $_SERVER['REQUEST_URI']);
108

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

112
echo "<center>\n";
113

Leigh B. Stoller's avatar
Leigh B. Stoller committed
114
#
115
# Buttons to export and to view the tags.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
116
#
117 118 119 120
echo "<form action='template_export.php' $style method=get>\n";
echo "<b><input type=hidden name=$urlarg value='$urlval'></b>";
if (isset($tag)) {
    echo "<b><input type=hidden name=tag value='$tag'></b>";
121
}
122 123
echo "<b><input type=submit name=submit value='Export'></b>";
echo "</form>";
124

125 126 127
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>";
128
echo "</form>";
129

130 131
echo "<div><iframe src='$url' class='outputframe' ".
	"id='outputframe' name='outputframe'></iframe></div>\n";
Leigh B. Stoller's avatar
Leigh B. Stoller committed
132
echo "</center><br>\n";
133

134 135 136 137
echo "<script type='text/javascript' language='javascript'>\n";
echo "SetupOutputArea('outputframe', false);\n"; 
echo "</script>\n";

138 139 140 141 142
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>