Project

General

Profile

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