delete_user.php
author peter
Mon, 11 Feb 2008 19:52:20 +0000
changeset 74 43c31dc98305
parent 73 8a239565e9b3
child 82 c255196bc447
permissions -rw-r--r--
[feladat @ 121] Moved the constants down, so the ROWAMOUNT can be defined in the config.inc.php file. This to solve ticket:20. Fixed a bug which was introduced in r112. The used arguments in the setLimit function where in the wrong order.
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
ae140472d97c [feladat @ 94]
rejo
parents: 13
diff changeset
     3
/*  PowerAdmin, a friendly web-based admin tool for PowerDNS.
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");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
$id = ($_POST["id"]) ? $_POST["id"] : $_GET["id"];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
if(isset($id)) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
	if($_POST["confirm"] == '1') 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
	{                
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
                $domain = is_array($_POST["domain"]) ? $_POST["domain"] : $domain = array();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
                $delete = is_array($_POST["delete"]) ? $_POST["delete"] : $delete = array();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
                
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
		if(count($domain) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
			foreach ($domain as $dom => $newowner) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
				if (!in_array($dom, $delete)) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
				{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
					add_owner($dom, $newowner);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
                                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
                        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
                if(count($delete) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
                	foreach ($delete as $del) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
                	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
                		delete_domain($del);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    48
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
		
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
                delete_user($id);
73
8a239565e9b3 [feladat @ 120]
peter
parents: 71
diff changeset
    52
                clean_page("users.php");
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    54
        include_once("inc/header.inc.php");
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    55
        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    56
	
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    57
    <h3><?php echo _('Delete user'); ?> "<?php echo get_fullname_from_userid($id) ?>"</h3>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    58
     <form method="post">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    59
        <?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
        $domains = get_domains_from_userid($id);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
        if (count($domains) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
        {
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    63
        	echo _('This user has access to the following zone(s)'); ?> :<BR><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
                $users = show_users($id);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
                if(count($users) < 1) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    66
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    67
                        $add = " CHECKED DISABLED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    68
                        $no_users = 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    69
                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
                ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    71
                <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    72
                 <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    73
		  <td class="n">Delete</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    74
		  <td class="n">Name</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    75
		<?php if (!$no_users) { ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    76
		  <td class="n">New owner</td>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    77
		<?php } ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    78
		 </tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    79
                <?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    80
                foreach ($domains as $d) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    81
                {
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    82
                        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    83
                 <tr>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    84
		  <td class="n" align="center"><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
                        if ($no_users) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    86
                     	{ 
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    87
                     		?><input type="hidden" name="delete[]" value="<?php echo $d["id"] ?>"><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    88
                        } 
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    89
                        ?><input type="checkbox"<?php echo $add ?> name="delete[]" value="<?php echo $d["id"] ?>"></td><td class="n"><?php echo $d["name"] ?></td><td class="n"><?php 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
                        if (!$no_users) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
                        { 
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    92
                        	?><select name="domain[<?php echo $d["id"] ?>]"><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    93
                        	foreach($users as $u) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    94
                        	{
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    95
                        	        ?><option value="<?php echo $u["id"] ?>"><?php echo $u["fullname"] ?></option><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
                        	}
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    97
                        	?></select></td><?php 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
                        } 
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
    99
                        ?></tr><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
                }
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   101
                ?></table><?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   103
        
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   104
        $message = _('You are going to delete this user, are you sure?');
65
ce1c4d5e1576 [feladat @ 112]
peter
parents: 47
diff changeset
   105
        if(($numrows = $db->queryOne("SELECT count(id) FROM zones WHERE owner=".$db->quote($id))) != 0)
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
        {
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   107
        	$message .= " " . _('This user has access to ') . $numrows . _(' zones, by deleting him you will also delete these zones.');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
        ?>
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   111
        <font class="warning"><?php echo $message ?></font><br>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   112
        <input type="hidden" name="id" value="<?php echo $id ?>">
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
   113
        <input type="hidden" name="confirm" value="1">
71
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   114
        <input type="submit" class="button" value="<?php echo _('Yes'); ?>"> <input type="button" class="button" OnClick="location.href='users.php'" value="<?php echo _('No'); ?>"></FORM>
e1b918eaf69a [feladat @ 118]
peter
parents: 65
diff changeset
   115
        <?php
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   116
        include_once("inc/footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   117
} 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   118
else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   119
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   120
        message("Nothing to do!");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   121
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   122