Project

General

Profile

« Previous | Next » 

Revision 1277

Added by Dietmar over 14 years ago

update headertext

View differences:

settings.php
1 1
<?php
2
/*
3
*
4
*                       About WebsiteBaker
5
*
6
* Website Baker is a PHP-based Content Management System (CMS)
7
* designed with one goal in mind: to enable its users to produce websites
8
* with ease.
9
*
10
*                       LICENSE INFORMATION
11
*
12
* WebsiteBaker is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU General Public License
14
* as published by the Free Software Foundation; either version 2
15
* of the License, or (at your option) any later version.
16
*
17
* WebsiteBaker is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
* See the GNU General Public License for more details.
21
*
22
* You should have received a copy of the GNU General Public License
23
* along with this program; if not, write to the Free Software
24
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
*
26
*                   WebsiteBaker Extra Information
27
*
28
*
29
*/
30 2
/**
31 3
 *
32 4
 * @category        admin
......
42 14
 * @filesource		$HeadURL$
43 15
 * @lastmodified    $Date$
44 16
 *
45
*/
17
 */
46 18

  
47 19
// Get page id
48
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id'])) {
20
if(!isset($_GET['page_id']) OR !is_numeric($_GET['page_id']))
21
{
49 22
	header("Location: index.php");
50 23
	exit(0);
51 24
} else {
......
61 34
require_once(WB_PATH.'/framework/functions-utf8.php');
62 35

  
63 36
// Get perms
64
$database = new database();
65
$results = $database->query("SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'");
37
/*$database = new database(); */
38

  
39
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id` = '.$page_id;
40
$results = $database->query($sql);
66 41
$results_array = $results->fetchRow();
42

  
67 43
$old_admin_groups = explode(',', $results_array['admin_groups']);
68 44
$old_admin_users = explode(',', $results_array['admin_users']);
69 45

  
70 46
// Work-out if we should check for existing page_code
71
$field_sql = $database->query("DESCRIBE ".TABLE_PREFIX."pages page_code");
47
$sql = 'DESCRIBE `'.TABLE_PREFIX.'pages` `page_code`';
48
$field_sql = $database->query($sql);
72 49
$field_set = $field_sql->numRows();
50

  
73 51
$in_old_group = FALSE;
74
foreach($admin->get_groups_id() as $cur_gid){
75
	if (in_array($cur_gid, $old_admin_groups)) {
52
foreach($admin->get_groups_id() as $cur_gid)
53
{
54
	if (in_array($cur_gid, $old_admin_groups))
55
    {
76 56
		$in_old_group = TRUE;
77 57
	}
78 58
}
79
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users))) {
59
if((!$in_old_group) AND !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
60
{
80 61
	$admin->print_error($MESSAGE['PAGES']['INSUFFICIENT_PERMISSIONS']);
81 62
}
82 63

  
83 64
// Get page details
84 65
/* $database = new database();  */
85
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE page_id = '$page_id'";
86
$results = $database->query($query);
66
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.$page_id;
67
$results = $database->query($sql);
87 68
if($database->is_error()) {
88 69
	$admin->print_header();
89 70
	$admin->print_error($database->get_error());
......
98 79
$user=$admin->get_user_details($results_array['modified_by']);
99 80

  
100 81
// Convert the unix ts for modified_when to human a readable form
101
if($results_array['modified_when'] != 0) {
82
if($results_array['modified_when'] != 0)
83
{
102 84
	$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
103 85
} else {
104 86
	$modified_ts = 'Unknown';
......
126 108
		);
127 109

  
128 110
// Work-out if we should show the "manage sections" link
129
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '$page_id' AND module = 'menu_link'");
130
if($query_sections->numRows() > 0) {
131
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
132
} elseif(MANAGE_SECTIONS == 'enabled') {
111
$sql = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.$page_id.' AND `module`="menu_link"';
112
$query_sections = $database->query($sql);
113
if($query_sections->numRows() > 0)
114
{
115
    $template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
116
} elseif(MANAGE_SECTIONS == 'enabled')
117
{
133 118
	$template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
134 119
} else {
135 120
	$template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
......
150 135
// Group list 1 (admin_groups)
151 136
	$admin_groups = explode(',', str_replace('_', '', $results_array['admin_groups']));
152 137

  
153
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
154
	
155
	$get_groups = $database->query($query);
138
	$sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups`';
139
    $get_groups = $database->query($sql);
140

  
156 141
	$template->set_block('main_block', 'group_list_block', 'group_list');
157 142
	// Insert admin group and current group first
158 143
	$admin_group_name = $get_groups->fetchRow();
......
204 189
// Group list 2 (viewing_groups)
205 190
	$viewing_groups = explode(',', str_replace('_', '', $results_array['viewing_groups']));
206 191

  
207
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
192
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'groups`';
193
    $get_groups = $database->query($sql);
208 194

  
209
	$get_groups = $database->query($query);
210 195
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
211 196
	// Insert admin group and current group first
212 197
	$admin_group_name = $get_groups->fetchRow();
......
222 207
							);
