Project

General

Profile

1 1246 Luisehahne
<?php
2
/****************************************************************************
3
* SVN Version information:
4
*
5
* $Id$
6
*
7
*****************************************************************************
8
*                          WebsiteBaker
9
*
10
* WebsiteBaker Project <http://www.websitebaker2.org/>
11
* Copyright (C) 2009, Website Baker Org. e.V.
12
*         http://start.websitebaker2.org/impressum-datenschutz.php
13
* Copyright (C) 2004-2009, Ryan Djurovich
14
*
15
*                        About WebsiteBaker
16
*
17
* Website Baker is a PHP-based Content Management System (CMS)
18
* designed with one goal in mind: to enable its users to produce websites
19
* with ease.
20
*
21
*****************************************************************************
22
*
23
*****************************************************************************
24
*                        LICENSE INFORMATION
25
*
26
* WebsiteBaker is free software; you can redistribute it and/or
27
* modify it under the terms of the GNU General Public License
28
* as published by the Free Software Foundation; either version 2
29
* of the License, or (at your option) any later version.
30
*
31
* WebsiteBaker is distributed in the hope that it will be useful,
32
* but WITHOUT ANY WARRANTY; without even the implied warranty of
33
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34
* See the GNU General Public License for more details.
35
*
36
* You should have received a copy of the GNU General Public License
37
* along with this program; if not, write to the Free Software
38
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
39
****************************************************************************
40
*
41
*****************************************************************************
42
*                   WebsiteBaker Extra Information
43
*
44
*
45
*
46
*
47
*****************************************************************************/
48
/**
49
 * @category    admin
50
 * @package     users
51
 * @author      Ryan Djurovich
52
 * @copyright   2004-2009, Ryan Djurovich
53
 * @copyright   2009-2010, Website Baker Org. e.V.
54
 * @version     $Id$
55
 * @platform    WebsiteBaker 2.8.x
56
 * @requirements >= PHP 4.3.4
57
 * @license     http://www.gnu.org/licenses/gpl.html
58
 *
59
 */
