Project

General

Profile

« Previous | Next » 

Revision 1243

Added by Dietmar over 14 years ago

Ticket #911 continue to fix CSS-errors in WB backend

View differences:

groups.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
// Include config file and admin class file
27
require('../../config.php');
28
require_once(WB_PATH.'/framework/class.admin.php');
29

  
30
// Create new database object
31
$database = new database();
32

  
33
if(!isset($_POST['action']) OR ($_POST['action'] != "modify" AND $_POST['action'] != "delete")) {
34
	header("Location: index.php");
35
	exit(0);
36
}
37

  
38
// Set parameter 'action' as alternative to javascript mechanism
39
if(isset($_POST['modify']))
40
	$_POST['action'] = "modify";
41
if(isset($_POST['delete']))
42
	$_POST['action'] = "delete";
43

  
44
// Check if group group_id is a valid number and doesnt equal 1
45
if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) {
46
	header("Location: index.php");
47
	exit(0);
48
}
49

  
50
if($_POST['action'] == 'modify') {
51
	// Create new admin object
52
	$admin = new admin('Access', 'groups_modify', false);
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
										)
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', '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', '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'");
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'");
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
	
169
	// Parse template object
170
	$template->parse('main', 'main_block', false);
171
	$template->pparse('output', 'page');
172
} elseif($_POST['action'] == 'delete') {
173
	// Create new admin object
174
	$admin = new admin('Access', 'groups_delete', false);
175
	// Print header
176
	$admin->print_header();
177
	// Delete the group
178
	$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$_POST['group_id']."' LIMIT 1");
179
	if($database->is_error()) {
180
		$admin->print_error($database->get_error());
181
	} else {
182
		// Delete users in the group
183
		$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$_POST['group_id']."'");
184
		if($database->is_error()) {
185
			$admin->print_error($database->get_error());
186
		} else {
187
			$admin->print_success($MESSAGE['GROUPS']['DELETED']);
188
		}
189
	}
190
}
191

  
192
// Print admin footer
193
$admin->print_footer();
194

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

  
61
// Include config file and admin class file
62
require('../../config.php');
63
require_once(WB_PATH.'/framework/class.admin.php');
64

  
65
// Create new database object
66
$database = new database();
67

  
68
if(!isset($_POST['action']) OR ($_POST['action'] != "modify" AND $_POST['action'] != "delete")) {
69
	header("Location: index.php");
70
	exit(0);
71
}
72

  
73
// Set parameter 'action' as alternative to javascript mechanism
74
if(isset($_POST['modify']))
75
	$_POST['action'] = "modify";
76
if(isset($_POST['delete']))
77
	$_POST['action'] = "delete";
78

  
79
// Check if group group_id is a valid number and doesnt equal 1
80
if(!isset($_POST['group_id']) OR !is_numeric($_POST['group_id']) OR $_POST['group_id'] == 1) {
81
	header("Location: index.php");
82
	exit(0);
83
}
84

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

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

  
227
// Print admin footer
228
$admin->print_footer();
229

  
195 230
?>

Also available in: Unified diff