Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version         $Id: sections.php 1893 2013-03-19 17:31:38Z Luisehahne $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/sections.php $
14
 * @lastmodified    $Date: 2013-03-19 18:31:38 +0100 (Tue, 19 Mar 2013) $
15
 *
16
 */
17

    
18
// Include config file
19
if(!defined('WB_URL'))
20
{
21
    $config_file = realpath('../../config.php');
22
    if(file_exists($config_file) && !defined('WB_URL'))
23
    {
24
    	require($config_file);
25
    }
26
}
27

    
28
// Make sure people are allowed to access this page
29
if(MANAGE_SECTIONS != 'enabled')
30
{
31
	header('Location: '.ADMIN_URL.'/pages/index.php');
32
	exit(0);
33
}
34
/* */
35
$debug = true; // to show position
36
If(!defined('DEBUG')) { define('DEBUG',$debug);}
37
// Create new admin object
38
if(!class_exists('admin', false)){ include(WB_PATH.'/framework/class.admin.php'); }
39
$admin = new admin('Pages', 'pages_view', false);
40

    
41
// Include the WB functions file
42
if(!function_exists('directory_list')) { require(WB_PATH.'/framework/functions.php'); }
43

    
44
$action = 'show';
45
// Get page id
46
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
47
$page_id = intval((isset(${$requestMethod}['page_id'])) ? ${$requestMethod}['page_id'] : 0);
48
$action = ($page_id ? 'show' : $action);
49
// Get section id if there is one
50
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
51
$section_id = ((isset(${$requestMethod}['section_id'])) ? ${$requestMethod}['section_id']  : 0);
52
$action = ($section_id ? 'delete' : $action);
53
// Get module if there is one
54
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
55
$module = ((isset(${$requestMethod}['module'])) ? ${$requestMethod}['module']  : 0);
56
$action = ($module != '' ? 'add' : $action);
57
$admin_header = true;
58
$backlink = ADMIN_URL.'/pages/sections.php?page_id='.(int)$page_id;
59

    
60
switch ($action):
61
	case 'delete' :
62
        if($admin->get_permission('pages_delete') == false)
