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:

branches/2.8.x/CHANGELOG
12 12

  
13 13
=============================== FEATURES FREEZE ================================
14 14
----------------------------------- Fixes 2.8.2 --------------------------------
15
11 Aug-2011 Build 1492 Dietmar Woellbrink (Luisehahne)
16
# Ticket #1107 Deleting users not possible
17
  Change handling, first user will be set to inactive
18
  secound inactive user will be show in an extra dropdown
19
  and can now deleted from user table or reactivated
15 20
11 Aug-2011 Build 1491 Dietmar Woellbrink (Luisehahne)
16 21
! comment out $email_body .= "\n\nIP: ".$_SERVER['REMOTE_ADDR'];
17 22
11 Aug-2011 Build 1490 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/admin/interface/version.php
52 52

  
53 53
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
54 54
if(!defined('VERSION')) define('VERSION', '2.8.2');
55
if(!defined('REVISION')) define('REVISION', '1491');
55
if(!defined('REVISION')) define('REVISION', '1492');
branches/2.8.x/wb/admin/users/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();
branches/2.8.x/wb/admin/users/index.php
20 20
require_once(WB_PATH.'/framework/class.admin.php');
21 21
$admin = new admin('Access', 'users');
22 22

  
23
$iUserStatus = 1;
24
$iUserStatus = ( ( $admin->get_get('status')==1 ) ? 0 : $iUserStatus );
25
unset($_GET);
26

  
23 27
// Create new template object for the modify/remove menu
24 28
$template = new Template(THEME_PATH.'/templates');
25 29
$template->set_file('page', 'users.htt');
......
27 31
$template->set_block("main_block", "manage_groups_block", "groups");
28 32
$template->set_var('ADMIN_URL', ADMIN_URL);
29 33
$template->set_var('FTAN', $admin->getFTAN());
34
$template->set_var('USER_STATUS', $iUserStatus );
30 35

  
36
$UserStatusActive = 'url('.THEME_URL.'/images/user.png)';
37
$UserStatusInactive = 'url('.THEME_URL.'/images/user_red.png)';
38

  
39
$sUserTitle = ($iUserStatus == 0) ? $MENU['USERS'].' '.strtolower($TEXT['ACTIVE']) : $MENU['USERS'].' '.strtolower($TEXT['DELETED']) ;
40

  
41
$template->set_var('TEXT_USERS', $sUserTitle.' '.$TEXT['SHOW'] );
42
$template->set_var('STATUS_ICON', ( ($iUserStatus==0) ? $UserStatusActive : $UserStatusInactive) );
43

  
31 44
// Get existing value from database
32
// $database = new database();
45
$sql  = 'SELECT `user_id`, `username`, `display_name`, `active` FROM `'.TABLE_PREFIX.'users` ' ;
46
$sql .= 'WHERE user_id != 1 ';
47
$sql .=     'AND active = '.$iUserStatus.' ';
48
$sql .= 'ORDER BY `display_name`,`username`';
49

  
33 50
$query = "SELECT user_id, username, display_name, active FROM ".TABLE_PREFIX."users WHERE user_id != '1' ORDER BY display_name,username";
34
$results = $database->query($query);
51
$results = $database->query($sql);
35 52
if($database->is_error()) {
36 53
	$admin->print_error($database->get_error(), 'index.php');
37 54
}
38 55

  
56
$sUserList  = $TEXT['LIST_OPTIONS'].' ';
57
$sUserList .= ($iUserStatus == 1) ? $MENU['USERS'].' '.strtolower($TEXT['ACTIVE']) : $MENU['USERS'].' '.strtolower($TEXT['DELETED']) ;
39 58
// Insert values into the modify/remove menu
40 59
$template->set_block('main_block', 'list_block', 'list');
41 60
if($results->numRows() > 0) {
42 61
	// Insert first value to say please select
43 62
	$template->set_var('VALUE', '');
44
	$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
45
	$template->set_var('STATUS', 'text-decoration :none;' );
63
	$template->set_var('NAME', $sUserList);
64
	$template->set_var('STATUS', 'class="user-active"' );
46 65
	$template->parse('list', 'list_block', true);
47 66
	// Loop through users
48 67
	while($user = $results->fetchRow()) {
49 68
		$template->set_var('VALUE',$admin->getIDKEY($user['user_id']));
50
		$template->set_var('STATUS', ($user['active']==false ? 'text-decoration:line-through' : 'text-decoration :none;') );
69
		$template->set_var('STATUS', ($user['active']==false ? 'class="user-inactive"' : 'class="user-active"') );
51 70
		$template->set_var('NAME', $user['display_name'].' ('.$user['username'].')');
52 71
		$template->parse('list', 'list_block', true);
53 72
	}
......
67 86
if($admin->get_permission('users_delete') != true) {
68 87
	$template->set_var('DISPLAY_DELETE', 'hide');
69 88
}
70

  
89
$HeaderTitle = $HEADING['MODIFY_DELETE_USER'].' ';
90
$HeaderTitle .= (($iUserStatus == 1) ? strtolower($TEXT['ACTIVE']) : strtolower($TEXT['DELETED']));
71 91
// Insert language headings
72 92
$template->set_var(array(
73
		'HEADING_MODIFY_DELETE_USER' => $HEADING['MODIFY_DELETE_USER'],
93
		'HEADING_MODIFY_DELETE_USER' => $HeaderTitle,
74 94
		'HEADING_ADD_USER' => $HEADING['ADD_USER']
75 95
		)
76 96
);
......
86 106
		'TEXT_MODIFY' => $TEXT['MODIFY'],
87 107
		'TEXT_DELETE' => $TEXT['DELETE'],
88 108
		'TEXT_MANAGE_GROUPS' => ( $admin->get_permission('groups') == true ) ? $TEXT['MANAGE_GROUPS'] : "**",
89
		'CONFIRM_DELETE' => $MESSAGE['USERS']['CONFIRM_DELETE']
109
		'CONFIRM_DELETE' => (($iUserStatus == 1) ? $TEXT['ARE_YOU_SURE'] : $MESSAGE['USERS']['CONFIRM_DELETE'])
90 110
		)
