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 1825 2012-11-20 17:46:08Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/sections.php $
14
 * @lastmodified    $Date: 2012-11-20 18:46:08 +0100 (Tue, 20 Nov 2012) $
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 = false; // to show position and section_id
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 if $menu is set
217
		if(!isset($block[1]) || $block[1] == '')
218
		{
219
			// Make our own menu list
220
			$block[1] = $TEXT['MAIN'];
221
		}
222

    
223
		/*-- load css files with jquery --*/
224
		// include jscalendar-setup
225
		$jscal_use_time = true; // whether to use a clock, too
226
		require_once(WB_PATH."/include/jscalendar/wb-setup.php");
227

    
228
		// Setup template object, parse vars to it, then parse it
229
		// Create new template object
230
		$tpl = new Template(dirname($admin->correct_theme_source('pages_sections.htt')));
231
		// $template->debug = true;
232
		$tpl->set_file('page', 'pages_sections.htt');
233
		$tpl->set_block('page', 'main_block', 'main');
234
		$tpl->set_block('main_block', 'module_block', 'module_list');
235
		$tpl->set_block('main_block', 'section_block', 'section_list');
236
		$tpl->set_block('section_block', 'block_block', 'block_list');
237
		$tpl->set_block('main_block', 'calendar_block', 'calendar_list');
238
		$tpl->set_var('FTAN', $admin->getFTAN());
239

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

    
284
// check settings page permission
285
	if( $admin->get_permission('pages_settings') )
286
	{
287
		$tpl->set_var(array(
288
				'SETTINGS_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'].'">',
289
				'SETTINGS_LINK_AFTER' => '</a>',
290
				'DISPLAY_MANAGE_SETTINGS' => 'link',
291
				));
292
	} else {
293
		$tpl->set_var(array(
294
				'SETTINGS_LINK_BEFORE' => '<span class="bold grey">',
295
				'SETTINGS_LINK_AFTER' => '</span>',
296
				'DISPLAY_MANAGE_SECTIONS' => 'link',
297
				));
298
	}
299

    
300
		// Insert variables
301
		$tpl->set_var(array(
302
						'PAGE_ID' => $results_array['page_id'],
303
						// 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
304
						'PAGE_IDKEY' => $results_array['page_id'],
305
						'VAR_PAGE_TITLE' => $results_array['page_title'],
306
						'SETTINGS_LINK' => ADMIN_URL.'/pages/settings.php?page_id='.$results_array['page_id'],
307
						'MODIFY_LINK' => ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id']
308
						)
309
					);
310

    
311
		$sql  = 'SELECT `section_id`,`module`,`position`,`block`,`publ_start`,`publ_end` ';
312
		$sql .= 'FROM `'.TABLE_PREFIX.'sections` ';
313
		$sql .= 'WHERE `page_id` = '.$page_id.' ';
314
		$sql .= 'ORDER BY `position` ASC';
315
		$query_sections = $database->query($sql);
316

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

    
450
					$tpl->set_var(array(
451
									'DISPLAY_DEBUG' => ' style="visibility="visible;"',
452
									'TEXT_SID' => 'SID',
453
									'DEBUG_COLSPAN_SIZE' => 9
454
									)
455
								);
456
				if($debug)
457
		        {
458
					$tpl->set_var(array(
459
									'DISPLAY_DEBUG' => ' style="visibility="visible;"',
460
									'TEXT_PID' => 'PID',
461
									'TEXT_SID' => 'SID',
462
									'POSITION' => $section['position']
463
									)
464
								);
465
				} else {
466
					$tpl->set_var(array(
467
									'DISPLAY_DEBUG' => ' style="display:none;"',
468
									'TEXT_PID' => '',
469
									'POSITION' => ''
470
									)
471
								);
472
				}
473
				$tpl->parse('section_list', 'section_block', true);
474
			}
475
		}
476

    
477
		// now add the calendars -- remember to to set the range to [1970, 2037] if the date is used as timestamp!
478
		// the loop is simply a copy from above.
479
		$sql  = 'SELECT `section_id`,`module` FROM `'.TABLE_PREFIX.'sections` ';
480
		$sql .= 'WHERE page_id = '.$page_id.' ';
481
		$sql .= 'ORDER BY `position` ASC';
482
		$query_sections = $database->query($sql);
483

    
484
		if($query_sections->numRows() > 0)
