Project

General

Profile

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 1473 2011-07-09 00:40:50Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/groups/groups.php $
15
 * @lastmodified    $Date: 2011-07-09 02:40:50 +0200 (Sat, 09 Jul 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
/*  */
47
	if (!$admin->checkFTAN())
48
	{
49
		$admin->print_header();
50
		$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
51
	}
52

    
53
	// Print header
54
	$admin->print_header();
55
	// Get existing values
56
	$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'");
57
	$group = $results->fetchRow();
58
	// Setup template object
59
	$template = new Template(THEME_PATH.'/templates');
60
	$template->set_file('page', 'groups_form.htt');
61
	$template->set_block('page', 'main_block', 'main');
62
	$template->set_var(	array(
63
							'ACTION_URL' => ADMIN_URL.'/groups/save.php',
64
							'SUBMIT_TITLE' => $TEXT['SAVE'],
65
							'GROUP_ID' => $group['group_id'],
66
							'GROUP_NAME' => $group['name'],
67
							'ADVANCED_ACTION' => 'groups.php',
68
							'FTAN' => $admin->getFTAN()
69
						));
70
	// Tell the browser whether or not to show advanced options
71
	if( true == (isset( $_POST['advanced']) AND ( strpos( $_POST['advanced'], ">>") > 0 ) ) ) {
72
		$template->set_var('DISPLAY_ADVANCED', '');
73
		$template->set_var('DISPLAY_BASIC', 'display:none;');
74
		$template->set_var('ADVANCED', 'yes');
75
		$template->set_var('ADVANCED_BUTTON', '&lt;&lt; '.$TEXT['HIDE_ADVANCED']);
76
	} else {
77
		$template->set_var('DISPLAY_ADVANCED', 'display:none;');
78
		$template->set_var('DISPLAY_BASIC', '');
79
		$template->set_var('ADVANCED', 'no');
80
		$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].'  &gt;&gt;');
81
	}
82

    
83
	// Explode system permissions
84
	$system_permissions = explode(',', $group['system_permissions']);
85
	// Check system permissions boxes
86
	foreach($system_permissions AS $name) {
87
			$template->set_var($name.'_checked', ' checked="checked"');
88
	}
89
	// Explode module permissions
90
	$module_permissions = explode(',', $group['module_permissions']);
91
	// Explode template permissions
92
	$template_permissions = explode(',', $group['template_permissions']);
93
	
94
	// Insert values into module list
95
	$template->set_block('main_block', 'module_list_block', 'module_list');
96
	$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "module" AND `function` = "page" ORDER BY `name`');
97
	if($result->numRows() > 0) {
98
		while($addon = $result->fetchRow()) {
99
			$template->set_var('VALUE', $addon['directory']);
100
			$template->set_var('NAME', $addon['name']);
101
			if(!is_numeric(array_search($addon['directory'], $module_permissions))) {
102
				$template->set_var('CHECKED', ' checked="checked"');
103
			} else {
104
				$template->set_var('CHECKED', '');
105
			}
106
			$template->parse('module_list', 'module_list_block', true);
107
		}
108
	}
109
	
110
	// Insert values into template list
111
	$template->set_block('main_block', 'template_list_block', 'template_list');
112
	$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "template" ORDER BY `name`');
113
	if($result->numRows() > 0) {
114
		while($addon = $result->fetchRow()) {
115
			$template->set_var('VALUE', $addon['directory']);
116
			$template->set_var('NAME', $addon['name']);
117
			if(!is_numeric(array_search($addon['directory'], $template_permissions))) {
118
				$template->set_var('CHECKED', ' checked="checked"');
119
			} else {
120
				$template->set_var('CHECKED', '');
121
			}
122
			$template->parse('template_list', 'template_list_block', true);
123
		}
124
	}
125
		
126
	// Insert language text and messages
127
	$template->set_var(array(
128
				'TEXT_RESET' => $TEXT['RESET'],
129
				'TEXT_ACTIVE' => $TEXT['ACTIVE'],
130
				'TEXT_DISABLED' => $TEXT['DISABLED'],
131
				'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
132
				'TEXT_USERNAME' => $TEXT['USERNAME'],
133
				'TEXT_PASSWORD' => $TEXT['PASSWORD'],
134
				'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
135
				'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
136
				'TEXT_EMAIL' => $TEXT['EMAIL'],
137
				'TEXT_GROUP' => $TEXT['GROUP'],
138
				'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'],
139
				'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'],
140
				'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'],
141
				'TEXT_NAME' => $TEXT['NAME'],
142
				'SECTION_PAGES' => $MENU['PAGES'],
143
				'SECTION_MEDIA' => $MENU['MEDIA'],
144
				'SECTION_MODULES' => $MENU['MODULES'],
145
				'SECTION_TEMPLATES' => $MENU['TEMPLATES'],
146
				'SECTION_LANGUAGES' => $MENU['LANGUAGES'],
147
				'SECTION_SETTINGS' => $MENU['SETTINGS'],
148
				'SECTION_USERS' => $MENU['USERS'],
149
				'SECTION_GROUPS' => $MENU['GROUPS'],
150
				'SECTION_ADMINTOOLS' => $MENU['ADMINTOOLS'],
151
				'TEXT_VIEW' => $TEXT['VIEW'],
152
				'TEXT_ADD' => $TEXT['ADD'],
153
				'TEXT_LEVEL' => $TEXT['LEVEL'],
154
				'TEXT_MODIFY' => $TEXT['MODIFY'],
155
				'TEXT_DELETE' => $TEXT['DELETE'],
156
				'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'],
157
				'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
158
				'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'],
159
				'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
160
				'TEXT_RENAME' => $TEXT['RENAME'],
161
				'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
162
				'TEXT_BASIC' => $TEXT['BASIC'],
163
				'TEXT_ADVANCED' => $TEXT['ADVANCED'],
164
				'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'],
165
				'HEADING_MODIFY_GROUP' => $HEADING['MODIFY_GROUP'],
166
			));
167
	
168
	// Parse template object
169
	$template->parse('main', 'main_block', false);
170
	$template->pparse('output', 'page');
171
} elseif($_POST['action'] == 'delete') {
172
	// Create new admin object
173
	$admin = new admin('Access', 'groups_delete', false);
174
/*  */
175
	if (!$admin->checkFTAN())
176
	{
177
		$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL);
178
	}
179
	// Print header
180
	$admin->print_header();
181
	// Delete the group
182
	$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1");
183
	if($database->is_error()) {
184
		$admin->print_error($database->get_error());
185
	} else {
186
		// Delete users in the group
187
		$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'");
188
		if($database->is_error()) {
189
			$admin->print_error($database->get_error());
190
		} else {
191
			$admin->print_success($MESSAGE['GROUPS']['DELETED']);
192
		}
193
	}
194
}
195

    
196
// Print admin footer
197
$admin->print_footer();
(3-3/5)