deletegroup.php3 2.84 KB
Newer Older
Leigh Stoller's avatar
Leigh Stoller committed
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh Stoller's avatar
Leigh Stoller committed
5 6
# All rights reserved.
#
Leigh Stoller's avatar
Leigh Stoller committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
include("defs.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Delete a Group");

#
# Only known and logged in users.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# First off, sanity check page args.
#
if (!isset($pid) ||
    strcmp($pid, "") == 0) {
    USERERROR("Must provide a Project ID!", 1);
}
if (!isset($gid) ||
    strcmp($gid, "") == 0) {
    USERERROR("Must privide a Group ID!", 1);
}

#
# We do not allow the default group to be deleted. Never ever!
#
if (strcmp($gid, $pid) == 0) {
    USERERROR("You are not allowed to delete a project's default group!", 1);
}

#
# Verify permission.
#
42
if (! TBProjAccessCheck($uid, $pid, $pid, $TB_PROJECT_DELGROUP)) {
Leigh Stoller's avatar
Leigh Stoller committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
    USERERROR("You do not have permission to delete groups in project $pid!",
	      1);
}

#
# Check to see if there are any active experiments. Abort if there are.
#
$query_result =
    DBQueryFatal("SELECT * FROM experiments where pid='$pid' and gid='$gid'");
if (mysql_num_rows($query_result)) {
    USERERROR("Project/Group '$pid/$gid' has active experiments. You must ".
	      "terminate ".
	      "those experiments 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
# set. Or, the user can hit the cancel button, in which case we should
# probably redirect the browser back up a level.
#
if ($canceled) {
    echo "<center><h2>
          Group removal canceled!
          </h2></center>\n";
    
    PAGEFOOTER();
    return;
}

if (!$confirmed) {
    echo "<center><h2>
          Are you <b>REALLY</b> sure you want to remove Group $gid
          in Project $pid?
          </h2>\n";
    
    echo "<form action='deletegroup.php3?pid=$pid&gid=$gid' method=post>";
    echo "<b><input type=submit name=confirmed value=Confirm></b>\n";
    echo "<b><input type=submit name=canceled value=Cancel></b>\n";
    echo "</form>\n";
    echo "</center>\n";

    PAGEFOOTER();
    return;
}

#
# Grab the unix group info of the project for running scripts.
#
TBGroupUnixInfo($pid, $pid, $unix_gid, $unix_name);

94 95 96 97 98 99 100
echo "<br>
      Group '$gid' in 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();

Leigh Stoller's avatar
Leigh Stoller committed
101
#
102 103
# Run the script. They will remove the group directory and the unix group,
# and the DB state.
Leigh Stoller's avatar
Leigh Stoller committed
104 105 106 107
#
SUEXEC($uid, $unix_gid, "webrmgroup $pid $gid", 1);

#
108
# Warm fuzzies.
Leigh Stoller's avatar
Leigh Stoller committed
109
#
110 111 112
echo "<br>
      <b>Done!</b>
      <br>\n";
Leigh Stoller's avatar
Leigh Stoller committed
113 114

#
115 116 117 118
# Back to ...
# 
echo "<br>
       <A href='showproject.php3?pid=$pid'>Back to Project page</a>\n";
Leigh Stoller's avatar
Leigh Stoller committed
119 120 121 122 123 124

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