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 2070 2014-01-03 01:21:42Z darkviper $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/users/delete.php $
15
 * @lastmodified    $Date: 2014-01-03 02:21:42 +0100 (Fri, 03 Jan 2014) $
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
	$database = WbDatabase::getInstance();
29
	$mLang = Translate::getInstance();
30
    $aUserID = array();
31
    $bRetVal = false;
32

    
33
    $action = 'default';
34
    $action = (isset($aActionRequest['delete']) ? 'delete' : $action );
35
    $action = (isset($aActionRequest['delete_outdated']) ? 'delete_outdated' : $action );
36

    
37
	switch($action) :
38
		case 'delete': // delete the user
39
    	    if(isset($aActionRequest['user_id'])) {
40
    			if(!is_array($aActionRequest['user_id'])) {
41
    		        $aUserID[] = $aActionRequest['user_id'];
42
    		    } else {
43
    		        $aUserID = $aActionRequest['user_id'];
44
    		    }
45
    	    } 
46
    		break;
47
		case 'delete_outdated': // delete Users awaiting activation
48
            if(isset($aActionRequest['activation_user_id'])) {
49
        		if(!is_array($aActionRequest['activation_user_id'])) {
50
        	        $aUserID[] = $aActionRequest['activation_user_id'];
51
        	    } else {
52
        	        $aUserID = $aActionRequest['activation_user_id'];
53
        	    }
54
            }
55
    		break;
56
		default: // show userlist with empty modify mask
57
	endswitch; // end of switch
58
    
59
//    if(isset($aActionRequest['activation_user_id'])) {
60
//		if(!is_array($aActionRequest['activation_user_id'])) {
61
//	
62
//	        $aUserID[] = $aActionRequest['activation_user_id'];
63
//	    } else {
64
//	        $aUserID = $aActionRequest['activation_user_id'];
65
//	    }
66
//    } else {
67
//	    if(isset($aActionRequest['user_id'])) {
68
//			if(!is_array($aActionRequest['user_id'])) {
69
//		
70
//		        $aUserID[] = $aActionRequest['user_id'];
71
//		    } else {
72
//		        $aUserID = $aActionRequest['user_id'];
73
//		    }
74
//	    } 
75
//    } 
76
    
77

    
78
    foreach ( $aUserID AS $key => $value)
79
    {
80
        switch ($_SERVER['REQUEST_METHOD']) :
81
			case 'GET': // insert/update user
82
                $_GET['user_id'] =$aUserID[$key];
83
				break;
84
			default: // show userlist with empty modify mask
85
                $_POST['user_id'] =$aUserID[$key];
86
		endswitch; // end of switch
87
		$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
88

    
89
		// Check if user id is a valid number and doesnt equal 1
90
		if($user_id == 0){
91
			msgQueue::add($mLang->MESSAGE_GENERIC_FORGOT_OPTIONS );
92
            return $bRetVal;
93
        }
94

    
95
		if( ($user_id < 2 ) )
96
		{
97
			// if($admin_header) { $admin->print_header(); }
98
			msgQueue::add($mLang->MESSAGE_GENERIC_SECURITY_ACCESS );
99
            return $bRetVal;
100
		}
101

    
102
		if( ($msg = msgQueue::getError()) == '')
103
		{
104
			$sql  = 'SELECT `active` FROM `'.TABLE_PREFIX.'users` '.
105
                    'WHERE `user_id` = '.$user_id;
106
            if( ($iDeleteUser = $database->get_one($sql)) != null ) {
107
                if($iDeleteUser) {
108
    				// Deactivate the user
109
        			$sql  = 'UPDATE `'.TABLE_PREFIX.'users` SET '.
110
                            '`active` = 0 '.
111
                            'WHERE `user_id` = '.$user_id;
112
                    if( $database->query($sql) ) {
113
                        msgQueue::add($mLang->TEXT_USERS_MARKED_DELETED, true);
114
                    }
115
                } else {
116

    
117

    
118
        			$sql  = 'DELETE FROM `'.TABLE_PREFIX.'users` '.
119
                            'WHERE `user_id` = '.$user_id;
120
                    if( $database->query($sql) ) {
121
                        msgQueue::add($mLang->MESSAGE_USERS_DELETED, true);
122
                    }
123
                }
124
                $bRetVal = true;
125
            }
126
            if($database->is_error()) {
127
                msgQueue::add( implode('<br />',explode(';',$database->get_error())) );
128
                $bRetVal = false;
129
           }
130
		}
131
    }
132
    if(isset($aActionRequest['clearmsg'])) { msgQueue::clear();  }
133
    return $bRetVal;
134
}
135

    
136
if(!isset($aActionRequest)) {
137
    $requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
138
    $aActionRequest = (isset(${$requestMethod})) ? ${$requestMethod} : null;
139
    $aActionRequest['clearmsg'] = true;
140
}
(2-2/7)