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