Revision 1358
Added by Dietmar almost 14 years ago
settings.php | ||
---|---|---|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category admin |
|
5 |
* @package pages |
|
6 |
* @author WebsiteBaker Project |
|
7 |
* @copyright 2004-2009, Ryan Djurovich |
|
8 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
9 |
* @link http://www.websitebaker2.org/ |
|
10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
11 |
* @platform WebsiteBaker 2.8.x |
|
12 |
* @requirements PHP 5.2.2 and higher |
|
13 |
* @version $Id$ |
|
14 |
* @filesource $HeadURL$ |
|
15 |
* @lastmodified $Date$ |
|
16 |
* |
|
17 |
*/ |
|
18 |
|
|
19 |
// Get page id |
|
20 |
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) |
|
21 |
{ |
|
22 |
header("Location: index.php"); |
|
23 |
exit(0); |
|
24 |
} else { |
|
25 |
$page_id = $_GET['page_id']; |
|
26 |
} |
|
27 |
|
|
28 |
// Create new admin object |
|
29 |
require('../../config.php'); |
|
30 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
31 |
$admin = new admin('Pages', 'pages_settings'); |
|
32 |
|
|
33 |
if (!$admin->checkFTAN('get')) |
|
34 |
{ |
|
35 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
36 |
exit(); |
|
37 |
} |
|
38 |
|
|
39 |
// Include the WB functions file |
|
40 |
require_once(WB_PATH.'/framework/functions-utf8.php'); |
|
41 |
|
|
42 |
// Get perms |
|
43 |
/*$database = new database(); */ |
|
44 |
|
|
45 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id; |
|
46 |
$results = $database->query($sql); |
|
47 |
$results_array = $results->fetchRow(); |
|
48 |
|
|
49 |
$old_admin_groups = explode(',', $results_array['admin_groups']); |
|
50 |
$old_admin_users = explode(',', $results_array['admin_users']); |
|
51 |
|
|
52 |
// Work-out if we should check for existing page_code |
|
53 |
$sql = 'DESCRIBE `'.TABLE_PREFIX.'pages` `page_code`'; |
|
54 |
$field_sql = $database->query($sql); |
|
55 |
$field_set = $field_sql->numRows(); |
|
56 |
|
|
57 |
$in_old_group = FALSE; |
|
58 |
foreach($admin->get_groups_id() as $cur_gid) |
|
59 |
{ |
|
60 |
if (in_array($cur_gid, $old_admin_groups)) |
|
61 |
{ |
|
62 |
$in_old_group = TRUE; |
|
63 |
} |
|
64 |
} |
|
65 |
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) |
|
66 |
{ |
|
67 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
68 |
} |
|
69 |
|
|
70 |
// Get page details |
|
71 |
/* $database = new database(); */ |
|
72 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.$page_id; |
|
73 |
$results = $database->query($sql); |
|
74 |
if($database->is_error()) { |
|
75 |
$admin->print_header(); |
|
76 |
$admin->print_error($database->get_error()); |
|
77 |
} |
|
78 |
if($results->numRows() == 0) { |
|
79 |
$admin->print_header(); |
|
80 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
81 |
} |
|
82 |
$results_array = $results->fetchRow(); |
|
83 |
|
|
84 |
// Get display name of person who last modified the page |
|
85 |
$user=$admin->get_user_details($results_array['modified_by']); |
|
86 |
|
|
87 |
// Convert the unix ts for modified_when to human a readable form |
|
88 |
if($results_array['modified_when'] != 0) |
|
89 |
{ |
|
90 |
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE); |
|
91 |
} else { |
|
92 |
$modified_ts = 'Unknown'; |
|
93 |
} |
|
94 |
|
|
95 |
// Setup template object, parse vars to it, then parse it |
|
96 |
$template = new Template(THEME_PATH.'/templates'); |
|
97 |
$template->set_file('page', 'pages_settings.htt'); |
|
98 |
$template->set_block('page', 'main_block', 'main'); |
|
99 |
$template->set_var('FTAN', $admin->getFTAN()); |
|
100 |
|
|
101 |
$template->set_var(array( |
|
102 |
'PAGE_ID' => $results_array['page_id'], |
|
103 |
'PAGE_TITLE' => ($results_array['page_title']), |
|
104 |
'MENU_TITLE' => ($results_array['menu_title']), |
|
105 |
'DESCRIPTION' => ($results_array['description']), |
|
106 |
'KEYWORDS' => ($results_array['keywords']), |
|
107 |
'MODIFIED_BY' => $user['display_name'], |
|
108 |
'MODIFIED_BY_USERNAME' => $user['username'], |
|
109 |
'MODIFIED_WHEN' => $modified_ts, |
|
110 |
'ADMIN_URL' => ADMIN_URL, |
|
111 |
'WB_URL' => WB_URL, |
|
112 |
'WB_PATH' => WB_PATH, |
|
113 |
'THEME_URL' => THEME_URL |
|
114 |
) |
|
115 |
); |
|
116 |
|
|
117 |
// Work-out if we should show the "manage sections" link |
|
118 |
$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.$page_id.' AND `module`="menu_link"'; |
|
119 |
$query_sections = $database->query($sql); |
|
120 |
if($query_sections->numRows() > 0) |
|
121 |
{ |
|
122 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;'); |
|
123 |
} elseif(MANAGE_SECTIONS == 'enabled') |
|
124 |
{ |
|
125 |
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']); |
|
126 |
} else { |
|
127 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;'); |
|
128 |
} |
|
129 |
|
|
130 |
// Visibility |
|
131 |
if($results_array['visibility'] == 'public') { |
|
132 |
$template->set_var('PUBLIC_SELECTED', ' selected="selected"'); |
|
133 |
} elseif($results_array['visibility'] == 'private') { |
|
134 |
$template->set_var('PRIVATE_SELECTED', ' selected="selected"'); |
|
135 |
} elseif($results_array['visibility'] == 'registered') { |
|
136 |
$template->set_var('REGISTERED_SELECTED', ' selected="selected"'); |
|
137 |
} elseif($results_array['visibility'] == 'hidden') { |
|
138 |
$template->set_var('HIDDEN_SELECTED', ' selected="selected"'); |
|
139 |
} elseif($results_array['visibility'] == 'none') { |
|
140 |
$template->set_var('NO_VIS_SELECTED', ' selected="selected"'); |
|
141 |
} |
|
142 |
// Group list 1 (admin_groups) |
|
143 |
$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups'])); |
|
144 |
|
|
145 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups`'; |
|
146 |
$get_groups = $database->query($sql); |
|
147 |
|
|
148 |
$template->set_block('main_block', 'group_list_block', 'group_list'); |
|
149 |
// Insert admin group and current group first |
|
150 |
$admin_group_name = $get_groups->fetchRow(); |
|
151 |
$template->set_var(array( |
|
152 |
'ID' => 1, |
|
153 |
'TOGGLE' => '', |
|
154 |
'DISABLED' => ' disabled="disabled"', |
|
155 |
'LINK_COLOR' => '000000', |
|
156 |
'CURSOR' => 'default', |
|
157 |
'NAME' => $admin_group_name['name'], |
|
158 |
'CHECKED' => ' checked="checked"' |
|
159 |
) |
|
160 |
); |
|
161 |
$template->parse('group_list', 'group_list_block', true); |
|
162 |
while($group = $get_groups->fetchRow()) { |
|
163 |
// check if the user is a member of this group |
|
164 |
$flag_disabled = ''; |
|
165 |
$flag_checked = ''; |
|
166 |
$flag_cursor = 'pointer'; |
|
167 |
$flag_color = ''; |
|
168 |
if (in_array($group["group_id"], $admin->get_groups_id())) { |
|
169 |
$flag_disabled = ''; //' disabled'; |
|
170 |
$flag_checked = ''; //' checked'; |
|
171 |
$flag_cursor = 'default'; |
|
172 |
$flag_color = '000000'; |
|
173 |
} |
|
174 |
|
|
175 |
// Check if the group is allowed to edit pages |
|
176 |
$system_permissions = explode(',', $group['system_permissions']); |
|
177 |
if(is_numeric(array_search('pages_modify', $system_permissions))) { |
|
178 |
$template->set_var(array( |
|
179 |
'ID' => $group['group_id'], |
|
180 |
'TOGGLE' => $group['group_id'], |
|
181 |
'DISABLED' => $flag_disabled, |
|
182 |
'LINK_COLOR' => $flag_color, |
|
183 |
'CURSOR' => $flag_cursor, |
|
184 |
'NAME' => $group['name'], |
|
185 |
'CHECKED' => $flag_checked |
|
186 |
) |
|
187 |
); |
|
188 |
if(is_numeric(array_search($group['group_id'], $admin_groups))) { |
|
189 |
$template->set_var('CHECKED', ' checked="checked"'); |
|
190 |
} else { |
|
191 |
if (!$flag_checked) $template->set_var('CHECKED', ''); |
|
192 |
} |
|
193 |
$template->parse('group_list', 'group_list_block', true); |
|
194 |
} |
|
195 |
} |
|
196 |
// Group list 2 (viewing_groups) |
|
197 |
$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups'])); |
|
198 |
|
|
199 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups`'; |
|
200 |
$get_groups = $database->query($sql); |
|
201 |
|
|
202 |
$template->set_block('main_block', 'group_list_block2', 'group_list2'); |
|
203 |
// Insert admin group and current group first |
|
204 |
$admin_group_name = $get_groups->fetchRow(); |
|
205 |
$template->set_var(array( |
|
206 |
'ID' => 1, |
|
207 |
'TOGGLE' => '', |
|
208 |
'DISABLED' => ' disabled="disabled"', |
|
209 |
'LINK_COLOR' => '000000', |
|
210 |
'CURSOR' => 'default', |
|
211 |
'NAME' => $admin_group_name['name'], |
|
212 |
'CHECKED' => ' checked="checked"' |
|
213 |
) |
|
214 |
); |
|
215 |
$template->parse('group_list2', 'group_list_block2', true); |
|
216 |
|
|
217 |
while($group = $get_groups->fetchRow()) |
|
218 |
{ |
|
219 |
// check if the user is a member of this group |
|
220 |
$flag_disabled = ''; |
|
221 |
$flag_checked = ''; |
|
222 |
$flag_cursor = 'pointer'; |
|
223 |
$flag_color = ''; |
|
224 |
if (in_array($group["group_id"], $admin->get_groups_id())) |
|
225 |
{ |
|
226 |
$flag_disabled = ''; //' disabled'; |
|
227 |
$flag_checked = ''; //' checked'; |
|
228 |
$flag_cursor = 'default'; |
|
229 |
$flag_color = '000000'; |
|
230 |
} |
|
231 |
|
|
232 |
$template->set_var(array( |
|
233 |
'ID' => $group['group_id'], |
|
234 |
'TOGGLE' => $group['group_id'], |
|
235 |
'DISABLED' => $flag_disabled, |
|
236 |
'LINK_COLOR' => $flag_color, |
|
237 |
'CURSOR' => $flag_cursor, |
|
238 |
'NAME' => $group['name'], |
|
239 |
'CHECKED' => $flag_checked |
|
240 |
) |
|
241 |
); |
|
242 |
if(is_numeric(array_search($group['group_id'], $viewing_groups))) |
|
243 |
{ |
|
244 |
$template->set_var('CHECKED', 'checked="checked"'); |
|
245 |
} else { |
|
246 |
if (!$flag_checked) {$template->set_var('CHECKED', '');} |
|
247 |
} |
|
248 |
|
|
249 |
$template->parse('group_list2', 'group_list_block2', true); |
|
250 |
|
|
251 |
} |
|
252 |
|
|
253 |
// Show private viewers |
|
254 |
if($results_array['visibility'] == 'private' OR $results_array['visibility'] == 'registered') |
|
255 |
{ |
|
256 |
$template->set_var('DISPLAY_VIEWERS', ''); |
|
257 |
} else { |
|
258 |
$template->set_var('DISPLAY_VIEWERS', 'display:none;'); |
|
259 |
} |
|
260 |
|
|
261 |
//-- insert page_code 20090904--> |
|
262 |
$template->set_var('DISPLAY_CODE_PAGE_LIST', ' id="multi_lingual" style="display:none;"'); |
|
263 |
|
|
264 |
// Work-out if page languages feature is enabled |
|
265 |
if((defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') ) |
|
266 |
{ |
|
267 |
// workout field is set but module missing |
|
268 |
$TEXT['PAGE_CODE'] = empty($TEXT['PAGE_CODE']) ? 'Pagecode' : $TEXT['PAGE_CODE']; |
|
269 |
$template->set_var( array( |
|
270 |
'DISPLAY_CODE_PAGE_LIST' => ' id="multi_lingual"', |
|
271 |
'TEXT_PAGE_CODE' => '<a href="'.WB_URL.'/modules/mod_multilingual/update_keys.php?page_id='.$page_id.'">'.$TEXT['PAGE_CODE'].'</a>' |
|
272 |
) |
|
273 |
); |
|
274 |
|
|
275 |
// Page_code list |
|
276 |
/* $database = new database(); */ |
|
277 |
function page_code_list($parent) |
|
278 |
{ |
|
279 |
global $admin, $database, $template, $results_array, $pageCode; |
|
280 |
$default_language = DEFAULT_LANGUAGE; |
|
281 |
|
|
282 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' AND `language` = "'.$default_language.'" ORDER BY `position` ASC'; |
|
283 |
$get_pages = $database->query($sql); |
|
284 |
|
|
285 |
while($page = $get_pages->fetchRow()) |
|
286 |
{ |
|
287 |
if(($admin->page_is_visible($page)==false) && ($page['visibility'] <> 'none') ) { continue; } |
|
288 |
|
|
289 |
$template->set_var('FLAG_CODE_ICON',' none '); |
|
290 |
if( $page['parent'] == 0 ) |
|
291 |
{ |
|
292 |
$template->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)'); |
|
293 |
} |
|
294 |
|
|
295 |
// If the current page cannot be parent, then its children neither |
|
296 |
$list_next_level = true; |
|
297 |
// Stop users from adding pages with a level of more than the set page level limit |
|
298 |
if($page['level']+1 < PAGE_LEVEL_LIMIT) |
|
299 |
{ |
|
300 |
// Get user perms |
|
301 |
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups'])); |
|
302 |
$admin_users = explode(',', str_replace('_', '', $page['admin_users'])); |
|
303 |
|
|
304 |
$in_group = FALSE; |
|
305 |
foreach($admin->get_groups_id() as $cur_gid) |
|
306 |
{ |
|
307 |
if (in_array($cur_gid, $admin_groups)) |
|
308 |
{ |
|
309 |
$in_group = TRUE; |
|
310 |
} |
|
311 |
} |
|
312 |
|
|
313 |
if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) |
|
314 |
{ |
|
315 |
$can_modify = true; |
|
316 |
} else { |
|
317 |
$can_modify = false; |
|
318 |
} |
|
319 |
|
|
320 |
$title_prefix = ''; |
|
321 |
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - '; } |
|
322 |
// $space = str_repeat(' ', 3); $space.'<'..'>' |
|
323 |
$template->set_var(array( |
|
324 |
'VALUE' => $page['page_code'], |
|
325 |
'PAGE_VALUE' => $title_prefix.$page['menu_title'], |
|
326 |
'PAGE_CODE' => $title_prefix.$page['page_id'] |
|
327 |
) |
|
328 |
); |
|
329 |
if($results_array['page_code'] == $page['page_code']) |
|
330 |
{ |
|
331 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
332 |
} elseif($results_array['page_code'] == $page['page_code']) |
|
333 |
{ |
|
334 |
$template->set_var('SELECTED', ' disabled="disabled" class="disabled"'); |
|
335 |
$list_next_level=false; |
|
336 |
} elseif($can_modify != true) |
|
337 |
{ |
|
338 |
$template->set_var('SELECTED', ' disabled="disabled" class="disabled"'); |
|
339 |
} else { |
|
340 |
$template->set_var('SELECTED', ''); |
|
341 |
} |
|
342 |
$template->parse('page_code_list', 'page_code_list_block', true); |
|
343 |
} |
|
344 |
if ($list_next_level) |
|
345 |
page_code_list($page['page_id']); |
|
346 |
} |
|
347 |
} |
|
348 |
|
|
349 |
// Insert code_page values from page to modify |
|
350 |
$template->set_block('main_block', 'page_code_list_block', 'page_code_list'); |
|
351 |
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) { |
|
352 |
if($results_array['parent'] == 0) { $selected = ' selected'; } else { $selected = ''; } |
|
353 |
$template->set_var(array( |
|
354 |
'VALUE' => '', |
|
355 |
'PAGE_CODE' => $TEXT['NONE'], |
|
356 |
'PAGE_VALUE' => '', |
|
357 |
'SELECTED' => $selected |
|
358 |
) |
|
359 |
); |
|
360 |
$template->parse('page_code_list', 'page_code_list_block', true); |
|
361 |
} |
|
362 |
// get pagecode form this page_id |
|
363 |
page_code_list(0); |
|
364 |
} |
|
365 |
//-- page code --> |
|
366 |
|
|
367 |
// Parent page list |
|
368 |
/* $database = new database(); */ |
|
369 |
function parent_list($parent) |
|
370 |
{ |
|
371 |
global $admin, $database, $template, $results_array,$field_set; |
|
372 |
|
|
373 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ORDER BY `position` ASC'; |
|
374 |
$get_pages = $database->query($sql); |
|
375 |
|
|
376 |
while($page = $get_pages->fetchRow()) |
|
377 |
{ |
|
378 |
if($admin->page_is_visible($page)==false) |
|
379 |
{ |
|
380 |
continue; |
|
381 |
} |
|
382 |
|
|
383 |
// if parent = 0 set flag_icon |
|
384 |
$template->set_var('FLAG_ROOT_ICON',' none '); |
|
385 |
if( $page['parent'] == 0 && $field_set) |
|
386 |
{ |
|
387 |
$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)'); |
|
388 |
} |
|
389 |
// If the current page cannot be parent, then its children neither |
|
390 |
$list_next_level = true; |
|
391 |
// Stop users from adding pages with a level of more than the set page level limit |
|
392 |
if($page['level']+1 < PAGE_LEVEL_LIMIT) |
|
393 |
{ |
|
394 |
// Get user perms |
|
395 |
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups'])); |
|
396 |
$admin_users = explode(',', str_replace('_', '', $page['admin_users'])); |
|
397 |
$in_group = FALSE; |
|
398 |
foreach($admin->get_groups_id() as $cur_gid) |
|
399 |
{ |
|
400 |
if (in_array($cur_gid, $admin_groups)) |
|
401 |
{ |
|
402 |
$in_group = TRUE; |
|
403 |
} |
|
404 |
} |
|
405 |
if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) |
|
406 |
{ |
|
407 |
$can_modify = true; |
|
408 |
} else { |
|
409 |
$can_modify = false; |
|
410 |
} |
|
411 |
// Title -'s prefix |
|
412 |
$title_prefix = ''; |
|
413 |
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; } |
|
414 |
$template->set_var(array( |
|
415 |
'ID' => $page['page_id'], |
|
416 |
'TITLE' => ($title_prefix.$page['menu_title']), |
|
417 |
'MENU-TITLE' => ($title_prefix.$page['menu_title']), |
|
418 |
'PAGE-TITLE' => ($title_prefix.$page['page_title']), |
|
419 |
'FLAG_ICON' => ' none ', |
|
420 |
)); |
|
421 |
|
|
422 |
if($results_array['parent'] == $page['page_id']) |
|
423 |
{ |
|
424 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
425 |
} elseif($results_array['page_id'] == $page['page_id']) |
|
426 |
{ |
|
427 |
$template->set_var('SELECTED', ' disabled="disabled" class="disabled"'); |
|
428 |
$list_next_level=false; |
|
429 |
} elseif($can_modify != true) |
|
430 |
{ |
|
431 |
$template->set_var('SELECTED', ' disabled="disabled" class="disabled"'); |
|
432 |
} else { |
|
433 |
$template->set_var('SELECTED', ''); |
|
434 |
} |
|
435 |
$template->parse('page_list2', 'page_list_block2', true); |
|
436 |
} |
|
437 |
if ($list_next_level) |
|
438 |
{ |
|
439 |
parent_list($page['page_id']); |
|
440 |
} |
|
441 |
|
|
442 |
} |
|
443 |
} |
|
444 |
|
|
445 |
$template->set_block('main_block', 'page_list_block2', 'page_list2'); |
|
446 |
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) { |
|
447 |
if($results_array['parent'] == 0) |
|
448 |
{ |
|
449 |
$selected = ' selected="selected"'; |
|
450 |
} else { |
|
451 |
$selected = ''; |
|
452 |
} |
|
453 |
$template->set_var(array( |
|
454 |
'ID' => '0', |
|
455 |
'TITLE' => $TEXT['NONE'], |
|
456 |
'SELECTED' => $selected |
|
457 |
) |
|
458 |
); |
|
459 |
$template->parse('page_list2', 'page_list_block2', true); |
|
460 |
} |
|
461 |
parent_list(0); |
|
462 |
|
|
463 |
if($modified_ts == 'Unknown') |
|
464 |
{ |
|
465 |
$template->set_var('DISPLAY_MODIFIED', 'hide'); |
|
466 |
} else { |
|
467 |
$template->set_var('DISPLAY_MODIFIED', ''); |
|
468 |
} |
|
469 |
|
|
470 |
// Templates list |
|
471 |
$template->set_block('main_block', 'template_list_block', 'template_list'); |
|
472 |
|
|
473 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "template" AND `function` = "template" order by `name`'; |
|
474 |
$result = $database->query($sql); |
|
475 |
|
|
476 |
if($result->numRows() > 0) |
|
477 |
{ |
|
478 |
while($addon = $result->fetchRow()) |
|
479 |
{ |
|
480 |
// Check if the user has perms to use this template |
|
481 |
if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true) |
|
482 |
{ |
|
483 |
$template->set_var('VALUE', $addon['directory']); |
|
484 |
$template->set_var('NAME', $addon['name']); |
|
485 |
if($addon['directory'] == $results_array['template']) |
|
486 |
{ |
|
487 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
488 |
} else { |
|
489 |
$template->set_var('SELECTED', ''); |
|
490 |
} |
|
491 |
$template->parse('template_list', 'template_list_block', true); |
|
492 |
} |
|
493 |
} |
|
494 |
} |
|
495 |
|
|
496 |
// Menu list |
|
497 |
if(MULTIPLE_MENUS == false) |
|
498 |
{ |
|
499 |
$template->set_var('DISPLAY_MENU_LIST', 'display:none;'); |
|
500 |
} |
|
501 |
// Include template info file (if it exists) |
|
502 |
if($results_array['template'] != '') |
|
503 |
{ |
|
504 |
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php'; |
|
505 |
} else { |
|
506 |
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php'; |
|
507 |
} |
|
508 |
if(file_exists($template_location)) |
|
509 |
{ |
|
510 |
require($template_location); |
|
511 |
} |
|
512 |
// Check if $menu is set |
|
513 |
if(!isset($menu[1]) OR $menu[1] == '') |
|
514 |
{ |
|
515 |
// Make our own menu list |
|
516 |
$menu[1] = $TEXT['MAIN']; |
|
517 |
} |
|
518 |
// Add menu options to the list |
|
519 |
$template->set_block('main_block', 'menu_list_block', 'menu_list'); |
|
520 |
foreach($menu AS $number => $name) |
|
521 |
{ |
|
522 |
$template->set_var('NAME', $name); |
|
523 |
$template->set_var('VALUE', $number); |
|
524 |
if($results_array['menu'] == $number) |
|
525 |
{ |
|
526 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
527 |
} else { |
|
528 |
$template->set_var('SELECTED', ''); |
|
529 |
} |
|
530 |
$template->parse('menu_list', 'menu_list_block', true); |
|
531 |
} |
|
532 |
|
|
533 |
// Insert language values |
|
534 |
$template->set_block('main_block', 'language_list_block', 'language_list'); |
|
535 |
|
|
536 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "language" ORDER BY `name`'; |
|
537 |
$result = $database->query($sql); |
|
538 |
|
|
539 |
if($result->numRows() > 0) |
|
540 |
{ |
|
541 |
while($addon = $result->fetchRow()) |
|
542 |
{ |
|
543 |
$l_codes[$addon['name']] = $addon['directory']; |
|
544 |
$l_names[$addon['name']] = entities_to_7bit($addon['name']); // sorting-problem workaround |
|
545 |
} |
|
546 |
asort($l_names); |
|
547 |
foreach($l_names as $l_name=>$v) |
|
548 |
{ |
|
549 |
// Insert code and name |
|
550 |
$template->set_var(array( |
|
551 |
'VALUE' => $l_codes[$l_name], |
|
552 |
'NAME' => $l_name, |
|
553 |
'FLAG_LANG_ICONS' => 'url('.THEME_URL.'/images/flags/'.strtolower($l_codes[$l_name]).'.png)', |
|
554 |
)); |
|
555 |
// Check if it is selected |
|
556 |
if($results_array['language'] == $l_codes[$l_name]) |
|
557 |
{ |
|
558 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
559 |
} else { |
|
560 |
$template->set_var('SELECTED', ''); |
|
561 |
} |
|
562 |
$template->parse('language_list', 'language_list_block', true); |
|
563 |
} |
|
564 |
} |
|
565 |
|
|
566 |
// Select disabled if searching is disabled |
|
567 |
if($results_array['searching'] == 0) |
|
568 |
{ |
|
569 |
$template->set_var('SEARCHING_DISABLED', ' selected="selected"'); |
|
570 |
} |
|
571 |
// Select what the page target is |
|
572 |
switch ($results_array['target']) |
|
573 |
{ |
|
574 |
case '_top': |
|
575 |
$template->set_var('TOP_SELECTED', ' selected="selected"'); |
|
576 |
break; |
|
577 |
case '_self': |
|
578 |
$template->set_var('SELF_SELECTED', ' selected="selected"'); |
|
579 |
break; |
|
580 |
case '_blank': |
|
581 |
$template->set_var('BLANK_SELECTED', ' selected="selected"'); |
|
582 |
break; |
|
583 |
} |
|
584 |
|
|
585 |
// Insert language text |
|
586 |
$template->set_var(array( |
|
587 |
'HEADING_MODIFY_PAGE_SETTINGS' => $HEADING['MODIFY_PAGE_SETTINGS'], |
|
588 |
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'], |
|
589 |
'TEXT_MODIFY' => $TEXT['MODIFY'], |
|
590 |
'TEXT_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'], |
|
591 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
|
592 |
'TEXT_PAGE_TITLE' => $TEXT['PAGE_TITLE'], |
|
593 |
'TEXT_MENU_TITLE' => $TEXT['MENU_TITLE'], |
|
594 |
'TEXT_TYPE' => $TEXT['TYPE'], |
|
595 |
'TEXT_MENU' => $TEXT['MENU'], |
|
596 |
'TEXT_PARENT' => $TEXT['PARENT'], |
|
597 |
'TEXT_VISIBILITY' => $TEXT['VISIBILITY'], |
|
598 |
'TEXT_PUBLIC' => $TEXT['PUBLIC'], |
|
599 |
'TEXT_PRIVATE' => $TEXT['PRIVATE'], |
|
600 |
'TEXT_REGISTERED' => $TEXT['REGISTERED'], |
|
601 |
'TEXT_NONE' => $TEXT['NONE'], |
|
602 |
'TEXT_HIDDEN' => $TEXT['HIDDEN'], |
|
603 |
'TEXT_TEMPLATE' => $TEXT['TEMPLATE'], |
|
604 |
'TEXT_TARGET' => $TEXT['TARGET'], |
|
605 |
'TEXT_SYSTEM_DEFAULT' => $TEXT['SYSTEM_DEFAULT'], |
|
606 |
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], |
|
607 |
'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'], |
|
608 |
'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'], |
|
609 |
'TEXT_TOP_FRAME' => $TEXT['TOP_FRAME'], |
|
610 |
'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'], |
|
611 |
'TEXT_ALLOWED_VIEWERS' => $TEXT['ALLOWED_VIEWERS'], |
|
612 |
'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'], |
|
613 |
'TEXT_KEYWORDS' => $TEXT['KEYWORDS'], |
|
614 |
'TEXT_SEARCHING' => $TEXT['SEARCHING'], |
|
615 |
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'], |
|
616 |
'TEXT_ENABLED' => $TEXT['ENABLED'], |
|
617 |
'TEXT_DISABLED' => $TEXT['DISABLED'], |
|
618 |
'TEXT_SAVE' => $TEXT['SAVE'], |
|
619 |
'TEXT_RESET' => $TEXT['RESET'], |
|
620 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
|
621 |
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'] |
|
622 |
) ); |
|
623 |
|
|
624 |
$template->parse('main', 'main_block', false); |
|
625 |
$template->pparse('output', 'page'); |
|
626 |
|
|
627 |
// Print admin footer |
|
628 |
$admin->print_footer(); |
|
629 |
|
|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category admin |
|
5 |
* @package pages |
|
6 |
* @author WebsiteBaker Project |
|
7 |
* @copyright 2004-2009, Ryan Djurovich |
|
8 |
* @copyright 2009-2010, Website Baker Org. e.V. |
|
9 |
* @link http://www.websitebaker2.org/ |
|
10 |
* @license http://www.gnu.org/licenses/gpl.html |
|
11 |
* @platform WebsiteBaker 2.8.x |
|
12 |
* @requirements PHP 4.3.4 and higher |
|
13 |
* @version $Id$ |
|
14 |
* @filesource $HeadURL$ |
|
15 |
* @lastmodified $Date$ |
|
16 |
* |
|
17 |
*/ |
|
18 |
|
|
19 |
// Get page id |
|
20 |
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) |
|
21 |
{ |
|
22 |
header("Location: index.php"); |
|
23 |
exit(0); |
|
24 |
} else { |
|
25 |
$page_id = $_GET['page_id']; |
|
26 |
} |
|
27 |
|
|
28 |
// Create new admin object |
|
29 |
require('../../config.php'); |
|
30 |
require_once(WB_PATH.'/framework/class.admin.php'); |
|
31 |
$admin = new admin('Pages', 'pages_settings'); |
|
32 |
|
|
33 |
// Include the WB functions file |
|
34 |
require_once(WB_PATH.'/framework/functions-utf8.php'); |
|
35 |
|
|
36 |
// Get perms |
|
37 |
/*$database = new database(); */ |
|
38 |
|
|
39 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id; |
|
40 |
$results = $database->query($sql); |
|
41 |
$results_array = $results->fetchRow(); |
|
42 |
|
|
43 |
$old_admin_groups = explode(',', $results_array['admin_groups']); |
|
44 |
$old_admin_users = explode(',', $results_array['admin_users']); |
|
45 |
|
|
46 |
// Work-out if we should check for existing page_code |
|
47 |
$sql = 'DESCRIBE `'.TABLE_PREFIX.'pages` `page_code`'; |
|
48 |
$field_sql = $database->query($sql); |
|
49 |
$field_set = $field_sql->numRows(); |
|
50 |
|
|
51 |
$in_old_group = FALSE; |
|
52 |
foreach($admin->get_groups_id() as $cur_gid) |
|
53 |
{ |
|
54 |
if (in_array($cur_gid, $old_admin_groups)) |
|
55 |
{ |
|
56 |
$in_old_group = TRUE; |
|
57 |
} |
|
58 |
} |
|
59 |
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) |
|
60 |
{ |
|
61 |
$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']); |
|
62 |
} |
|
63 |
|
|
64 |
// Get page details |
|
65 |
/* $database = new database(); */ |
|
66 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.$page_id; |
|
67 |
$results = $database->query($sql); |
|
68 |
if($database->is_error()) { |
|
69 |
$admin->print_header(); |
|
70 |
$admin->print_error($database->get_error()); |
|
71 |
} |
|
72 |
if($results->numRows() == 0) { |
|
73 |
$admin->print_header(); |
|
74 |
$admin->print_error($MESSAGE['PAGES']['NOT_FOUND']); |
|
75 |
} |
|
76 |
$results_array = $results->fetchRow(); |
|
77 |
|
|
78 |
// Get display name of person who last modified the page |
|
79 |
$user=$admin->get_user_details($results_array['modified_by']); |
|
80 |
|
|
81 |
// Convert the unix ts for modified_when to human a readable form |
|
82 |
if($results_array['modified_when'] != 0) |
|
83 |
{ |
|
84 |
$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE); |
|
85 |
} else { |
|
86 |
$modified_ts = 'Unknown'; |
|
87 |
} |
|
88 |
|
|
89 |
// Setup template object, parse vars to it, then parse it |
|
90 |
$template = new Template(THEME_PATH.'/templates'); |
|
91 |
$template->set_file('page', 'pages_settings.htt'); |
|
92 |
$template->set_block('page', 'main_block', 'main'); |
|
93 |
$template->set_var('FTAN', $admin->getFTAN()); |
|
94 |
|
|
95 |
$template->set_var(array( |
|
96 |
'PAGE_ID' => $results_array['page_id'], |
|
97 |
'PAGE_TITLE' => ($results_array['page_title']), |
|
98 |
'MENU_TITLE' => ($results_array['menu_title']), |
|
99 |
'DESCRIPTION' => ($results_array['description']), |
|
100 |
'KEYWORDS' => ($results_array['keywords']), |
|
101 |
'MODIFIED_BY' => $user['display_name'], |
|
102 |
'MODIFIED_BY_USERNAME' => $user['username'], |
|
103 |
'MODIFIED_WHEN' => $modified_ts, |
|
104 |
'ADMIN_URL' => ADMIN_URL, |
|
105 |
'WB_URL' => WB_URL, |
|
106 |
'WB_PATH' => WB_PATH, |
|
107 |
'THEME_URL' => THEME_URL |
|
108 |
) |
|
109 |
); |
|
110 |
|
|
111 |
// Work-out if we should show the "manage sections" link |
|
112 |
$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.$page_id.' AND `module`="menu_link"'; |
|
113 |
$query_sections = $database->query($sql); |
|
114 |
if($query_sections->numRows() > 0) |
|
115 |
{ |
|
116 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;'); |
|
117 |
} elseif(MANAGE_SECTIONS == 'enabled') |
|
118 |
{ |
|
119 |
$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']); |
|
120 |
} else { |
|
121 |
$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;'); |
|
122 |
} |
|
123 |
|
|
124 |
// Visibility |
|
125 |
if($results_array['visibility'] == 'public') { |
|
126 |
$template->set_var('PUBLIC_SELECTED', ' selected="selected"'); |
|
127 |
} elseif($results_array['visibility'] == 'private') { |
|
128 |
$template->set_var('PRIVATE_SELECTED', ' selected="selected"'); |
|
129 |
} elseif($results_array['visibility'] == 'registered') { |
|
130 |
$template->set_var('REGISTERED_SELECTED', ' selected="selected"'); |
|
131 |
} elseif($results_array['visibility'] == 'hidden') { |
|
132 |
$template->set_var('HIDDEN_SELECTED', ' selected="selected"'); |
|
133 |
} elseif($results_array['visibility'] == 'none') { |
|
134 |
$template->set_var('NO_VIS_SELECTED', ' selected="selected"'); |
|
135 |
} |
|
136 |
// Group list 1 (admin_groups) |
|
137 |
$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups'])); |
|
138 |
|
|
139 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups`'; |
|
140 |
$get_groups = $database->query($sql); |
|
141 |
|
|
142 |
$template->set_block('main_block', 'group_list_block', 'group_list'); |
|
143 |
// Insert admin group and current group first |
|
144 |
$admin_group_name = $get_groups->fetchRow(); |
|
145 |
$template->set_var(array( |
|
146 |
'ID' => 1, |
|
147 |
'TOGGLE' => '', |
|
148 |
'DISABLED' => ' disabled="disabled"', |
|
149 |
'LINK_COLOR' => '000000', |
|
150 |
'CURSOR' => 'default', |
|
151 |
'NAME' => $admin_group_name['name'], |
|
152 |
'CHECKED' => ' checked="checked"' |
|
153 |
) |
|
154 |
); |
|
155 |
$template->parse('group_list', 'group_list_block', true); |
|
156 |
while($group = $get_groups->fetchRow()) { |
|
157 |
// check if the user is a member of this group |
|
158 |
$flag_disabled = ''; |
|
159 |
$flag_checked = ''; |
|
160 |
$flag_cursor = 'pointer'; |
|
161 |
$flag_color = ''; |
|
162 |
if (in_array($group["group_id"], $admin->get_groups_id())) { |
|
163 |
$flag_disabled = ''; //' disabled'; |
|
164 |
$flag_checked = ''; //' checked'; |
|
165 |
$flag_cursor = 'default'; |
|
166 |
$flag_color = '000000'; |
|
167 |
} |
|
168 |
|
|
169 |
// Check if the group is allowed to edit pages |
|
170 |
$system_permissions = explode(',', $group['system_permissions']); |
|
171 |
if(is_numeric(array_search('pages_modify', $system_permissions))) { |
|
172 |
$template->set_var(array( |
|
173 |
'ID' => $group['group_id'], |
|
174 |
'TOGGLE' => $group['group_id'], |
|
175 |
'DISABLED' => $flag_disabled, |
|
176 |
'LINK_COLOR' => $flag_color, |
|
177 |
'CURSOR' => $flag_cursor, |
|
178 |
'NAME' => $group['name'], |
|
179 |
'CHECKED' => $flag_checked |
|
180 |
) |
|
181 |
); |
|
182 |
if(is_numeric(array_search($group['group_id'], $admin_groups))) { |
|
183 |
$template->set_var('CHECKED', ' checked="checked"'); |
|
184 |
} else { |
|
185 |
if (!$flag_checked) $template->set_var('CHECKED', ''); |
|
186 |
} |
|
187 |
$template->parse('group_list', 'group_list_block', true); |
|
188 |
} |
|
189 |
} |
|
190 |
// Group list 2 (viewing_groups) |
|
191 |
$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups'])); |
|
192 |
|
|
193 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups`'; |
|
194 |
$get_groups = $database->query($sql); |
|
195 |
|
|
196 |
$template->set_block('main_block', 'group_list_block2', 'group_list2'); |
|
197 |
// Insert admin group and current group first |
|
198 |
$admin_group_name = $get_groups->fetchRow(); |
|
199 |
$template->set_var(array( |
|
200 |
'ID' => 1, |
|
201 |
'TOGGLE' => '', |
|
202 |
'DISABLED' => ' disabled="disabled"', |
|
203 |
'LINK_COLOR' => '000000', |
|
204 |
'CURSOR' => 'default', |
|
205 |
'NAME' => $admin_group_name['name'], |
|
206 |
'CHECKED' => ' checked="checked"' |
|
207 |
) |
|
208 |
); |
|
209 |
$template->parse('group_list2', 'group_list_block2', true); |
|
210 |
|
|
211 |
while($group = $get_groups->fetchRow()) |
|
212 |
{ |
|
213 |
// check if the user is a member of this group |
|
214 |
$flag_disabled = ''; |
|
215 |
$flag_checked = ''; |
|
216 |
$flag_cursor = 'pointer'; |
|
217 |
$flag_color = ''; |
|
218 |
if (in_array($group["group_id"], $admin->get_groups_id())) |
|
219 |
{ |
|
220 |
$flag_disabled = ''; //' disabled'; |
|
221 |
$flag_checked = ''; //' checked'; |
|
222 |
$flag_cursor = 'default'; |
|
223 |
$flag_color = '000000'; |
|
224 |
} |
|
225 |
|
|
226 |
$template->set_var(array( |
|
227 |
'ID' => $group['group_id'], |
|
228 |
'TOGGLE' => $group['group_id'], |
|
229 |
'DISABLED' => $flag_disabled, |
|
230 |
'LINK_COLOR' => $flag_color, |
|
231 |
'CURSOR' => $flag_cursor, |
|
232 |
'NAME' => $group['name'], |
|
233 |
'CHECKED' => $flag_checked |
|
234 |
) |
|
235 |
); |
|
236 |
if(is_numeric(array_search($group['group_id'], $viewing_groups))) |
|
237 |
{ |
|
238 |
$template->set_var('CHECKED', 'checked="checked"'); |
|
239 |
} else { |
|
240 |
if (!$flag_checked) {$template->set_var('CHECKED', '');} |
|
241 |
} |
|
242 |
|
|
243 |
$template->parse('group_list2', 'group_list_block2', true); |
|
244 |
|
|
245 |
} |
|
246 |
|
|
247 |
// Show private viewers |
|
248 |
if($results_array['visibility'] == 'private' OR $results_array['visibility'] == 'registered') |
|
249 |
{ |
|
250 |
$template->set_var('DISPLAY_VIEWERS', ''); |
|
251 |
} else { |
|
252 |
$template->set_var('DISPLAY_VIEWERS', 'display:none;'); |
|
253 |
} |
|
254 |
|
|
255 |
//-- insert page_code 20090904--> |
|
256 |
$template->set_var('DISPLAY_CODE_PAGE_LIST', ' id="multi_lingual" style="display:none;"'); |
|
257 |
|
|
258 |
// Work-out if page languages feature is enabled |
|
259 |
if((defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') ) |
|
260 |
{ |
|
261 |
// workout field is set but module missing |
|
262 |
$TEXT['PAGE_CODE'] = empty($TEXT['PAGE_CODE']) ? 'Pagecode' : $TEXT['PAGE_CODE']; |
|
263 |
$template->set_var( array( |
|
264 |
'DISPLAY_CODE_PAGE_LIST' => ' id="multi_lingual"', |
|
265 |
'TEXT_PAGE_CODE' => '<a href="'.WB_URL.'/modules/mod_multilingual/update_keys.php?page_id='.$page_id.'">'.$TEXT['PAGE_CODE'].'</a>' |
|
266 |
) |
|
267 |
); |
|
268 |
|
|
269 |
// Page_code list |
|
270 |
/* $database = new database(); */ |
|
271 |
function page_code_list($parent) |
|
272 |
{ |
|
273 |
global $admin, $database, $template, $results_array, $pageCode; |
|
274 |
$default_language = DEFAULT_LANGUAGE; |
|
275 |
|
|
276 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' AND `language` = "'.$default_language.'" ORDER BY `position` ASC'; |
|
277 |
$get_pages = $database->query($sql); |
|
278 |
|
|
279 |
while($page = $get_pages->fetchRow()) |
|
280 |
{ |
|
281 |
if(($admin->page_is_visible($page)==false) && ($page['visibility'] <> 'none') ) { continue; } |
|
282 |
|
|
283 |
$template->set_var('FLAG_CODE_ICON',' none '); |
|
284 |
if( $page['parent'] == 0 ) |
|
285 |
{ |
|
286 |
$template->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)'); |
|
287 |
} |
|
288 |
|
|
289 |
// If the current page cannot be parent, then its children neither |
|
290 |
$list_next_level = true; |
|
291 |
// Stop users from adding pages with a level of more than the set page level limit |
|
292 |
if($page['level']+1 < PAGE_LEVEL_LIMIT) |
|
293 |
{ |
|
294 |
// Get user perms |
|
295 |
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups'])); |
|
296 |
$admin_users = explode(',', str_replace('_', '', $page['admin_users'])); |
|
297 |
|
|
298 |
$in_group = FALSE; |
|
299 |
foreach($admin->get_groups_id() as $cur_gid) |
|
300 |
{ |
|
301 |
if (in_array($cur_gid, $admin_groups)) |
|
302 |
{ |
|
303 |
$in_group = TRUE; |
|
304 |
} |
|
305 |
} |
|
306 |
|
|
307 |
if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) |
|
308 |
{ |
|
309 |
$can_modify = true; |
|
310 |
} else { |
|
311 |
$can_modify = false; |
|
312 |
} |
|
313 |
|
|
314 |
$title_prefix = ''; |
|
315 |
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - '; } |
|
316 |
// $space = str_repeat(' ', 3); $space.'<'..'>' |
|
317 |
$template->set_var(array( |
|
318 |
'VALUE' => $page['page_code'], |
|
319 |
'PAGE_VALUE' => $title_prefix.$page['menu_title'], |
|
320 |
'PAGE_CODE' => $title_prefix.$page['page_id'] |
|
321 |
) |
|
322 |
); |
|
323 |
if($results_array['page_code'] == $page['page_code']) |
|
324 |
{ |
|
325 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
326 |
} elseif($results_array['page_code'] == $page['page_code']) |
|
327 |
{ |
|
328 |
$template->set_var('SELECTED', ' disabled="disabled" class="disabled"'); |
|
329 |
$list_next_level=false; |
|
330 |
} elseif($can_modify != true) |
|
331 |
{ |
|
332 |
$template->set_var('SELECTED', ' disabled="disabled" class="disabled"'); |
|
333 |
} else { |
|
334 |
$template->set_var('SELECTED', ''); |
|
335 |
} |
|
336 |
$template->parse('page_code_list', 'page_code_list_block', true); |
|
337 |
} |
|
338 |
if ($list_next_level) |
|
339 |
page_code_list($page['page_id']); |
|
340 |
} |
|
341 |
} |
|
342 |
|
|
343 |
// Insert code_page values from page to modify |
|
344 |
$template->set_block('main_block', 'page_code_list_block', 'page_code_list'); |
|
345 |
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) { |
|
346 |
if($results_array['parent'] == 0) { $selected = ' selected'; } else { $selected = ''; } |
|
347 |
$template->set_var(array( |
|
348 |
'VALUE' => '', |
|
349 |
'PAGE_CODE' => $TEXT['NONE'], |
|
350 |
'PAGE_VALUE' => '', |
|
351 |
'SELECTED' => $selected |
|
352 |
) |
|
353 |
); |
|
354 |
$template->parse('page_code_list', 'page_code_list_block', true); |
|
355 |
} |
|
356 |
// get pagecode form this page_id |
|
357 |
page_code_list(0); |
|
358 |
} |
|
359 |
//-- page code --> |
|
360 |
|
|
361 |
// Parent page list |
|
362 |
/* $database = new database(); */ |
|
363 |
function parent_list($parent) |
|
364 |
{ |
|
365 |
global $admin, $database, $template, $results_array,$field_set; |
|
366 |
|
|
367 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ORDER BY `position` ASC'; |
|
368 |
$get_pages = $database->query($sql); |
|
369 |
|
|
370 |
while($page = $get_pages->fetchRow()) |
|
371 |
{ |
|
372 |
if($admin->page_is_visible($page)==false) |
|
373 |
{ |
|
374 |
continue; |
|
375 |
} |
|
376 |
|
|
377 |
// if parent = 0 set flag_icon |
|
378 |
$template->set_var('FLAG_ROOT_ICON',' none '); |
|
379 |
if( $page['parent'] == 0 && $field_set) |
|
380 |
{ |
|
381 |
$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)'); |
|
382 |
} |
|
383 |
// If the current page cannot be parent, then its children neither |
|
384 |
$list_next_level = true; |
|
385 |
// Stop users from adding pages with a level of more than the set page level limit |
|
386 |
if($page['level']+1 < PAGE_LEVEL_LIMIT) |
|
387 |
{ |
|
388 |
// Get user perms |
|
389 |
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups'])); |
|
390 |
$admin_users = explode(',', str_replace('_', '', $page['admin_users'])); |
|
391 |
$in_group = FALSE; |
|
392 |
foreach($admin->get_groups_id() as $cur_gid) |
|
393 |
{ |
|
394 |
if (in_array($cur_gid, $admin_groups)) |
|
395 |
{ |
|
396 |
$in_group = TRUE; |
|
397 |
} |
|
398 |
} |
|
399 |
if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) |
|
400 |
{ |
|
401 |
$can_modify = true; |
|
402 |
} else { |
|
403 |
$can_modify = false; |
|
404 |
} |
|
405 |
// Title -'s prefix |
|
406 |
$title_prefix = ''; |
|
407 |
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; } |
|
408 |
$template->set_var(array( |
|
409 |
'ID' => $page['page_id'], |
|
410 |
'TITLE' => ($title_prefix.$page['menu_title']), |
|
411 |
'MENU-TITLE' => ($title_prefix.$page['menu_title']), |
|
412 |
'PAGE-TITLE' => ($title_prefix.$page['page_title']), |
|
413 |
'FLAG_ICON' => ' none ', |
|
414 |
)); |
|
415 |
|
|
416 |
if($results_array['parent'] == $page['page_id']) |
|
417 |
{ |
|
418 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
419 |
} elseif($results_array['page_id'] == $page['page_id']) |
|
420 |
{ |
|
421 |
$template->set_var('SELECTED', ' disabled="disabled" class="disabled"'); |
|
422 |
$list_next_level=false; |
|
423 |
} elseif($can_modify != true) |
|
424 |
{ |
|
425 |
$template->set_var('SELECTED', ' disabled="disabled" class="disabled"'); |
|
426 |
} else { |
|
427 |
$template->set_var('SELECTED', ''); |
|
428 |
} |
|
429 |
$template->parse('page_list2', 'page_list_block2', true); |
|
430 |
} |
|
431 |
if ($list_next_level) |
|
432 |
{ |
|
433 |
parent_list($page['page_id']); |
|
434 |
} |
|
435 |
|
|
436 |
} |
|
437 |
} |
|
438 |
|
|
439 |
$template->set_block('main_block', 'page_list_block2', 'page_list2'); |
|
440 |
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) { |
|
441 |
if($results_array['parent'] == 0) |
|
442 |
{ |
|
443 |
$selected = ' selected="selected"'; |
|
444 |
} else { |
|
445 |
$selected = ''; |
|
446 |
} |
|
447 |
$template->set_var(array( |
|
448 |
'ID' => '0', |
|
449 |
'TITLE' => $TEXT['NONE'], |
|
450 |
'SELECTED' => $selected |
|
451 |
) ); |
|
452 |
$template->parse('page_list2', 'page_list_block2', true); |
|
453 |
} |
|
454 |
parent_list(0); |
|
455 |
|
|
456 |
if($modified_ts == 'Unknown') |
|
457 |
{ |
|
458 |
$template->set_var('DISPLAY_MODIFIED', 'hide'); |
|
459 |
} else { |
|
460 |
$template->set_var('DISPLAY_MODIFIED', ''); |
|
461 |
} |
|
462 |
|
|
463 |
// Templates list |
|
464 |
$template->set_block('main_block', 'template_list_block', 'template_list'); |
|
465 |
|
|
466 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "template" AND `function` = "template" order by `name`'; |
|
467 |
$result = $database->query($sql); |
|
468 |
|
|
469 |
if($result->numRows() > 0) |
|
470 |
{ |
|
471 |
while($addon = $result->fetchRow()) |
|
472 |
{ |
|
473 |
// Check if the user has perms to use this template |
|
474 |
if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true) |
|
475 |
{ |
|
476 |
$template->set_var('VALUE', $addon['directory']); |
|
477 |
$template->set_var('NAME', $addon['name']); |
|
478 |
if($addon['directory'] == $results_array['template']) |
|
479 |
{ |
|
480 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
481 |
} else { |
|
482 |
$template->set_var('SELECTED', ''); |
|
483 |
} |
|
484 |
$template->parse('template_list', 'template_list_block', true); |
|
485 |
} |
|
486 |
} |
|
487 |
} |
|
488 |
|
|
489 |
// Menu list |
|
490 |
if(MULTIPLE_MENUS == false) |
|
491 |
{ |
|
492 |
$template->set_var('DISPLAY_MENU_LIST', 'display:none;'); |
|
493 |
} |
|
494 |
// Include template info file (if it exists) |
|
495 |
if($results_array['template'] != '') |
|
496 |
{ |
|
497 |
$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php'; |
|
498 |
} else { |
|
499 |
$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php'; |
|
500 |
} |
|
501 |
if(file_exists($template_location)) |
|
502 |
{ |
|
503 |
require($template_location); |
|
504 |
} |
|
505 |
// Check if $menu is set |
|
506 |
if(!isset($menu[1]) OR $menu[1] == '') |
|
507 |
{ |
|
508 |
// Make our own menu list |
|
509 |
$menu[1] = $TEXT['MAIN']; |
|
510 |
} |
|
511 |
// Add menu options to the list |
|
512 |
$template->set_block('main_block', 'menu_list_block', 'menu_list'); |
|
513 |
foreach($menu AS $number => $name) |
|
514 |
{ |
|
515 |
$template->set_var('NAME', $name); |
|
516 |
$template->set_var('VALUE', $number); |
|
517 |
if($results_array['menu'] == $number) |
|
518 |
{ |
|
519 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
520 |
} else { |
|
521 |
$template->set_var('SELECTED', ''); |
|
522 |
} |
|
523 |
$template->parse('menu_list', 'menu_list_block', true); |
|
524 |
} |
|
525 |
|
|
526 |
// Insert language values |
|
527 |
$template->set_block('main_block', 'language_list_block', 'language_list'); |
|
528 |
|
|
529 |
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "language" ORDER BY `name`'; |
|
530 |
$result = $database->query($sql); |
|
531 |
|
|
532 |
if($result->numRows() > 0) |
|
533 |
{ |
|
534 |
while($addon = $result->fetchRow()) |
|
535 |
{ |
|
536 |
$l_codes[$addon['name']] = $addon['directory']; |
|
537 |
$l_names[$addon['name']] = entities_to_7bit($addon['name']); // sorting-problem workaround |
|
538 |
} |
|
539 |
asort($l_names); |
|
540 |
foreach($l_names as $l_name=>$v) |
|
541 |
{ |
|
542 |
// Insert code and name |
|
543 |
$template->set_var(array( |
|
544 |
'VALUE' => $l_codes[$l_name], |
|
545 |
'NAME' => $l_name, |
|
546 |
'FLAG_LANG_ICONS' => 'url('.THEME_URL.'/images/flags/'.strtolower($l_codes[$l_name]).'.png)', |
|
547 |
)); |
|
548 |
// Check if it is selected |
|
549 |
if($results_array['language'] == $l_codes[$l_name]) |
|
550 |
{ |
|
551 |
$template->set_var('SELECTED', ' selected="selected"'); |
|
552 |
} else { |
|
553 |
$template->set_var('SELECTED', ''); |
|
554 |
} |
|
555 |
$template->parse('language_list', 'language_list_block', true); |
|
556 |
} |
|
557 |
} |
|
558 |
|
|
559 |
// Select disabled if searching is disabled |
|
560 |
if($results_array['searching'] == 0) |
|
561 |
{ |
|
562 |
$template->set_var('SEARCHING_DISABLED', ' selected="selected"'); |
|
563 |
} |
|
564 |
// Select what the page target is |
|
565 |
switch ($results_array['target']) |
|
566 |
{ |
|
567 |
case '_top': |
|
568 |
$template->set_var('TOP_SELECTED', ' selected="selected"'); |
|
569 |
break; |
|
570 |
case '_self': |
|
571 |
$template->set_var('SELF_SELECTED', ' selected="selected"'); |
|
572 |
break; |
|
573 |
case '_blank': |
|
574 |
$template->set_var('BLANK_SELECTED', ' selected="selected"'); |
|
575 |
break; |
|
576 |
} |
|
577 |
|
|
578 |
// Insert language text |
|
579 |
$template->set_var(array( |
|
580 |
'HEADING_MODIFY_PAGE_SETTINGS' => $HEADING['MODIFY_PAGE_SETTINGS'], |
|
581 |
'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'], |
|
582 |
'TEXT_MODIFY' => $TEXT['MODIFY'], |
|
583 |
'TEXT_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'], |
|
584 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
|
585 |
'TEXT_PAGE_TITLE' => $TEXT['PAGE_TITLE'], |
|
586 |
'TEXT_MENU_TITLE' => $TEXT['MENU_TITLE'], |
|
587 |
'TEXT_TYPE' => $TEXT['TYPE'], |
|
588 |
'TEXT_MENU' => $TEXT['MENU'], |
|
589 |
'TEXT_PARENT' => $TEXT['PARENT'], |
|
590 |
'TEXT_VISIBILITY' => $TEXT['VISIBILITY'], |
|
591 |
'TEXT_PUBLIC' => $TEXT['PUBLIC'], |
|
592 |
'TEXT_PRIVATE' => $TEXT['PRIVATE'], |
|
593 |
'TEXT_REGISTERED' => $TEXT['REGISTERED'], |
|
594 |
'TEXT_NONE' => $TEXT['NONE'], |
|
595 |
'TEXT_HIDDEN' => $TEXT['HIDDEN'], |
|
596 |
'TEXT_TEMPLATE' => $TEXT['TEMPLATE'], |
|
597 |
'TEXT_TARGET' => $TEXT['TARGET'], |
|
598 |
'TEXT_SYSTEM_DEFAULT' => $TEXT['SYSTEM_DEFAULT'], |
|
599 |
'TEXT_PLEASE_SELECT' => $TEXT['PLEASE_SELECT'], |
|
600 |
'TEXT_NEW_WINDOW' => $TEXT['NEW_WINDOW'], |
|
601 |
'TEXT_SAME_WINDOW' => $TEXT['SAME_WINDOW'], |
|
602 |
'TEXT_TOP_FRAME' => $TEXT['TOP_FRAME'], |
|
603 |
'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'], |
|
604 |
'TEXT_ALLOWED_VIEWERS' => $TEXT['ALLOWED_VIEWERS'], |
|
605 |
'TEXT_DESCRIPTION' => $TEXT['DESCRIPTION'], |
|
606 |
'TEXT_KEYWORDS' => $TEXT['KEYWORDS'], |
|
607 |
'TEXT_SEARCHING' => $TEXT['SEARCHING'], |
|
608 |
'TEXT_LANGUAGE' => $TEXT['LANGUAGE'], |
|
609 |
'TEXT_ENABLED' => $TEXT['ENABLED'], |
|
610 |
'TEXT_DISABLED' => $TEXT['DISABLED'], |
|
611 |
'TEXT_SAVE' => $TEXT['SAVE'], |
|
612 |
'TEXT_RESET' => $TEXT['RESET'], |
|
613 |
'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'], |
|
614 |
'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'] |
|
615 |
) ); |
|
616 |
|
|
617 |
$template->parse('main', 'main_block', false); |
|
618 |
$template->pparse('output', 'page'); |
|
619 |
|
|
620 |
// Print admin footer |
|
621 |
$admin->print_footer(); |
|
622 |
|
|
630 | 623 |
?> |
Also available in: Unified diff
validation fixes in pages backend theme