Project

General

Profile

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