Project

General

Profile

1 1358 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6 1707 Luisehahne
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8 1358 Luisehahne
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11 1373 Luisehahne
 * @requirements    PHP 5.2.2 and higher
12 1358 Luisehahne
 * @version         $Id$
13
 * @filesource		$HeadURL$
14
 * @lastmodified    $Date$
15
 *
16
 */
17
18
// Include config file
19
require('../../config.php');
20
21
// Make sure people are allowed to access this page
22
if(MANAGE_SECTIONS != 'enabled')
23
{
24
	header('Location: '.ADMIN_URL.'/pages/index.php');
25
	exit(0);
26
}
27 1402 Luisehahne
/* */
28
$debug = false; // to show position and section_id
29
If(!defined('DEBUG')) { define('DEBUG',$debug);}
30 1475 Luisehahne
// Include the WB functions file
31
require_once(WB_PATH.'/framework/functions.php');
32 1402 Luisehahne
// Create new admin object
33
require_once(WB_PATH.'/framework/class.admin.php');
34 1475 Luisehahne
$admin = new admin('Pages', 'pages_modify', false);
35 1358 Luisehahne
36 1475 Luisehahne
$action = 'show';
37 1358 Luisehahne
// Get page id
38 1475 Luisehahne
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
39
$page_id = intval((isset(${$requestMethod}['page_id'])) ? ${$requestMethod}['page_id'] : 0);
40
$action = ($page_id ? 'show' : $action);
41
// Get section id if there is one
42
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
43
$section_id = ((isset(${$requestMethod}['section_id'])) ? ${$requestMethod}['section_id']  : 0);
44
$action = ($section_id ? 'delete' : $action);
45
// Get module if there is one
46
$requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
47
$module = ((isset(${$requestMethod}['module'])) ? ${$requestMethod}['module']  : 0);
48
$action = ($module != '' ? 'add' : $action);
49
$admin_header = true;
50
$backlink = ADMIN_URL.'/pages/sections.php?page_id='.(int)$page_id;
51 1358 Luisehahne
52 1475 Luisehahne
switch ($action):
53
	case 'delete' :
54 1358 Luisehahne
55 1475 Luisehahne
		if( ( !($section_id = intval($admin->checkIDKEY('section_id', 0, $_SERVER['REQUEST_METHOD'])) )) )
56
		{
57
			if($admin_header) { $admin->print_header(); }
58
			$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink);
59
		}
60 1358 Luisehahne
61 1475 Luisehahne
		$action = 'show';
62
	    $sql  = 'SELECT `module` FROM `'.TABLE_PREFIX.'sections` ';
63
	    $sql .= 'WHERE `section_id` ='.$section_id;
64
        if( ( ($modulname = $database->get_one($sql)) == $module) && ($section_id > 0 ) ) {
65
			// Include the modules delete file if it exists
66
			if(file_exists(WB_PATH.'/modules/'.$modulname.'/delete.php'))
67
		    {
68
				require(WB_PATH.'/modules/'.$modulname.'/delete.php');
69
			}
70
		    $sql  = 'DELETE FROM `'.TABLE_PREFIX.'sections` ';
71
		    $sql .= 'WHERE `section_id` ='.(int)$section_id.' LIMIT 1';
72
			if( !$database->query($sql) ) {
73
				if($admin_header) { $admin->print_header(); }
74
				$admin->print_error($database->get_error(),$backlink);
75
			}  else {
76
				require_once(WB_PATH.'/framework/class.order.php');
77
				$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
78
				$order->clean($page_id);
79
				$format = $TEXT['SECTION'].' %d  %s %s '.strtolower( $TEXT['DELETED']);
80
				$message = sprintf ($format,$section_id,strtoupper($modulname),strtolower($TEXT['SUCCESS']));
81
				if($admin_header) { $admin->print_header(); }
82
				$admin_header = false;
83
				unset($_POST);
84
				$admin->print_success($message, $backlink );
85
			}
86
        } else {
87
			if($admin_header) { $admin->print_header(); }
88
			$admin->print_error($module.' '.strtolower($TEXT['NOT_FOUND']),$backlink);
89
        }
90 1358 Luisehahne
91 1475 Luisehahne
		break;
92
	case 'add' :
93
94
		if (!$admin->checkFTAN())
