Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2011, Website Baker 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 and higher
12
 * @version         $Id: index.php 1529 2011-11-25 05:03:32Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/index.php $
14
 * @lastmodified    $Date: 2011-11-25 06:03:32 +0100 (Fri, 25 Nov 2011) $
15
 *
16
 */
17

    
18
require('../../config.php');
19
require_once(WB_PATH.'/framework/class.admin.php');
20
$admin = new admin('Pages', 'pages');
21

    
22
$admin->clearIDKEY();
23

    
24
// Include the WB functions file
25
require_once(WB_PATH.'/framework/functions.php');
26
// eggsurplus: add child pages for a specific page
27
?>
28
<script type="text/javascript" src="<?php print ADMIN_URL; ?>/pages/eggsurplus.js"></script>
29
<?php
30

    
31
// fixes A URI contains impermissible characters or quotes around the URI are not closed.
32
$MESSAGE['PAGES_DELETE_CONFIRM'] = url_encode(  $MESSAGE['PAGES_DELETE_CONFIRM'] );
33

    
34
function set_node ($parent,& $par)
35
{
36
    $retval = '';
37

    
38
	if($par['num_subs'] )
39
	{
40
    $retval .= "\n".'<ul id="p'.$parent.'"';
41
	if ($parent != 0)
42
	{
43
		$retval .= ' class="page_list"';
44
		if (isset ($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1')
45
		{
46
			 $retval .= ' style="display:block"';
47
		}
48
	}
49
	$retval .= ">\n";
50
 	}
51

    
52
	return $retval;
53
}
54

    
55
function make_list($parent = 0, $editable_pages = 0) {
56
	// Get objects and vars from outside this function
57
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $par;
58

    
59
    print set_node ($parent,$par);
60

    
61
	// Get page list from database
62
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
63
    $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
64
    $sql .= 'ORDER BY `position` ASC';
65
	$get_pages = $database->query($sql);
66

    
67
	// Insert values into main page list
68
	if($get_pages->numRows() > 0)
69
	{
70
		while($page = $get_pages->fetchRow())
71
		{
72
			// Get user perms
73
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
74
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
75
			$in_group = FALSE;
76
			foreach($admin->get_groups_id() as $cur_gid)
77
            {
78
				if (in_array($cur_gid, $admin_groups))
79
                {
80
					$in_group = TRUE;
81
				}
82
			}
83
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users)))
84
            {
85
				if($page['visibility'] == 'deleted')
86
                {
87
					if(PAGE_TRASH == 'inline')
88
                    {
89
						$can_modify = true;
90
						$editable_pages = $editable_pages+1;
91
					} else {
92
						$can_modify = false;
93
					}
94
				} elseif($page['visibility'] != 'deleted')
95
                {
96
					$can_modify = true;
97
					$editable_pages = $editable_pages+1;
98
				}
99
			} else {
100
				if($page['visibility'] == 'private')
101
                {
102
					continue;
103
				}
104
				else {
105
					$can_modify = false;
106
				}
107
			}
108

    
109
			// Work out if we should show a plus or not
110
            $sql = 'SELECT `page_id`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$page['page_id'].' ';
111
            $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
112
            // $sql .= ' ORDER BY `position` ASC';
113
        	$get_page_subs = $database->query($sql);
114
			$num_subs = $get_page_subs->numRows();
115
			$par['num_subs'] = $num_subs;
116
/*
117
			if(PAGE_TRASH != 'inline')
118
            {
119
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
120
			} else {
121
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
122
			}
123
*/
124
			if($get_page_subs->numRows() > 0)
125
            {
126
				$display_plus = true;
127
			} else {
128
				$display_plus = false;
129
			}
130
			// Work out how many pages there are for this parent
131
			$num_pages = $get_pages->numRows();
132
			?>
133
			<li class="p<?php echo $page['parent']; ?>">
134
			<table summary="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>" class="pages_view" cellpadding="0" cellspacing="0">
135
			<tr>
136
				<td valign="middle" width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
137
					<?php
138
					if($display_plus == true) {
139
					?>
140
					<a href="javascript:toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
141
						<img src="<?php echo THEME_URL; ?>/images/<?php if(isset($_COOKIE['p'.$page['page_id']]) && $_COOKIE['p'.$page['page_id']] == '1'){ echo 'minus'; } else { echo 'plus'; } ?>_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id']; ?>');" name="plus_minus_<?php echo $page['page_id']; ?>" alt="+" />
142
					</a>
143
					<?php
144
					}
145
					?>
146
				</td>
147
				<?php if($admin->get_permission('pages_modify') == true && $can_modify == true) { ?>
148
				<td class="list_menu_title">
149
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo  $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
150
						<?php if($page['visibility'] == 'public') { ?>
151
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
152
						<?php } elseif($page['visibility'] == 'private') { ?>
153
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
154
						<?php } elseif($page['visibility'] == 'registered') { ?>
155
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
156
						<?php } elseif($page['visibility'] == 'hidden') { ?>
157
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
158
						<?php } elseif($page['visibility'] == 'none') { ?>
159
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
160
						<?php } elseif($page['visibility'] == 'deleted') { ?>
161
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
162
						<?php }
163
						echo '<span class="modify_link">'.($page['menu_title']).'</span>'; ?>
164
					</a>
165
				</td>
166
				<?php } else { ?>
167
				<td class="list_menu_title">
168
					<?php if($page['visibility'] == 'public') { ?>
169
						<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
170
					<?php } elseif($page['visibility'] == 'private') { ?>
171
						<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
172
					<?php } elseif($page['visibility'] == 'registered') { ?>
173
						<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
174
					<?php } elseif($page['visibility'] == 'hidden') { ?>
175
						<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
176
					<?php } elseif($page['visibility'] == 'none') { ?>
177
						<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
178
					<?php } elseif($page['visibility'] == 'deleted') { ?>
179
						<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
180
					<?php }
181
					echo ($page['menu_title']); ?>
182
				</td>
183
				<?php } ?>
184
				<td class="list_page_title">
185
					<?php echo ($page['page_title']); ?>
186
				</td>
187
				<td class="list_page_id">
188
					<?php echo $page['page_id']; ?>
189
				</td>
190

    
191
				<td class="list_actions">
192
					<?php if($page['visibility'] != 'deleted' && $page['visibility'] != 'none') { ?>
193
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
194
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" alt="<?php echo $TEXT['VIEW']; ?>" />
195
					</a>
196
					<?php } ?>
197
				</td>
198
				<td class="list_actions">
199
					<?php if($page['visibility'] != 'deleted') { ?>
200
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
201
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
202
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" alt="<?php echo $TEXT['SETTINGS']; ?>" />
203
						</a>
204
						<?php } ?>
205
					<?php } else { ?>
206
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
207
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" alt="<?php echo $TEXT['RESTORE']; ?>" />
208
						</a>
209
					<?php } ?>
210
				</td>
211
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
212
				<td class="list_actions">
213
				<?php
214
				// Work-out if we should show the "manage dates" link
215
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true)
216
                {
217
                    $sql = 'SELECT `publ_start`, `publ_end` FROM `'.TABLE_PREFIX.'sections` ';
218
                    $sql .= 'WHERE `page_id` = '.$page['page_id'].' AND `module` != \'menu_link\' ';
219
					// $query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
220
					if( ($query_sections = $database->query($sql)) )
221
                    {
222
						$mdate_display=false;
223
						while($mdate_res = $query_sections->fetchRow())
224
                        {
225
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
226
                            {
227
								$mdate_display=true;
228
								break;
229
							}
230
						}
231
						if($mdate_display==1)
232
                        {
233
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
234
							?>
235
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
236
							<img src="<?php echo THEME_URL."/images/$file"; ?>" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
237
							</a>
238
						<?php } else { ?>
239
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
240
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
241
						<?php } ?>
242
					<?php } ?>
243
				<?php } ?>
