delmmlist.php3 3.1 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2005-2012 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/>.
# 
# }}}
23 24 25 26 27 28 29 30 31 32
#
include("defs.php3");

#
# No Testbed Header; we zap back.
#

#
# Only known and logged in users.
#
33 34 35
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
36 37

#
38
# Verify page arguments.
39
#
40 41 42 43
$reqargs = RequiredPageArguments("listname",        PAGEARG_STRING);
$optargs = OptionalPageArguments("canceled",        PAGEARG_BOOLEAN,
				 "confirmed",       PAGEARG_BOOLEAN);

44
if (! TBvalid_mailman_listname($listname)) {
45
    $listname = CleanString($listname);
46 47 48 49 50 51
    PAGEARGERROR("Invalid characters in $listname!");
}

#
# Grab the DB state.
#
52
$query_result = DBQueryFatal("select owner_idx from mailman_listnames ".
53 54 55 56 57 58
			     "where listname='$listname'");

if (!mysql_num_rows($query_result)) {
    USERERROR("No such list $listname!", 1);
}
$row = mysql_fetch_array($query_result);
59
$owner_idx = $row['owner_idx'];
60 61 62 63

#
# Verify permission.
#
64
if ($this_user->uid_idx() != $owner_idx && !$isadmin) {
65 66 67 68 69 70 71 72 73
    USERERROR("You do not have permission to delete list $listname!", 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.
#
74
if (isset($canceled) && $canceled) {
75 76 77 78 79 80 81 82 83 84
    PAGEHEADER("Delete a Mailman List");
    
    echo "<center><h2>
          List removal canceled!
          </h2></center>\n";
    
    PAGEFOOTER();
    return;
}

85
if (!isset($confirmed)) {
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    PAGEHEADER("Delete a Mailman List");
    
    echo "<center><h2>
          Are you <b>REALLY</b> sure you want to remove $listname
          </h2>\n";
    
    echo "<form action='delmmlist.php3?listname=$listname' 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;
}

102
PAGEHEADER("Delete a Mailman List");
103
STARTBUSY("Deleting list $listname");
104
SUEXEC($uid, $TBADMINGROUP, "webdelmmlist -u $listname", SUEXEC_ACTION_DIE);
105
STOPBUSY();
106 107 108 109 110 111

#
# Worked, so delete the record from the DB.
#
DBQueryFatal("delete from mailman_listnames ".
	     "where listname='$listname'");
112 113 114 115
#
# Back to the lists list.
# 
PAGEREPLACE("showmmlists.php3");
116 117

#
118
# Standard Testbed Footer
119
# 
120
PAGEFOOTER();
121
?>