95
		{
96
			$admin->print_header();
97
			$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'],$backlink);
98
		}
99
		$action = 'show';
100
		$module = preg_replace('/\W/', '', $module );  // fix secunia 2010-91-4
101
		require_once(WB_PATH.'/framework/class.order.php');
102
		// Get new order
103 1358 Luisehahne
		$order = new order(TABLE_PREFIX.'sections', 'position', 'section_id', 'page_id');
104 1475 Luisehahne
		$position = $order->get_new($page_id);
105
		// Insert module into DB
106
	    $sql  = 'INSERT INTO `'.TABLE_PREFIX.'sections` SET ';
107
	    $sql .= '`page_id` = '.(int)$page_id.', ';
108
	    $sql .= '`module` = \''.$module.'\', ';
109
	    $sql .= '`position` = '.(int)$position.', ';
110
	    $sql .= '`block` = 1';
111
        if($database->query($sql)) {
112
			// Get the section id
113
			$section_id = $database->get_one("SELECT LAST_INSERT_ID()");
114
			// Include the selected modules add file if it exists
115
			if(file_exists(WB_PATH.'/modules/'.$module.'/add.php'))
116
		    {
117
				require(WB_PATH.'/modules/'.$module.'/add.php');
118
			}
119
        } elseif ($database->is_error())  {
120
			if($admin_header) { $admin->print_header(); }
121
			$admin->print_error($database->get_error());
122
		}
123
		break;
124
	default:
125
		break;
126
endswitch;
127 1358 Luisehahne
128 1475 Luisehahne
switch ($action):
129
	default:
130 1358 Luisehahne
131 1475 Luisehahne
		if($admin_header) { $admin->print_header(); }
132
		// Get perms
133
		$sql  = 'SELECT `admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` ';
134
		$sql .= 'WHERE `page_id` = '.$page_id;
135
		$results = $database->query($sql);
136 1358 Luisehahne
137 1475 Luisehahne
		$results_array = $results->fetchRow();
138
		$old_admin_groups = explode(',', $results_array['admin_groups']);
139
		$old_admin_users = explode(',', $results_array['admin_users']);
140
		$in_old_group = FALSE;
141
		foreach($admin->get_groups_id() as $cur_gid)
142
		{
143
			if (in_array($cur_gid, $old_admin_groups))
144
		    {
145
				$in_old_group = TRUE;
146
			}
147
		}
148
		if((!$in_old_group) && !is_numeric(array_search($admin->get_user_id(), $old_admin_users)))
149
		{
150
			$admin->print_header();
151 1707 Luisehahne
			$admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS']);
152 1475 Luisehahne
		}
153 1358 Luisehahne
154 1475 Luisehahne
		// Get page details
155
		$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'pages` ';
156
		$sql .= 'WHERE `page_id` = '.$page_id;
157
		$results = $database->query($sql);
158 1358 Luisehahne
159 1475 Luisehahne
		if($database->is_error())
160
		{
161
			// $admin->print_header();
162
			$admin->print_error($database->get_error());
163
		}
164
		if($results->numRows() == 0)
165
		{
166
			// $admin->print_header();
167 1707 Luisehahne
			$admin->print_error($MESSAGE['PAGES_NOT_FOUND']);
168 1475 Luisehahne
		}
169
		$results_array = $results->fetchRow();
170 1358 Luisehahne
171 1707 Luisehahne
		// Get display name of person who last modified the page
172
			$user=$admin->get_user_details($results_array['modified_by']);
173
		// Convert the unix ts for modified_when to human a readable form
174
			if($results_array['modified_when'] != 0) {
175
				$modified_ts = gmdate(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE);
176
			} else {
177
				$modified_ts = 'Unknown';
178
			}
179
180 1475 Luisehahne
		// Set module permissions
181
		$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
182 1358 Luisehahne
183 1475 Luisehahne
		// Unset block var
184
		unset($block);
185
		// Include template info file (if it exists)
186
		if($results_array['template'] != '')
187
		{
188
			$template_location = WB_PATH.'/templates/'.$results_array['template'].'/info.php';
189
		} else {
190
			$template_location = WB_PATH.'/templates/'.DEFAULT_TEMPLATE.'/info.php';
191
		}
192
		if(file_exists($template_location))
193
		{
194
			require($template_location);
195
		}
196
		// Check if $menu is set
