Project

General

Profile

1
<?php
2

    
3
// $Id: index.php 944 2009-02-22 09:39:58Z Ruebenwurzel $
4

    
5
/*
6

    
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

    
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

    
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

    
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

    
24
*/
25

    
26
require('../../config.php');
27
require_once(WB_PATH.'/framework/class.admin.php');
28
$admin = new admin('Pages', 'pages');
29
// Include the WB functions file
30
require_once(WB_PATH.'/framework/functions.php');
31

    
32
?>
33
<!-- Addition for remembering expanded state of pages -->
34
<script language="JavaScript">
35
function writeSessionCookie (cookieName, cookieValue) {
36
    document.cookie = escape(cookieName) + "=" + escape(cookieValue) + ";";
37
}
38
</script>
39
<!-- End addition -->
40

    
41
<script type="text/javascript" language="javascript">
42
function toggle_viewers() {
43
	if(document.add.visibility.value == 'private') {
44
		document.getElementById('viewers').style.display = 'block';
45
	} else if(document.add.visibility.value == 'registered') {
46
		document.getElementById('viewers').style.display = 'block';
47
	} else {
48
		document.getElementById('viewers').style.display = 'none';
49
	}
50
}
51
function toggle_visibility(id){
52
	if(document.getElementById(id).style.display == "block") {
53
		document.getElementById(id).style.display = "none";
54
		writeSessionCookie (id, "0");//Addition for remembering expanded state of pages
55
	} else {
56
		document.getElementById(id).style.display = "block";
57
		writeSessionCookie (id, "1");//Addition for remembering expanded state of pages
58
	}
59
}
60
var plus = new Image;
61
plus.src = "<?php echo THEME_URL; ?>/images/plus_16.png";
62
var minus = new Image;
63
minus.src = "<?php echo THEME_URL; ?>/images/minus_16.png";
64
function toggle_plus_minus(id) {
65
	var img_src = document.images['plus_minus_' + id].src;
66
	if(img_src == plus.src) {
67
		document.images['plus_minus_' + id].src = minus.src;
68
	} else {
69
		document.images['plus_minus_' + id].src = plus.src;
70
	}
71
}
72
</script>
73

    
74
<?php
75

    
76
function make_list($parent, $editable_pages) {
77
	// Get objects and vars from outside this function
78
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING;
79
	?>
80
	<ul id="p<?php echo $parent; ?>" <?php if($parent != 0) { echo 'class="page_list" '; if(isset($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1'){ echo 'style="display:block"'; }} ?>>
81
	<?php	
82
	// Get page list from database
83
	$database = new database();
84
	if(PAGE_TRASH != 'inline') {
85
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
86
	} else {
87
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
88
	}
89
	$get_pages = $database->query($query);
90
	
91
	// Insert values into main page list
92
	if($get_pages->numRows() > 0)	{
93
		while($page = $get_pages->fetchRow()) {
94
			// Get user perms
95
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
96
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
97

    
98
			$in_group = FALSE;
99
			foreach($admin->get_groups_id() as $cur_gid){
100
			    if (in_array($cur_gid, $admin_groups)) {
101
			        $in_group = TRUE;
102
			    }
103
			}
104
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
105
				if($page['visibility'] == 'deleted') {
106
					if(PAGE_TRASH == 'inline') {
107
						$can_modify = true;
108
						$editable_pages = $editable_pages+1;
109
					} else {
110
						$can_modify = false;
111
					}
112
				} elseif($page['visibility'] != 'deleted') {
113
					$can_modify = true;
114
					$editable_pages = $editable_pages+1;
115
				}
116
			} else {
117
				if($page['visibility'] == 'private') {
118
					continue;
119
				}
120
				else {
121
					$can_modify = false;
122
				}
123
			}
124
						
125
			// Work out if we should show a plus or not
126
			if(PAGE_TRASH != 'inline') {
127
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
128
			} else {
129
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
130
			}
131
			if($get_page_subs->numRows() > 0) {
132
				$display_plus = true;
133
			} else {
134
				$display_plus = false;
135
			}
136
			
137
			// Work out how many pages there are for this parent
138
			$num_pages = $get_pages->numRows();
139
			?>
140
			
141
			<li id="p<?php echo $page['parent']; ?>">
142
			<table class="pages_view">
143
			<tr>
144
				<td width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
145
					<?php
146
					if($display_plus == true) {
147
					?>
148
					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
149
						<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']; ?>" border="0" alt="+" />
150
					</a>
151
					<?php
152
					}
153
					?>
154
				</td>
155
				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
156
				<td>
157
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
158
						<?php if($page['visibility'] == 'public') { ?>
159
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
160
						<?php } elseif($page['visibility'] == 'private') { ?>
161
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
162
						<?php } elseif($page['visibility'] == 'registered') { ?>
163
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
164
						<?php } elseif($page['visibility'] == 'hidden') { ?>
165
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
166
						<?php } elseif($page['visibility'] == 'none') { ?>
167
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
168
						<?php } elseif($page['visibility'] == 'deleted') { ?>
169
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
170
						<?php } 
171
						echo '<div class="modify_link">'.($page['page_title']).'</div>'; ?>
172
					</a>				
173
				</td>
174
				<?php } else { ?>
175
				<td>
176
					<?php if($page['visibility'] == 'public') { ?>
177
						<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
178
					<?php } elseif($page['visibility'] == 'private') { ?>
179
						<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
180
					<?php } elseif($page['visibility'] == 'registered') { ?>
181
						<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
182
					<?php } elseif($page['visibility'] == 'hidden') { ?>
183
						<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
184
					<?php } elseif($page['visibility'] == 'none') { ?>
185
						<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
186
					<?php } elseif($page['visibility'] == 'deleted') { ?>
187
						<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
188
					<?php } 
189
					echo ($page['page_title']); ?>
190
				</td>
191
				<?php } ?>
192
				<td align="left" width="252">
193
					<font color="#999999"><?php echo ($page['menu_title']); ?></font>
194
				</td>
195
				<td width="20">
196
					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
197
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
198
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
199
					</a>
200
					<?php } ?>
201
				</td>
202
				<td width="20">
203
					<?php if($page['visibility'] != 'deleted') { ?>
204
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
205
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
206
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
207
						</a>
208
						<?php } ?>
209
					<?php } else { ?>
210
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
211
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
212
						</a>
213
					<?php } ?>
214
				</td>
215
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
216

    
217
				<!-- 'MANAGE SECTIONS' BUTTON -->
218
				<td width="20">
219
					<?php
220
					// Work-out if we should show the "manage sections" link
221
					$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '" . $page['page_id'] . "' AND module = 'menu_link'");
222
					if(($query_sections->numRows() == 0) && (MANAGE_SECTIONS == 'enabled')) {
223
					?>
224
						<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
225
						<img src="<?php echo THEME_URL; ?>/images/sections_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />	
226
						</a>
227
					<?php } ?>
228
				</td>
229

    
230
				<td width="20">
231
				<?php
232
				// Work-out if we should show the "manage dates" link
233
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true) {
234
					$query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
235
					if($query_sections->numRows() > 0) {
236
						$mdate_display=false;
237
						while($mdate_res = $query_sections->fetchRow()) {
238
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0') {
239
								$mdate_display=true;
240
								break;
241
							}
242
						}
243
						if($mdate_display==1) {
244
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
245
							?>
246
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
247
							<img src="<?php echo THEME_URL."/images/$file"; ?>" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />	
248
							</a>
249
						<?php } else { ?>
250
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
251
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>	
252
						<?php } ?>
253
					<?php } ?>
254
				<?php } ?>