223 208
	$template->parse('group_list2', 'group_list_block2', true);
224 209

  
225
	while($group = $get_groups->fetchRow()) {
210
	while($group = $get_groups->fetchRow())
211
    {
226 212
		// check if the user is a member of this group
227 213
		$flag_disabled = '';
228 214
		$flag_checked =  '';
229 215
		$flag_cursor =   'pointer';
230 216
		$flag_color =    '';
231
		if (in_array($group["group_id"], $admin->get_groups_id())) {
217
		if (in_array($group["group_id"], $admin->get_groups_id()))
218
        {
232 219
			$flag_disabled = ''; //' disabled';
233 220
			$flag_checked =  ''; //' checked';
234 221
			$flag_cursor =   'default';
......
245 232
										'CHECKED' => $flag_checked
246 233
										)
247 234
								);
248
		if(is_numeric(array_search($group['group_id'], $viewing_groups))) {
235
		if(is_numeric(array_search($group['group_id'], $viewing_groups)))
236
        {
249 237
			$template->set_var('CHECKED', 'checked="checked"');
250 238
		} else {
251
			if (!$flag_checked) $template->set_var('CHECKED', '');
239
			if (!$flag_checked) {$template->set_var('CHECKED', '');}
252 240
		}
241

  
253 242
		$template->parse('group_list2', 'group_list_block2', true);
243

  
254 244
	}
245

  
255 246
// Show private viewers
256
if($results_array['visibility'] == 'private' OR $results_array['visibility'] == 'registered') {
247
if($results_array['visibility'] == 'private' OR $results_array['visibility'] == 'registered')
248
{
257 249
	$template->set_var('DISPLAY_VIEWERS', '');
258 250
} else {
259 251
	$template->set_var('DISPLAY_VIEWERS', 'display:none;');
......
261 253

  
262 254
//-- insert page_code 20090904-->
263 255
$template->set_var('DISPLAY_CODE_PAGE_LIST', ' id="multi_lingual" style="display:none;"');
256

  
264 257
// Work-out if page languages feature is enabled
265 258
if((defined('PAGE_LANGUAGES') && PAGE_LANGUAGES) && $field_set && file_exists(WB_PATH.'/modules/mod_multilingual/update_keys.php') )
266 259
{
......
274 267

  
275 268
	// Page_code list
276 269
   /* 	$database = new database();  */
277
	function page_code_list($parent) {
270
	function page_code_list($parent)
271
    {
278 272
		global $admin, $database, $template, $results_array, $pageCode;
279 273
		$default_language = DEFAULT_LANGUAGE;
280
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND language = '$default_language' ORDER BY position ASC";
281
		$get_pages = $database->query($query);
282
		while($page = $get_pages->fetchRow()) {
274

  
275
        $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' AND `language` = "'.$default_language.'" ORDER BY `position` ASC';
276
        $get_pages = $database->query($sql);
277

  
278
		while($page = $get_pages->fetchRow())
279
        {
283 280
			if($admin->page_is_visible($page)==false)
284 281
				continue;
285 282
			$template->set_var('FLAG_CODE_ICON',' none ');
286
			if( $page['parent'] == 0 ) {
283
			if( $page['parent'] == 0 )
284
            {
287 285
				$template->set_var('FLAG_CODE_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
288 286
			}
289 287
			// If the current page cannot be parent, then its children neither
290 288
			$list_next_level = true;
291 289
			// Stop users from adding pages with a level of more than the set page level limit
292
			if($page['level']+1 < PAGE_LEVEL_LIMIT) {
290
			if($page['level']+1 < PAGE_LEVEL_LIMIT)
291
            {
293 292
				// Get user perms
294 293
				$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
295 294
				$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
296 295

  
297 296
				$in_group = FALSE;
298
				foreach($admin->get_groups_id() as $cur_gid){
297
				foreach($admin->get_groups_id() as $cur_gid)
298
                {
299 299
					if (in_array($cur_gid, $admin_groups))
300 300
					{
301 301
						$in_group = TRUE;
302 302
					}
303 303
				}
304 304

  
305
				if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
305
				if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users)))
306
                {
306 307
					$can_modify = true;
307 308
				} else {
308 309
					$can_modify = false;
......
333 334
				page_code_list($page['page_id']);
334 335
		}
335 336
	}
337

  
336 338
	// Insert code_page values from page to modify
337 339
	$template->set_block('main_block', 'page_code_list_block', 'page_code_list');
338 340
	if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
......
347 349
		$template->parse('page_code_list', 'page_code_list_block', true);
348 350
	}
349 351
	// get pagecode form this page_id
350
	page_code_list(0);
352
   	page_code_list(0);
351 353
}
352 354
//-- page code -->
353 355

  
354 356
// Parent page list
355 357
/* $database = new database();  */
356
function parent_list($parent) {
358
function parent_list($parent)
359
{
357 360
	global $admin, $database, $template, $results_array,$field_set;
358
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
359
	$get_pages = $database->query($query);
360
	while($page = $get_pages->fetchRow()) {
361

  
362
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ORDER BY `position` ASC';
363
    $get_pages = $database->query($sql);
364

  
365
	while($page = $get_pages->fetchRow())
366
    {
361 367
		if($admin->page_is_visible($page)==false)
362
			continue;
368
        {
369
          continue;
370
        }
371

  
363 372
		// if parent = 0 set flag_icon
364 373
		$template->set_var('FLAG_ROOT_ICON',' none ');
365
		if( $page['parent'] == 0  && $field_set) {
374
		if( $page['parent'] == 0  && $field_set)
375
        {
366 376
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
367 377
		}
368 378
		// If the current page cannot be parent, then its children neither
369 379
		$list_next_level = true;
370 380
		// Stop users from adding pages with a level of more than the set page level limit
371
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
381
		if($page['level']+1 < PAGE_LEVEL_LIMIT)
382
        {
372 383
			// Get user perms
373 384
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
374 385
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
375 386
			$in_group = FALSE;
376
			foreach($admin->get_groups_id() as $cur_gid){
377
				if (in_array($cur_gid, $admin_groups)) {
387
			foreach($admin->get_groups_id() as $cur_gid)
388
            {
389
				if (in_array($cur_gid, $admin_groups))
390
                {
378 391
					$in_group = TRUE;
379 392
				}
380 393
			}
381
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
394
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users)))
395
            {
382 396
				$can_modify = true;
383 397
			} else {
384 398
				$can_modify = false;
......
394 408
											'FLAG_ICON' => ' none ',
395 409
											));
396 410

  
397
			if($results_array['parent'] == $page['page_id']) {
411
			if($results_array['parent'] == $page['page_id'])
412
            {
398 413
				$template->set_var('SELECTED', ' selected="selected"');
399
			} elseif($results_array['page_id'] == $page['page_id']) {
414
			} elseif($results_array['page_id'] == $page['page_id'])
415
            {
400 416
				$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
401 417
				$list_next_level=false;
402
			} elseif($can_modify != true) {
418
			} elseif($can_modify != true)
419
            {
403 420
				$template->set_var('SELECTED', ' disabled="disabled" class="disabled"');
404 421
			} else {
405 422
				$template->set_var('SELECTED', '');
......
407 424
			$template->parse('page_list2', 'page_list_block2', true);
408 425
		}
409 426
		if ($list_next_level)
410
			parent_list($page['page_id']);
427
        {
428
          parent_list($page['page_id']);
429
        }
430

  
411 431
	}
412 432
}
413 433

  
414 434
$template->set_block('main_block', 'page_list_block2', 'page_list2');
415 435
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
416
	if($results_array['parent'] == 0) {
436
	if($results_array['parent'] == 0)
437
    {
417 438
		$selected = ' selected="selected"';
418 439
	} else { 
419 440
		$selected = '';
......
428 449
}
429 450
parent_list(0);
430 451

  
431
if($modified_ts == 'Unknown') {
452
if($modified_ts == 'Unknown')
453
{
432 454
	$template->set_var('DISPLAY_MODIFIED', 'hide');
433 455
} else {
434 456
	$template->set_var('DISPLAY_MODIFIED', '');
435 457
}
458

  
436 459
// Templates list
437 460
$template->set_block('main_block', 'template_list_block', 'template_list');
438
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'template' and function = 'template' order by name");
439
if($result->numRows() > 0) {
440
	while($addon = $result->fetchRow()) { 
461

  
462
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "template" AND `function` = "template" order by `name`';
463
$result = $database->query($sql);
464

  
465
if($result->numRows() > 0)
466
{
467
	while($addon = $result->fetchRow())
468
    {
441 469
		// Check if the user has perms to use this template
442
		if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true) {
470
		if($addon['directory'] == $results_array['template'] OR $admin->get_permission($addon['directory'], 'template') == true)
471
        {
443 472
			$template->set_var('VALUE', $addon['directory']);
444 473
			$template->set_var('NAME', $addon['name']);
445
			if($addon['directory'] == $results_array['template']) {
474
			if($addon['directory'] == $results_array['template'])
475
            {
446 476
				$template->set_var('SELECTED', ' selected="selected"');
447 477
			} else {
448 478
				$template->set_var('SELECTED', '');
......
453 483
}
454 484

  
455 485
// Menu list
456
if(MULTIPLE_MENUS == false) {
486
if(MULTIPLE_MENUS == false)
487
{
457 488
	$template->set_var('DISPLAY_MENU_LIST', 'display:none;');
458 489
}
459 490
// Include template info file (if it exists)
460
if($results_array['template'] != '') {
491
if($results_array['template'] != '')
492
{
461 493
	$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
462 494
} else {
463 495
	$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
464 496
}
465
if(file_exists($template_location)) {
497
if(file_exists($template_location))
498
{
466 499
	require($template_location);
467 500
}
468 501
// Check if $menu is set
469
if(!isset($menu[1]) OR $menu[1] == '') {
502
if(!isset($menu[1]) OR $menu[1] == '')
503
{
470 504
	// Make our own menu list
471 505
	$menu[1] = $TEXT['MAIN'];
472 506
}
473 507
// Add menu options to the list
474 508
$template->set_block('main_block', 'menu_list_block', 'menu_list');
475
foreach($menu AS $number => $name) {
509
foreach($menu AS $number => $name)
510
{
476 511
	$template->set_var('NAME', $name);
477 512
	$template->set_var('VALUE', $number);
478
	if($results_array['menu'] == $number) {
513
	if($results_array['menu'] == $number)
514
    {
479 515
		$template->set_var('SELECTED', ' selected="selected"');
480 516
	} else {
481 517
		$template->set_var('SELECTED', '');
......
485 521

  
486 522
// Insert language values
487 523
$template->set_block('main_block', 'language_list_block', 'language_list');
488
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' order by name");
489
if($result->numRows() > 0) {
490
	while($addon = $result->fetchRow()) {
524

  
525
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'addons` WHERE `type` = "language" ORDER BY `name`';
526
$result = $database->query($sql);
527

  
528
if($result->numRows() > 0)
529
{
530
	while($addon = $result->fetchRow())
531
    {
491 532
		$l_codes[$addon['name']] = $addon['directory'];
492 533
		$l_names[$addon['name']] = entities_to_7bit($addon['name']); // sorting-problem workaround
493 534
	}
494 535
	asort($l_names);
495
	foreach($l_names as $l_name=>$v) {
536
	foreach($l_names as $l_name=>$v)
537
    {
496 538
		// Insert code and name
497 539
		$template->set_var(array(
498 540
								'VALUE' => $l_codes[$l_name],
......
500 542
								'FLAG_LANG_ICONS' => 'url('.THEME_URL.'/images/flags/'.strtolower($l_codes[$l_name]).'.png)',
501 543
								));
502 544
		// Check if it is selected
503
		if($results_array['language'] == $l_codes[$l_name]) {
545
		if($results_array['language'] == $l_codes[$l_name])
546
        {
504 547
			$template->set_var('SELECTED', ' selected="selected"');
505 548
		} else {
506 549
			$template->set_var('SELECTED', '');
......
510 553
}
511 554

  
512 555
// Select disabled if searching is disabled
513
if($results_array['searching'] == 0) {
556
if($results_array['searching'] == 0)
557
{
514 558
	$template->set_var('SEARCHING_DISABLED', ' selected="selected"');
515 559
}
516 560
// Select what the page target is
517
switch ($results_array['target']) {
561
switch ($results_array['target'])
562
{
518 563
	case '_top':
519 564
		$template->set_var('TOP_SELECTED', ' selected="selected"');
520 565
		break;
......
525 570
		$template->set_var('BLANK_SELECTED', ' selected="selected"');
526 571
		break;
527 572
}
528
	
529 573

  
530 574
// Insert language text
531 575
$template->set_var(array(

Also available in: Unified diff