60
61
62
require('../../config.php');
63
require_once(WB_PATH.'/framework/class.admin.php');
64
$admin = new admin('Access', 'users');
65
66
// Create new template object for the modify/remove menu
67
$template = new Template(THEME_PATH.'/templates');
68
$template->set_file('page', 'users.htt');
69
$template->set_block('page', 'main_block', 'main');
70
$template->set_block("main_block", "manage_groups_block", "groups");
71
$template->set_var('ADMIN_URL', ADMIN_URL);
72
73
// Get existing value from database
74
$database = new database();
75
$query = "SELECT user_id, username, display_name FROM ".TABLE_PREFIX."users WHERE user_id != '1' ORDER BY username";
76
$results = $database->query($query);
77
if($database->is_error()) {
78
	$admin->print_error($database->get_error(), 'index.php');
79
}
80
81
// Insert values into the modify/remove menu
82
$template->set_block('main_block', 'list_block', 'list');
83
if($results->numRows() > 0) {
84
	// Insert first value to say please select
85
	$template->set_var('VALUE', '');
86
	$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
87
	$template->parse('list', 'list_block', true);
88
	// Loop through users
89
	while($user = $results->fetchRow()) {
90
		$template->set_var('VALUE', $user['user_id']);
91
		$template->set_var('NAME', $user['display_name'].' ('.$user['username'].')');
92
		$template->parse('list', 'list_block', true);
93
	}
94
} else {
95
	// Insert single value to say no users were found
96
	$template->set_var('NAME', $TEXT['NONE_FOUND']);
97
	$template->parse('list', 'list_block', true);
98
}
99
100
// Insert permissions values
101
if($admin->get_permission('users_add') != true) {
102
	$template->set_var('DISPLAY_ADD', 'hide');
103
}
104
if($admin->get_permission('users_modify') != true) {
105
	$template->set_var('DISPLAY_MODIFY', 'hide');
106
}
107
if($admin->get_permission('users_delete') != true) {
108
	$template->set_var('DISPLAY_DELETE', 'hide');
109
}
110
111
// Insert language headings
112
$template->set_var(array(
113
		'HEADING_MODIFY_DELETE_USER' => $HEADING['MODIFY_DELETE_USER'],
114
		'HEADING_ADD_USER' => $HEADING['ADD_USER']
115
		)
116
);
117
// insert urls
118
$template->set_var(array(
119
		'ADMIN_URL' => ADMIN_URL,
120
		'WB_URL' => WB_URL,
121
		'WB_PATH' => WB_PATH,
122
		'THEME_URL' => THEME_URL
123
		)
124
);
125
// Insert language text and messages
126
$template->set_var(array(
127
		'TEXT_MODIFY' => $TEXT['MODIFY'],
128
		'TEXT_DELETE' => $TEXT['DELETE'],
129
		'TEXT_MANAGE_GROUPS' => ( $admin->get_permission('groups') == true ) ? $TEXT['MANAGE_GROUPS'] : "**",
130
		'CONFIRM_DELETE' => $MESSAGE['USERS']['CONFIRM_DELETE']
131
		)
132
);
133
if ( $admin->get_permission('groups') == true ) $template->parse("groups", "manage_groups_block", true);
134
// Parse template object
135
$template->parse('main', 'main_block', false);
136
$template->pparse('output', 'page');
137
138
// Setup template for add user form
139
$template = new Template(THEME_PATH.'/templates');
140
$template->set_file('page', 'users_form.htt');
141
$template->set_block('page', 'main_block', 'main');
142
$template->set_var('DISPLAY_EXTRA', 'display:none;');
143
$template->set_var('ACTIVE_CHECKED', ' checked="checked"');
144
$template->set_var('ACTION_URL', ADMIN_URL.'/users/add.php');
145
$template->set_var('SUBMIT_TITLE', $TEXT['ADD']);
146
// insert urls
147
$template->set_var(array(
148
		'ADMIN_URL' => ADMIN_URL,
149
		'WB_URL' => WB_URL,
150
		'WB_PATH' => WB_PATH,
151
		'THEME_URL' => THEME_URL
152
		)
153
);
154
155
// Add groups to list
156
$template->set_block('main_block', 'group_list_block', 'group_list');
157
$results = $database->query("SELECT group_id, name FROM ".TABLE_PREFIX."groups WHERE group_id != '1'");
158
if($results->numRows() > 0) {
159
	$template->set_var('ID', '');
160
	$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
161
	$template->set_var('SELECTED', ' selected="selected"');
162
	$template->parse('group_list', 'group_list_block', true);
163
	while($group = $results->fetchRow()) {
164
		$template->set_var('ID', $group['group_id']);
165
		$template->set_var('NAME', $group['name']);
166
		$template->set_var('SELECTED', '');
167
		$template->parse('group_list', 'group_list_block', true);
168
	}
169
}
170
// Only allow the user to add a user to the Administrators group if they belong to it
171
if(in_array(1, $admin->get_groups_id())) {
172
	$users_groups = $admin->get_groups_name();
173
	$template->set_var('ID', '1');
174
	$template->set_var('NAME', $users_groups[1]);
175
	$template->set_var('SELECTED', '');
176
	$template->parse('group_list', 'group_list_block', true);
177
} else {
178
	if($results->numRows() == 0) {
179
		$template->set_var('ID', '');
180
		$template->set_var('NAME', $TEXT['NONE_FOUND']);
181
		$template->parse('group_list', 'group_list_block', true);
182
	}
183
}
184
185
// Insert permissions values
186
if($admin->get_permission('users_add') != true) {
187
	$template->set_var('DISPLAY_ADD', 'hide');
188
}
189
190
// Generate username field name
191
$username_fieldname = 'username_';
192
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
193
srand((double)microtime()*1000000);
194
$i = 0;
195
while ($i <= 7) {
196
	$num = rand() % 33;
197
	$tmp = substr($salt, $num, 1);
198
	$username_fieldname = $username_fieldname . $tmp;
199
	$i++;
200
}
201
202
// Work-out if home folder should be shown
203
if(!HOME_FOLDERS) {
204
	$template->set_var('DISPLAY_HOME_FOLDERS', 'display:none;');
205
}
206
207
// Include the WB functions file
208
require_once(WB_PATH.'/framework/functions.php');
209
210
// Add media folders to home folder list
211
$template->set_block('main_block', 'folder_list_block', 'folder_list');
212
foreach(directory_list(WB_PATH.MEDIA_DIRECTORY) AS $name) {
213
	$template->set_var('NAME', str_replace(WB_PATH, '', $name));
214
	$template->set_var('FOLDER', str_replace(WB_PATH.MEDIA_DIRECTORY, '', $name));
215
	$template->set_var('SELECTED', ' ');
216
	$template->parse('folder_list', 'folder_list_block', true);
217
}
218
219
// Insert language text and messages
220
$template->set_var(array(
221
			'TEXT_RESET' => $TEXT['RESET'],
222
			'TEXT_ACTIVE' => $TEXT['ACTIVE'],
223
			'TEXT_DISABLED' => $TEXT['DISABLED'],
224
			'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
225
			'TEXT_USERNAME' => $TEXT['USERNAME'],
226
			'TEXT_PASSWORD' => $TEXT['PASSWORD'],
227
			'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
228
			'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
229
			'TEXT_EMAIL' => $TEXT['EMAIL'],
230
			'TEXT_GROUP' => $TEXT['GROUP'],
231
			'TEXT_NONE' => $TEXT['NONE'],
232
			'TEXT_HOME_FOLDER' => $TEXT['HOME_FOLDER'],
233
			'USERNAME_FIELDNAME' => $username_fieldname,
234
			'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD']
235
			)
236
	);
237
238
// Parse template for add user form
239
$template->parse('main', 'main_block', false);
240
$template->pparse('output', 'page');
241
242
$admin->print_footer();
243
244 4 ryan
?>