delete_user.php
author rejo
Mon, 14 Jul 2008 22:44:32 +0000
changeset 190 7a683326ccec
parent 185 6baa2f78d3fe
permissions -rw-r--r--
[feladat @ 299] Fixed a number of undefined errors warnings. Updated a number variable names for consistency. Update PHP syntax for consistency.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?php
47
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     2
119
f74e4f88b680 [feladat @ 222]
rejo
parents: 110
diff changeset
     3
/*  Poweradmin, a friendly web-based admin tool for PowerDNS.
47
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     4
 *  See <https://rejo.zenger.nl/poweradmin> for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     5
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     6
 *  Copyright 2007, 2008  Rejo Zenger <rejo@zenger.nl>
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     7
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     8
 *  This program is free software: you can redistribute it and/or modify
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     9
 *  it under the terms of the GNU General Public License as published by
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    10
 *  the Free Software Foundation, either version 3 of the License, or
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    11
 *  (at your option) any later version.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    12
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    13
 *  This program is distributed in the hope that it will be useful,
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    16
 *  GNU General Public License for more details.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    17
 *
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    18
 *  You should have received a copy of the GNU General Public License
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    20
 */
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
    21
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
require_once("inc/toolkit.inc.php");
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    23
include_once("inc/header.inc.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    25
verify_permission('user_edit_own') ? $perm_edit_own = "1" : $perm_edit_own = "0" ;
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    26
verify_permission('user_edit_others') ? $perm_edit_others = "1" : $perm_edit_others = "0" ;
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    27
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    28
if (!(isset($_GET['id']) && v_num($_GET['id']))) {
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    29
	error(ERR_INV_INPUT);
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    30
	include_once("inc/footer.inc.php");
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    31
	exit;
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    32
} else {
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    33
	$uid = $_GET['id'];
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    34
}
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    35
185
6baa2f78d3fe [feladat @ 293]
rejo
parents: 126
diff changeset
    36
if (isset($_POST['commit'])) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    37
	if (delete_user($uid,$_POST['zone'])) {
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    38
		success(SUC_USER_DEL);	
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    39
	}
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    40
} else {
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    41
126
cb06e3e29ed8 [feladat @ 230]
peter
parents: 119
diff changeset
    42
	if (($uid != $_SESSION['userid'] && !verify_permission('user_edit_others')) || ($uid == $_SESSION['userid'] && !verify_permission('user_edit_own'))) {
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    43
		error(ERR_PERM_DEL_USER);
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    44
		include_once("inc/footer.inc.php");
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    45
		exit;
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    46
	} else {
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    47
		$fullname = get_fullname_from_userid($uid);
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    48
		$zones = get_zones("own",$uid);
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    49
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    50
		echo "     <h2>" . _('Delete user') . " \"" . $fullname . "\"</h2>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    51
		echo "     <form method=\"post\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    52
		echo "      <table>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    53
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    54
		if (count($zones) > 0) {
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    56
			$users = show_users();
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    57
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    58
			echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    59
			echo "        <td colspan=\"5\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    60
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    61
			echo "         " . _('You are about to delete a user. This user is owner for a number of zones. Please decide what to do with these zones.') . "\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    62
			echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    63
			echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    64
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    65
			echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    66
			echo "        <th>" . _('Zone') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    67
			echo "        <th>" . _('Delete') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    68
			echo "        <th>" . _('Leave') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    69
			echo "        <th>" . _('Add new owner') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    70
			echo "        <th>" . _('Owner to be added') . "</th>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    71
			echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    72
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    73
			foreach ($zones as $zone) {
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    74
				echo "       <input type=\"hidden\" name=\"zone[" . $zone['id'] . "][zid]\" value=\"" . $zone['id'] . "\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    75
				echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    76
				echo "        <td>" . $zone['name'] . "</td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    77
				echo "        <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"delete\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    78
				echo "        <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"leave\" CHECKED></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    79
				echo "        <td><input type=\"radio\" name=\"zone[" . $zone['id'] . "][target]\" value=\"new_owner\"></td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    80
				echo "        <td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    81
				echo "         <select name=\"zone[" . $zone['id'] . "][newowner]\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    83
				foreach ($users as $user) {
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    84
					echo "          <option value=\"" . $user["id"] . "\">" . $user["fullname"] . "</option>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    85
				}
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    86
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    87
				echo "         </select>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    88
				echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    89
				echo "       </tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    90
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
		}
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    93
		echo "       <tr>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    94
		echo "        <td colspan=\"5\">\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    95
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    96
		echo "         " . _('Really delete this user?') . "\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    97
		echo "        </td>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
    98
		echo "       </tr>\n";
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
   100
		echo "      </table>\n";
110
455405c757e1 [feladat @ 210]
rejo
parents: 82
diff changeset
   101
		echo "     <input type=\"submit\" class=\"button\" name=\"commit\" value=\"" . _('Commit changes') . "\">\n";
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
   102
		echo "     </form>\n";
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
   103
	}
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   104
}
82
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
   105
include_once("inc/footer.inc.php");
c255196bc447 [feladat @ 182]
rejo
parents: 73
diff changeset
   106
?>