Project

General

Profile

1 1243 Luisehahne
<?php
2
/**
3
 *
4 1269 Luisehahne
 * @category        admin
5 1271 Luisehahne
 * @package         groups
6 1269 Luisehahne
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8 1349 Luisehahne
 * @copyright       2009-2011, Website Baker Org. e.V.
9 1269 Luisehahne
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12 1374 Luisehahne
 * @requirements    PHP 5.2.2 and higher
13 1269 Luisehahne
 * @version         $Id$
14 1270 Luisehahne
 * @filesource		$HeadURL$
15
 * @lastmodified    $Date$
16 1243 Luisehahne
 *
17 1277 Luisehahne
 */
18 1243 Luisehahne
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 1323 Luisehahne
// $database = new database();
25 1243 Luisehahne
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 1398 FrankH
47
	if (!$admin->checkFTAN())
48
	{
49
		$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL);
50
		exit();
51
	}
52 1243 Luisehahne
	// Print header
53
	$admin->print_header();
54
	// Get existing values
55
	$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'");
56
	$group = $results->fetchRow();
57
	// Setup template object
58
	$template = new Template(THEME_PATH.'/templates');
59
	$template->set_file('page', 'groups_form.htt');
60
	$template->set_block('page', 'main_block', 'main');
61
	$template->set_var(	array(
62 1398 FrankH
							'ACTION_URL' => ADMIN_URL.'/groups/save.php',
63
							'SUBMIT_TITLE' => $TEXT['SAVE'],
64
							'GROUP_ID' => $group['group_id'],
65
							'GROUP_NAME' => $group['name'],
66
							'ADVANCED_ACTION' => 'groups.php',
67
							'FTAN' => $admin->getFTAN()
68
						));
69 1243 Luisehahne
	// Tell the browser whether or not to show advanced options
70
	if( true == (isset( $_POST['advanced']) AND ( strpos( $_POST['advanced'], ">>") > 0 ) ) ) {
71
		$template->set_var('DISPLAY_ADVANCED', '');
72
		$template->set_var('DISPLAY_BASIC', 'display:none;');
73
		$template->set_var('ADVANCED', 'yes');
74
		$template->set_var('ADVANCED_BUTTON', '&lt;&lt; '.$TEXT['HIDE_ADVANCED']);
75
	} else {
76
		$template->set_var('DISPLAY_ADVANCED', 'display:none;');
77
		$template->set_var('DISPLAY_BASIC', '');
78
		$template->set_var('ADVANCED', 'no');
79
		$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].'  &gt;&gt;');
80
	}
81
82
	// Explode system permissions
83
	$system_permissions = explode(',', $group['system_permissions']);
84
	// Check system permissions boxes
85
	foreach($system_permissions AS $name) {
86
			$template->set_var($name.'_checked', ' checked="checked"');
87
	}
88
	// Explode module permissions
89
	$module_permissions = explode(',', $group['module_permissions']);
90
	// Explode template permissions
91
	$template_permissions = explode(',', $group['template_permissions']);
92
93
	// Insert values into module list
94
	$template->set_block('main_block', 'module_list_block', 'module_list');
95 1322 Luisehahne
	$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "module" AND `function` = "page" ORDER BY `name`');
96 1243 Luisehahne
	if($result->numRows() > 0) {
97
		while($addon = $result->fetchRow()) {
98
			$template->set_var('VALUE', $addon['directory']);
99
			$template->set_var('NAME', $addon['name']);
100
			if(!is_numeric(array_search($addon['directory'], $module_permissions))) {
101
				$template->set_var('CHECKED', ' checked="checked"');
102
			} else {
103
				$template->set_var('CHECKED', '');
104
			}
105
			$template->parse('module_list', 'module_list_block', true);
106
		}
107
	}
108
109
	// Insert values into template list
110
	$template->set_block('main_block', 'template_list_block', 'template_list');
