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 1835 2012-12-10 18:39:34Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/sections.php $
14
 * @lastmodified    $Date: 2012-12-10 19:39:34 +0100 (Mon, 10 Dec 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 = 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 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_SECTION' => $TEXT['SECTION'],
255
						'TEXT_ID' => 'ID',
256
						'TEXT_TYPE' => $TEXT['TYPE'],
257
						'TEXT_BLOCK' => $TEXT['BLOCK'],
258
						'TEXT_PUBL_START_DATE' => $TEXT{'PUBL_START_DATE'},
259
						'TEXT_PUBL_END_DATE' => $TEXT['PUBL_END_DATE'],
260
						'TEXT_ACTIONS' => $TEXT['ACTIONS'],
261
						'MODIFIED_BY'          => $user['display_name'],
262
						'MODIFIED_BY_USERNAME' => $user['username'],
263
						'MODIFIED_WHEN'        => $modified_ts,
264
						'ADMIN_URL' => ADMIN_URL,
265
						'WB_URL' => WB_URL,
266
						'THEME_URL' => THEME_URL
267
						)
268
					);
269
// check modify page permission
270
	if( $admin->get_permission('pages_modify') )
271
	{
272
		$tpl->set_var(array(
273
				'MODIFY_LINK_BEFORE' => '<a href="'.ADMIN_URL.'/pages/modify.php?page_id='.$results_array['page_id'].'">',
274
				'MODIFY_LINK_AFTER' => '</a>',
275
				'DISPLAY_MANAGE_MODIFY' => 'link',
276
				));
277
	} else {
278
		$tpl->set_var(array(
279
				'MODIFY_LINK_BEFORE' => '<span class="bold grey">',
280
				'MODIFY_LINK_AFTER' => '</span>',
281
				'DISPLAY_MANAGE_MODIFY' => 'link',
282
				));
283
	}
284

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

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

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

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

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

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

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

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

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

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

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