255
				</td>
256
				<td width="20">
257
				<?php if($page['position'] != 1) { ?>
258
					<?php if($page['visibility'] != 'deleted') { ?>
259
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
260
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
261
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
262
						</a>
263
						<?php } ?>
264
					<?php } ?>
265
				<?php } ?>
266
				</td>
267
				<td width="20">
268
				<?php if($page['position'] != $num_pages) { ?>
269
					<?php if($page['visibility'] != 'deleted') { ?>
270
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
271
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
272
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
273
						</a>
274
						<?php } ?>
275
					<?php } ?>
276
				<?php } ?>
277
				</td>
278
				<td width="20">
279
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
280
					<a href="javascript: confirm_link('<?php echo $MESSAGE['PAGES']['DELETE_CONFIRM']; ?>?', '<?php echo ADMIN_URL; ?>/pages/delete.php?page_id=<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
281
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
282
					</a>
283
					<?php } ?>
284
				</td>
285
			</tr>
286
			</table>
287
			</li>
288
							
289
			<?php
290
			// Get subs
291
			$editable_pages=make_list($page['page_id'], $editable_pages);
292
		}
293

    
294
	}
295
	?>
296
	</ul>
297
	<?php
298
	return $editable_pages;
299
}
300

    
301
// Generate pages list
302
if($admin->get_permission('pages_view') == true) {
303
	?>
304
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
305
	<tr>
306
		<td>
307
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
308
		</td>
309
		<td align="right">
310
			<?php
311
				// Check if there are any pages that are in trash, and if we should show a link to the trash page
312
				if(PAGE_TRASH == 'separate') {
313
					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
314
					if($query_trash->numRows() > 0) {
315
						?>
316
						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
317
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
318
						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
319
						<?php
320
					}
321
				}
322
			?>
323
		</td>
324
	</tr>
325
	</table>
326
	<div class="pages_list">
327
	<table cellpadding="0" cellspacing="0" border="0">
328
	<tr>
329
		<td width="20px">
330
			&nbsp;
331
		</td>
332
		<td width="314px">
333
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['PAGE_TITLE']; ?>:
334
		</td>
335
		<td width="256px" align="left">
336
			<?php echo $TEXT['MENU_TITLE']; ?>:
337
		</td>
338
		<td width="130px" align="center">
339
			<?php echo $TEXT['ACTIONS']; ?>:
340
		</td>		
341
	</tr>
342
	</table>
343
	<?php
344
	$editable_pages = make_list(0, 0);
345
	?>
346
	</div>
347
	<div class="empty_list">
348
		<?php echo $TEXT['NONE_FOUND']; ?>
349
	</div>
350
	<?php
351
} else {
352
	$editable_pages = 0;
353
}
354

    
355
// Setup template object
356
$template = new Template(THEME_PATH.'/templates');
357
$template->set_file('page', 'pages.htt');
358
$template->set_block('page', 'main_block', 'main');
359

    
360
// Figure out if the no pages found message should be shown or not
361
if($editable_pages == 0) {
362
	?>
363
	<style type="text/css">
364
	.pages_list {
365
		display: none;
366
	}
367
	</style>
368
	<?php
369
} else {
370
	?>
371
	<style type="text/css">
372
	.empty_list {
373
		display: none;
374
	}
375
	</style>
376
	<?php
377
}
378

    
379
// Insert values into the add page form
380

    
381
// Group list 1
382

    
383
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
384

    
385
	$get_groups = $database->query($query);