63
        {
64
			$admin->print_header();
65
			$admin->print_error($module.' '.strtolower($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']),$backlink);
66
        }
67

    
68
		if( ( !($section_id = intval($admin->checkIDKEY('section_id', 0, $_SERVER['REQUEST_METHOD'])) )) )
69
		{
70
			if($admin_header) { $admin->print_header(); }
71
			$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink);
72
		}
73

    
74
		$action = 'show';
75
	    $sql  = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
76
	    $sql .= 'WHERE `section_id` ='.$section_id;
77
        if( ( ($modulname = $database->get_one($sql)) == $module) && ($section_id > 0 ) ) {
78
			// Include the modules delete file if it exists
79
			if(file_exists(WB_PATH.'/modules/'.$modulname.'/delete.php'))
80
		    {
81
				require(WB_PATH.'/modules/'.$modulname.'/delete.php');
82
			}
83
		    $sql  = 'DELETE FROM `'.TABLE_PREFIX.'sections` ';
84
		    $sql .= 'WHERE `section_id` ='.(int)$section_id.' LIMIT 1';
85
			if( !$database->query($sql) ) {
86
				if($admin_header) { $admin->print_header(); }
87
				$admin->print_error($database->get_error(),$backlink);
88
			}  else {
89
				require_once(WB_PATH.'/framework/class.order.php');
90
				$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
91
				$order->clean($page_id);
92
				$format = $TEXT['SECTION'].' %d  %s %s '.strtolower( $TEXT['DELETED']);
93
				$message = sprintf ($format,$section_id,strtoupper($modulname),strtolower($TEXT['SUCCESS']));
94
				if($admin_header) { $admin->print_header(); }
95
				$admin_header = false;
96
				unset($_POST);
97
				$admin->print_success($message, $backlink );
98
			}
99
        } else {
100
			if($admin_header) { $admin->print_header(); }
101
			$admin->print_error($module.' '.strtolower($TEXT['NOT_FOUND']),$backlink);
102
        }
103

    
104
		break;
105
	case 'add' :
106
        if($admin->get_permission('pages_add') == false)
107
        {
108
			$admin->print_header();
109
			$admin->print_error($module.' '.strtolower($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']),$backlink);
110
        }
111
		if (!$admin->checkFTAN())
112
		{
113
			$admin->print_header();
114
			$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink);
115
		}
116
		$action = 'show';
117
		$module = preg_replace('/\W/', '', $module );  // fix secunia 2010-91-4
118
		require_once(WB_PATH.'/framework/class.order.php');
119
		// Get new order
120
		$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
121
		$position = $order->get_new($page_id);
122
		// Insert module into DB
123
	    $sql  = 'INSERT INTO `'.TABLE_PREFIX.'sections` SET ';
124
	    $sql .= '`page_id` = '.(int)$page_id.', ';
125
	    $sql .= '`module` = \''.$module.'\', ';
126
	    $sql .= '`position` = '.(int)$position.', ';
127
	    $sql .= '`block` = \'1\', ';
128
        $sql .= '`publ_start` = \'0\',';
129
        $sql .= '`publ_end` = \'0\' ';
130

    
131
        if($database->query($sql)) {
132
			// Get the section id
133
			$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
134
			// Include the selected modules add file if it exists
135
			if(file_exists(WB_PATH.'/modules/'.$module.'/add.php'))
136
		    {
137
				require(WB_PATH.'/modules/'.$module.'/add.php');
138
			}
139
        } elseif ($database->is_error())  {
140
			if($admin_header) { $admin->print_header(); }
141
			$admin->print_error($database->get_error());
142
		}
143
		break;
144
	default:
145
		break;
146
endswitch;
147

    
148
switch ($action):
149
	default:
150

    
151
		if($admin_header) { $admin->print_header(); }
152
		// Get perms
153
		$sql  = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
154
		$sql .= 'WHERE `page_id` = '.$page_id;
155
		$results = $database->query($sql);
156

    
157
		$results_array = $results->fetchRow();
158
		$old_admin_groups = explode(',', $results_array['admin_groups']);
159
		$old_admin_users = explode(',', $results_array['admin_users']);
160
		$in_old_group = FALSE;
161
		foreach($admin->get_groups_id() as $cur_gid)
162
		{
163
			if (in_array($cur_gid, $old_admin_groups))
164
		    {
165
				$in_old_group = TRUE;
166
			}
167
		}
168
		if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
169
		{
170
			$admin->print_header();
171
			$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
172
		}
173

    
174
		// Get page details
175
		$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
176
		$sql .= 'WHERE `page_id` = '.$page_id;
177
		$results = $database->query($sql);
178

    
179
		if($database->is_error())
180
		{
181
			// $admin->print_header();
182
			$admin->print_error($database->get_error());
183
		}
184
		if($results->numRows() == 0)
185
		{
186
			// $admin->print_header();
187
			$admin->print_error($MESSAGE['PAGES_NOT_FOUND']);
188
		}
189
		$results_array = $results->fetchRow();
190

    
191
		// Get display name of person who last modified the page
192
			$user=$admin->get_user_details($results_array['modified_by']);
193
		// Convert the unix ts for modified_when to human a readable form
194
			if($results_array['modified_when'] != 0) {
195
				$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
196
			} else {
197
				$modified_ts = 'Unknown';
198
			}
199

    
200
		// Set module permissions
201
		$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
202

    
203
		// Unset block var
204
		unset($block);
205
		// Include template info file (if it exists)
206
		if($results_array['template'] != '')
207
		{
208
			$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
209
		} else {
210
			$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
211
		}
212
		if(file_exists($template_location))
213
		{
214
			require($template_location);
215
		}
216
 // check block settings from template/info.php
217
	if(isset($block) && is_array($block) && sizeof($block) > 0) {
218
		if(isset($block[0])) {
219
		throw new AppException('Invalid index 0 for $block[] in '.str_replace(WB_PATH,'',$template_location).'. '
220
		                     . 'The list must start with $block[1]. Please correct it!');
221
		}
222
		foreach($block as $iIndex=>$sBlockTitle) {
223
			if(trim($sBlockTitle) == '' ) {
224
			 $block[$iIndex] = $TEXT['BLOCK'].'_'.$iIndex;
225
			}
226
		}
227
	}else {
228
		// Make our own menu list
229
		$block = array(1, $TEXT['MAIN']);
230
	}
231
		/*-- load css files with jquery --*/
232
		// include jscalendar-setup
233
		$jscal_use_time = true; // whether to use a clock, too
234
		require_once(WB_PATH."/include/jscalendar/wb-setup.php");
235

    
236
		// Setup template object, parse vars to it, then parse it
237
		// Create new template object
238
		$tpl = new Template(dirname($admin->correct_theme_source('pages_sections.htt')));
239
		// $template->debug = true;
240
		$tpl->set_file('page', 'pages_sections.htt');
241
		$tpl->set_block('page', 'main_block', 'main');
242
		$tpl->set_block('main_block', 'module_block', 'module_list');
243
		$tpl->set_block('main_block', 'section_block', 'section_list');
244
		$tpl->set_block('section_block', 'block_block', 'block_list');
245
		$tpl->set_block('main_block', 'calendar_block', 'calendar_list');
246
		$tpl->set_var('FTAN', $admin->getFTAN());
247

    
248
		// set first defaults and messages
249
		$tpl->set_var(array(
250
						'PAGE_ID' => $results_array['page_id'],
251
						// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
252
						'PAGE_IDKEY' => $results_array['page_id'],
253
						'TEXT_PAGE' => $TEXT['PAGE'],
254
						'PAGE_TITLE' => ($results_array['page_title']),
255
						'MENU_TITLE' => ($results_array['menu_title']),
256
						'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
257
						'TEXT_LAST_MODIFIED' => $TEXT['LAST_UPDATED_BY'],
258
						'HEADING_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
259
						'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
260
						'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
261
						'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
262
						'TEXT_SECTION' => $TEXT['SECTION'],
263
						'TEXT_ID' => 'ID',
264
						'TEXT_TYPE' => $TEXT['TYPE'],
265
						'TEXT_BLOCK' => $TEXT['BLOCK'],
266
						'TEXT_PUBL_START_DATE' => $TEXT{'PUBL_START_DATE'},
267
						'TEXT_PUBL_END_DATE' => $TEXT['PUBL_END_DATE'],
268
						'TEXT_ACTIONS' => $TEXT['ACTIONS'],
269
						'MODIFIED_BY'          => $user['display_name'],
270
						'MODIFIED_BY_USERNAME' => $user['username'],
271
						'MODIFIED_WHEN'        => $modified_ts,
272
						'ADMIN_URL' => ADMIN_URL,
273
						'WB_URL' => WB_URL,
274
						'THEME_URL' => THEME_URL
275
						)
276
					);
277
// check modify page permission
278
	if( $admin->get_permission('pages_modify') )
279
	{
280
		$tpl->set_var(array(
281
				'MODIFY_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'].'">',
282
				'MODIFY_LINK_AFTER' => '</a>',
283
				'DISPLAY_MANAGE_MODIFY' => 'link',
284
				));
285
	} else {
286
		$tpl->set_var(array(
287
				'MODIFY_LINK_BEFORE' => '<span class="bold grey">',
288
				'MODIFY_LINK_AFTER' => '</span>',
289
				'DISPLAY_MANAGE_MODIFY' => 'link',
290
				));
291
	}
292

    
293
// check settings page permission
294
	if( $admin->get_permission('pages_settings') )
295
	{
296
		$tpl->set_var(array(
297
				'SETTINGS_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'].'">',
298
				'SETTINGS_LINK_AFTER' => '</a>',
299
				'DISPLAY_MANAGE_SETTINGS' => 'link',
300
				));
301
	} else {
302
		$tpl->set_var(array(
303
				'SETTINGS_LINK_BEFORE' => '<span class="bold grey">',
304
				'SETTINGS_LINK_AFTER' => '</span>',
305
				'DISPLAY_MANAGE_SECTIONS' => 'link',
306
				));
307
	}
