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