1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category admin
|
5
|
* @package groups
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright Ryan Djurovich
|
8
|
* @copyright WebsiteBaker Org. e.V.
|
9
|
* @link http://websitebaker.org/
|
10
|
* @license http://www.gnu.org/licenses/gpl.html
|
11
|
* @platform WebsiteBaker 2.8.3
|
12
|
* @requirements PHP 5.3.6 and higher
|
13
|
* @version $Id: index.php 2 2017-07-02 15:14:29Z Manuela $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/admin/groups/index.php $
|
15
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
16
|
*
|
17
|
*/
|
18
|
// Print admin header
|
19
|
if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
|
20
|
if ( !class_exists('admin', false) ) { require(WB_PATH.'/framework/class.admin.php'); }
|
21
|
$admin = new admin('Access', 'groups');
|
22
|
$requestMethod = '_'.($GLOBALS['_SERVER']['REQUEST_METHOD']);
|
23
|
$aRequestVars = (@(${$requestMethod}) ? : null);
|
24
|
|
25
|
$bAdvanced = intval (@$aRequestVars['advanced'] ?: 0);
|
26
|
$sDefaultModules = array('wysiwyg','menu_link','jsadmin');
|
27
|
$sDefaultTemplates = array('DefaultTheme','DefaultTemplate');
|
28
|
// Setup template object, parse vars to it, then parse it
|
29
|
// Create new template object
|
30
|
$template = new Template(dirname($admin->correct_theme_source('groups.htt')));
|
31
|
// $template->debug = true;
|
32
|
$template->set_file('page', 'groups.htt');
|
33
|
$template->set_block('page', 'main_block', 'main');
|
34
|
$template->set_block('main_block', 'manage_users_block', 'users');
|
35
|
// insert urls
|
36
|
$ftan = $admin->getFTAN();
|
37
|
$template->set_var(array(
|
38
|
'ADMIN_URL' => ADMIN_URL,
|
39
|
'WB_URL' => WB_URL,
|
40
|
'THEME_URL' => THEME_URL,
|
41
|
'FTAN' => $ftan
|
42
|
)
|
43
|
);
|
44
|
/*-------------------------------------------------------------------------------------------------------*/
|
45
|
// Get existing value from database
|
46
|
$query = 'SELECT `group_id`, `name` FROM `'.TABLE_PREFIX.'groups` WHERE `group_id` != 1';
|
47
|
$results = $database->query($query);
|
48
|
if($database->is_error()) {
|
49
|
$admin->print_error($database->get_error(), 'index.php');
|
50
|
}
|
51
|
// Insert values into the modify/remove menu
|
52
|
$template->set_block('main_block', 'list_block', 'list');
|
53
|
if($results->numRows() > 0) {
|
54
|
// Insert first value to say please select
|
55
|
$template->set_var('VALUE', '');
|
56
|
$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
|
57
|
$template->parse('list', 'list_block', true);
|
58
|
// Loop through groups
|
59
|
while($group = $results->fetchRow(MYSQLI_ASSOC)) {
|
60
|
$template->set_var('VALUE',$admin->getIDKEY($group['group_id']));
|
61
|
$template->set_var('NAME', $group['name']);
|
62
|
$template->parse('list', 'list_block', true);
|
63
|
}
|
64
|
} else {
|
65
|
// Insert single value to say no groups were found
|
66
|
$template->set_var('NAME', $TEXT['NONE_FOUND']);
|
67
|
$template->parse('list', 'list_block', true);
|
68
|
}
|
69
|
/*-------------------------------------------------------------------------------------------------------*/
|
70
|
// Insert permissions values
|
71
|
if($admin->get_permission('groups_add') != true) {
|
72
|
$template->set_var('DISPLAY_ADD', 'hide');
|
73
|
}
|
74
|
if($admin->get_permission('groups_modify') != true) {
|
75
|
$template->set_var('DISPLAY_MODIFY', 'hide');
|
76
|
}
|
77
|
if($admin->get_permission('groups_delete') != true) {
|
78
|
$template->set_var('DISPLAY_DELETE', 'hide');
|
79
|
}
|
80
|
// Insert language headings
|
81
|
$template->set_var(array(
|
82
|
'HEADING_MODIFY_DELETE_GROUP' => $HEADING['MODIFY_DELETE_GROUP'],
|
83
|
'HEADING_ADD_GROUP' => $HEADING['ADD_GROUP']
|
84
|
)
|
85
|
);
|
86
|
// Insert language text and messages
|
87
|
$template->set_var(array(
|
88
|
'TEXT_MODIFY' => $TEXT['MODIFY'],
|
89
|
'TEXT_DELETE' => $TEXT['DELETE'],
|
90
|
'TEXT_MANAGE_USERS' => ( $admin->get_permission('users') == true ) ? $TEXT['MANAGE_USERS']: "",
|
91
|
'CONFIRM_DELETE' => $TEXT['GROUP'].' '.$TEXT['DELETE'].', '.$TEXT['ARE_YOU_SURE']
|
92
|
)
|
93
|
);
|
94
|
if ( $admin->get_permission('users') == true ) $template->parse("users", "manage_users_block", true);
|
95
|
// Parse template object
|
96
|
$template->parse('main', 'main_block', false);
|
97
|
$template->pparse('output', 'page');
|
98
|
/*-------------------------------------------------------------------------------------------------------*/
|
99
|
// Setup template object, parse vars to it, then parse it
|
100
|
// Create new template object
|
101
|
$template = new Template(dirname($admin->correct_theme_source('groups_form.htt')));
|
102
|
// $template->debug = true;
|
103
|
//$template->set_unknowns('keep');
|
104
|
$template->set_file('page', 'groups_form.htt');
|
105
|
$template->set_block('page', 'main_block', 'main');
|
106
|
/*-------------------------------------------------------------------------------------------------------*/
|
107
|
$template->set_var('DISPLAY_EXTRA', 'display:none;');
|
108
|
$template->set_var('GROUP_NAME', '');
|
109
|
$template->set_var('ACTION_URL', ADMIN_URL.'/groups/add.php');
|
110
|
$template->set_var('SUBMIT_TITLE', $TEXT['ADD']);
|
111
|
$template->set_var('ADVANCED_LINK', ADMIN_URL.'/groups/index.php');
|
112
|
$template->set_var('CANCEL_LINK', ADMIN_URL.'/access/index.php');
|
113
|
/*-------------------------------------------------------------------------------------------------------*/
|
114
|
// Tell the browser whether or not to show advanced options
|
115
|
$template->set_block('main_block', 'groups_basic_block', 'groups_basic');
|
116
|
$template->set_block('main_block', 'groups_extended_block', 'groups_extended');
|
117
|
if($bAdvanced)
|
118
|
{
|
119
|
$template->set_var('DISPLAY_ADVANCED', '');
|
120
|
$template->set_var('DISPLAY_BASIC', 'display:none;');
|
121
|
$template->set_var('ADVANCED_VALUE', 0);
|
122
|
$template->set_var('ADVANCED_BUTTON', '« '.$TEXT['HIDE_ADVANCED']);
|
123
|
$template->parse('groups_extended', 'groups_extended_block', true);
|
124
|
$template->set_block('groups_basic', '', '');
|
125
|
} else {
|
126
|
$template->set_var('DISPLAY_ADVANCED', 'display:none;');
|
127
|
$template->set_var('DISPLAY_BASIC', '');
|
128
|
$template->set_var('ADVANCED_VALUE', 1);
|
129
|
$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' »');
|
130
|
$template->parse('groups_basic', 'groups_basic_block', true);
|
131
|
$template->set_block('groups_extended', '');
|
132
|
}
|
133
|
/*
|
134
|
*/
|
135
|
/*-------------------------------------------------------------------------------------------------------*/
|
136
|
// Insert permissions values
|
137
|
if($admin->get_permission('groups_add') != true) {
|
138
|
$template->set_var('DISPLAY_ADD', 'hide');
|
139
|
}
|
140
|
/*-------------------------------------------------------------------------------------------------------*/
|
141
|
$sPermissions = array();
|
142
|
$system_permissions = array();
|
143
|
// Check system permissions boxes
|
144
|
$sOldWorkingDir = getcwd();
|
145
|
// Explode module permissions
|
146
|
chdir(WB_PATH.'/modules/');
|
147
|
$aAvailableItemsList = glob('*', GLOB_ONLYDIR|GLOB_NOSORT);
|
148
|
$module_permissions = array_diff($aAvailableItemsList, $sDefaultModules);
|
149
|
// Explode template permissions
|
150
|
chdir(WB_PATH.'/templates/');
|
151
|
$aAvailableItemsList = glob('*', GLOB_ONLYDIR|GLOB_NOSORT);
|
152
|
$template_permissions = array_diff($aAvailableItemsList, $sDefaultTemplates);
|
153
|
chdir($sOldWorkingDir);
|
154
|
|
155
|
/*-------------------------------------------------------------------------------------------------------*/
|
156
|
// Insert values into module list
|
157
|
$template->set_block('main_block', 'module_list_block', 'module_list');
|
158
|
$template->set_block('main_block', 'module_group_block', 'module_group');
|
159
|
$aTmp = array();
|
160
|
$aCheckedList = array();
|
161
|
$GroupsFunction = '';
|
162
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
|
163
|
. 'WHERE `type` = \'module\' '
|
164
|
. 'AND `function` IN (\'page\', \'tool\') '
|
165
|
// . 'GROUP BY `function` '
|
166
|
. 'ORDER BY `function`, `name`';
|
167
|
if($result = $database->query($sql))
|
168
|
{
|
169
|
$i=0;
|
170
|
while($addon = $result->fetchRow(MYSQLI_ASSOC)) {
|
171
|
$template->set_var('OPTGROUP', '');
|
172
|
$template->set_block('module_group_block', '');
|
173
|
if (strcasecmp($addon['function'], $GroupsFunction)!== 0){
|
174
|
$template->set_var('OPTGROUP', ucwords($addon['function']));
|
175
|
$template->parse('module_group', 'module_group_block', true);
|
176
|
}
|
177
|
if (!is_readable(WB_PATH.'/modules/'.$addon['directory'])){
|
178
|
$aTmp[] = $addon['directory'];
|
179
|
continue;
|
180
|
}
|
181
|
$template->set_var('VALUE', $addon['directory']);
|
182
|
$template->set_var('NAME', (($addon['function'] == 'page') ? $addon['name'] :''.$addon['name']));
|
183
|
if (!is_numeric(array_search($addon['directory'], $module_permissions)) )
|
184
|
{
|
185
|
$template->set_var('CHECKED', ' checked="checked"');
|
186
|
$aCheckedList[$i]['directory'] = $addon['directory'];
|
187
|
$aCheckedList[$i]['name'] = $addon['name'];
|
188
|
++$i;
|
189
|
} else {
|
190
|
$template->set_var('CHECKED', '');
|
191
|
}
|
192
|
$GroupsFunction = $addon['function'];
|
193
|
$template->parse('module_list', 'module_list_block', true);
|
194
|
}
|
195
|
}
|
196
|
|
197
|
// Insert values into template list
|
198
|
$template->set_block('main_block', 'template_list_block', 'template_list');
|
199
|
$template->set_block('main_block', 'template_group_block', 'template_group');
|
200
|
$aTmp = array();
|
201
|
$aCheckedList = array();
|
202
|
$GroupsFunction = '';
|
203
|
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` '
|
204
|
. 'WHERE `type` = \'template\' '
|
205
|
. 'ORDER BY `function`, `name`';
|
206
|
if($result = $database->query($sql))
|
207
|
{
|
208
|
$i=0;
|
209
|
while( $addon = $result->fetchRow(MYSQLI_ASSOC)) {
|
210
|
$template->set_var('OPTGROUP', '');
|
211
|
$template->set_block('template_function', '');
|
212
|
if (strcasecmp($addon['function'], $GroupsFunction)!== 0){
|
213
|
$template->set_var('OPTGROUP', ucwords($addon['function']));
|
214
|
$template->parse('template_group', 'template_group_block', true);
|
215
|
}
|
216
|
if (!is_readable(WB_PATH.'/templates/'.$addon['directory'])){
|
217
|
$aTmp[] = $addon['directory'];
|
218
|
continue;
|
219
|
}
|
220
|
$template->set_var('VALUE', $addon['directory']);
|
221
|
$template->set_var('NAME', $addon['name'] );
|
222
|
if(!is_numeric(array_search($addon['directory'], $template_permissions)))
|
223
|
{
|
224
|
$template->set_var('CHECKED', ' checked="checked"');
|
225
|
$aCheckedList[$i]['directory'] = $addon['directory'];
|
226
|
$aCheckedList[$i]['name'] = $addon['name'];
|
227
|
++$i;
|
228
|
} else {
|
229
|
$template->set_var('CHECKED', '');
|
230
|
}
|
231
|
$GroupsFunction = $addon['function'];
|
232
|
$template->parse('template_list', 'template_list_block', true);
|
233
|
}
|
234
|
}
|
235
|
/*-------------------------------------------------------------------------------------------------------*/
|
236
|
// Insert language text and messages
|
237
|
$template->set_var(array(
|
238
|
'TEXT_CANCEL' => $TEXT['CANCEL'],
|
239
|
'TEXT_RESET' => $TEXT['RESET'],
|
240
|
'TEXT_FILESYSTEM_PERMISSIONS' => $TEXT['FILESYSTEM_PERMISSIONS'],
|
241
|
'TEXT_ACTIVE' => $TEXT['ACTIVE'],
|
242
|
'TEXT_DISABLED' => $TEXT['DISABLED'],
|
243
|
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
|
244
|
'TEXT_USERNAME' => $TEXT['USERNAME'],
|
245
|
'TEXT_PASSWORD' => $TEXT['PASSWORD'],
|
246
|
'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
|
247
|
'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
|
248
|
'TEXT_EMAIL' => $TEXT['EMAIL'],
|
249
|
'TEXT_GROUP' => $TEXT['GROUP'],
|
250
|
'TEXT_GROUPS' => $MENU['GROUPS'],
|
251
|
'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'],
|
252
|
'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'],
|
253
|
'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'],
|
254
|
'TEXT_NAME' => $TEXT['NAME'],
|
255
|
'SECTION_PAGES' => $MENU['PAGES'],
|
256
|
'SECTION_MEDIA' => $MENU['MEDIA'],
|
257
|
'SECTION_MODULES' => $MENU['MODULES'],
|
258
|
'SECTION_TEMPLATES' => $MENU['TEMPLATES'],
|
259
|
'SECTION_SETTINGS' => $MENU['SETTINGS'],
|
260
|
'SECTION_LANGUAGES' => $MENU['LANGUAGES'],
|
261
|
'SECTION_USERS' => $MENU['USERS'],
|
262
|
'SECTION_GROUPS' => $MENU['GROUPS'],
|
263
|
'SECTION_ADMINTOOLS' => $MENU['ADMINTOOLS'],
|
264
|
'TEXT_VIEW' => $TEXT['VIEW'],
|
265
|
'TEXT_ADD' => $TEXT['ADD'],
|
266
|
'TEXT_LEVEL' => $TEXT['LEVEL'],
|
267
|
'TEXT_MODIFY' => $TEXT['MODIFY'],
|
268
|
'TEXT_DELETE' => $TEXT['DELETE'],
|
269
|
'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'],
|
270
|
'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
|
271
|
'HEADING_MODIFY_INTRO_PAGE' => $TEXT['INTRO_PAGE'],//$HEADING['MODIFY_INTRO_PAGE'],
|
272
|
'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
|
273
|
'TEXT_RENAME' => $TEXT['RENAME'],
|
274
|
'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
|
275
|
'TEXT_BASIC' => $TEXT['BASIC'],
|
276
|
'TEXT_ADVANCED' => $TEXT['ADVANCED'],
|
277
|
'CHANGING_PASSWORD' => $MESSAGE['USERS_CHANGING_PASSWORD'],
|
278
|
// 'CHECKED' => ' checked="checked"',
|
279
|
'ADMIN_URL' => ADMIN_URL,
|
280
|
'WB_URL' => WB_URL,
|
281
|
'THEME_URL' => THEME_URL,
|
282
|
'FTAN' => $ftan,
|
283
|
'DEBUG_MSG'=>(@$DebugOLutput?:'')
|
284
|
)
|
285
|
);
|
286
|
|
287
|
// Parse template for add group form
|
288
|
$template->parse('main', 'main_block', false);
|
289
|
$template->pparse('output', 'page');
|
290
|
|
291
|
// Print the admin footer
|
292
|
$admin->print_footer();
|