244
				</td>
245
				<td class="list_actions">
246
				<?php if($page['position'] != 1) { ?>
247
					<?php if($page['visibility'] != 'deleted') { ?>
248
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
249
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
250
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="<?php echo $TEXT['MOVE_UP']; ?>" />
251
						</a>
252
						<?php } ?>
253
					<?php } ?>
254
				<?php } ?>
255
				</td>
256
				<td class="list_actions">
257
				<?php if($page['position'] != $num_pages) { ?>
258
					<?php if($page['visibility'] != 'deleted') { ?>
259
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
260
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
261
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="<?php echo $TEXT['MOVE_DOWN']; ?>" />
262
						</a>
263
						<?php } ?>
264
					<?php } ?>
265
				<?php } ?>
266
				</td>
267
				<td class="list_actions">
268
					<?php if($admin->get_permission('pages_delete') == true && $can_modify == true) { // add IdKey ?>
269
					<a href="javascript:confirm_link('<?php echo $MESSAGE['PAGES_DELETE_CONFIRM']; ?>?','<?php echo ADMIN_URL; ?>/pages/delete.php?page_id=<?php echo $admin->getIDKEY($page['page_id']); ?>');" title="<?php echo $TEXT['DELETE']; ?>">
270
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['DELETE']; ?>" />
271
					</a>
272
					<?php } ?>
