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 1374 2011-01-10 12:21:47Z Luisehahne $
|
14
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/groups/groups.php $
|
15
|
* @lastmodified $Date: 2011-01-10 13:21:47 +0100 (Mon, 10 Jan 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
|
// 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" ORDER BY `name`');
|
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" ORDER BY `name`');
|
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
|
|
188
|
?>
|