Commit 6744cb66 authored by Leigh Stoller's avatar Leigh Stoller

Clean up the cvsweb code that had bitrotted, and hook in the template

cvs repo from the template show page.
parent e9f64cc2
......@@ -46,7 +46,7 @@
# SUCH DAMAGE.
#
# $FreeBSD: projects/cvsweb/cvsweb.cgi,v 1.119.2.6 2002/09/26 20:56:05 scop Exp $
# $Id: cvsweb.cgi,v 1.9 2007-04-07 05:39:29 johnsond Exp $
# $Id: cvsweb.cgi,v 1.10 2007-07-20 18:52:07 stoller Exp $
# $Idaemons: /home/cvs/cvsweb/cvsweb.cgi,v 1.84 2001/10/07 20:50:10 knu Exp $
#
###
......@@ -312,7 +312,7 @@ $maycompress =
# their current value) to any link/query string
# you construct
@stickyvars = qw(cvsroot hideattic sortby logsort f only_with_tag
pid eid exptidx);
pid eid exptidx guid version);
@unsafevars = qw(logsort only_with_tag r1 r2 rev sortby tr1 tr2);
if (-f $config) {
......
......@@ -32,9 +32,7 @@ $use_viewvc = 0;
#
# Verify form arguments.
#
$optargs = OptionalPageArguments("experiment", PAGEARG_EXPERIMENT,
"instance", PAGEARG_INSTANCE,
"template", PAGEARG_TEMPLATE,
$optargs = OptionalPageArguments("template", PAGEARG_TEMPLATE,
"project", PAGEARG_PROJECT,
"embedded", PAGEARG_BOOLEAN);
if (!isset($embedded)) {
......@@ -57,111 +55,44 @@ if (isset($project)) {
header("Location: $url");
return;
}
if (isset($experiment)) {
#
# Wants access to the experiment archive, which is really a repo.
#
$pid = $experiment->pid();
$eid = $experiment->eid();
if (! ISADMIN() &&
! $experiment->AccessCheck($this_user, $TB_EXPT_READINFO)) {
USERERROR("Not enough permission to view '$pid/$eid'", 1);
}
# Get the repo index for the experiment.
#
# Authenticated access to the project repo.
#
if (! ISADMIN() &&
! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) {
# Then check to see if the project cvs repo is public.
$query_result =
DBQueryFatal("select s.archive_idx from experiments as e ".
"left join experiment_stats as s on s.exptidx=e.idx ".
"where e.pid='$pid' and e.eid='$eid'");
DBQueryFatal("select cvsrepo_public from projects ".
"where pid='$pid'");
if (!mysql_num_rows($query_result)) {
TBERROR("Error getting repo index for '$pid/$eid'", 1);
TBERROR("Error getting cvsrepo_public bit", 1);
}
$row = mysql_fetch_array($query_result);
if (!isset($row[0])) {
TBERROR("Error getting repo index for '$pid/$eid'", 1);
}
$repoidx = $row[0];
$repodir = "/usr/testbed/exparchive/$repoidx/repo/";
$use_viewvc = 1;
}
else {
#
# Wants access to the project repo.
#
if (! ISADMIN() &&
! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) {
# Then check to see if the project cvs repo is public.
$query_result =
DBQueryFatal("select cvsrepo_public from projects ".
"where pid='$pid'");
if (!mysql_num_rows($query_result)) {
TBERROR("Error getting cvsrepo_public bit", 1);
}
$row = mysql_fetch_array($query_result);
if ($row[0] == 0) {
USERERROR("You are not a member of Project $pid.", 1);
}
if ($row[0] == 0) {
USERERROR("You are not a member of Project $pid.", 1);
}
$repodir = "$TBCVSREPO_DIR/$pid";
}
$repodir = "$TBCVSREPO_DIR/$pid";
}
elseif (isset($experiment) || isset($instance) || isset($template)) {
elseif (isset($template)) {
if (!$CVSSUPPORT) {
USERERROR("Project CVS support is not enabled!", 1);
}
# Must be logged in for this!
if ($this_user) {
CheckLoginOrDie();
}
$this_user = CheckLoginOrDie();
if (isset($template)) {
$experiment = $template->GetExperiment();
}
if (isset($instance)) {
$pid = $instance->pid();
$eid = $instance->eid();
$idx = $instance->exptidx();
$project = $instance->Project();
}
else {
$pid = $experiment->pid();
$eid = $experiment->eid();
$idx = $experiment->idx();
$project = $experiment->Project();
}
# Need the pid/eid/gid. Access the stats table since we want to provide
# cvs access to terminated experiments via the archive.
$query_result =
DBQueryFatal("select s.archive_idx,a.archived ".
" from experiment_stats as s ".
"left join archives as a on a.idx=s.archive_idx ".
"where s.exptidx='$idx'");
if (!mysql_num_rows($query_result)) {
USERERROR("Experiment '$idx' is not a valid experiment", 1);
}
$row = mysql_fetch_array($query_result);
$repoidx = $row[0];
$archived = $row[1];
$guid = $template->guid();
$vers = $template->vers();
$pid = $template->pid();
$project = $template->GetProject();
# Lets do group level check since it might not be a current experiment.
if (!$archived) {
if (! ISADMIN() &&
! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) {
USERERROR("Not enough permission to view archive", 1);
}
$repodir = "/usr/testbed/exparchive/$repoidx/repo/";
}
else {
if (! ISADMIN()) {
USERERROR("Must be administrator to view historical archives!", 1);
}
$repodir = "/usr/testbed/exparchive/Archive/$repoidx/repo/";
if (! ISADMIN() &&
! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) {
USERERROR("Not enough permission to view cvs repo for template", 1);
}
$use_viewvc = 1;
# Repo for the entire template stored here per-template.
$repodir = "$TBPROJ_DIR/$pid/templates/$guid/cvsrepo/$guid";
}
else {
$this_user = CheckLoginOrDie();
......
......@@ -11,16 +11,21 @@
chdir("../");
require("defs.php3");
#
# Make sure that URL args are cleaned.
#
RequiredPageArguments();
# Must be logged in.
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify form arguments.
#
$optargs = OptionalPageArguments("template", PAGEARG_TEMPLATE,
"project", PAGEARG_PROJECT,
"embedded", PAGEARG_BOOLEAN);
if (!isset($embedded)) {
$embedded = 0;
}
#
# Form the real url.
#
......@@ -32,24 +37,20 @@ $newurl = preg_replace("/php3/","php3/",$newurl);
#
PAGEHEADER("Emulab CVS Repository");
?>
<head>
<style type="text/css">
#cvsfr {
width: 100%;
height: 800px;
if (isset($project)) {
;
}
elseif (isset($template)) {
echo $template->PageHeader();
}
</style>
</head>
<div id="cvscon">
<iframe id="cvsfr" scrolling=yes src="<?php echo $newurl ?>" border=0></iframe>
</div>
echo "<div><iframe src='$newurl' class='outputframe' ".
"id='outputframe' name='outputframe'></iframe></div>\n";
echo "</center><br>\n";
<?php
echo "<script type='text/javascript' language='javascript'>\n";
echo "SetupOutputArea('outputframe', false);\n";
echo "</script>\n";
#
# Standard Testbed Footer
......
......@@ -167,6 +167,15 @@ class Template
return $this->experiment;
}
function GetProject() {
$pid = $this->pid();
if (! ($project = Project::Lookup($pid))) {
TBERROR("Could not lookup project $pid!", 1);
}
return $project;
}
# Return the unixgid for operating on this template.
function UnixGID() {
$experiment = $this->experiment;
......@@ -2282,7 +2291,7 @@ function MakeLink($which, $args, $text)
$page = "showuser.php3";
}
elseif ($which == "template") {
$page = "template_show.php";
$page = "/template_show.php";
}
elseif ($which == "metadata") {
$page = "template_metadata.php";
......
......@@ -323,6 +323,9 @@ if ($template->EventCount() > 0) {
WRITESUBMENUBUTTON("Browse Datastore",
CreateURL("archive_view", $template));
WRITESUBMENUBUTTON("Browse CVS Repository",
CreateURL("cvswebwrap", $template));
WRITESUBMENUBUTTON("View Records",
CreateURL("template_history", $template));
......
......@@ -105,6 +105,7 @@ $url_mapping["spitreport"] = "spitreport.php";
$url_mapping["statechange"] = "statechange.php";
$url_mapping["experimentrun_show"] = "experimentrun_show.php";
$url_mapping["instance_show"] = "instance_show.php";
$url_mapping["cvswebwrap"] = "cvsweb/cvswebwrap.php3";
#
# The caller will pass in a page id, and a list of things. If the thing
......
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