273
				</td>
274
				<?php
275
				// eggsurplus: Add action to add a page as a child
276
				?>
277
				<td class="list_actions">
278
					<?php if(($admin->get_permission('pages_add')) == (true && $can_modify == true) && ($page['visibility'] != 'deleted')) { ?>
279
					<a href="javascript:add_child_page('<?php echo $page['page_id']; ?>');" title="<?php echo $HEADING['ADD_CHILD_PAGE']; ?>">
280
						<img src="<?php echo THEME_URL; ?>/images/siteadd.png" name="addpage_<?php echo $page['page_id']; ?>" alt="Add Child Page" />
281
					</a>
282
					<?php } ?>
283
				</td>
284
				<?php
285
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
286
				?>
287

    
288
			</tr>
289
			</table>
290
			<?php
291
			if ( $page['parent'] == 0)
292
            {
293
				$page_tmp_id = $page['page_id'];
294
			}
295
			// Get subs
296
			$editable_pages=make_list($page['page_id'], $editable_pages);
297
            print '</li>'."\n";
298
		}
299
	}
300
	$output = ($par['num_subs'] )? '</ul>'."\n" : '';
301
    $par['num_subs'] = (empty($output) ) ?  1 : $par['num_subs'];
302
    print $output;
303
	return $editable_pages;
304
}
305

    
306
// Generate pages list
307
if($admin->get_permission('pages_view') == true) {
308
	?>
309
	<div class="jsadmin hide"></div>
310
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0" width="100%">
311
	<tr>
312
		<td>
313
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
314
		</td>
315
		<td align="right"></td>
316
	</tr>
317
	</table>
318
	<div class="pages_list">
319
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0">
320
	<tr class="pages_list_header">
321
		<td class="header_list_menu_title">
322
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE']; ?>:
323
		</td>
324
		<td class="header_list_page_title">
325
			<?php echo $TEXT['PAGE_TITLE']; ?>:
326
		</td>
327
		<td class="header_list_page_id">
328
			ID:
329
		</td>
330
		<td class="header_list_actions">
331
			<?php echo $TEXT['ACTIONS']; ?>:
332
		</td>
333
	</tr>
334
	</table>
335
	<?php
336
	// Work-out if we should check for existing page_code
337
	$field_set = $database->field_exists(TABLE_PREFIX.'pages', 'page_code');
338

    
339
    $par = array();
340
	$par['num_subs'] = 1;
341
	$editable_pages = make_list(0, 0);
342
} else {
343
	$editable_pages = 0;
344
}
345
 ?></div><?php
346

    
347
if(intval($editable_pages) == 0 ) {
348
	?>
349
	<div class="empty_list">
350
		<?php echo $TEXT['NONE_FOUND']; ?>
351
	</div>
352
	<?php
353
}
354
// Setup template object, parse vars to it, then parse it
355
$ThemePath = realpath(WB_PATH.$admin->correct_theme_source('pages.htt'));
356
// Create new template object
357
$template = new Template($ThemePath);
358
// $template->debug = true;
359
$template->set_file('page', 'pages.htt');
360
$template->set_block('page', 'main_block', 'main');
361
// Insert values into the add page form
362
$template->set_var('FTAN', $admin->getFTAN());
363

    
364
// Group list 1
365

    
366
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
367
	$get_groups = $database->query($query);