308

    
309
		// Insert variables
310
		$tpl->set_var(array(
311
						'PAGE_ID' => $results_array['page_id'],
312
						// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
313
						'PAGE_IDKEY' => $results_array['page_id'],
314
						'VAR_PAGE_TITLE' => $results_array['page_title'],
315
						'SETTINGS_LINK' => ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'],
316
						'MODIFY_LINK' => ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id']
317
						)
318
					);
319
// setting trash only if more than one section exists
320
		$tpl->set_block('section_block', 'delete_block', 'delete');
321
		if( $bSectionCanDelete = ($database->get_one('SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` WHERE `page_id`='.$page_id))!=1 ) {
322
		}
323

    
324
		$sql  = 'SELECT `section_id`,`module`,`position`,`block`,`publ_start`,`publ_end` ';
325
		$sql .= 'FROM `'.TABLE_PREFIX.'sections` ';
326
		$sql .= 'WHERE `page_id` = '.$page_id.' ';
327
		$sql .= 'ORDER BY `position` ASC';
328
		$query_sections = $database->query($sql);
329

    
330
		if($query_sections->numRows() > 0)
331
		{
332
			$num_sections = $query_sections->numRows();
333
			while($section = $query_sections->fetchRow())
334
		    {
335
				if(!is_numeric(array_search($section['module'], $module_permissions)))
336
		        {
337
					// Get the modules real name
338
		            $sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
339
		            $sql .= 'WHERE `directory` = "'.$section['module'].'"';
340
		            if(!$database->get_one($sql) || !file_exists(WB_PATH.'/modules/'.$section['module']))
341
					{
342
						$edit_page = '<span class="module_disabled">'.$section['module'].'</span>';
343
					}else
344
					{
345
						$edit_page = '';
346
					}
347
					$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'section_');
348
					$edit_page_0 = '<a id="sid'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'];
349
					$edit_page_1  = ($sec_anchor!='') ? '#'.$sec_anchor.$section['section_id'].'">' : '">';
350
					$edit_page_1 .= $section['module'].'</a>';
351
					if(SECTION_BLOCKS)
352
		            {
353
						if($edit_page == '')
354
						{
355
							if(defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION)
356
							{
357
								$edit_page = $edit_page_0.'&amp;wysiwyg='.$section['section_id'].$edit_page_1;
358
							} else {
359
								$edit_page = $edit_page_0.$edit_page_1;
360
							}
361
						}
362
						$input_attribute = 'input_normal';
363
						$tpl->set_var(array(
364
								'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"',
365
								'NAME_SIZE' => 300,
366
								'INPUT_ATTRIBUTE' => $input_attribute,
367
								'VAR_SECTION_ID' => $section['section_id'],
368
								'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']),
369
								// 'VAR_SECTION_IDKEY' => $section['section_id'],
370
								'VAR_POSITION' => $section['position'],
371
								'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
372
								'SELECT' => '',
373
								'SET_NONE_DISPLAY_OPTION' => ''
374
								)
375
							);
376
						// Add block options to the section_list
377
						$tpl->clear_var('block_list');
378
						foreach($block AS $number => $name)
379
		                {
380
							$tpl->set_var('NAME', htmlentities(strip_tags($name)));
381
							$tpl->set_var('VALUE', $number);
382
							$tpl->set_var('SIZE', 1);
383
							if($section['block'] == $number)
384
		                    {
385
								$tpl->set_var('SELECTED', ' selected="selected"');
386
							} else {
387
								$tpl->set_var('SELECTED', '');
388
							}
389
							$tpl->parse('block_list', 'block_block', true);
390
						}
391
					} else {
392
						if($edit_page == '')
393
						{
394
							$edit_page = $edit_page_0.'#wb_'.$edit_page_1;
395
						}
396
						$input_attribute = 'input_normal';
397
						$tpl->set_var(array(
398
								'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:hidden;"',
399
								'NAME_SIZE' => 300,
400
								'INPUT_ATTRIBUTE' => $input_attribute,
401
								'VAR_SECTION_ID' => $section['section_id'],
402
								'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']),
403
								// 'VAR_SECTION_IDKEY' => $section['section_id'],
404
								'VAR_POSITION' => $section['position'],
405
								'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
406
								'NAME' => htmlentities(strip_tags($block[1])),
407
								'VALUE' => 1,
408
								'SET_NONE_DISPLAY_OPTION' => '<option>&nbsp;</option>'
409
								)
