delete_user.php
author rejo
Wed, 13 Jun 2007 13:32:39 +0000
changeset 22 0918664b9ff6
parent 13 2ff220cfde13
child 47 ae140472d97c
permissions -rw-r--r--
[feladat @ 69] Changed some left-over "domains" to "zones" in web interface.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     1
<?php
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     2
require_once("inc/toolkit.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     3
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
$id = ($_POST["id"]) ? $_POST["id"] : $_GET["id"];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
if(isset($id)) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
	if($_POST["confirm"] == '1') 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
	{                
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
                $domain = is_array($_POST["domain"]) ? $_POST["domain"] : $domain = array();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
                $delete = is_array($_POST["delete"]) ? $_POST["delete"] : $delete = array();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
                
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
		if(count($domain) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
			foreach ($domain as $dom => $newowner) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
				if (!in_array($dom, $delete)) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
				{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
					add_owner($dom, $newowner);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    20
                                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
                        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
                if(count($delete) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
                	foreach ($delete as $del) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
                	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
                		delete_domain($del);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
		
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
                delete_user($id);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
                clean_page($BASE_URL . $BASE_PATH . "users.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
        include_once("inc/header.inc.php");
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    35
        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    36
	
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    37
    <h3><? echo _('Delete user'); ?> "<? echo get_fullname_from_userid($id) ?>"</h3>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    38
     <form method="post">
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
        $domains = get_domains_from_userid($id);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
        if (count($domains) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
        {
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    43
        	echo _('This user has access to the following zone(s)'); ?> :<BR><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
                $users = show_users($id);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
                if(count($users) < 1) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
                        $add = " CHECKED DISABLED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    48
                        $no_users = 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
                ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    51
                <table>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    52
                 <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    53
		  <td class="n">Delete</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    54
		  <td class="n">Name</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    55
		<? if (!$no_users) { ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    56
		  <td class="n">New owner</td>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    57
		<? } ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    58
		 </tr>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
                <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    60
                foreach ($domains as $d) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
                {
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    62
                        ?>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    63
                 <tr>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    64
		  <td class="n" align="center"><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
                        if ($no_users) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    66
                     	{ 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    67
                     		?><input type="hidden" name="delete[]" value="<? echo $d["id"] ?>"><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    68
                        } 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    69
                        ?><input type="checkbox"<? echo $add ?> name="delete[]" value="<? echo $d["id"] ?>"></td><td class="n"><? echo $d["name"] ?></td><td class="n"><? 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
                        if (!$no_users) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    71
                        { 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    72
                        	?><select name="domain[<? echo $d["id"] ?>]"><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
                        	foreach($users as $u) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
                        	{
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    75
                        	        ?><option value="<? echo $u["id"] ?>"><? echo $u["fullname"] ?></option><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    76
                        	}
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    77
                        	?></select></td><? 
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    78
                        } 
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    79
                        ?></tr><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    80
                }
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    81
                ?></table><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    82
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
        
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    84
        $message = _('You are going to delete this user, are you sure?');
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 3
diff changeset
    85
        if(($numrows = $db->queryOne("select count(id) from zones where owner=$id")) != 0)
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    86
        {
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    87
        	$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
    88
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
        ?>
13
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    91
        <font class="warning"><? echo $message ?></font><br>
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    92
        <input type="hidden" name="id" value="<? echo $id ?>">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    93
        <input type="hidden" name="confirm" value="1">
2ff220cfde13 [feladat @ 60]
rejo
parents: 8
diff changeset
    94
        <input type="submit" class="button" value="<? echo _('Yes'); ?>"> <input type="button" class="button" OnClick="location.href='users.php'" value="<? echo _('No'); ?>"></FORM>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    96
        include_once("inc/footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
} 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
        message("Nothing to do!");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102