197
		if(!isset($block[1]) || $block[1] == '')
198
		{
199
			// Make our own menu list
200
			$block[1] = $TEXT['MAIN'];
201
		}
202 1358 Luisehahne
203 1475 Luisehahne
		/*-- load css files with jquery --*/
204
		// include jscalendar-setup
205
		$jscal_use_time = true; // whether to use a clock, too
206
		require_once(WB_PATH."/include/jscalendar/wb-setup.php");
207 1358 Luisehahne
208 1529 Luisehahne
		// Setup template object, parse vars to it, then parse it
209
		// Create new template object
210 1625 Luisehahne
		$tpl = new Template(dirname($admin->correct_theme_source('pages_sections.htt')));
211 1529 Luisehahne
		// $template->debug = true;
212 1475 Luisehahne
		$tpl->set_file('page', 'pages_sections.htt');
213
		$tpl->set_block('page', 'main_block', 'main');
214
		$tpl->set_block('main_block', 'module_block', 'module_list');
215
		$tpl->set_block('main_block', 'section_block', 'section_list');
216
		$tpl->set_block('section_block', 'block_block', 'block_list');
217
		$tpl->set_block('main_block', 'calendar_block', 'calendar_list');
218
		$tpl->set_var('FTAN', $admin->getFTAN());
219 1358 Luisehahne
220 1475 Luisehahne
		// set first defaults and messages
221
		$tpl->set_var(array(
222
						'PAGE_ID' => $results_array['page_id'],
223
						// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
224
						'PAGE_IDKEY' => $results_array['page_id'],
225
						'TEXT_PAGE' => $TEXT['PAGE'],
226
						'PAGE_TITLE' => ($results_array['page_title']),
227
						'MENU_TITLE' => ($results_array['menu_title']),
228
						'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
229 1707 Luisehahne
						'TEXT_LAST_MODIFIED' => $TEXT['LAST_UPDATED_BY'],
230 1475 Luisehahne
						'HEADING_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
231
						'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
232
						'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
233
						'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
234
						'TEXT_ID' => 'ID',
235
						'TEXT_TYPE' => $TEXT['TYPE'],
236
						'TEXT_BLOCK' => $TEXT['BLOCK'],
237
						'TEXT_PUBL_START_DATE' => $TEXT{'PUBL_START_DATE'},
238
						'TEXT_PUBL_END_DATE' => $TEXT['PUBL_END_DATE'],
239
						'TEXT_ACTIONS' => $TEXT['ACTIONS'],
240 1707 Luisehahne
						'MODIFIED_BY'          => $user['display_name'],
241
						'MODIFIED_BY_USERNAME' => $user['username'],
242
						'MODIFIED_WHEN'        => $modified_ts,
243 1475 Luisehahne
						'ADMIN_URL' => ADMIN_URL,
244
						'WB_URL' => WB_URL,
245
						'THEME_URL' => THEME_URL
246
						)
247
					);
248 1707 Luisehahne
// check modify page permission
249
	if( $admin->get_permission('pages_modify') )
250
	{
251
		$tpl->set_var(array(
252
				'MODIFY_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'].'">',
253
				'MODIFY_LINK_AFTER' => '</a>',
254
				'DISPLAY_MANAGE_MODIFY' => 'link',
255
				));
256
	} else {
257
		$tpl->set_var(array(
258
				'MODIFY_LINK_BEFORE' => '<span class="bold grey">',
259
				'MODIFY_LINK_AFTER' => '</span>',
260
				'DISPLAY_MANAGE_MODIFY' => 'link',
261
				));
262
	}
263 1358 Luisehahne
264 1707 Luisehahne
// check settings page permission
265
	if( $admin->get_permission('pages_settings') )
266
	{
267
		$tpl->set_var(array(
268
				'SETTINGS_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'].'">',
269
				'SETTINGS_LINK_AFTER' => '</a>',
270
				'DISPLAY_MANAGE_SETTINGS' => 'link',
271
				));
272
	} else {
273
		$tpl->set_var(array(
274
				'SETTINGS_LINK_BEFORE' => '<span class="bold grey">',
275
				'SETTINGS_LINK_AFTER' => '</span>',
276
				'DISPLAY_MANAGE_SECTIONS' => 'link',
277
				));
278
	}
279
280 1475 Luisehahne
		// Insert variables
