Project

General

Profile

1
<?php
2
/*
3
*
4
*                       About WebsiteBaker
5
*
6
* Website Baker is a PHP-based Content Management System (CMS)
7
* designed with one goal in mind: to enable its users to produce websites
8
* with ease.
9
*
10
*                       LICENSE INFORMATION
11
*
12
* WebsiteBaker is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU General Public License
14
* as published by the Free Software Foundation; either version 2
15
* of the License, or (at your option) any later version.
16
*
17
* WebsiteBaker is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
* See the GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
*
26
*                   WebsiteBaker Extra Information
27
*
28
*
29
*/
30
/**
31
 *
32
 * @category        admin
33
 * @package         groups
34
 * @author          WebsiteBaker Project
35
 * @copyright       2004-2009, Ryan Djurovich
36
 * @copyright       2009-2010, Website Baker Org. e.V.
37
 * @link			http://www.websitebaker2.org/
38
 * @license         http://www.gnu.org/licenses/gpl.html
39
 * @platform        WebsiteBaker 2.8.x
40
 * @requirements    PHP 4.3.4 and higher
41
 * @version         $Id: groups.php 1271 2010-01-23 02:30:24Z Luisehahne $
42
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/groups/groups.php $
43
 * @lastmodified    $Date: 2010-01-23 03:30:24 +0100 (Sat, 23 Jan 2010) $
44
 *
45
*/
46

    
47
// Include config file and admin class file
48
require('../../config.php');
49
require_once(WB_PATH.'/framework/class.admin.php');
50

    
51
// Create new database object
52
$database = new database();
53

    
54
if(!isset($_POST['action']) OR ($_POST['action'] != "modify" AND $_POST['action'] != "delete")) {
55
	header("Location: index.php");
56
	exit(0);
57
}
58

    
59
// Set parameter 'action' as alternative to javascript mechanism
60
if(isset($_POST['modify']))
61
	$_POST['action'] = "modify";
62
if(isset($_POST['delete']))
63
	$_POST['action'] = "delete";
64

    
65
// Check if group group_id is a valid number and doesnt equal 1
66
if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) {
67
	header("Location: index.php");
68
	exit(0);
69
}
70

    
71
if($_POST['action'] == 'modify') {
72
	// Create new admin object
73
	$admin = new admin('Access', 'groups_modify', false);
74
	// Print header
75
	$admin->print_header();
76
	// Get existing values
77
	$results = $database->query("SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."'");
78
	$group = $results->fetchRow();
79
	// Setup template object
80
	$template = new Template(THEME_PATH.'/templates');
81
	$template->set_file('page', 'groups_form.htt');
82
	$template->set_block('page', 'main_block', 'main');
83
	$template->set_var(	array(
84
										'ACTION_URL' => ADMIN_URL.'/groups/save.php',
85
										'SUBMIT_TITLE' => $TEXT['SAVE'],
86
										'GROUP_ID' => $group['group_id'],
87
										'GROUP_NAME' => $group['name'],
88
										'ADVANCED_ACTION' => 'groups.php'
89
										)
90
							);
91
	// Tell the browser whether or not to show advanced options
92
	if( true == (isset( $_POST['advanced']) AND ( strpos( $_POST['advanced'], ">>") > 0 ) ) ) {
93
		$template->set_var('DISPLAY_ADVANCED', '');
94
		$template->set_var('DISPLAY_BASIC', 'display:none;');
95
		$template->set_var('ADVANCED', 'yes');
96
		$template->set_var('ADVANCED_BUTTON', '&lt;&lt; '.$TEXT['HIDE_ADVANCED']);
97
	} else {
98
		$template->set_var('DISPLAY_ADVANCED', 'display:none;');
99
		$template->set_var('DISPLAY_BASIC', '');
100
		$template->set_var('ADVANCED', 'no');
101
		$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].'  &gt;&gt;');
102
	}
103

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

    
213
// Print admin footer
214
$admin->print_footer();
215

    
216
?>
(3-3/5)