deleteproject.php3 3.36 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
3
# Copyright (c) 2000-2003, 2006, 2007 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/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24 25 26 27 28
include("defs.php3");

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

#
# Currently, only admin users can do this. Change later.
#
if (! $isadmin) {
37
    USERERROR("You do not have permission to remove projects", 1);
38 39 40
}

#
41
# Verify page arguments.
42
#
43 44 45 46 47 48 49
$reqargs = RequiredPageArguments("project",   PAGEARG_PROJECT);
$optargs = OptionalPageArguments("canceled",  PAGEARG_BOOLEAN,
				 "confirmed", PAGEARG_BOOLEAN,
				 "confirmed_twice", PAGEARG_BOOLEAN);

# Need these below.
$pid = $project->pid();
50

51 52 53 54 55 56

#
# Standard Testbed Header
#
PAGEHEADER("Terminating Project and Remove all Trace");

57 58 59
#
# Check to see if there are any active experiments. Abort if there are.
#
60 61 62
if ($project->ExperimentList(0)) {
    USERERROR("Project '$pid' has active experiments.<br>".
	      "You must terminate ".
63 64 65 66 67 68 69 70 71
	      "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.
#
72
if (isset($canceled) && $canceled) {
73 74 75 76 77 78 79 80
    echo "<center><h2>
          Project removal canceled!
          </h2></center>\n";
    
    PAGEFOOTER();
    return;
}

81
if (!isset($confirmed)) {
82 83 84
    echo "<center><h2>
          Are you <b>REALLY</b> sure you want to remove Project '$pid?'
          </h2>\n";
85 86

    $url = CreateURL("deleteproject", $project);
87
    
88
    echo "<form action='$url' method=\"post\">";
89 90 91 92 93 94 95 96 97
    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;
}

98
if (!isset($confirmed_twice)) {
99 100 101 102 103
    echo "<center><h2>
	  Okay, lets be sure.<br>
          Are you <b>REALLY REALLY</b> sure you want to remove Project '$pid?'
          </h2>\n";
    
104 105 106
    $url = CreateURL("deleteproject", $project);
    
    echo "<form action='$url' method=\"post\">";
107 108 109 110 111 112 113 114 115 116
    echo "<input type=hidden name=confirmed value=Confirm>\n";
    echo "<b><input type=submit name=confirmed_twice value=Confirm></b>\n";
    echo "<b><input type=submit name=canceled value=Cancel></b>\n";
    echo "</form>\n";
    echo "</center>\n";

    PAGEFOOTER();
    return;
}

117 118 119
STARTBUSY("Removing all trace of project '$pid'");
SUEXEC($uid, $TBADMINGROUP, "webrmproj $pid", SUEXEC_ACTION_DIE);
STOPBUSY();
120 121 122 123 124 125

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