281
		$tpl->set_var(array(
282
						'PAGE_ID' => $results_array['page_id'],
283
						// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
284
						'PAGE_IDKEY' => $results_array['page_id'],
285
						'VAR_PAGE_TITLE' => $results_array['page_title'],
286
						'SETTINGS_LINK' => ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'],
287
						'MODIFY_LINK' => ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id']
288
						)
289
					);
290 1358 Luisehahne
291 1475 Luisehahne
		$sql  = 'SELECT `section_id`,`module`,`position`,`block`,`publ_start`,`publ_end` ';
292
		$sql .= 'FROM `'.TABLE_PREFIX.'sections` ';
293
		$sql .= 'WHERE `page_id` = '.$page_id.' ';
294
		$sql .= 'ORDER BY `position` ASC';
295
		$query_sections = $database->query($sql);
296
297
		if($query_sections->numRows() > 0)
298
		{
299
			$num_sections = $query_sections->numRows();
300
			while($section = $query_sections->fetchRow())
301
		    {
302
				if(!is_numeric(array_search($section['module'], $module_permissions)))
303
		        {
304
					// Get the modules real name
305
		            $sql = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
306
		            $sql .= 'WHERE `directory` = "'.$section['module'].'"';
307
		            if(!$database->get_one($sql) || !file_exists(WB_PATH.'/modules/'.$section['module']))
308 1358 Luisehahne
					{
309 1475 Luisehahne
						$edit_page = '<span class="module_disabled">'.$section['module'].'</span>';
310
					}else
311
					{
312
						$edit_page = '';
313
					}
314 1518 Luisehahne
					$sec_anchor = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : '');
315 1475 Luisehahne
					$edit_page_0 = '<a id="sid'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'];
316 1518 Luisehahne
					$edit_page_1  = ($sec_anchor!='') ? '#'.$sec_anchor.$section['section_id'].'">' : '">';
317
					$edit_page_1 .= $section['module'].'</a>';
318 1475 Luisehahne
					if(SECTION_BLOCKS)
319
		            {
320
						if($edit_page == '')
321
						{
322
							if(defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION)
323
							{
324 1518 Luisehahne
								$edit_page = $edit_page_0.'&amp;wysiwyg='.$section['section_id'].$edit_page_1;
325 1475 Luisehahne
							} else {
326 1518 Luisehahne
								$edit_page = $edit_page_0.$edit_page_1;
327 1475 Luisehahne
							}
328
						}
329
						$input_attribute = 'input_normal';
330
						$tpl->set_var(array(
331
								'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"',
332
								'NAME_SIZE' => 300,
333
								'INPUT_ATTRIBUTE' => $input_attribute,
334
								'VAR_SECTION_ID' => $section['section_id'],
335
								'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']),
336
								// 'VAR_SECTION_IDKEY' => $section['section_id'],
337
								'VAR_POSITION' => $section['position'],
338
								'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
339
								'SELECT' => '',
340
								'SET_NONE_DISPLAY_OPTION' => ''
341
								)
342
							);
343
						// Add block options to the section_list
344
						$tpl->clear_var('block_list');
345
						foreach($block AS $number => $name)
346
		                {
347
							$tpl->set_var('NAME', htmlentities(strip_tags($name)));
348
							$tpl->set_var('VALUE', $number);
349
							$tpl->set_var('SIZE', 1);
350
							if($section['block'] == $number)
351
		                    {
352
								$tpl->set_var('SELECTED', ' selected="selected"');
353
							} else {
354
								$tpl->set_var('SELECTED', '');
355
							}
356
							$tpl->parse('block_list', 'block_block', true);
357
						}
358 1358 Luisehahne
					} else {
359 1475 Luisehahne
						if($edit_page == '')
360
						{
361
							$edit_page = $edit_page_0.'#wb_'.$edit_page_1;
362
						}
363
						$input_attribute = 'input_normal';
364
						$tpl->set_var(array(
365
								'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:hidden;"',
366
								'NAME_SIZE' => 300,
367
								'INPUT_ATTRIBUTE' => $input_attribute,
368
								'VAR_SECTION_ID' => $section['section_id'],
369
								'VAR_SECTION_IDKEY' => $admin->getIDKEY($section['section_id']),
370
								// 'VAR_SECTION_IDKEY' => $section['section_id'],
371
								'VAR_POSITION' => $section['position'],
372
								'LINK_MODIFY_URL_VAR_MODUL_NAME' => $edit_page,
373
								'NAME' => htmlentities(strip_tags($block[1])),
374
								'VALUE' => 1,
375
								'SET_NONE_DISPLAY_OPTION' => ''
376
								)
377
							);
378 1358 Luisehahne
					}