386
	$template->set_block('main_block', 'group_list_block', 'group_list');
387
	// Insert admin group and current group first
388
	$admin_group_name = $get_groups->fetchRow();
389
	$template->set_var(array(
390
									'ID' => 1,
391
									'TOGGLE' => '',
392
									'DISABLED' => ' disabled',
393
									'LINK_COLOR' => '000000',
394
									'CURSOR' => 'default',
395
									'NAME' => $admin_group_name['name'],
396
									'CHECKED' => ' checked'
397
									)
398
							);
399
	$template->parse('group_list', 'group_list_block', true);
400

    
401
	while($group = $get_groups->fetchRow()) {
402
		// check if the user is a member of this group
403
		$flag_disabled = '';
404
		$flag_checked =  '';
405
		$flag_cursor =   'pointer';
406
		$flag_color =    '';
407
		if (in_array($group["group_id"], $admin->get_groups_id())) {
408
			$flag_disabled = ''; //' disabled';
409
			$flag_checked =  ' checked';
410
			$flag_cursor =   'default';
411
			$flag_color =    '000000';
412
		}
413

    
414
		// Check if the group is allowed to edit pages
415
		$system_permissions = explode(',', $group['system_permissions']);
416
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
417
			$template->set_var(array(
418
											'ID' => $group['group_id'],
419
											'TOGGLE' => $group['group_id'],
420
											'CHECKED' => $flag_checked,
421
											'DISABLED' => $flag_disabled,
422
											'LINK_COLOR' => $flag_color,
423
											'CURSOR' => $flag_checked,
424
											'NAME' => $group['name'],
425
											)
426
									);
427
			$template->parse('group_list', 'group_list_block', true);
428
		}
