Project

General

Profile

1 1386 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         groups
6 1529 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7 1386 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
// Print admin header
19
require('../../config.php');
20
require_once(WB_PATH.'/framework/class.admin.php');
21
$admin = new admin('Access', 'groups');
22 1398 FrankH
$ftan = $admin->getFTAN();
23 1386 Luisehahne
24 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
25
// Create new template object
26 1625 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('groups.htt')));
27 1529 Luisehahne
// $template->debug = true;
28 1386 Luisehahne
$template->set_file('page', 'groups.htt');
29
$template->set_block('page', 'main_block', 'main');
30
$template->set_block('main_block', 'manage_users_block', 'users');
31
// insert urls
32
$template->set_var(array(
33
	'ADMIN_URL' => ADMIN_URL,
34
	'WB_URL' => WB_URL,
35 1398 FrankH
	'THEME_URL' => THEME_URL,
36
	'FTAN' => $ftan
37 1386 Luisehahne
	)
38
);
39
40
// Get existing value from database
41
// $database = new database();
42
$query = "SELECT group_id,name FROM ".TABLE_PREFIX."groups WHERE group_id != '1'";
43
$results = $database->query($query);
44
if($database->is_error()) {
45
	$admin->print_error($database->get_error(), 'index.php');
46
}
47
48
// Insert values into the modify/remove menu
49
$template->set_block('main_block', 'list_block', 'list');
50
if($results->numRows() > 0) {
51
	// Insert first value to say please select
52
	$template->set_var('VALUE', '');
53
	$template->set_var('NAME', $TEXT['PLEASE_SELECT'].'...');
54
	$template->parse('list', 'list_block', true);
55
	// Loop through groups
56
	while($group = $results->fetchRow()) {
57 1475 Luisehahne
		$template->set_var('VALUE',$admin->getIDKEY($group['group_id']));
58 1386 Luisehahne
		$template->set_var('NAME', $group['name']);
59
		$template->parse('list', 'list_block', true);
60
	}
61
} else {
62
	// Insert single value to say no groups were found
63
	$template->set_var('NAME', $TEXT['NONE_FOUND']);
64
	$template->parse('list', 'list_block', true);
65
}
66
67
// Insert permissions values
68
if($admin->get_permission('groups_add') != true) {
69
	$template->set_var('DISPLAY_ADD', 'hide');
70
}
71
if($admin->get_permission('groups_modify') != true) {
72
	$template->set_var('DISPLAY_MODIFY', 'hide');
73
}
74
if($admin->get_permission('groups_delete') != true) {
75
	$template->set_var('DISPLAY_DELETE', 'hide');
76
}
77
78
// Insert language headings
79
$template->set_var(array(
80
	'HEADING_MODIFY_DELETE_GROUP' => $HEADING['MODIFY_DELETE_GROUP'],
81
	'HEADING_ADD_GROUP' => $HEADING['ADD_GROUP']
82
	)
83
);
84
// Insert language text and messages
85
$template->set_var(array(
86
	'TEXT_MODIFY' => $TEXT['MODIFY'],
87
	'TEXT_DELETE' => $TEXT['DELETE'],
88
	'TEXT_MANAGE_USERS' => ( $admin->get_permission('users') == true ) ? $TEXT['MANAGE_USERS']: "",
89
	'CONFIRM_DELETE' => $MESSAGE['GROUPS']['CONFIRM_DELETE']
90
	)
91
);
92
if ( $admin->get_permission('users') == true ) $template->parse("users", "manage_users_block", true);
93
// Parse template object
94
$template->parse('main', 'main_block', false);
95
$template->pparse('output', 'page');
96
97 1529 Luisehahne
// Setup template object, parse vars to it, then parse it
98
// Create new template object
99 1625 Luisehahne
$template = new Template(dirname($admin->correct_theme_source('groups_form.htt')));
100 1529 Luisehahne
// $template->debug = true;
101 1386 Luisehahne
$template->set_file('page', 'groups_form.htt');
102
$template->set_block('page', 'main_block', 'main');
103
$template->set_var('DISPLAY_EXTRA', 'display:none;');
104
$template->set_var('ACTION_URL', ADMIN_URL.'/groups/add.php');
105
$template->set_var('SUBMIT_TITLE', $TEXT['ADD']);
106 1493 Luisehahne
$template->set_var('ADVANCED_LINK', 'index.php');
107 1386 Luisehahne
108
// Tell the browser whether or not to show advanced options
109
if ( true == (isset( $_POST['advanced']) AND ( strpos( $_POST['advanced'], ">>") > 0 ) ) ) {
110
	$template->set_var('DISPLAY_ADVANCED', '');
111
	$template->set_var('DISPLAY_BASIC', 'display:none;');
112
	$template->set_var('ADVANCED', 'yes');
113
	$template->set_var('ADVANCED_BUTTON', '<< '.$TEXT['HIDE_ADVANCED']);
114
} else {
115
	$template->set_var('DISPLAY_ADVANCED', 'display:none;');
116
	$template->set_var('DISPLAY_BASIC', '');
117
	$template->set_var('ADVANCED', 'no');
118
	$template->set_var('ADVANCED_BUTTON', $TEXT['SHOW_ADVANCED'].' >>');
119
}
120
121
// Insert permissions values
122
if($admin->get_permission('groups_add') != true) {
123
	$template->set_var('DISPLAY_ADD', 'hide');
124
}
125
126
// Insert values into module list
127
$template->set_block('main_block', 'module_list_block', 'module_list');
128
$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "module" AND `function` = "page" ORDER BY `name`');
129
if($result->numRows() > 0) {
130
	while($addon = $result->fetchRow()) {
131
		$template->set_var('VALUE', $addon['directory']);
132
		$template->set_var('NAME', $addon['name']);
133
		$template->parse('module_list', 'module_list_block', true);
134
	}
135
}
136
137
// Insert values into template list
138
$template->set_block('main_block', 'template_list_block', 'template_list');
139
$result = $database->query('SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "template" ORDER BY `name`');
140
if($result->numRows() > 0) {
141
	while($addon = $result->fetchRow()) {
142
		$template->set_var('VALUE', $addon['directory']);
143
		$template->set_var('NAME', $addon['name']);
144
		$template->parse('template_list', 'template_list_block', true);
145
	}
146
}
147
148
// Insert language text and messages
149
$template->set_var(array(
150
								'TEXT_RESET' => $TEXT['RESET'],
151
								'TEXT_ACTIVE' => $TEXT['ACTIVE'],
152
								'TEXT_DISABLED' => $TEXT['DISABLED'],
153
								'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
154
								'TEXT_USERNAME' => $TEXT['USERNAME'],
155
								'TEXT_PASSWORD' => $TEXT['PASSWORD'],
156
								'TEXT_RETYPE_PASSWORD' => $TEXT['RETYPE_PASSWORD'],
157
								'TEXT_DISPLAY_NAME' => $TEXT['DISPLAY_NAME'],
158
								'TEXT_EMAIL' => $TEXT['EMAIL'],
159
								'TEXT_GROUP' => $TEXT['GROUP'],
160
								'TEXT_SYSTEM_PERMISSIONS' => $TEXT['SYSTEM_PERMISSIONS'],
161
								'TEXT_MODULE_PERMISSIONS' => $TEXT['MODULE_PERMISSIONS'],
162
								'TEXT_TEMPLATE_PERMISSIONS' => $TEXT['TEMPLATE_PERMISSIONS'],
163
								'TEXT_NAME' => $TEXT['NAME'],
164
								'SECTION_PAGES' => $MENU['PAGES'],
165
								'SECTION_MEDIA' => $MENU['MEDIA'],
166
								'SECTION_MODULES' => $MENU['MODULES'],
167
								'SECTION_TEMPLATES' => $MENU['TEMPLATES'],
168
								'SECTION_SETTINGS' => $MENU['SETTINGS'],
169
								'SECTION_LANGUAGES' => $MENU['LANGUAGES'],
170
								'SECTION_USERS' => $MENU['USERS'],
171
								'SECTION_GROUPS' => $MENU['GROUPS'],
172
								'SECTION_ADMINTOOLS' => $MENU['ADMINTOOLS'],
173
								'TEXT_VIEW' => $TEXT['VIEW'],
174
								'TEXT_ADD' => $TEXT['ADD'],
175
								'TEXT_LEVEL' => $TEXT['LEVEL'],
176
								'TEXT_MODIFY' => $TEXT['MODIFY'],
177
								'TEXT_DELETE' => $TEXT['DELETE'],
178
								'TEXT_MODIFY_CONTENT' => $TEXT['MODIFY_CONTENT'],
179
								'TEXT_MODIFY_SETTINGS' => $TEXT['MODIFY_SETTINGS'],
180
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE'],
181
								'TEXT_CREATE_FOLDER' => $TEXT['CREATE_FOLDER'],
182
								'TEXT_RENAME' => $TEXT['RENAME'],
183
								'TEXT_UPLOAD_FILES' => $TEXT['UPLOAD_FILES'],
184
								'TEXT_BASIC' => $TEXT['BASIC'],
185
								'TEXT_ADVANCED' => $TEXT['ADVANCED'],
186
								'CHANGING_PASSWORD' => $MESSAGE['USERS']['CHANGING_PASSWORD'],
187
								'CHECKED' => ' checked="checked"',
188
								'ADMIN_URL' => ADMIN_URL,
189
								'WB_URL' => WB_URL,
190 1398 FrankH
								'THEME_URL' => THEME_URL,
191
								'FTAN' => $ftan
192 1386 Luisehahne
								)
193
						);
194
195
// Parse template for add group form
196
$template->parse('main', 'main_block', false);
197
$template->pparse('output', 'page');
198
199
// Print the admin footer
200
$admin->print_footer();