1
|
<?php
|
2
|
|
3
|
// $Id: settings.php 398 2006-12-23 20:22:14Z Ruebenwurzel $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2006, 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
|
// Get page id
|
27
|
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
|
28
|
header("Location: index.php");
|
29
|
exit(0);
|
30
|
} else {
|
31
|
$page_id = $_GET['page_id'];
|
32
|
}
|
33
|
|
34
|
// Create new admin object
|
35
|
require('../../config.php');
|
36
|
require_once(WB_PATH.'/framework/class.admin.php');
|
37
|
$admin = new admin('Pages', 'pages_settings');
|
38
|
|
39
|
// Get perms
|
40
|
$database = new database();
|
41
|
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
|
42
|
$results_array = $results->fetchRow();
|
43
|
$old_admin_groups = explode(',', $results_array['admin_groups']);
|
44
|
$old_admin_users = explode(',', $results_array['admin_users']);
|
45
|
if(!is_numeric(array_search($admin->get_group_id(), $old_admin_groups)) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
|
46
|
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
|
47
|
}
|
48
|
|
49
|
// Get page details
|
50
|
$database = new database();
|
51
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
|
52
|
$results = $database->query($query);
|
53
|
if($database->is_error()) {
|
54
|
$admin->print_header();
|
55
|
$admin->print_error($database->get_error());
|
56
|
}
|
57
|
if($results->numRows() == 0) {
|
58
|
$admin->print_header();
|
59
|
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']);
|
60
|
}
|
61
|
$results_array = $results->fetchRow();
|
62
|
|
63
|
// Get display name of person who last modified the page
|
64
|
$user=$admin->get_user_details($results_array['modified_by']);
|
65
|
|
66
|
// Convert the unix ts for modified_when to human a readable form
|
67
|
if($results_array['modified_when'] != 0) {
|
68
|
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
|
69
|
} else {
|
70
|
$modified_ts = 'Unknown';
|
71
|
}
|
72
|
|
73
|
// Setup template object, parse vars to it, then parse it
|
74
|
$template = new Template(ADMIN_PATH.'/pages');
|
75
|
$template->set_file('page', 'settings.html');
|
76
|
$template->set_block('page', 'main_block', 'main');
|
77
|
$template->set_var(array(
|
78
|
'PAGE_ID' => $results_array['page_id'],
|
79
|
'PAGE_TITLE' => (htmlentities($results_array['page_title'])),
|
80
|
'MENU_TITLE' => (htmlentities($results_array['menu_title'])),
|
81
|
'DESCRIPTION' => ($results_array['description']),
|
82
|
'KEYWORDS' => ($results_array['keywords']),
|
83
|
'MODIFIED_BY' => $user['display_name'],
|
84
|
'MODIFIED_BY_USERNAME' => $user['username'],
|
85
|
'MODIFIED_WHEN' => $modified_ts,
|
86
|
'ADMIN_URL' => ADMIN_URL
|
87
|
)
|
88
|
);
|
89
|
|
90
|
// Work-out if we should show the "manage sections" link
|
91
|
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
|
92
|
if($query_sections->numRows() > 0) {
|
93
|
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
|
94
|
} elseif(MANAGE_SECTIONS == 'enabled') {
|
95
|
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
|
96
|
} else {
|
97
|
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'none');
|
98
|
}
|
99
|
|
100
|
// Visibility
|
101
|
if($results_array['visibility'] == 'public') {
|
102
|
$template->set_var('PUBLIC_SELECTED', ' selected');
|
103
|
} elseif($results_array['visibility'] == 'private') {
|
104
|
$template->set_var('PRIVATE_SELECTED', ' selected');
|
105
|
} elseif($results_array['visibility'] == 'registered') {
|
106
|
$template->set_var('REGISTERED_SELECTED', ' selected');
|
107
|
} elseif($results_array['visibility'] == 'hidden') {
|
108
|
$template->set_var('HIDDEN_SELECTED', ' selected');
|
109
|
} elseif($results_array['visibility'] == 'none') {
|
110
|
$template->set_var('NO_VIS_SELECTED', ' selected');
|
111
|
}
|
112
|
// Group list 1 (admin_groups)
|
113
|
$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
|
114
|
if($admin->get_group_id() == 1) {
|
115
|
$query = "SELECT * FROM ".TABLE_PREFIX."groups";
|
116
|
} else {
|
117
|
$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
|
118
|
}
|
119
|
$get_groups = $database->query($query);
|
120
|
$template->set_block('main_block', 'group_list_block', 'group_list');
|
121
|
// Insert admin group and current group first
|
122
|
$admin_group_name = $get_groups->fetchRow();
|
123
|
$template->set_var(array(
|
124
|
'ID' => 1,
|
125
|
'TOGGLE' => '',
|
126
|
'DISABLED' => ' disabled',
|
127
|
'LINK_COLOR' => '000000',
|
128
|
'CURSOR' => 'default',
|
129
|
'NAME' => $admin_group_name['name'],
|
130
|
'CHECKED' => ' checked'
|
131
|
)
|
132
|
);
|
133
|
$template->parse('group_list', 'group_list_block', true);
|
134
|
if($admin->get_group_id() != 1) {
|
135
|
$template->set_var(array(
|
136
|
'ID' => $admin->get_group_id(),
|
137
|
'TOGGLE' => '',
|
138
|
'DISABLED' => ' disabled',
|
139
|
'LINK_COLOR' => '000000',
|
140
|
'CURSOR' => 'default',
|
141
|
'NAME' => $admin->get_group_name(),
|
142
|
'CHECKED' => ' checked'
|
143
|
)
|
144
|
);
|
145
|
$template->parse('group_list', 'group_list_block', true);
|
146
|
}
|
147
|
while($group = $get_groups->fetchRow()) {
|
148
|
// Check if the group is allowed to edit pages
|
149
|
$system_permissions = explode(',', $group['system_permissions']);
|
150
|
if(is_numeric(array_search('pages_modify', $system_permissions))) {
|
151
|
$template->set_var(array(
|
152
|
'ID' => $group['group_id'],
|
153
|
'TOGGLE' => $group['group_id'],
|
154
|
'DISABLED' => '',
|
155
|
'LINK_COLOR' => '',
|
156
|
'CURSOR' => 'pointer',
|
157
|
'NAME' => $group['name'],
|
158
|
'CHECKED' => ''
|
159
|
)
|
160
|
);
|
161
|
if(is_numeric(array_search($group['group_id'], $admin_groups))) {
|
162
|
$template->set_var('CHECKED', 'checked');
|
163
|
} else {
|
164
|
$template->set_var('CHECKED', '');
|
165
|
}
|
166
|
$template->parse('group_list', 'group_list_block', true);
|
167
|
}
|
168
|
}
|
169
|
// Group list 2 (viewing_groups)
|
170
|
$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups']));
|
171
|
if($admin->get_group_id() == 1) {
|
172
|
$query = "SELECT * FROM ".TABLE_PREFIX."groups";
|
173
|
} else {
|
174
|
$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
|
175
|
}
|
176
|
$get_groups = $database->query($query);
|
177
|
$template->set_block('main_block', 'group_list_block2', 'group_list2');
|
178
|
// Insert admin group and current group first
|
179
|
$admin_group_name = $get_groups->fetchRow();
|
180
|
$template->set_var(array(
|
181
|
'ID' => 1,
|
182
|
'TOGGLE' => '',
|
183
|
'DISABLED' => ' disabled',
|
184
|
'LINK_COLOR' => '000000',
|
185
|
'CURSOR' => 'default',
|
186
|
'NAME' => $admin_group_name['name'],
|
187
|
'CHECKED' => ' checked'
|
188
|
)
|
189
|
);
|
190
|
$template->parse('group_list2', 'group_list_block2', true);
|
191
|
if($admin->get_group_id() != 1) {
|
192
|
$template->set_var(array(
|
193
|
'ID' => $admin->get_group_id(),
|
194
|
'TOGGLE' => '',
|
195
|
'DISABLED' => ' disabled',
|
196
|
'LINK_COLOR' => '000000',
|
197
|
'CURSOR' => 'default',
|
198
|
'NAME' => $admin->get_group_name(),
|
199
|
'CHECKED' => ' checked'
|
200
|
)
|
201
|
);
|
202
|
$template->parse('group_list2', 'group_list_block2', true);
|
203
|
}
|
204
|
while($group = $get_groups->fetchRow()) {
|
205
|
$template->set_var(array(
|
206
|
'ID' => $group['group_id'],
|
207
|
'TOGGLE' => $group['group_id'],
|
208
|
'DISABLED' => '',
|
209
|
'LINK_COLOR' => '',
|
210
|
'CURSOR' => 'pointer',
|
211
|
'NAME' => $group['name'],
|
212
|
)
|
213
|
);
|
214
|
if(is_numeric(array_search($group['group_id'], $viewing_groups))) {
|
215
|
$template->set_var('CHECKED', 'checked');
|
216
|
} else {
|
217
|
$template->set_var('CHECKED', '');
|
218
|
}
|
219
|
$template->parse('group_list2', 'group_list_block2', true);
|
220
|
}
|
221
|
// Show private viewers
|
222
|
if($results_array['visibility'] == 'private' OR $results_array['visibility'] == 'registered') {
|
223
|
$template->set_var('DISPLAY_VIEWERS', '');
|
224
|
} else {
|
225
|
$template->set_var('DISPLAY_VIEWERS', 'none');
|
226
|
}
|
227
|
|
228
|
// Parent page list
|
229
|
$database = new database();
|
230
|
function parent_list($parent) {
|
231
|
global $admin, $database, $template, $results_array;
|
232
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
|
233
|
$get_pages = $database->query($query);
|
234
|
while($page = $get_pages->fetchRow()) {
|
235
|
// If the current page cannot be parent, then its children neither
|
236
|
$list_next_level = true;
|
237
|
// Stop users from adding pages with a level of more than the set page level limit
|
238
|
if($page['level']+1 < PAGE_LEVEL_LIMIT) {
|
239
|
// Get user perms
|
240
|
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
|
241
|
$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
|
242
|
if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
|
243
|
$can_modify = true;
|
244
|
} else {
|
245
|
$can_modify = false;
|
246
|
}
|
247
|
// Title -'s prefix
|
248
|
$title_prefix = '';
|
249
|
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
|
250
|
$template->set_var(array(
|
251
|
'ID' => $page['page_id'],
|
252
|
'TITLE' => ($title_prefix.htmlentities($page['page_title']))
|
253
|
)
|
254
|
);
|
255
|
if($results_array['parent'] == $page['page_id']) {
|
256
|
$template->set_var('SELECTED', ' selected');
|
257
|
} elseif($results_array['page_id'] == $page['page_id']) {
|
258
|
$template->set_var('SELECTED', ' disabled="disabled" style="color: #aaa;"');
|
259
|
$list_next_level=false;
|
260
|
} elseif($can_modify != true) {
|
261
|
$template->set_var('SELECTED', ' disabled="disabled" style="color: #aaa;"');
|
262
|
} else {
|
263
|
$template->set_var('SELECTED', '');
|
264
|
}
|
265
|
$template->parse('page_list2', 'page_list_block2', true);
|
266
|
}
|
267
|
if ($list_next_level)
|
268
|
parent_list($page['page_id']);
|
269
|
}
|
270
|
}
|
271
|
$template->set_block('main_block', 'page_list_block2', 'page_list2');
|
272
|
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
|
273
|
if($results_array['parent'] == 0) { $selected = ' selected'; } else { $selected = ''; }
|
274
|
$template->set_var(array(
|
275
|
'ID' => '0',
|
276
|
'TITLE' => $TEXT['NONE'],
|
277
|
'SELECTED' => $selected
|
278
|
)
|
279
|
);
|
280
|
$template->parse('page_list2', 'page_list_block2', true);
|
281
|
}
|
282
|
parent_list(0);
|
283
|
|
284
|
if($modified_ts == 'Unknown') {
|
285
|
$template->set_var('DISPLAY_MODIFIED', 'hide');
|
286
|
} else {
|
287
|
$template->set_var('DISPLAY_MODIFIED', '');
|
288
|
}
|
289
|
// Templates list
|
290
|
$template->set_block('main_block', 'template_list_block', 'template_list');
|
291
|
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' order by name");
|
292
|
if($result->numRows() > 0) {
|
293
|
while($addon = $result->fetchRow()) {
|
294
|
// Check if the user has perms to use this template
|
295
|
if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true) {
|
296
|
$template->set_var('VALUE', $addon['directory']);
|
297
|
$template->set_var('NAME', $addon['name']);
|
298
|
if($addon['directory'] == $results_array['template']) {
|
299
|
$template->set_var('SELECTED', ' selected');
|
300
|
} else {
|
301
|
$template->set_var('SELECTED', '');
|
302
|
}
|
303
|
$template->parse('template_list', 'template_list_block', true);
|
304
|
}
|
305
|
}
|
306
|
}
|
307
|
|
308
|
// Menu list
|
309
|
if(MULTIPLE_MENUS == false) {
|
310
|
$template->set_var('DISPLAY_MENU_LIST', 'none');
|
311
|
}
|
312
|
// Include template info file (if it exists)
|
313
|
if($results_array['template'] != '') {
|
314
|
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
|
315
|
} else {
|
316
|
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
|
317
|
}
|
318
|
if(file_exists($template_location)) {
|
319
|
require($template_location);
|
320
|
}
|
321
|
// Check if $menu is set
|
322
|
if(!isset($menu[1]) OR $menu[1] == '') {
|
323
|
// Make our own menu list
|
324
|
$menu[1] = $TEXT['MAIN'];
|
325
|
}
|
326
|
// Add menu options to the list
|
327
|
$template->set_block('main_block', 'menu_list_block', 'menu_list');
|
328
|
foreach($menu AS $number => $name) {
|
329
|
$template->set_var('NAME', $name);
|
330
|
$template->set_var('VALUE', $number);
|
331
|
if($results_array['menu'] == $number) {
|
332
|
$template->set_var('SELECTED', 'selected');
|
333
|
} else {
|
334
|
$template->set_var('SELECTED', '');
|
335
|
}
|
336
|
$template->parse('menu_list', 'menu_list_block', true);
|
337
|
}
|
338
|
|
339
|
// Language list
|
340
|
if($handle = opendir(WB_PATH.'/languages/')) {
|
341
|
$template->set_block('main_block', 'language_list_block', 'language_list');
|
342
|
while (false !== ($file = readdir($handle))) {
|
343
|
if($file != '.' AND $file != '..' AND $file != '.svn' AND $file != 'index.php') {
|
344
|
// Include the languages info file
|
345
|
require(WB_PATH.'/languages/'.$file);
|
346
|
// Work-out if this language is selected
|
347
|
if($language_code == $results_array['language']) { $selected = ' selected'; } else { $selected = ''; }
|
348
|
// Set the language info
|
349
|
$template->set_var(array('VALUE' => $language_code, 'SELECTED' => $selected, 'NAME' => $language_name));
|
350
|
// Parse row
|
351
|
$template->parse('language_list', 'language_list_block', true);
|
352
|
}
|
353
|
}
|
354
|
}
|
355
|
// Restore to original language
|
356
|
require(WB_PATH.'/languages/'.LANGUAGE.'.php');
|
357
|
|
358
|
// Select disabled if searching is disabled
|
359
|
if($results_array['searching'] == 0) {
|
360
|
$template->set_var('SEARCHING_DISABLED', ' selected');
|
361
|
}
|
362
|
// Select what the page target is
|
363
|
switch ($results_array['target']) {
|
364
|
case '_top':
|
365
|
$template->set_var('TOP_SELECTED', ' selected');
|
366
|
break;
|
367
|
case '_self':
|
368
|
$template->set_var('SELF_SELECTED', ' selected');
|
369
|
break;
|
370
|
case '_blank':
|
371
|
$template->set_var('BLANK_SELECTED', ' selected');
|
372
|
break;
|
373
|
}
|
374
|
|
375
|
|
376
|
// Insert language text
|
377
|
$template->set_var(array(
|
378
|
'HEADING_MODIFY_PAGE_SETTINGS' => $HEADING['MODIFY_PAGE_SETTINGS'],
|
379
|
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
|
380
|
'TEXT_MODIFY' => $TEXT['MODIFY'],
|
381
|
'TEXT_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
|
382
|
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
|
383
|
'TEXT_PAGE_TITLE' => $TEXT['PAGE_TITLE'],
|
384
|
'TEXT_MENU_TITLE' => $TEXT['MENU_TITLE'],
|
385
|
'TEXT_TYPE' => $TEXT['TYPE'],
|
386
|
'TEXT_MENU' => $TEXT['MENU'],
|
387
|
'TEXT_PARENT' => $TEXT['PARENT'],
|
388
|
'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
|
389
|
'TEXT_PUBLIC' => $TEXT['PUBLIC'],
|
390
|
'TEXT_PRIVATE' => $TEXT['PRIVATE'],
|
391
|
'TEXT_REGISTERED' => $TEXT['REGISTERED'],
|
392
|
'TEXT_NONE' => $TEXT['NONE'],
|
393
|
'TEXT_HIDDEN' => $TEXT['HIDDEN'],
|
394
|
'TEXT_TEMPLATE' => $TEXT['TEMPLATE'],
|
395
|
'TEXT_TARGET' => $TEXT['TARGET'],
|
396
|
'TEXT_SYSTEM_DEFAULT' => $TEXT['SYSTEM_DEFAULT'],
|
397
|
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'],
|
398
|
'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'],
|
399
|
'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'],
|
400
|
'TEXT_TOP_FRAME' => $TEXT['TOP_FRAME'],
|
401
|
'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
|
402
|
'TEXT_ALLOWED_VIEWERS' => $TEXT['ALLOWED_VIEWERS'],
|
403
|
'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'],
|
404
|
'TEXT_KEYWORDS' => $TEXT['KEYWORDS'],
|
405
|
'TEXT_SEARCHING' => $TEXT['SEARCHING'],
|
406
|
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'],
|
407
|
'TEXT_ENABLED' => $TEXT['ENABLED'],
|
408
|
'TEXT_DISABLED' => $TEXT['DISABLED'],
|
409
|
'TEXT_SAVE' => $TEXT['SAVE'],
|
410
|
'TEXT_RESET' => $TEXT['RESET'],
|
411
|
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
|
412
|
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
|
413
|
)
|
414
|
);
|
415
|
|
416
|
$template->parse('main', 'main_block', false);
|
417
|
$template->pparse('output', 'page');
|
418
|
|
419
|
// Print admin footer
|
420
|
$admin->print_footer();
|
421
|
|
422
|
?>
|