379 1475 Luisehahne
					// Insert icon and images
380
					$tpl->set_var(array(
381
								'CLOCK_16_PNG' => 'clock_16.png',
382
								'CLOCK_DEL_16_PNG' => 'clock_del_16.png',
383
								'DELETE_16_PNG' => 'delete_16.png'
384
								)
385
							);
386
					// set calendar start values
387
					if($section['publ_start']==0)
388
		            {
389
						$tpl->set_var('VALUE_PUBL_START', '');
390 1358 Luisehahne
					} else {
391 1475 Luisehahne
						$tpl->set_var('VALUE_PUBL_START', date($jscal_format, $section['publ_start']));
392 1358 Luisehahne
					}
393 1475 Luisehahne
					// set calendar start values
394
					if($section['publ_end']==0)
395
		            {
396
						$tpl->set_var('VALUE_PUBL_END', '');
397
					} else {
398
						$tpl->set_var('VALUE_PUBL_END', date($jscal_format, $section['publ_end']));
399
					}
400
					// Insert icons up and down
401
					if($section['position'] != 1 )
402
		            {
403
						$tpl->set_var(
404
									'VAR_MOVE_UP_URL',
405
									'<a href="'.ADMIN_URL.'/pages/move_up.php?page_id='.$page_id.'&amp;section_id='.$section['section_id'].'">
406
									<img src="'.THEME_URL.'/images/up_16.png" alt="{TEXT_MOVE_UP}" />
407
									</a>' );
408
					} else {
409
						$tpl->set_var(array(
410
									'VAR_MOVE_UP_URL' => ''
411
									)
412
								);
413
					}
414
					if($section['position'] != $num_sections ) {
415
						$tpl->set_var(
416
									'VAR_MOVE_DOWN_URL',
417
									'<a href="'.ADMIN_URL.'/pages/move_down.php?page_id='.$page_id.'&amp;section_id='.$section['section_id'].'">
418
									<img src="'.THEME_URL.'/images/down_16.png" alt="{TEXT_MOVE_DOWN}" />
419
									</a>' );
420
					} else {
421
						$tpl->set_var(array(
422
									'VAR_MOVE_DOWN_URL' => ''
423
									)
424
								);
425
					}
426
				} else {
427
				  continue;
428 1358 Luisehahne
				}
429 1475 Luisehahne
430
					$tpl->set_var(array(
431
									'DISPLAY_DEBUG' => ' style="visibility="visible;"',
432
									'TEXT_SID' => 'SID',
433
									'DEBUG_COLSPAN_SIZE' => 9
434
									)
435
								);
436
				if($debug)
437
		        {
438
					$tpl->set_var(array(
439
									'DISPLAY_DEBUG' => ' style="visibility="visible;"',
440
									'TEXT_PID' => 'PID',
441
									'TEXT_SID' => 'SID',
442
									'POSITION' => $section['position']
443
									)
444
								);
445
				} else {
446
					$tpl->set_var(array(
447
									'DISPLAY_DEBUG' => ' style="display:none;"',
448
									'TEXT_PID' => '',
449
									'POSITION' => ''
450
									)
451
								);
452 1358 Luisehahne
				}
453 1475 Luisehahne
				$tpl->parse('section_list', 'section_block', true);
454 1358 Luisehahne
			}
455
		}
456
457 1475 Luisehahne
		// now add the calendars -- remember to to set the range to [1970, 2037] if the date is used as timestamp!
458
		// the loop is simply a copy from above.
459
		$sql  = 'SELECT `section_id`,`module` FROM `'.TABLE_PREFIX.'sections` ';
460
		$sql .= 'WHERE page_id = '.$page_id.' ';
461
		$sql .= 'ORDER BY `position` ASC';
462
		$query_sections = $database->query($sql);
463 1358 Luisehahne
464 1475 Luisehahne
		if($query_sections->numRows() > 0)
