Revision 2065
Added by Dietmar almost 11 years ago
- /admin/users bugfixes user deactivating and deleting
delete.php | ||
---|---|---|
25 | 25 |
/* -------------------------------------------------------- */ |
26 | 26 |
function delete_user($admin, &$aActionRequest) |
27 | 27 |
{ |
28 |
global $TEXT, $MESSAGE; |
|
29 | 28 |
$database = WbDatabase::getInstance(); |
29 |
$mLang = Translate::getInstance(); |
|
30 | 30 |
$aUserID = array(); |
31 | 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 | 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 |
|
|
50 | 78 |
foreach ( $aUserID AS $key => $value) |
51 | 79 |
{ |
52 | 80 |
switch ($_SERVER['REQUEST_METHOD']) : |
... | ... | |
60 | 88 |
|
61 | 89 |
// Check if user id is a valid number and doesnt equal 1 |
62 | 90 |
if($user_id == 0){ |
63 |
msgQueue::add($MESSAGE['GENERIC_FORGOT_OPTIONS'] );
|
|
91 |
msgQueue::add($mLang->MESSAGE_GENERIC_FORGOT_OPTIONS );
|
|
64 | 92 |
return $bRetVal; |
65 | 93 |
} |
66 | 94 |
|
67 | 95 |
if( ($user_id < 2 ) ) |
68 | 96 |
{ |
69 | 97 |
// if($admin_header) { $admin->print_header(); } |
70 |
msgQueue::add($MESSAGE['GENERIC_SECURITY_ACCESS'] );
|
|
98 |
msgQueue::add($mLang->MESSAGE_GENERIC_SECURITY_ACCESS );
|
|
71 | 99 |
return $bRetVal; |
72 | 100 |
} |
73 | 101 |
|
... | ... | |
77 | 105 |
'WHERE `user_id` = '.$user_id; |
78 | 106 |
if( ($iDeleteUser = $database->get_one($sql)) != null ) { |
79 | 107 |
if($iDeleteUser) { |
80 |
// Delete the user
|
|
108 |
// Deactivate the user
|
|
81 | 109 |
$sql = 'UPDATE `'.TABLE_PREFIX.'users` SET '. |
82 | 110 |
'`active` = 0 '. |
83 | 111 |
'WHERE `user_id` = '.$user_id; |
84 | 112 |
if( $database->query($sql) ) { |
85 |
msgQueue::add($TEXT['USERS_DELETED'], true);
|
|
113 |
msgQueue::add($mLang->TEXT_USERS_MARKED_DELETED, true);
|
|
86 | 114 |
} |
87 | 115 |
} else { |
116 |
|
|
117 |
|
|
88 | 118 |
$sql = 'DELETE FROM `'.TABLE_PREFIX.'users` '. |
89 | 119 |
'WHERE `user_id` = '.$user_id; |
90 | 120 |
if( $database->query($sql) ) { |
91 |
msgQueue::add($MESSAGE['USERS_DELETED'], true);
|
|
121 |
msgQueue::add($mLang->MESSAGE_USERS_DELETED, true);
|
|
92 | 122 |
} |
93 | 123 |
} |
94 | 124 |
$bRetVal = true; |
Also available in: Unified diff