410
							);
411
					}
412
					// Insert icon and images
413
					$tpl->set_var(array(
414
								'CLOCK_16_PNG' => 'clock_16.png',
415
								'CLOCK_DEL_16_PNG' => 'clock_del_16.png',
416
								'DELETE_16_PNG' => 'delete_16.png'
417
								)
418
							);
419
					// set calendar start values
420
					if($section['publ_start']==0)
421
		            {
422
						$tpl->set_var('VALUE_PUBL_START', '');
423
					} else {
424
						$tpl->set_var('VALUE_PUBL_START', date($jscal_format, $section['publ_start']));
425
					}
426
					// set calendar start values
427
					if($section['publ_end']==0)
428
		            {
429
						$tpl->set_var('VALUE_PUBL_END', '');
430
					} else {
431
						$tpl->set_var('VALUE_PUBL_END', date($jscal_format, $section['publ_end']));
432
					}
433
					// Insert icons up and down
434
					if($section['position'] != 1 )
435
		            {
436
						$tpl->set_var(
437
									'VAR_MOVE_UP_URL',
438
									'<a href="'.ADMIN_URL.'/pages/move_up.php?page_id='.$page_id.'&amp;section_id='.$section['section_id'].'">
439
									<img src="'.THEME_URL.'/images/up_16.png" alt="{TEXT_MOVE_UP}" />
440
									</a>' );
441
					} else {
442
						$tpl->set_var(array(
443
									'VAR_MOVE_UP_URL' => ''
444
									)
445
								);
446
					}
447
					if($section['position'] != $num_sections ) {
448
						$tpl->set_var(
449
									'VAR_MOVE_DOWN_URL',
450
									'<a href="'.ADMIN_URL.'/pages/move_down.php?page_id='.$page_id.'&amp;section_id='.$section['section_id'].'">
451
									<img src="'.THEME_URL.'/images/down_16.png" alt="{TEXT_MOVE_DOWN}" />
452
									</a>' );
453
					} else {
454
						$tpl->set_var(array(
455
									'VAR_MOVE_DOWN_URL' => ''
456
									)
457
								);
458
					}
459

    
460
				} else {
461
				  continue;
462
				}
463

    
464
					$tpl->set_var(array(
465
									'DISPLAY_DEBUG' => ' style="visibility:visible;"',
466
									'TEXT_SID' => 'SID',
467
									'DEBUG_COLSPAN_SIZE' => 9
468
									)
469
								);
470
				if($debug)
471
		        {
472
					$tpl->set_var(array(
473
									'DISPLAY_DEBUG' => ' style="visibility:visible;"',
474
									'TEXT_PID' => 'PID',
475
									'TEXT_SID' => 'SID',
476
									'POSITION' => $section['position']
477
									)
478
								);
479
				} else {
480
					$tpl->set_var(array(
481
									'DISPLAY_DEBUG' => ' style="display:none;"',
482
									'TEXT_PID' => '',
483
									'POSITION' => ''
484
									)
485
								);
486
				}
487
				if($bSectionCanDelete) {
488
					$tpl->parse('delete', 'delete_block', false);
489
				} else {
490
					$tpl->parse('delete', '', false);
491
				} 
492
				$tpl->parse('section_list', 'section_block', true);
493
			}
