Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.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 1914 2013-06-07 03:51:48Z Luisehahne $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/sections.php $
14
 * @lastmodified    $Date: 2013-06-07 05:51:48 +0200 (Fri, 07 Jun 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
$mLang = Translate::getinstance();
44
$mLang->enableAddon('admin\pages');
45

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

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

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

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

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

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

    
150
switch ($action):
151
	default:
152

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

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

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

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

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

    
202
		// Set module permissions
203
		$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
204

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

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

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

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

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

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

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

    
462
				} else {
463
				  continue;
464
				}
465

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

    
497
		}
498

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

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

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

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

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

    
608
// Print admin footer
609
$admin->print_footer();
(20-20/24)