91 111
);
92 112
if ( $admin->get_permission('groups') == true ) $template->parse("groups", "manage_groups_block", true);
......
177 197

  
178 198
// Insert language text and messages
179 199
$template->set_var(array(
200
			'TEXT_CANCEL' => $TEXT['CANCEL'],
180 201
			'TEXT_RESET' => $TEXT['RESET'],
181 202
			'TEXT_ACTIVE' => $TEXT['ACTIVE'],
182 203
			'TEXT_DISABLED' => $TEXT['DISABLED'],
branches/2.8.x/wb/templates/wb_theme/theme.css
169 169
.msg-box { background : #e5ffe6; border :0.2em #009900 solid; color :#336600; margin-bottom :1em; padding :0.63em; text-align :center; }
170 170
.error-box { background :#fee; border :0.2em #844 solid; color :#400; margin-bottom :1em; padding :0.63em; text-align :center; }
171 171
.msg-box p,
172
.error-box p { font-size :120%; }
172
.error-box p { font-size :120%; }
173

  
174
select > option.user-inactive { color :#990000; }
175
button.status { cursor :pointer; border-radius :5px; -khtml-border-radius :5px; -webkit-border-radius :5px; -moz-border-radius :5px; }
branches/2.8.x/wb/templates/wb_theme/templates/users_form.htt
85 85
	<td>
86 86
		<input type="submit" name="submit" value="{SUBMIT_TITLE}" />
87 87
		<input type="reset" name="reset" value="{TEXT_RESET}" />
88
		<input type="button" style="width: 100px; margin-top: 5px;" onclick="javascript: window.location = 'index.php';" value="{TEXT_CANCEL}">
88 89
	</td>
89 90
</tr>
90 91
</table>
branches/2.8.x/wb/templates/wb_theme/templates/users.htt
1 1
<!-- BEGIN main_block -->
2 2

  
3 3
<form name="users" action="users.php" method="post">
4
<input type="hidden" name="status" value="{USER_STATUS}" />
4 5
{FTAN}
5
<input type="hidden" name="action" value="delete" />
6 6

  
7 7
<table summary="" cellpadding="0" cellspacing="0" border="0" width="100%">
8 8
<tr>
......
16 16
	</td>
17 17
</tr>
18 18
</table>
19

  
20
<br />
21

  
19
<button type="button" name="status" title="{TEXT_USERS}" style="width: 40px; background: {STATUS_ICON} no-repeat center" value="{USER_STATUS}" onclick="javascript: window.location = 'index.php?status={USER_STATUS}';" class="status {DISPLAY_MODIFY}" >&nbsp;</button>
22 20
<select name="user_id" style="width: 500px;">
23 21
<!-- BEGIN list_block -->
24
	<option value="{VALUE}" style="{STATUS}">{NAME}</option>
22
	<option value="{VALUE}" {STATUS}>{NAME}</option>
25 23
<!-- END list_block -->
26 24
</select>
27 25

  
......
31 29
</form>
32 30

  
33 31
<br />
34

  
35 32
<h2 style="margin-top: 20px;" class="{DISPLAY_ADD}">{HEADING_ADD_USER}</h2>
36 33

  
37 34
<!-- END main_block -->
branches/2.8.x/wb/templates/argos_theme/theme.css
190 190
.msg-box { background : #e5ffe6; border :0.2em #009900 solid; color :#336600; margin-bottom :1em; padding :0.63em; text-align :center; }
191 191
.error-box { background :#fee; border :0.2em #844 solid; color :#400; margin-bottom :1em; padding :0.63em; text-align :center; }
192 192
.msg-box p,
193
.error-box p { font-size :120%; }
193
.error-box p { font-size :120%; }
194
select > option.user-inactive { color :#990000; }
195
button.status { cursor :pointer; border-radius :5px; -khtml-border-radius :5px; -webkit-border-radius :5px; -moz-border-radius :5px; }
branches/2.8.x/wb/templates/argos_theme/templates/users.htt
1 1
<!-- BEGIN main_block -->
2 2

  
3 3
<form name="users" action="users.php" method="post">
4
<input type="hidden" name="action" value="delete" />
4
<input type="hidden" name="userstatus" value="{USER_STATUS}" />
5 5
{FTAN}
6 6

  
7 7
<table summary="" cellpadding="5" cellspacing="0" border="0" align="center" width="100%" style="margin-bottom:10px;">
......
14 14
		</td>
15 15
     </tr>
16 16
</table>
17

  
17
<button type="button" name="status" title="{TEXT_USERS}" style="width: 30px; background: {STATUS_ICON} no-repeat center" value="{USER_STATUS}" onclick="javascript: window.location = 'index.php?status={USER_STATUS}';" class="status {DISPLAY_MODIFY}" >&nbsp;</button>
18 18
<select name="user_id" style="width: 500px;">
19 19
<!-- BEGIN list_block -->
20
	<option value="{VALUE}" style="{STATUS}">{NAME}</option>
20
	<option value="{VALUE}" {STATUS}>{NAME}</option>
21 21
<!-- END list_block -->
22 22
</select>
23 23

  
......
27 27
</form>
28 28

  
29 29
<br />
30

  
31 30
<h2 style="margin-top: 20px;" class="{DISPLAY_ADD}">{HEADING_ADD_USER}</h2>
32 31

  
33 32
<!-- END main_block -->
branches/2.8.x/wb/templates/argos_theme/templates/users_form.htt
85 85
	<td>
86 86
		<input type="submit" name="submit" value="{SUBMIT_TITLE}" />
87 87
		<input type="reset" name="reset" value="{TEXT_RESET}" />
88
		<input type="button" style="width: 100px; margin-top: 5px;" onclick="javascript: window.location = 'index.php';" value="{TEXT_CANCEL}">
88 89
	</td>
89 90
</tr>
90 91
</table>
branches/2.8.x/wb/languages/DE.php
350 350
$TEXT['UPGRADE'] = 'Aktualisieren';
351 351
$TEXT['UPLOAD_FILES'] = 'Datei(en) &uuml;bertragen';
352 352
$TEXT['URL'] = 'URL';
353
$TEXT['USER'] = 'Besitzer';
353
$TEXT['USER'] = 'Benutzer';
354 354
$TEXT['USERNAME'] = 'Benutzername';
355 355
$TEXT['USERS_ACTIVE'] = 'Benutzer ist aktiv';
356 356
$TEXT['USERS_CAN_SELFDELETE'] = 'Selbstl&ouml;schung m&ouml;glich';

Also available in: Unified diff