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