465
		{
466
			$num_sections = $query_sections->numRows();
467
			while($section = $query_sections->fetchRow())
468
		    {
469
				// Get the modules real name
470
		        $sql  = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
471
		        $sql .= 'WHERE `directory` = "'.$section['module'].'"';
472
		        $module_name = $database->get_one($sql);
473 1358 Luisehahne
474 1475 Luisehahne
				if(!is_numeric(array_search($section['module'], $module_permissions)))
475
		        {
476
					$tpl->set_var(array(
477
								'jscal_ifformat' => $jscal_ifformat,
478
								'jscal_firstday' => $jscal_firstday,
479
								'jscal_today' => $jscal_today,
480
								'start_date' => 'start_date'.$section['section_id'],
481
								'end_date' => 'end_date'.$section['section_id'],
482
								'trigger_start' => 'trigger_start'.$section['section_id'],
483
								'trigger_end' => 'trigger_stop'.$section['section_id']
484
								)
485
							);
486
					if(isset($jscal_use_time) && $jscal_use_time==TRUE) {
487
						$tpl->set_var(array(
488
								'showsTime' => "true",
489
								'timeFormat' => "24"
490
								)
491
							);
492
					}  else {
493
						$tpl->set_var(array(
494
								'showsTime' => "false",
495
								'timeFormat' => "24"
496
								)
497
							);
498
					}
499
				}
500
				$tpl->parse('calendar_list', 'calendar_block', true);
501 1358 Luisehahne
			}
502
		}
503
504 1475 Luisehahne
		// Work-out if we should show the "Add Section" form
505
		$sql  = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` ';
506
		$sql .= 'WHERE `page_id` = '.$page_id.' AND `module` = "menu_link"';
507
		$query_sections = $database->query($sql);
508
		if($query_sections->numRows() == 0)
509
		{
510
			// Modules list
511
		    $sql  = 'SELECT `name`,`directory`,`type` FROM `'.TABLE_PREFIX.'addons` ';
512
		    $sql .= 'WHERE `type` = "module" AND `function` = "page" AND `directory` != "menu_link" ';
513
		    $sql .= 'ORDER BY `name`';
514
		    $result = $database->query($sql);
515
		// if(DEBUG && $database->is_error()) { $admin->print_error($database->get_error()); }
516 1358 Luisehahne
517 1475 Luisehahne
			if($result->numRows() > 0)
518
		    {
519
				while ($module = $result->fetchRow())
520
		        {
521
					// Check if user is allowed to use this module   echo  $module['directory'],'<br />';
522
					if(!is_numeric(array_search($module['directory'], $module_permissions)))
523
		            {
524
						$tpl->set_var('VALUE', $module['directory']);
525
						$tpl->set_var('NAME', $module['name']);
526
						if($module['directory'] == 'wysiwyg')
527
		                {
528
							$tpl->set_var('SELECTED', ' selected="selected"');
529
						} else {
530
							$tpl->set_var('SELECTED', '');
531
						}
532
						$tpl->parse('module_list', 'module_block', true);
533
					} else {
534
					  continue;
535
					}
536 1358 Luisehahne
				}
537
			}
538
		}
539 1475 Luisehahne
		// Insert language text and messages
540
		$tpl->set_var(array(
541
							'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
542 1517 Luisehahne
							'TEXT_ARE_YOU_SURE' => $TEXT['ARE_YOU_SURE'],
543 1475 Luisehahne
							'TEXT_TYPE' => $TEXT['TYPE'],
544
							'TEXT_ADD' => $TEXT['ADD'],
545
							'TEXT_SAVE' =>  $TEXT['SAVE'],
546
							'TEXTLINK_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
547
							'TEXT_CALENDAR' => $TEXT['CALENDAR'],
548
							'TEXT_DELETE_DATE' => $TEXT['DELETE_DATE'],
549
							'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
550
							'TEXT_MOVE_UP' => $TEXT['MOVE_UP'],
551
							'TEXT_MOVE_DOWN' => $TEXT['MOVE_DOWN']
552
							)
553
						);
554
		$tpl->parse('main', 'main_block', false);
555
		$tpl->pparse('output', 'page');
556
		// include the required file for Javascript admin
557
		if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
558
		{
559
			include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
560
		}
561
		break;
562
endswitch;
563 1358 Luisehahne
564
// Print admin footer
565
$admin->print_footer();