Commit ba3d5a21 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Clean up and changes reflecting mods to backend rmproj script. Move

all the DB changes to the script. Add more error checks. Remove mail,
since thats done in the backend now.
parent 6b0a3a7a
<?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2002 University of Utah and the Flux Group.
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");
......@@ -27,23 +27,9 @@ if (! $isadmin) {
#
# Confirm a real project
#
$query_result =
DBQueryFatal("SELECT head_uid FROM projects where pid='$pid'");
if (mysql_num_rows($query_result) == 0) {
USERERROR("No such project '$pid'", 1);
}
$row = mysql_fetch_row($query_result);
$head_uid = $row[0];
#
# Check user.
#
if (!$isadmin) {
if (strcmp($uid, $head_uid)) {
USERERROR("Only the project leader or an administrator may ".
"terminate a project!", 1);
}
if (! TBValidProject($pid)) {
USERERROR("No such project '$pid'", 1);
}
#
......@@ -56,16 +42,6 @@ if (mysql_num_rows($query_result)) {
"those experiments before you can remove the project!", 1);
}
#
# Check to see if there are any groups. Force them to be deleted.
#
$query_result =
DBQueryFatal("SELECT * FROM groups where pid='$pid' and pid!=gid");
if (mysql_num_rows($query_result)) {
USERERROR("Project '$pid' has active groups. You must delete ".
"those groups before you can remove the project!", 1);
}
#
# We run this twice. The first time we are checking for a confirmation
# by putting up a form. The next time through the confirmation will be
......@@ -115,47 +91,24 @@ if (!$confirmed_twice) {
return;
}
#
# The group membership table needs to be cleaned.
#
$query_result =
DBQueryFatal("delete FROM group_membership where pid='$pid'");
echo "<br>
Project '$pid' is being removed!<br><br>
This will take a minute or two. <b>Please</b> do not click the Stop
button during this time. If you do not receive notification within
a reasonable amount of time, please contact $TBMAILADDR.<br>\n";
flush();
#
# Remove the project directory and the group.
#
SUEXEC($uid, $TBADMINGROUP, "rmproj $pid", 0);
#
# Then the project table itself.
#
$query_result =
DBQueryFatal("delete FROM projects where pid='$pid'");
SUEXEC($uid, $TBADMINGROUP, "rmproj $pid", 1);
#
# Warm fuzzies.
#
echo "<center><h2>
Project '$pid' has been removed with prejudice!
</h2></center>\n";
#
# Generate an email to the testbed list so we all know what happened.
#
$query_result =
DBQueryFatal("select usr_name,usr_email FROM users where uid='$uid'");
if (($row = mysql_fetch_row($query_result)) == 0) {
DBFatal("Getting user info for $uid");
}
$uid_name = $row[0];
$uid_email = $row[1];
TBMAIL($TBMAIL_OPS,
"Project $pid removed",
"Project '$pid' has been removed by $uid ($uid_name).\n\n".
"Please remember to remove the backup directory in /proj\n\n",
"From: $uid_name <$uid_email>\n".
"Errors-To: $TBMAIL_WWW");
echo "<br>
<b>Done!</b>
<br>\n";
#
# Standard Testbed Footer
......
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