Project

General

Profile

1
<?php
2

    
3
/**
4
 *
5
 * @category        admin
6
 * @package         pages
7
 * @author          Ryan Djurovich (2004-2009), WebsiteBaker Project
8
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id: delete.php 1844 2012-12-28 06:03:26Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/users/delete.php $
15
 * @lastmodified    $Date: 2012-12-28 07:03:26 +0100 (Fri, 28 Dec 2012) $
16
 *
17
 */
18

    
19
/* -------------------------------------------------------- */
20
// Must include code to stop this file being accessed directly
21
if(!defined('WB_URL')) {
22
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
23
	throw new IllegalFileException();
24
}
25
/* -------------------------------------------------------- */
26
function delete_user($admin, &$aActionRequest)
27
{
28
	global $TEXT, $MESSAGE;
29
	$database = WbDatabase::getInstance();
30
    $aUserID = array();
31
    $bRetVal = false;
32
    if(isset($aActionRequest['activation_user_id'])) {
33
		if(!is_array($aActionRequest['activation_user_id'])) {
34
	
35
	        $aUserID[] = $aActionRequest['activation_user_id'];
36
	    } else {
37
	        $aUserID = $aActionRequest['activation_user_id'];
38
	    }
39
    } else {
40
	    if(isset($aActionRequest['user_id'])) {
41
			if(!is_array($aActionRequest['user_id'])) {
42
		
43
		        $aUserID[] = $aActionRequest['user_id'];
44
		    } else {
45
		        $aUserID = $aActionRequest['user_id'];
46
		    }
47
	    } 
48
    } 
49

    
50
    foreach ( $aUserID AS $key => $value)
51
    {
52
        switch ($_SERVER['REQUEST_METHOD']) :
53
			case 'GET': // insert/update user
54
                $_GET['user_id'] =$aUserID[$key];
55
				break;
56
			default: // show userlist with empty modify mask
57
                $_POST['user_id'] =$aUserID[$key];
58
		endswitch; // end of switch
59
		$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
60

    
61
		// Check if user id is a valid number and doesnt equal 1
62
		if($user_id == 0){
63
			msgQueue::add($MESSAGE['GENERIC_FORGOT_OPTIONS'] );
64
            return $bRetVal;
65
        }
66

    
67
		if( ($user_id < 2 ) )
68
		{
69
			// if($admin_header) { $admin->print_header(); }
70
			msgQueue::add($MESSAGE['GENERIC_SECURITY_ACCESS'] );
71
            return $bRetVal;
72
		}
73

    
74
		if( ($msg = msgQueue::getError()) == '')
75
		{
76
			$sql  = 'SELECT `active` FROM `'.TABLE_PREFIX.'users` '.
77
                    'WHERE `user_id` = '.$user_id;
78
            if( ($iDeleteUser = $database->get_one($sql)) != null ) {
79
                if($iDeleteUser) {
80
    				// Delete the user
81
        			$sql  = 'UPDATE `'.TABLE_PREFIX.'users` SET '.
82
                            '`active` = 0 '.
83
                            'WHERE `user_id` = '.$user_id;
84
                    if( $database->query($sql) ) {
85
                        msgQueue::add($TEXT['USERS_DELETED'], true);
86
                    }
87
                } else {
88
        			$sql  = 'DELETE FROM `'.TABLE_PREFIX.'users` '.
89
                            'WHERE `user_id` = '.$user_id;
90
                    if( $database->query($sql) ) {
91
                        msgQueue::add($MESSAGE['USERS_DELETED'], true);
92
                    }
93
                }
94
                $bRetVal = true;
95
            }
96
            if($database->is_error()) {
97
                msgQueue::add( implode('<br />',explode(';',$database->get_error())) );
98
                $bRetVal = false;
99
           }
100
		}
101
    }
102
    if(isset($aActionRequest['clearmsg'])) { msgQueue::clear();  }
103
    return $bRetVal;
104
}
105

    
106
if(!isset($aActionRequest)) {
107
    $requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
108
    $aActionRequest = (isset(${$requestMethod})) ? ${$requestMethod} : null;
109
    $aActionRequest['clearmsg'] = true;
110
}
(2-2/7)