Project

General

Profile

« Previous | Next » 

Revision 1492

Added by Dietmar over 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:

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'],

Also available in: Unified diff