delete_user.php
author rejo
Sun, 22 Apr 2007 07:27:49 +0000
changeset 9 d55459cd1712
parent 8 47dd15d8bb8c
child 13 2ff220cfde13
permissions -rw-r--r--
[feladat @ 22] - Fixed bug in install.php (was still using sequence stuff). - Changed alignment of columns in user listing in users.php.
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
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     3
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     4
// | PowerAdmin								|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     5
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     6
// | Copyright (c) 1997-2002 The PowerAdmin Team			|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     7
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     8
// | This source file is subject to the license carried by the overal	|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
     9
// | program PowerAdmin as found on http://poweradmin.sf.net		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    10
// | The PowerAdmin program falls under the QPL License:		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    11
// | http://www.trolltech.com/developer/licensing/qpl.html		|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    12
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    13
// | Authors: Roeland Nieuwenhuis <trancer <AT> trancer <DOT> nl>	|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    14
// |          Sjeemz <sjeemz <AT> sjeemz <DOT> nl>			|
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    15
// +--------------------------------------------------------------------+
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    16
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    17
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    18
// $Id: delete_user.php,v 1.9 2003/01/01 22:33:46 azurazu Exp $
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    19
//
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    20
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    21
require_once("inc/toolkit.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    22
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    23
$id = ($_POST["id"]) ? $_POST["id"] : $_GET["id"];
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    24
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    25
if(isset($id)) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    26
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    27
	if($_POST["confirm"] == '1') 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    28
	{                
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    29
                $domain = is_array($_POST["domain"]) ? $_POST["domain"] : $domain = array();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    30
                $delete = is_array($_POST["delete"]) ? $_POST["delete"] : $delete = array();
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    31
                
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    32
		if(count($domain) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    33
		{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    34
			foreach ($domain as $dom => $newowner) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    35
			{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    36
				if (!in_array($dom, $delete)) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    37
				{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    38
					add_owner($dom, $newowner);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    39
                                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    40
                        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    41
                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    42
                if(count($delete) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    43
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    44
                	foreach ($delete as $del) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    45
                	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    46
                		delete_domain($del);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    47
			}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    48
		}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    49
		
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    50
                delete_user($id);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    51
                clean_page($BASE_URL . $BASE_PATH . "users.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    52
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    53
        include_once("inc/header.inc.php");
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    54
        ?><H2><? echo _('Delete user'); ?> "<?= get_fullname_from_userid($id) ?>"</H2>
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    55
        <FORM METHOD="post">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    56
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    57
        $domains = get_domains_from_userid($id);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    58
        if (count($domains) > 0) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    59
        {
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    60
        	echo _('This user has access to the following domain(s)'); ?> :<BR><?
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    61
                $users = show_users($id);
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    62
                if(count($users) < 1) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    63
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    64
                        $add = " CHECKED DISABLED";
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    65
                        $no_users = 1;
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    66
                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    67
                ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    68
                <TABLE BORDER="0" CELLSPACING="4">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    69
                <TR STYLE="font-weight: Bold"><TD WIDTH="50" CLASS="tdbg">Delete</TD><TD CLASS="tdbg">Name</TD><? if (!$no_users) { ?><TD CLASS="tdbg">New owner</TD><? } ?></TR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    70
                <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    71
                foreach ($domains as $d) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    72
                {
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    73
                        ?><TR><TD CLASS="tdbg" ALIGN="center"><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    74
                        if ($no_users) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    75
                     	{ 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    76
                     		?><INPUT TYPE="hidden" NAME="delete[]" VALUE="<?= $d["id"] ?>"><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    77
                        } 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    78
                        ?><INPUT TYPE="checkbox"<?= $add ?> NAME="delete[]" VALUE="<?= $d["id"] ?>"></TD><TD CLASS="tdbg"><?= $d["name"] ?></TD><TD CLASS="tdbg"><? 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    79
                        if (!$no_users) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    80
                        { 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    81
                        	?><SELECT NAME="domain[<?= $d["id"] ?>]"><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    82
                        	foreach($users as $u) 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    83
                        	{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    84
                        	        ?><OPTION VALUE="<?= $u["id"] ?>"><?= $u["fullname"] ?></OPTION><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    85
                        	}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    86
                        	?></SELECT></TD><? 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    87
                        } 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    88
                        ?></TR><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    89
                }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    90
                ?></TABLE><?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    91
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    92
        
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
    93
        $message = _('You are going to delete this user, are you sure?');
8
47dd15d8bb8c [feladat @ 20]
rejo
parents: 3
diff changeset
    94
        if(($numrows = $db->queryOne("select count(id) from zones where owner=$id")) != 0)
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    95
        {
3
64525a2eb098 [feladat @ 4]
rejo
parents: 2
diff changeset
    96
        	$message .= " " . _('This user has access to ') . $numrows . _('domain(s), by deleting him you will also delete these domains');
1
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    97
        }
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    98
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
    99
        ?>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   100
        <BR><FONT CLASS="warning"><?= $message ?></FONT><BR><BR>
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   101
        <INPUT TYPE="hidden" NAME="id" VALUE="<?=$id ?>">
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   102
        <INPUT TYPE="hidden" NAME="confirm" VALUE="1">
2
9a485c41cfcf [feladat @ 3]
rejo
parents: 1
diff changeset
   103
        <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
   104
        <?
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   105
        include_once("inc/footer.inc.php");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   106
} 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   107
else 
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   108
{
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   109
        message("Nothing to do!");
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   110
}
58094faf794d [feladat @ 2]
rejo
parents:
diff changeset
   111