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