1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package users
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2004-2009, Ryan Djurovich
|
8
|
* @copyright 2009-2011, Website Baker 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: index.php 1475 2011-07-12 23:07:10Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/users/index.php $
|
15
|
* @lastmodified $Date: 2011-07-13 01:07:10 +0200 (Wed, 13 Jul 2011) $
|
16
|
*
|
17
|
*/
|
18
|
|
19
|
require('../../config.php');
|
20
|
require_once(WB_PATH.'/framework/class.admin.php');
|
21
|
$admin = new admin('Access', 'users');
|
22
|
|
23
|
// Create new template object for the modify/remove menu
|
24
|
$template = new Template(THEME_PATH.'/templates');
|
25
|
$template->set_file('page', 'users.htt');
|
26
|
$template->set_block('page', 'main_block', 'main');
|
27
|
$template->set_block("main_block", "manage_groups_block", "groups");
|
28
|
$template->set_var('ADMIN_URL', ADMIN_URL);
|
29
|
$template->set_var('FTAN', $admin->getFTAN());
|
30
|
|
31
|
// Get existing value from database
|
32
|
// $database = new database();
|
33
|
$query = "SELECT user_id, username, display_name FROM ".TABLE_PREFIX."users WHERE user_id != '1' ORDER BY display_name,username";
|
34
|
$results = $database->query($query);
|
35
|
if($database->is_error()) {
|
36
|
$admin->print_error($database->get_error(), 'index.php');
|
37
|
}
|
38
|
|
39
|
// Insert values into the modify/remove menu
|
40
|
$template->set_block('main_block', 'list_block', 'list');
|
41
|
if($results->numRows() > 0) {
|
42
|
// Insert first value to say please select
|
43
|
$template->set_var('VALUE', '');
|
44
|
$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
|
45
|
$template->parse('list', 'list_block', true);
|
46
|
// Loop through users
|
47
|
while($user = $results->fetchRow()) {
|
48
|
$template->set_var('VALUE',$admin->getIDKEY($user['user_id']));
|
49
|
$template->set_var('NAME', $user['display_name'].' ('.$user['username'].')');
|
50
|
$template->parse('list', 'list_block', true);
|
51
|
}
|
52
|
} else {
|
53
|
// Insert single value to say no users were found
|
54
|
$template->set_var('NAME', $TEXT['NONE_FOUND']);
|
55
|
$template->parse('list', 'list_block', true);
|
56
|
}
|
57
|
|
58
|
// Insert permissions values
|
59
|
if($admin->get_permission('users_add') != true) {
|
60
|
$template->set_var('DISPLAY_ADD', 'hide');
|
61
|
}
|
62
|
if($admin->get_permission('users_modify') != true) {
|
63
|
$template->set_var('DISPLAY_MODIFY', 'hide');
|
64
|
}
|
65
|
if($admin->get_permission('users_delete') != true) {
|
66
|
$template->set_var('DISPLAY_DELETE', 'hide');
|
67
|
}
|
68
|
|
69
|
// Insert language headings
|
70
|
$template->set_var(array(
|
71
|
'HEADING_MODIFY_DELETE_USER' => $HEADING['MODIFY_DELETE_USER'],
|
72
|
'HEADING_ADD_USER' => $HEADING['ADD_USER']
|
73
|
)
|
74
|
);
|
75
|
// insert urls
|
76
|
$template->set_var(array(
|
77
|
'ADMIN_URL' => ADMIN_URL,
|
78
|
'WB_URL' => WB_URL,
|
79
|
'THEME_URL' => THEME_URL
|
80
|
)
|
81
|
);
|
82
|
// Insert language text and messages
|
83
|
$template->set_var(array(
|
84
|
'TEXT_MODIFY' => $TEXT['MODIFY'],
|
85
|
'TEXT_DELETE' => $TEXT['DELETE'],
|
86
|
'TEXT_MANAGE_GROUPS' => ( $admin->get_permission('groups') == true ) ? $TEXT['MANAGE_GROUPS'] : "**",
|
87
|
'CONFIRM_DELETE' => $MESSAGE['USERS']['CONFIRM_DELETE']
|
88
|
)
|
89
|
);
|
90
|
if ( $admin->get_permission('groups') == true ) $template->parse("groups", "manage_groups_block", true);
|
91
|
// Parse template object
|
92
|
$template->parse('main', 'main_block', false);
|
93
|
$template->pparse('output', 'page');
|
94
|
|
95
|
// Setup template for add user form
|
96
|
$template = new Template(THEME_PATH.'/templates');
|
97
|
$template->set_file('page', 'users_form.htt');
|
98
|
$template->set_block('page', 'main_block', 'main');
|
99
|
$template->set_var('DISPLAY_EXTRA', 'display:none;');
|
100
|
$template->set_var('ACTIVE_CHECKED', ' checked="checked"');
|
101
|
$template->set_var('ACTION_URL', ADMIN_URL.'/users/add.php');
|
102
|
$template->set_var('SUBMIT_TITLE', $TEXT['ADD']);
|
103
|
$template->set_var('FTAN', $admin->getFTAN());
|
104
|
// insert urls
|
105
|
$template->set_var(array(
|
106
|
'ADMIN_URL' => ADMIN_URL,
|
107
|
'WB_URL' => WB_URL,
|
108
|
'THEME_URL' => THEME_URL
|
109
|
)
|
110
|
);
|
111
|
|
112
|
// Add groups to list
|
113
|
$template->set_block('main_block', 'group_list_block', 'group_list');
|
114
|
$results = $database->query("SELECT group_id, name FROM ".TABLE_PREFIX."groups WHERE group_id != '1'");
|
115
|
if($results->numRows() > 0) {
|
116
|
$template->set_var('ID', '');
|
117
|
$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
|
118
|
$template->set_var('SELECTED', ' selected="selected"');
|
119
|
$template->parse('group_list', 'group_list_block', true);
|
120
|
while($group = $results->fetchRow()) {
|
121
|
$template->set_var('ID', $group['group_id']);
|
122
|
$template->set_var('NAME', $group['name']);
|
123
|
$template->set_var('SELECTED', '');
|
124
|
$template->parse('group_list', 'group_list_block', true);
|
125
|
}
|
126
|
}
|
127
|
// Only allow the user to add a user to the Administrators group if they belong to it
|
128
|
if(in_array(1, $admin->get_groups_id())) {
|
129
|
$users_groups = $admin->get_groups_name();
|
130
|
$template->set_var('ID', '1');
|
131
|
$template->set_var('NAME', $users_groups[1]);
|
132
|
$template->set_var('SELECTED', '');
|
133
|
$template->parse('group_list', 'group_list_block', true);
|
134
|
} else {
|
135
|
if($results->numRows() == 0) {
|
136
|
$template->set_var('ID', '');
|
137
|
$template->set_var('NAME', $TEXT['NONE_FOUND']);
|
138
|
$template->parse('group_list', 'group_list_block', true);
|
139
|
}
|
140
|
}
|
141
|
|
142
|
// Insert permissions values
|
143
|
if($admin->get_permission('users_add') != true) {
|
144
|
$template->set_var('DISPLAY_ADD', 'hide');
|
145
|
}
|
146
|
|
147
|
// Generate username field name
|
148
|
$username_fieldname = 'username_';
|
149
|
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
|
150
|
srand((double)microtime()*1000000);
|
151
|
$i = 0;
|
152
|
while ($i <= 7) {
|
153
|
$num = rand() % 33;
|
154
|
$tmp = substr($salt, $num, 1);
|
155
|
$username_fieldname = $username_fieldname . $tmp;
|
156
|
$i++;
|
157
|
}
|
158
|
|
159
|
// Work-out if home folder should be shown
|
160
|
if(!HOME_FOLDERS) {
|
161
|
$template->set_var('DISPLAY_HOME_FOLDERS', 'display:none;');
|
162
|
}
|
163
|
|
164
|
// Include the WB functions file
|
165
|
require_once(WB_PATH.'/framework/functions.php');
|
166
|
|
167
|
// Add media folders to home folder list
|
168
|
$template->set_block('main_block', 'folder_list_block', 'folder_list');
|
169
|
foreach(directory_list(WB_PATH.MEDIA_DIRECTORY) AS $name) {
|
170
|
$template->set_var('NAME', str_replace(WB_PATH, '', $name));
|
171
|
$template->set_var('FOLDER', str_replace(WB_PATH.MEDIA_DIRECTORY, '', $name));
|
172
|
$template->set_var('SELECTED', ' ');
|
173
|
$template->parse('folder_list', 'folder_list_block', true);
|
174
|
}
|
175
|
|
176
|
// Insert language text and messages
|
177
|
$template->set_var(array(
|
178
|
'TEXT_RESET' => $TEXT['RESET'],
|
179
|
'TEXT_ACTIVE' => $TEXT['ACTIVE'],
|
180
|
'TEXT_DISABLED' => $TEXT['DISABLED'],
|
181
|
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
|
182
|
'TEXT_USERNAME' => $TEXT['USERNAME'],
|
183
|
'TEXT_PASSWORD' => $TEXT['PASSWORD'],
|
184
|
'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
|
185
|
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
|
186
|
'TEXT_EMAIL' => $TEXT['EMAIL'],
|
187
|
'TEXT_GROUP' => $TEXT['GROUP'],
|
188
|
'TEXT_NONE' => $TEXT['NONE'],
|
189
|
'TEXT_HOME_FOLDER' => $TEXT['HOME_FOLDER'],
|
190
|
'USERNAME_FIELDNAME' => $username_fieldname,
|
191
|
'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD']
|
192
|
)
|
193
|
);
|
194
|
|
195
|
// Parse template for add user form
|
196
|
$template->parse('main', 'main_block', false);
|
197
|
$template->pparse('output', 'page');
|
198
|
|
199
|
$admin->print_footer();
|