Revision 1289
Added by kweitzel almost 15 years ago
groups.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 |
// Include config file and admin class file |
|
27 |
require('../../config.php'); |
|
28 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
29 |
|
|
30 |
// Create new database object |
|
31 |
$database = new database(); |
|
32 |
|
|
33 |
if(!isset($_POST['action']) OR ($_POST['action'] != "modify" AND $_POST['action'] != "delete")) { |
|
34 |
header("Location: index.php"); |
|
35 |
exit(0); |
|
36 |
} |
|
37 |
|
|
38 |
// Check if group group_id is a valid number and doesnt equal 1 |
|
39 |
if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) { |
|
40 |
header("Location: index.php"); |
|
41 |
exit(0); |
|
42 |
} |
|
43 |
|
|
44 |
if($_POST['action'] == 'modify') { |
|
45 |
// Create new admin object |
|
46 |
$admin = new admin('Access', 'groups_modify', false); |
|
47 |
// Print header |
|
48 |
$admin->print_header(); |
|
49 |
// Get existing values |
|
50 |
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'"); |
|
51 |
$group = $results->fetchRow(); |
|
52 |
// Setup template object |
|
53 |
$template = new Template(THEME_PATH.'/templates'); |
|
54 |
$template->set_file('page', 'groups_form.htt'); |
|
55 |
$template->set_block('page', 'main_block', 'main'); |
|
56 |
$template->set_var( array( |
|
57 |
'ACTION_URL' => ADMIN_URL.'/groups/save.php', |
|
58 |
'SUBMIT_TITLE' => $TEXT['SAVE'], |
|
59 |
'GROUP_ID' => $group['group_id'], |
|
60 |
'GROUP_NAME' => $group['name'], |
|
61 |
'ADVANCED_ACTION' => 'groups.php' |
|
62 |
) |
|
63 |
); |
|
64 |
// Tell the browser whether or not to show advanced options |
|
65 |
if( true == (isset( $_POST['advanced']) AND ( strpos( $_POST['advanced'], ">>") > 0 ) ) ) { |
|
66 |
$template->set_var('DISPLAY_ADVANCED', ''); |
|
67 |
$template->set_var('DISPLAY_BASIC', 'none'); |
|
68 |
$template->set_var('ADVANCED', 'yes'); |
|
69 |
$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']); |
|
70 |
} else { |
|
71 |
$template->set_var('DISPLAY_ADVANCED', 'none'); |
|
72 |
$template->set_var('DISPLAY_BASIC', ''); |
|
73 |
$template->set_var('ADVANCED', 'no'); |
|
74 |
$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>'); |
|
75 |
} |
|
76 |
|
|
77 |
// Explode system permissions |
|
78 |
$system_permissions = explode(',', $group['system_permissions']); |
|
79 |
// Check system permissions boxes |
|
80 |
foreach($system_permissions AS $name) { |
|
81 |
$template->set_var($name.'_checked', ' checked="checked"'); |
|
82 |
} |
|
83 |
// Explode module permissions |
|
84 |
$module_permissions = explode(',', $group['module_permissions']); |
|
85 |
// Explode template permissions |
|
86 |
$template_permissions = explode(',', $group['template_permissions']); |
|
87 |
|
|
88 |
// Insert values into module list |
|
89 |
$template->set_block('main_block', 'module_list_block', 'module_list'); |
|
90 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page'"); |
|
91 |
if($result->numRows() > 0) { |
|
92 |
while($addon = $result->fetchRow()) { |
|
93 |
$template->set_var('VALUE', $addon['directory']); |
|
94 |
$template->set_var('NAME', $addon['name']); |
|
95 |
if(!is_numeric(array_search($addon['directory'], $module_permissions))) { |
|
96 |
$template->set_var('CHECKED', ' checked="checked"'); |
|
97 |
} else { |
|
98 |
$template->set_var('CHECKED', ''); |
|
99 |
} |
|
100 |
$template->parse('module_list', 'module_list_block', true); |
|
101 |
} |
|
102 |
} |
|
103 |
|
|
104 |
// Insert values into template list |
|
105 |
$template->set_block('main_block', 'template_list_block', 'template_list'); |
|
106 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'"); |
|
107 |
if($result->numRows() > 0) { |
|
108 |
while($addon = $result->fetchRow()) { |
|
109 |
$template->set_var('VALUE', $addon['directory']); |
|
110 |
$template->set_var('NAME', $addon['name']); |
|
111 |
if(!is_numeric(array_search($addon['directory'], $template_permissions))) { |
|
112 |
$template->set_var('CHECKED', ' checked="checked"'); |
|
113 |
} else { |
|
114 |
$template->set_var('CHECKED', ''); |
|
115 |
} |
|
116 |
$template->parse('template_list', 'template_list_block', true); |
|
117 |
} |
|
118 |
} |
|
119 |
|
|
120 |
// Insert language text and messages |
|
121 |
$template->set_var(array( |
|
122 |
'TEXT_RESET' => $TEXT['RESET'], |
|
123 |
'TEXT_ACTIVE' => $TEXT['ACTIVE'], |
|
124 |
'TEXT_DISABLED' => $TEXT['DISABLED'], |
|
125 |
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], |
|
126 |
'TEXT_USERNAME' => $TEXT['USERNAME'], |
|
127 |
'TEXT_PASSWORD' => $TEXT['PASSWORD'], |
|
128 |
'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'], |
|
129 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
130 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
131 |
'TEXT_GROUP' => $TEXT['GROUP'], |
|
132 |
'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'], |
|
133 |
'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'], |
|
134 |
'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'], |
|
135 |
'TEXT_NAME' => $TEXT['NAME'], |
|
136 |
'SECTION_PAGES' => $MENU['PAGES'], |
|
137 |
'SECTION_MEDIA' => $MENU['MEDIA'], |
|
138 |
'SECTION_MODULES' => $MENU['MODULES'], |
|
139 |
'SECTION_TEMPLATES' => $MENU['TEMPLATES'], |
|
140 |
'SECTION_LANGUAGES' => $MENU['LANGUAGES'], |
|
141 |
'SECTION_SETTINGS' => $MENU['SETTINGS'], |
|
142 |
'SECTION_USERS' => $MENU['USERS'], |
|
143 |
'SECTION_GROUPS' => $MENU['GROUPS'], |
|
144 |
'SECTION_ADMINTOOLS' => $MENU['ADMINTOOLS'], |
|
145 |
'TEXT_VIEW' => $TEXT['VIEW'], |
|
146 |
'TEXT_ADD' => $TEXT['ADD'], |
|
147 |
'TEXT_LEVEL' => $TEXT['LEVEL'], |
|
148 |
'TEXT_MODIFY' => $TEXT['MODIFY'], |
|
149 |
'TEXT_DELETE' => $TEXT['DELETE'], |
|
150 |
'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'], |
|
151 |
'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'], |
|
152 |
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'], |
|
153 |
'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'], |
|
154 |
'TEXT_RENAME' => $TEXT['RENAME'], |
|
155 |
'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'], |
|
156 |
'TEXT_BASIC' => $TEXT['BASIC'], |
|
157 |
'TEXT_ADVANCED' => $TEXT['ADVANCED'], |
|
158 |
'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'], |
|
159 |
'HEADING_MODIFY_GROUP' => $HEADING['MODIFY_GROUP'] |
|
160 |
) |
|
161 |
); |
|
162 |
|
|
163 |
// Parse template object |
|
164 |
$template->parse('main', 'main_block', false); |
|
165 |
$template->pparse('output', 'page'); |
|
166 |
} elseif($_POST['action'] == 'delete') { |
|
167 |
// Create new admin object |
|
168 |
$admin = new admin('Access', 'groups_delete', false); |
|
169 |
// Print header |
|
170 |
$admin->print_header(); |
|
171 |
// Delete the group |
|
172 |
$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1"); |
|
173 |
if($database->is_error()) { |
|
174 |
$admin->print_error($database->get_error()); |
|
175 |
} else { |
|
176 |
// Delete users in the group |
|
177 |
$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'"); |
|
178 |
if($database->is_error()) { |
|
179 |
$admin->print_error($database->get_error()); |
|
180 |
} else { |
|
181 |
$admin->print_success($MESSAGE['GROUPS']['DELETED']); |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
// Print admin footer |
|
187 |
$admin->print_footer(); |
|
188 |
|
|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category admin |
|
5 |
* @package groups |
|
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 |
// Include config file and admin class file |
|
20 |
require('../../config.php'); |
|
21 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
22 |
|
|
23 |
// Create new database object |
|
24 |
$database = new database(); |
|
25 |
|
|
26 |
if(!isset($_POST['action']) OR ($_POST['action'] != "modify" AND $_POST['action'] != "delete")) { |
|
27 |
header("Location: index.php"); |
|
28 |
exit(0); |
|
29 |
} |
|
30 |
|
|
31 |
// Set parameter 'action' as alternative to javascript mechanism |
|
32 |
if(isset($_POST['modify'])) |
|
33 |
$_POST['action'] = "modify"; |
|
34 |
if(isset($_POST['delete'])) |
|
35 |
$_POST['action'] = "delete"; |
|
36 |
|
|
37 |
// Check if group group_id is a valid number and doesnt equal 1 |
|
38 |
if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) { |
|
39 |
header("Location: index.php"); |
|
40 |
exit(0); |
|
41 |
} |
|
42 |
|
|
43 |
if($_POST['action'] == 'modify') { |
|
44 |
// Create new admin object |
|
45 |
$admin = new admin('Access', 'groups_modify', false); |
|
46 |
// Print header |
|
47 |
$admin->print_header(); |
|
48 |
// Get existing values |
|
49 |
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'"); |
|
50 |
$group = $results->fetchRow(); |
|
51 |
// Setup template object |
|
52 |
$template = new Template(THEME_PATH.'/templates'); |
|
53 |
$template->set_file('page', 'groups_form.htt'); |
|
54 |
$template->set_block('page', 'main_block', 'main'); |
|
55 |
$template->set_var( array( |
|
56 |
'ACTION_URL' => ADMIN_URL.'/groups/save.php', |
|
57 |
'SUBMIT_TITLE' => $TEXT['SAVE'], |
|
58 |
'GROUP_ID' => $group['group_id'], |
|
59 |
'GROUP_NAME' => $group['name'], |
|
60 |
'ADVANCED_ACTION' => 'groups.php' |
|
61 |
) |
|
62 |
); |
|
63 |
// Tell the browser whether or not to show advanced options |
|
64 |
if( true == (isset( $_POST['advanced']) AND ( strpos( $_POST['advanced'], ">>") > 0 ) ) ) { |
|
65 |
$template->set_var('DISPLAY_ADVANCED', ''); |
|
66 |
$template->set_var('DISPLAY_BASIC', 'display:none;'); |
|
67 |
$template->set_var('ADVANCED', 'yes'); |
|
68 |
$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']); |
|
69 |
} else { |
|
70 |
$template->set_var('DISPLAY_ADVANCED', 'display:none;'); |
|
71 |
$template->set_var('DISPLAY_BASIC', ''); |
|
72 |
$template->set_var('ADVANCED', 'no'); |
|
73 |
$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>'); |
|
74 |
} |
|
75 |
|
|
76 |
// Explode system permissions |
|
77 |
$system_permissions = explode(',', $group['system_permissions']); |
|
78 |
// Check system permissions boxes |
|
79 |
foreach($system_permissions AS $name) { |
|
80 |
$template->set_var($name.'_checked', ' checked="checked"'); |
|
81 |
} |
|
82 |
// Explode module permissions |
|
83 |
$module_permissions = explode(',', $group['module_permissions']); |
|
84 |
// Explode template permissions |
|
85 |
$template_permissions = explode(',', $group['template_permissions']); |
|
86 |
|
|
87 |
// Insert values into module list |
|
88 |
$template->set_block('main_block', 'module_list_block', 'module_list'); |
|
89 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page'"); |
|
90 |
if($result->numRows() > 0) { |
|
91 |
while($addon = $result->fetchRow()) { |
|
92 |
$template->set_var('VALUE', $addon['directory']); |
|
93 |
$template->set_var('NAME', $addon['name']); |
|
94 |
if(!is_numeric(array_search($addon['directory'], $module_permissions))) { |
|
95 |
$template->set_var('CHECKED', ' checked="checked"'); |
|
96 |
} else { |
|
97 |
$template->set_var('CHECKED', ''); |
|
98 |
} |
|
99 |
$template->parse('module_list', 'module_list_block', true); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
// Insert values into template list |
|
104 |
$template->set_block('main_block', 'template_list_block', 'template_list'); |
|
105 |
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template'"); |
|
106 |
if($result->numRows() > 0) { |
|
107 |
while($addon = $result->fetchRow()) { |
|
108 |
$template->set_var('VALUE', $addon['directory']); |
|
109 |
$template->set_var('NAME', $addon['name']); |
|
110 |
if(!is_numeric(array_search($addon['directory'], $template_permissions))) { |
|
111 |
$template->set_var('CHECKED', ' checked="checked"'); |
|
112 |
} else { |
|
113 |
$template->set_var('CHECKED', ''); |
|
114 |
} |
|
115 |
$template->parse('template_list', 'template_list_block', true); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
// Insert language text and messages |
|
120 |
$template->set_var(array( |
|
121 |
'TEXT_RESET' => $TEXT['RESET'], |
|
122 |
'TEXT_ACTIVE' => $TEXT['ACTIVE'], |
|
123 |
'TEXT_DISABLED' => $TEXT['DISABLED'], |
|
124 |
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], |
|
125 |
'TEXT_USERNAME' => $TEXT['USERNAME'], |
|
126 |
'TEXT_PASSWORD' => $TEXT['PASSWORD'], |
|
127 |
'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'], |
|
128 |
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'], |
|
129 |
'TEXT_EMAIL' => $TEXT['EMAIL'], |
|
130 |
'TEXT_GROUP' => $TEXT['GROUP'], |
|
131 |
'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'], |
|
132 |
'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'], |
|
133 |
'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'], |
|
134 |
'TEXT_NAME' => $TEXT['NAME'], |
|
135 |
'SECTION_PAGES' => $MENU['PAGES'], |
|
136 |
'SECTION_MEDIA' => $MENU['MEDIA'], |
|
137 |
'SECTION_MODULES' => $MENU['MODULES'], |
|
138 |
'SECTION_TEMPLATES' => $MENU['TEMPLATES'], |
|
139 |
'SECTION_LANGUAGES' => $MENU['LANGUAGES'], |
|
140 |
'SECTION_SETTINGS' => $MENU['SETTINGS'], |
|
141 |
'SECTION_USERS' => $MENU['USERS'], |
|
142 |
'SECTION_GROUPS' => $MENU['GROUPS'], |
|
143 |
'SECTION_ADMINTOOLS' => $MENU['ADMINTOOLS'], |
|
144 |
'TEXT_VIEW' => $TEXT['VIEW'], |
|
145 |
'TEXT_ADD' => $TEXT['ADD'], |
|
146 |
'TEXT_LEVEL' => $TEXT['LEVEL'], |
|
147 |
'TEXT_MODIFY' => $TEXT['MODIFY'], |
|
148 |
'TEXT_DELETE' => $TEXT['DELETE'], |
|
149 |
'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'], |
|
150 |
'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'], |
|
151 |
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'], |
|
152 |
'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'], |
|
153 |
'TEXT_RENAME' => $TEXT['RENAME'], |
|
154 |
'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'], |
|
155 |
'TEXT_BASIC' => $TEXT['BASIC'], |
|
156 |
'TEXT_ADVANCED' => $TEXT['ADVANCED'], |
|
157 |
'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'], |
|
158 |
'HEADING_MODIFY_GROUP' => $HEADING['MODIFY_GROUP'] |
|
159 |
) |
|
160 |
); |
|
161 |
|
|
162 |
// Parse template object |
|
163 |
$template->parse('main', 'main_block', false); |
|
164 |
$template->pparse('output', 'page'); |
|
165 |
} elseif($_POST['action'] == 'delete') { |
|
166 |
// Create new admin object |
|
167 |
$admin = new admin('Access', 'groups_delete', false); |
|
168 |
// Print header |
|
169 |
$admin->print_header(); |
|
170 |
// Delete the group |
|
171 |
$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1"); |
|
172 |
if($database->is_error()) { |
|
173 |
$admin->print_error($database->get_error()); |
|
174 |
} else { |
|
175 |
// Delete users in the group |
|
176 |
$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'"); |
|
177 |
if($database->is_error()) { |
|
178 |
$admin->print_error($database->get_error()); |
|
179 |
} else { |
|
180 |
$admin->print_success($MESSAGE['GROUPS']['DELETED']); |
|
181 |
} |
|
182 |
} |
|
183 |
} |
|
184 |
|
|
185 |
// Print admin footer |
|
186 |
$admin->print_footer(); |
|
187 |
|
|
189 | 188 |
?> |
190 | 189 |
Also available in: Unified diff
Branch 2.8.1 merged back into Trunk