Project

General

Profile

« Previous | Next » 

Revision 1492

Added by Dietmar almost 13 years ago

Ticket #1107 Deleting users not possible
Change handling, first user will be set to inactive
secound inactive user will be show in an extra dropdown
and can now deleted from user table or reactivated

View differences:

users.php
31 31
			$admin = new admin('Access', 'users_modify');
32 32
			$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
33 33
			// Check if user id is a valid number and doesnt equal 1
34
			if($user_id == 0){
35
			$admin->print_error($MESSAGE['GENERIC_FORGOT_OPTIONS'] );
36
            }
34 37
			if( ($user_id < 2 ) )
35 38
			{
36 39
				// if($admin_header) { $admin->print_header(); }
37 40
				$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'] );
38 41
			}
39 42
			// Get existing values
40
			$results = $database->query("SELECT * FROM ".TABLE_PREFIX."users WHERE user_id = '".$user_id."'");
43
			$results = $database->query("SELECT * FROM `".TABLE_PREFIX."users` WHERE `user_id` = '".$user_id."'");
41 44
			$user = $results->fetchRow();
42 45

  
43 46
			// Setup template object
......
149 152
			// Insert language text and messages
150 153
			$template->set_var(array(
151 154
								'TEXT_RESET' => $TEXT['RESET'],
155
								'TEXT_CANCEL' => $TEXT['CANCEL'],
152 156
								'TEXT_ACTIVE' => $TEXT['ACTIVE'],
153 157
								'TEXT_DISABLED' => $TEXT['DISABLED'],
154 158
								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
......
169 173
			// Parse template object
170 174
			$template->parse('main', 'main_block', false);
171 175
			$template->pparse('output', 'page');
176
			// Print admin footer
177
			$admin->print_footer();
172 178
			break;
173 179
		case 'delete' :
174 180
			// Print header
175 181
			$admin = new admin('Access', 'users_delete');
176 182
			$user_id = intval($admin->checkIDKEY('user_id', 0, $_SERVER['REQUEST_METHOD']));
177 183
			// Check if user id is a valid number and doesnt equal 1
184
			if($user_id == 0){
185
			$admin->print_error($MESSAGE['GENERIC_FORGOT_OPTIONS'] );
186
            }
178 187
			if( ($user_id < 2 ) )
179 188
			{
180 189
				// if($admin_header) { $admin->print_header(); }
181 190
				$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'] );
182 191
			}
183
			// Delete the user
184
			$database->query("UPDATE `".TABLE_PREFIX."users` SET `active` = 0 WHERE `user_id` = '".$user_id."' ");
192
			$sql  = 'SELECT `active` FROM `'.TABLE_PREFIX.'users` ';
193
            $sql .= 'WHERE `user_id` = '.$user_id.'';
194
            if( ($iDeleteUser = $database->get_one($sql)) == 1 ) {
195
				// Delete the user
196
				$database->query("UPDATE `".TABLE_PREFIX."users` SET `active` = 0 WHERE `user_id` = '".$user_id."' ");
197
            } else {
198
				$database->query("DELETE FROM `".TABLE_PREFIX."users` WHERE `user_id` = ".$user_id);
199
            }
200

  
185 201
			if($database->is_error()) {
186 202
				$admin->print_error($database->get_error());
187 203
			} else {
188
				$admin->print_success($MESSAGE['USERS']['DELETED']);
204
				$admin->print_success($MESSAGE['USERS_DELETED']);
189 205
			}
206
			// Print admin footer
207
			$admin->print_footer();
190 208
			break;
191 209
	default:
192 210
			break;
193 211
endswitch;
194

  
195
// Print admin footer
196
$admin->print_footer();

Also available in: Unified diff