deleteproject.php3 2.67 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003, 2006, 2007 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6
# All rights reserved.
#
7 8 9 10 11
include("defs.php3");

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

#
# Currently, only admin users can do this. Change later.
#
if (! $isadmin) {
20
    USERERROR("You do not have permission to remove projects", 1);
21 22 23
}

#
24
# Verify page arguments.
25
#
26 27 28 29 30 31 32
$reqargs = RequiredPageArguments("project",   PAGEARG_PROJECT);
$optargs = OptionalPageArguments("canceled",  PAGEARG_BOOLEAN,
				 "confirmed", PAGEARG_BOOLEAN,
				 "confirmed_twice", PAGEARG_BOOLEAN);

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

34 35 36 37 38 39

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

40 41 42
#
# Check to see if there are any active experiments. Abort if there are.
#
43 44 45
if ($project->ExperimentList(0)) {
    USERERROR("Project '$pid' has active experiments.<br>".
	      "You must terminate ".
46 47 48 49 50 51 52 53 54
	      "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.
#
55
if (isset($canceled) && $canceled) {
56 57 58 59 60 61 62 63
    echo "<center><h2>
          Project removal canceled!
          </h2></center>\n";
    
    PAGEFOOTER();
    return;
}

64
if (!isset($confirmed)) {
65 66 67
    echo "<center><h2>
          Are you <b>REALLY</b> sure you want to remove Project '$pid?'
          </h2>\n";
68 69

    $url = CreateURL("deleteproject", $project);
70
    
71
    echo "<form action='$url' method=\"post\">";
72 73 74 75 76 77 78 79 80
    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;
}

81
if (!isset($confirmed_twice)) {
82 83 84 85 86
    echo "<center><h2>
	  Okay, lets be sure.<br>
          Are you <b>REALLY REALLY</b> sure you want to remove Project '$pid?'
          </h2>\n";
    
87 88 89
    $url = CreateURL("deleteproject", $project);
    
    echo "<form action='$url' method=\"post\">";
90 91 92 93 94 95 96 97 98 99
    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;
}

100 101 102
STARTBUSY("Removing all trace of project '$pid'");
SUEXEC($uid, $TBADMINGROUP, "webrmproj $pid", SUEXEC_ACTION_DIE);
STOPBUSY();
103 104 105 106 107 108

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