494

    
495
		}
496

    
497
		// now add the calendars -- remember to to set the range to [1970, 2037] if the date is used as timestamp!
498
		// the loop is simply a copy from above.
499
		$sql  = 'SELECT `section_id`,`module` FROM `'.TABLE_PREFIX.'sections` ';
500
		$sql .= 'WHERE page_id = '.$page_id.' ';
501
		$sql .= 'ORDER BY `position` ASC';
502
		$query_sections = $database->query($sql);
503

    
504
		if($query_sections->numRows() > 0)
505
		{
506
			$num_sections = $query_sections->numRows();
507
			while($section = $query_sections->fetchRow())
508
		    {
509
				// Get the modules real name
510
		        $sql  = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
511
		        $sql .= 'WHERE `directory` = "'.$section['module'].'"';
512
		        $module_name = $database->get_one($sql);
513

    
514
				if(!is_numeric(array_search($section['module'], $module_permissions)))
515
		        {
516
					$tpl->set_var(array(
517
								'jscal_ifformat' => $jscal_ifformat,
518
								'jscal_firstday' => $jscal_firstday,
519
								'jscal_today' => $jscal_today,
520
								'start_date' => 'start_date'.$section['section_id'],
521
								'end_date' => 'end_date'.$section['section_id'],
522
								'trigger_start' => 'trigger_start'.$section['section_id'],
523
								'trigger_end' => 'trigger_stop'.$section['section_id']
524
								)
525
							);
526
					if(isset($jscal_use_time) && $jscal_use_time==TRUE) {
527
						$tpl->set_var(array(
528
								'showsTime' => "true",
529
								'timeFormat' => "24"
530
								)
531
							);
532
					}  else {
533
						$tpl->set_var(array(
534
								'showsTime' => "false",
535
								'timeFormat' => "24"
536
								)
537
							);
538
					}
539
				}
540
				$tpl->parse('calendar_list', 'calendar_block', true);
541
			}
542
		}