429
	}
430
// Group list 2
431

    
432
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
433

    
434
	$get_groups = $database->query($query);
435
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
436
	// Insert admin group and current group first
437
	$admin_group_name = $get_groups->fetchRow();
438
	$template->set_var(array(
439
									'ID' => 1,
440
									'TOGGLE' => '',
441
									'DISABLED' => ' disabled',
442
									'LINK_COLOR' => '000000',
443
									'CURSOR' => 'default',
444
									'NAME' => $admin_group_name['name'],
445
									'CHECKED' => ' checked'
446
									)
447
							);
448
	$template->parse('group_list2', 'group_list_block2', true);
449

    
450
	while($group = $get_groups->fetchRow()) {
451
		// check if the user is a member of this group
452
		$flag_disabled = '';
453
		$flag_checked =  '';
454
		$flag_cursor =   'pointer';
455
		$flag_color =    '';
456
		if (in_array($group["group_id"], $admin->get_groups_id())) {
457
			$flag_disabled = ''; //' disabled';
458
			$flag_checked =  ' checked';
459
			$flag_cursor =   'default';
460
			$flag_color =    '000000';
461
		}
462

    
463
		$template->set_var(array(
464
										'ID' => $group['group_id'],
465
										'TOGGLE' => $group['group_id'],
466
										'CHECKED' => $flag_checked,
467
										'DISABLED' => $flag_disabled,
468
										'LINK_COLOR' => $flag_color,
469
										'CURSOR' => $flag_cursor,
470
										'NAME' => $group['name'],
471
										)
472
								);
473
		$template->parse('group_list2', 'group_list_block2', true);
474
	}
475

    
476
// Parent page list
477
$database = new database();
478
function parent_list($parent) {
479
	global $admin, $database, $template;
480
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
481
	$get_pages = $database->query($query);
482
	while($page = $get_pages->fetchRow()) {
483
		if($admin->page_is_visible($page)==false)
484
			continue;
485
		// Stop users from adding pages with a level of more than the set page level limit
486
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
487
			// Get user perms
488
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
489
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
490
			
491
			$in_group = FALSE;
492
			foreach($admin->get_groups_id() as $cur_gid){
493
			    if (in_array($cur_gid, $admin_groups)) {
494
			        $in_group = TRUE;
495
			    }
496
			}
497
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
498
				$can_modify = true;
499
			} else {
500
				$can_modify = false;
501
			}
502
			// Title -'s prefix
503
			$title_prefix = '';
504
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
505
				$template->set_var(array(
506
												'ID' => $page['page_id'],
507
												'TITLE' => ($title_prefix.$page['page_title'])
508
												)
509
										);
510
				if($can_modify == true) {
511
					$template->set_var('DISABLED', '');
512
				} else {
513
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
514
				}
515
				$template->parse('page_list2', 'page_list_block2', true);
516
		}
517
		parent_list($page['page_id']);
518
	}
519
}
520
$template->set_block('main_block', 'page_list_block2', 'page_list2');
521
if($admin->get_permission('pages_add_l0') == true) {
522
	$template->set_var(array(
523
									'ID' => '0',
524
									'TITLE' => $TEXT['NONE'],
525
									'SELECTED' => ' selected',
526
									'DISABLED' => ''
527
									)
528
							);
529
	$template->parse('page_list2', 'page_list_block2', true);
530
}
531
parent_list(0);
532

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

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

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

    
591

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

    
596
// Print admin 
597
$admin->print_footer();
598

    
599
?>
(4-4/16)