485
		{
486
			$num_sections = $query_sections->numRows();
487
			while($section = $query_sections->fetchRow())
488
		    {
489
				// Get the modules real name
490
		        $sql  = 'SELECT `name` FROM `'.TABLE_PREFIX.'addons` ';
491
		        $sql .= 'WHERE `directory` = "'.$section['module'].'"';
492
		        $module_name = $database->get_one($sql);
493

    
494
				if(!is_numeric(array_search($section['module'], $module_permissions)))
495
		        {
496
					$tpl->set_var(array(
497
								'jscal_ifformat' => $jscal_ifformat,
498
								'jscal_firstday' => $jscal_firstday,
499
								'jscal_today' => $jscal_today,
500
								'start_date' => 'start_date'.$section['section_id'],
501
								'end_date' => 'end_date'.$section['section_id'],
502
								'trigger_start' => 'trigger_start'.$section['section_id'],
503
								'trigger_end' => 'trigger_stop'.$section['section_id']
504
								)
505
							);
506
					if(isset($jscal_use_time) && $jscal_use_time==TRUE) {
507
						$tpl->set_var(array(
508
								'showsTime' => "true",
509
								'timeFormat' => "24"
510
								)
511
							);
512
					}  else {
513
						$tpl->set_var(array(
514
								'showsTime' => "false",
515
								'timeFormat' => "24"
516
								)
517
							);
518
					}
519
				}
520
				$tpl->parse('calendar_list', 'calendar_block', true);
521
			}
522
		}
523

    
524
		// Work-out if we should show the "Add Section" form
525
		$sql  = 'SELECT `section_id` FROM `'.TABLE_PREFIX.'sections` ';
526
		$sql .= 'WHERE `page_id` = '.$page_id.' AND `module` = "menu_link"';
527
		$query_sections = $database->query($sql);
528
		if($query_sections->numRows() == 0)
529
		{
530
			// Modules list
531
		    $sql  = 'SELECT `name`,`directory`,`type` FROM `'.TABLE_PREFIX.'addons` ';
532
		    $sql .= 'WHERE `type` = "module" AND `function` = "page" AND `directory` != "menu_link" ';
533
		    $sql .= 'ORDER BY `name`';
534
		    $result = $database->query($sql);
535
		// if(DEBUG && $database->is_error()) { $admin->print_error($database->get_error()); }
536

    
537
			if($result->numRows() > 0)
538
		    {
539
				while ($module = $result->fetchRow())
540
		        {
541
					// Check if user is allowed to use this module   echo  $module['directory'],'<br />';
542
					if(!is_numeric(array_search($module['directory'], $module_permissions)))
543
		            {
544
						$tpl->set_var('VALUE', $module['directory']);
545
						$tpl->set_var('NAME', $module['name']);
546
						if($module['directory'] == 'wysiwyg')
547
		                {
548
							$tpl->set_var('SELECTED', ' selected="selected"');
549
						} else {
550
							$tpl->set_var('SELECTED', '');
551
						}
552
						$tpl->parse('module_list', 'module_block', true);
553
					} else {
554
					  continue;
555
					}
556
				}
557
			}
558
		}
559
		// Insert language text and messages
560
		$tpl->set_var(array(
561
							'TEXT_MANAGE_SECTIONS' => $HEADING['MANAGE_SECTIONS'],
562
							'TEXT_ARE_YOU_SURE' => $TEXT['ARE_YOU_SURE'],
563
							'TEXT_TYPE' => $TEXT['TYPE'],
564
							'TEXT_ADD' => $TEXT['ADD'],
565
							'TEXT_SAVE' =>  $TEXT['SAVE'],
566
							'TEXTLINK_MODIFY_PAGE' => $HEADING['MODIFY_PAGE'],
567
							'TEXT_CALENDAR' => $TEXT['CALENDAR'],
568
							'TEXT_DELETE_DATE' => $TEXT['DELETE_DATE'],
569
							'TEXT_ADD_SECTION' => $TEXT['ADD_SECTION'],
570
							'TEXT_MOVE_UP' => $TEXT['MOVE_UP'],
571
							'TEXT_MOVE_DOWN' => $TEXT['MOVE_DOWN']
572
							)
573
						);
574
		$tpl->parse('main', 'main_block', false);
575
		$tpl->pparse('output', 'page');
576
		// include the required file for Javascript admin
577
		if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
578
		{
579
			include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
580
		}
581
		break;
582
endswitch;
583

    
584
// Print admin footer
585
$admin->print_footer();
(18-18/22)