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 1475 2011-07-12 23:07:10Z Luisehahne $
14
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/groups/groups.php $
15
 * @lastmodified    $Date: 2011-07-13 01:07:10 +0200 (Wed, 13 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
// Set parameter 'action' as alternative to javascript mechanism
24
$action = 'cancel';
25
// Set parameter 'action' as alternative to javascript mechanism
26
$action = (isset($_POST['modify']) ? 'modify' : $action );
27
$action = (isset($_POST['delete']) ? 'delete' : $action );
28

    
29
switch ($action):
30
	case 'modify' :
31

    
32
			// Create new admin object
33
			$admin = new admin('Access', 'groups_modify' );
34
			// Check if group group_id is a valid number and doesnt equal 1
35
			$group_id = intval($admin->checkIDKEY('group_id', 0, $_SERVER['REQUEST_METHOD']));
36
			if( ($group_id < 2 ) )
37
			{
38
				// if($admin_header) { $admin->print_header(); }
39
				$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'] );
40
			}
41

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

    
70
			// Explode system permissions
71
			$system_permissions = explode(',', $group['system_permissions']);
72
			// Check system permissions boxes
73
			foreach($system_permissions AS $name) {
74
					$template->set_var($name.'_checked', ' checked="checked"');
75
			}
76
			// Explode module permissions
77
			$module_permissions = explode(',', $group['module_permissions']);
78
			// Explode template permissions
79
			$template_permissions = explode(',', $group['template_permissions']);
80

    
81
			// Insert values into module list
82
			$template->set_block('main_block', 'module_list_block', 'module_list');
83
			$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "module" AND `function` = "page" ORDER BY `name`');
84
			if($result->numRows() > 0) {
85
				while($addon = $result->fetchRow()) {
86
					$template->set_var('VALUE', $addon['directory']);
87
					$template->set_var('NAME', $addon['name']);
88
					if(!is_numeric(array_search($addon['directory'], $module_permissions))) {
89
						$template->set_var('CHECKED', ' checked="checked"');
90
					} else {
91
						$template->set_var('CHECKED', '');
92
					}
93
					$template->parse('module_list', 'module_list_block', true);
94
				}
95
			}
96

    
97
			// Insert values into template list
98
			$template->set_block('main_block', 'template_list_block', 'template_list');
99
			$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "template" ORDER BY `name`');
100
			if($result->numRows() > 0) {
101
				while($addon = $result->fetchRow()) {
102
					$template->set_var('VALUE', $addon['directory']);
103
					$template->set_var('NAME', $addon['name']);
104
					if(!is_numeric(array_search($addon['directory'], $template_permissions))) {
105
						$template->set_var('CHECKED', ' checked="checked"');
106
					} else {
107
						$template->set_var('CHECKED', '');
108
					}
109
					$template->parse('template_list', 'template_list_block', true);
110
				}
111
			}
112

    
113
			// Insert language text and messages
114
			$template->set_var(array(
115
						'TEXT_RESET' => $TEXT['RESET'],
116
						'TEXT_ACTIVE' => $TEXT['ACTIVE'],
117
						'TEXT_DISABLED' => $TEXT['DISABLED'],
118
						'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
119
						'TEXT_USERNAME' => $TEXT['USERNAME'],
120
						'TEXT_PASSWORD' => $TEXT['PASSWORD'],
121
						'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
122
						'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
123
						'TEXT_EMAIL' => $TEXT['EMAIL'],
124
						'TEXT_GROUP' => $TEXT['GROUP'],
125
						'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'],
126
						'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'],
127
						'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'],
128
						'TEXT_NAME' => $TEXT['NAME'],
129
						'SECTION_PAGES' => $MENU['PAGES'],
130
						'SECTION_MEDIA' => $MENU['MEDIA'],
131
						'SECTION_MODULES' => $MENU['MODULES'],
132
						'SECTION_TEMPLATES' => $MENU['TEMPLATES'],
133
						'SECTION_LANGUAGES' => $MENU['LANGUAGES'],
134
						'SECTION_SETTINGS' => $MENU['SETTINGS'],
135
						'SECTION_USERS' => $MENU['USERS'],
136
						'SECTION_GROUPS' => $MENU['GROUPS'],
137
						'SECTION_ADMINTOOLS' => $MENU['ADMINTOOLS'],
138
						'TEXT_VIEW' => $TEXT['VIEW'],
139
						'TEXT_ADD' => $TEXT['ADD'],
140
						'TEXT_LEVEL' => $TEXT['LEVEL'],
141
						'TEXT_MODIFY' => $TEXT['MODIFY'],
142
						'TEXT_DELETE' => $TEXT['DELETE'],
143
						'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'],
144
						'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
145
						'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'],
146
						'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
147
						'TEXT_RENAME' => $TEXT['RENAME'],
148
						'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
149
						'TEXT_BASIC' => $TEXT['BASIC'],
150
						'TEXT_ADVANCED' => $TEXT['ADVANCED'],
151
						'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'],
152
						'HEADING_MODIFY_GROUP' => $HEADING['MODIFY_GROUP'],
153
					));
154

    
155
			// Parse template object
156
			$template->parse('main', 'main_block', false);
157
			$template->pparse('output', 'page');
158
			break;
159
		case 'delete' :
160
			// Create new admin object
161
			$admin = new admin('Access', 'groups_delete');
162
			$group_id = intval($admin->checkIDKEY('group_id', 0, $_SERVER['REQUEST_METHOD']));
163
			// Check if user id is a valid number and doesnt equal 1
164
			if( ($group_id < 2 ) )
165
			{
166
				// if($admin_header) { $admin->print_header(); }
167
				$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'] );
168
			}
169
			// Print header
170
			$admin->print_header();
171
			// Delete the group
172
			$database->query("DELETE FROM ".TABLE_PREFIX."groups WHERE group_id = '".$group_id."' LIMIT 1");
173
			if($database->is_error()) {
174
				$admin->print_error($database->get_error());
175
			} else {
176
				// Delete users in the group
177
				$database->query("DELETE FROM ".TABLE_PREFIX."users WHERE group_id = '".$group_id."'");
178
				if($database->is_error()) {
179
					$admin->print_error($database->get_error());
180
				} else {
181
					$admin->print_success($MESSAGE['GROUPS']['DELETED']);
182
				}
183
			}
184
			break;
185
	default:
186
			break;
187
endswitch;
188

    
189
// Print admin footer
190
$admin->print_footer();
(3-3/5)