368
	$template->set_block('main_block', 'group_list_block', 'group_list');
369
	// Insert admin group and current group first
370
	$admin_group_name = $get_groups->fetchRow();
371
	$template->set_var(array(
372
									'ID' => 1,
373
									'TOGGLE' => '1',
374
									'DISABLED' => ' disabled="disabled"',
375
									'LINK_COLOR' => '000000',
376
									'CURSOR' => 'default',
377
									'NAME' => $admin_group_name['name'],
378
									'CHECKED' => ' checked="checked"'
379
									)
380
							);
381
	$template->parse('group_list', 'group_list_block', true);
382

    
383
	while($group = $get_groups->fetchRow()) {
384
		// check if the user is a member of this group
385
		$flag_disabled = '';
386
		$flag_checked =  '';
387
		$flag_cursor =   'pointer';
388
		$flag_color =    '';
389
		if (in_array($group["group_id"], $admin->get_groups_id())) {
390
			$flag_disabled = ''; //' disabled';
391
			$flag_checked =  ' checked="checked"';
392
			$flag_cursor =   'default';
393
			$flag_color =    '000000';
394
		}
395

    
396
		// Check if the group is allowed to edit pages
397
		$system_permissions = explode(',', $group['system_permissions']);
398
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
399
			$template->set_var(array(
400
											'ID' => $group['group_id'],
401
											'TOGGLE' => $group['group_id'],
402
											'CHECKED' => $flag_checked,
403
											'DISABLED' => $flag_disabled,
404
											'LINK_COLOR' => $flag_color,
405
											'CURSOR' => $flag_checked,
406
											'NAME' => $group['name'],
407
											)
408
									);
409
			$template->parse('group_list', 'group_list_block', true);
410
		}
411
	}
412
// Group list 2
413

    
414
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
415

    
416
	$get_groups = $database->query($query);
417
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
418
	// Insert admin group and current group first
419
	$admin_group_name = $get_groups->fetchRow();
420
	$template->set_var(array(
421
									'ID' => 1,
422
									'TOGGLE' => '1',
423
									'DISABLED' => ' disabled="disabled"',
424
									'LINK_COLOR' => '000000',
425
									'CURSOR' => 'default',
426
									'NAME' => $admin_group_name['name'],
427
									'CHECKED' => ' checked="checked"'
428
									)
429
							);
430
	$template->parse('group_list2', 'group_list_block2', true);
431

    
432
	while($group = $get_groups->fetchRow()) {
433
		// check if the user is a member of this group
434
		$flag_disabled = '';
435
		$flag_checked =  '';
436
		$flag_cursor =   'pointer';
437
		$flag_color =    '';
438
		if (in_array($group["group_id"], $admin->get_groups_id())) {
439
			$flag_disabled = ''; //' disabled';
440
			$flag_checked =  ' checked="checked"';
441
			$flag_cursor =   'default';
442
			$flag_color =    '000000';
443
		}
444

    
445
		$template->set_var(array(
446
										'ID' => $group['group_id'],
447
										'TOGGLE' => $group['group_id'],
448
										'CHECKED' => $flag_checked,
449
										'DISABLED' => $flag_disabled,
450
										'LINK_COLOR' => $flag_color,
451
										'CURSOR' => $flag_cursor,
452
										'NAME' => $group['name'],
453
										)
454
								);
455
		$template->parse('group_list2', 'group_list_block2', true);
456
	}