543

    
544
		// Work-out if we should show the "Add Section" form
545
		$sql  = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` ';
546
		$sql .= 'WHERE `page_id` = '.$page_id.' AND `module` = "menu_link"';
547
		$query_sections = $database->query($sql);
548
		$tpl->set_var('TEXT_PLEASE_SELECT', $TEXT['NONE']);
549
		if($query_sections->numRows() == 0)
550
		{
551
			$tpl->set_var('TEXT_PLEASE_SELECT', $TEXT['PLEASE_SELECT']);
552
			// Modules list
553
		    $sql  = 'SELECT `name`,`directory`,`type` FROM `'.TABLE_PREFIX.'addons` ';
554
		    $sql .= 'WHERE `type` = "module" AND `function` = "page" AND `directory` != "menu_link" ';
555
		    $sql .= 'ORDER BY `name`';
556
		    $result = $database->query($sql);
557
		// if(DEBUG && $database->is_error()) { $admin->print_error($database->get_error()); }
558

    
559
			if($result->numRows() > 0)
560
		    {
561
				while ($module = $result->fetchRow())
562
		        {
563
					// Check if user is allowed to use this module   echo  $module['directory'],'<br />';
564
					if(!is_numeric(array_search($module['directory'], $module_permissions)))
565
		            {
566
						$tpl->set_var('VALUE', $module['directory']);
567
						$tpl->set_var('NAME', $module['name']);
568
						if($module['directory'] == 'wysiwyg')
569
		                {
570
							$tpl->set_var('SELECTED', ' selected="selected"');
571
						} else {
572
							$tpl->set_var('SELECTED', '');
573
						}
574
						$tpl->parse('module_list', 'module_block', true);
575
					} else {
576
					  continue;
577
					}
578
				}
579
			}
580
		}
581
		// Insert language text and messages
582
		$tpl->set_var(array(
583
							'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
584
							'TEXT_ARE_YOU_SURE' => $TEXT['ARE_YOU_SURE'],
585
							'TEXT_TYPE' => $TEXT['TYPE'],
586
							'TEXT_ADD' => $TEXT['ADD'],
587
							'TEXT_SAVE' =>  $TEXT['SAVE'],
588
							'TEXTLINK_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
589
							'TEXT_CALENDAR' => $TEXT['CALENDAR'],
590
							'TEXT_DELETE_DATE' => $TEXT['DELETE_DATE'],
591
							'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
592
							'TEXT_MOVE_UP' => $TEXT['MOVE_UP'],
593
							'TEXT_MOVE_DOWN' => $TEXT['MOVE_DOWN']
594
							)
595
						);
596
		$tpl->parse('main', 'main_block', false);
597
		$tpl->pparse('output', 'page');
598
		// include the required file for Javascript admin
599
		if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
600
		{
601
			include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
602
		}
603
		break;
604
endswitch;
605

    
606
// Print admin footer
607
$admin->print_footer();
(19-19/23)