111 1322 Luisehahne
	$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "template" ORDER BY `name`');
112 1243 Luisehahne
	if($result->numRows() > 0) {
113
		while($addon = $result->fetchRow()) {
114
			$template->set_var('VALUE', $addon['directory']);
115
			$template->set_var('NAME', $addon['name']);
116
			if(!is_numeric(array_search($addon['directory'], $template_permissions))) {
117
				$template->set_var('CHECKED', ' checked="checked"');
118
			} else {
119
				$template->set_var('CHECKED', '');
120
			}
121
			$template->parse('template_list', 'template_list_block', true);
122
		}
123
	}
124
125
	// Insert language text and messages
126
	$template->set_var(array(
127 1398 FrankH
				'TEXT_RESET' => $TEXT['RESET'],
128
				'TEXT_ACTIVE' => $TEXT['ACTIVE'],
129
				'TEXT_DISABLED' => $TEXT['DISABLED'],
130
				'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
131
				'TEXT_USERNAME' => $TEXT['USERNAME'],
132
				'TEXT_PASSWORD' => $TEXT['PASSWORD'],
133
				'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
134
				'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
135
				'TEXT_EMAIL' => $TEXT['EMAIL'],
136
				'TEXT_GROUP' => $TEXT['GROUP'],
137
				'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'],
138
				'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'],
139
				'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'],
140
				'TEXT_NAME' => $TEXT['NAME'],
141
				'SECTION_PAGES' => $MENU['PAGES'],
142
				'SECTION_MEDIA' => $MENU['MEDIA'],
143
				'SECTION_MODULES' => $MENU['MODULES'],
144
				'SECTION_TEMPLATES' => $MENU['TEMPLATES'],
145
				'SECTION_LANGUAGES' => $MENU['LANGUAGES'],
146
				'SECTION_SETTINGS' => $MENU['SETTINGS'],
147
				'SECTION_USERS' => $MENU['USERS'],
148
				'SECTION_GROUPS' => $MENU['GROUPS'],
149
				'SECTION_ADMINTOOLS' => $MENU['ADMINTOOLS'],
150
				'TEXT_VIEW' => $TEXT['VIEW'],
151
				'TEXT_ADD' => $TEXT['ADD'],
152
				'TEXT_LEVEL' => $TEXT['LEVEL'],
153
				'TEXT_MODIFY' => $TEXT['MODIFY'],
154
				'TEXT_DELETE' => $TEXT['DELETE'],
155
				'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'],
156
				'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
157
				'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'],
158
				'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
159
				'TEXT_RENAME' => $TEXT['RENAME'],
160
				'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
161
				'TEXT_BASIC' => $TEXT['BASIC'],
162
				'TEXT_ADVANCED' => $TEXT['ADVANCED'],
163
				'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'],
164
				'HEADING_MODIFY_GROUP' => $HEADING['MODIFY_GROUP'],
165
			));
166 1243 Luisehahne
167
	// Parse template object
168
	$template->parse('main', 'main_block', false);
169
	$template->pparse('output', 'page');
170
} elseif($_POST['action'] == 'delete') {
171
	// Create new admin object
172
	$admin = new admin('Access', 'groups_delete', false);
173 1398 FrankH
174
	if (!$admin->checkFTAN())
175
	{
176
		$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL);
177
		exit();
178
	}
179
180 1243 Luisehahne
	// Print header
181
	$admin->print_header();
182
	// Delete the group
183
	$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1");
184
	if($database->is_error()) {
185
		$admin->print_error($database->get_error());
186
	} else {
187
		// Delete users in the group
188
		$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'");
189
		if($database->is_error()) {
190
			$admin->print_error($database->get_error());
191
		} else {
192
			$admin->print_success($MESSAGE['GROUPS']['DELETED']);
193
		}
194
	}
195
}
196
197
// Print admin footer
198
$admin->print_footer();
199
200 239 stefan
?>