457

    
458

    
459
// Parent page list
460
// $database = new database();
461
function parent_list($parent)
462
{
463
	global $admin, $database, $template, $field_set;
464
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
465
	$get_pages = $database->query($query);
466
	while($page = $get_pages->fetchRow()) {
467
		if($admin->page_is_visible($page)==false)
468
			continue;
469
		// if parent = 0 set flag_icon
470
		$template->set_var('FLAG_ROOT_ICON',' none ');
471
		if( $page['parent'] == 0 && $field_set) {
472
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
473
		}
474
		// Stop users from adding pages with a level of more than the set page level limit
475
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
476
			// Get user perms
477
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
478
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
479
			
480
			$in_group = FALSE;
481
			foreach($admin->get_groups_id() as $cur_gid) {
482
				if (in_array($cur_gid, $admin_groups)) {
483
					$in_group = TRUE;
484
				}
485
			}
486
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users))) {
487
				$can_modify = true;
488
			} else {
489
				$can_modify = false;
490
			}
491
			// Title -'s prefix
492
			$title_prefix = '';
493
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - &nbsp;'; }
494
				$template->set_var(array(
495
										'ID' => $page['page_id'],
496
										'TITLE' => ($title_prefix.$page['menu_title']),
497
										'MENU-TITLE' => ($title_prefix.$page['menu_title']),
498
										'PAGE-TITLE' => ($title_prefix.$page['page_title'])
499
										));
500
				if($can_modify == true) {
501
					$template->set_var('DISABLED', '');
502
				} else {
503
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
504
				}
505
				$template->parse('page_list2', 'page_list_block2', true);
506
		}
507
		parent_list($page['page_id']);
508
	}
509
}
510
$template->set_block('main_block', 'page_list_block2', 'page_list2');
511
if($admin->get_permission('pages_add_l0') == true) {
512
	$template->set_var(array(
513
						'ID' => '0',
514
						'TITLE' => $TEXT['NONE'],
515
						'SELECTED' => ' selected="selected"',
516
						'DISABLED' => ''
517
					)
518
				);
519
	$template->parse('page_list2', 'page_list_block2', true);
520
}
521
parent_list(0);
522

    
523
// Explode module permissions
524
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
525
// Modules list
526
$template->set_block('main_block', 'module_list_block', 'module_list');
527
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
528
if($result->numRows() > 0) {
529
	while ($module = $result->fetchRow()) {
530
		// Check if user is allowed to use this module
531
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
532
			$template->set_var('VALUE', $module['directory']);
533
			$template->set_var('NAME', $module['name']);
534
			if($module['directory'] == 'wysiwyg') {
535
				$template->set_var('SELECTED', ' selected="selected"');
536
			} else {
537
				$template->set_var('SELECTED', '');
538
			}
539
			$template->parse('module_list', 'module_list_block', true);
540
		}
541
	}
542
}
543

    
544
// Insert urls
545
$template->set_var(array(
546
								'THEME_URL' => THEME_URL,
547
								'WB_URL' => WB_URL,
548
								'ADMIN_URL' => ADMIN_URL,
549
								)
550
						);
551

    
552
// Insert language headings
553
$template->set_var(array(
554
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
555
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
556
								)
557
						);
558
// Insert language text and messages
559
$template->set_var(array(
560
								'TEXT_TITLE' => $TEXT['TITLE'],
561
								'TEXT_TYPE' => $TEXT['TYPE'],
562
								'TEXT_PARENT' => $TEXT['PARENT'],
563
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
564
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
565
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
566
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
567
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
568
								'TEXT_NONE' => $TEXT['NONE'],
569
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
570
								'TEXT_ADD' => $TEXT['ADD'],
571
								'TEXT_RESET' => $TEXT['RESET'],
572
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
573
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
574
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
575
								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
576
								)
577
						);
578

    
579
// Insert permissions values
580
if($admin->get_permission('pages_add') != true) {
581
	$template->set_var('DISPLAY_ADD', 'hide');
582
} elseif($admin->get_permission('pages_add_l0') != true && $editable_pages == 0) {
583
	$template->set_var('DISPLAY_ADD', 'hide');
584
}
585
if($admin->get_permission('pages_intro') != true || INTRO_PAGE != 'enabled') {
586
	$template->set_var('DISPLAY_INTRO', 'hide');
587
}
588

    
589

    
590
// Parse template object
591
$template->parse('main', 'main_block', false);
592
$template->pparse('output', 'page');
593

    
594
// include the required file for Javascript admin
595
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
596
{
597
	include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
598
}
599

    
600
// Print admin
601
$admin->print_footer();
(6-6/22)