Project

General

Profile

1 238 stefan
<?php
2
3 398 Ruebenwurz
// $Id$
4
5 238 stefan
/*
6
7
 Website Baker Project <http://www.websitebaker.org/>
8 915 Ruebenwurz
 Copyright (C) 2004-2009, Ryan Djurovich
9 238 stefan
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 385 Ruebenwurz
<!-- 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 238 stefan
<script type="text/javascript" language="javascript">
42
function toggle_viewers() {
43
	if(document.add.visibility.value == 'private') {
44 804 thorn
		document.getElementById('viewers').style.display = 'block';
45 238 stefan
	} else if(document.add.visibility.value == 'registered') {
46 804 thorn
		document.getElementById('viewers').style.display = 'block';
47 238 stefan
	} else {
48 804 thorn
		document.getElementById('viewers').style.display = 'none';
49 238 stefan
	}
50
}
51
function toggle_visibility(id){
52
	if(document.getElementById(id).style.display == "block") {
53
		document.getElementById(id).style.display = "none";
54 385 Ruebenwurz
		writeSessionCookie (id, "0");//Addition for remembering expanded state of pages
55 238 stefan
	} else {
56
		document.getElementById(id).style.display = "block";
57 385 Ruebenwurz
		writeSessionCookie (id, "1");//Addition for remembering expanded state of pages
58 238 stefan
	}
59
}
60
var plus = new Image;
61
plus.src = "<?php echo ADMIN_URL; ?>/images/plus_16.png";
62
var minus = new Image;
63
minus.src = "<?php echo ADMIN_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
<style type="text/css">
75
.pages_list img {
76
	display: block;
77
}
78
ul, li {
79
	list-style: none;
80
	margin: 0;
81
	padding: 0;
82
}
83
.page_list {
84
	display: none;
85
}
86
</style>
87
88
<noscript>
89
	<style type="text/css">
90
	.page_list {
91
		display: block;
92
	}
93
	</style>
94
</noscript>
95
<?php
96
97
function make_list($parent, $editable_pages) {
98
	// Get objects and vars from outside this function
99 529 doc
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING;
100 238 stefan
	?>
101 557 thorn
	<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;"'; }} ?>>
102 238 stefan
	<?php
103
	// Get page list from database
104
	$database = new database();
105
	if(PAGE_TRASH != 'inline') {
106
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
107
	} else {
108
		$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
109
	}
110
	$get_pages = $database->query($query);
111
112
	// Insert values into main page list
113
	if($get_pages->numRows() > 0)	{
114
		while($page = $get_pages->fetchRow()) {
115
			// Get user perms
116
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
117
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
118 546 doc
119
			$in_group = FALSE;
120
			foreach($admin->get_groups_id() as $cur_gid){
121
			    if (in_array($cur_gid, $admin_groups)) {
122
			        $in_group = TRUE;
123
			    }
124
			}
125
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
126 238 stefan
				if($page['visibility'] == 'deleted') {
127
					if(PAGE_TRASH == 'inline') {
128
						$can_modify = true;
129
						$editable_pages = $editable_pages+1;
130
					} else {
131
						$can_modify = false;
132
					}
133
				} elseif($page['visibility'] != 'deleted') {
134
					$can_modify = true;
135
					$editable_pages = $editable_pages+1;
136
				}
137
			} else {
138 537 doc
				if($page['visibility'] == 'private') {
139
					continue;
140
				}
141
				else {
142
					$can_modify = false;
143
				}
144 238 stefan
			}
145
146
			// Work out if we should show a plus or not
147
			if(PAGE_TRASH != 'inline') {
148
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
149
			} else {
150
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
151
			}
152
			if($get_page_subs->numRows() > 0) {
153
				$display_plus = true;
154
			} else {
155
				$display_plus = false;
156
			}
157
158
			// Work out how many pages there are for this parent
159
			$num_pages = $get_pages->numRows();
160
			?>
161
162
			<li id="p<?php echo $page['parent']; ?>" style="padding: 2px 0px 2px 0px;">
163 686 doc
			<table width="720" cellpadding="1" cellspacing="0" border="0" style="background-color: #ECF3F7;">
164 693 doc
			<tr onmouseover="this.style.backgroundColor = '#F1F8DD'" onmouseout="this.style.backgroundColor = '#ECF3F7'">
165 238 stefan
				<td width="20" style="padding-left: <?php echo $page['level']*20; ?>px;">
166
					<?php
167
					if($display_plus == true) {
168
					?>
169
					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
170 557 thorn
						<img src="<?php echo ADMIN_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="+" />
171 238 stefan
					</a>
172
					<?php
173
					}
174
					?>
175
				</td>
176
				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
177
				<td>
178 529 doc
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
179
						<?php if($page['visibility'] == 'public') { ?>
180
							<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" align="left" style="margin-right: 5px" />
181
						<?php } elseif($page['visibility'] == 'private') { ?>
182
							<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" align="left" style="margin-right: 5px" />
183
						<?php } elseif($page['visibility'] == 'registered') { ?>
184
							<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" align="left" style="margin-right: 5px" />
185
						<?php } elseif($page['visibility'] == 'hidden') { ?>
186
							<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" border="0" align="left" style="margin-right: 5px" />
187
						<?php } elseif($page['visibility'] == 'none') { ?>
188
							<img src="<?php echo ADMIN_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" align="left" style="margin-right: 5px" />
189
						<?php } elseif($page['visibility'] == 'deleted') { ?>
190
							<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" align="left" style="margin-right: 5px" />
191
						<?php }
192
						echo ($page['page_title']); ?>
193
					</a>
194 238 stefan
				</td>
195
				<?php } else { ?>
196
				<td>
197 529 doc
					<?php if($page['visibility'] == 'public') { ?>
198
						<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" align="left" style="margin-right: 5px" />
199
					<?php } elseif($page['visibility'] == 'private') { ?>
200
						<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" align="left" style="margin-right: 5px" />
201
					<?php } elseif($page['visibility'] == 'registered') { ?>
202
						<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" align="left" style="margin-right: 5px" />
203
					<?php } elseif($page['visibility'] == 'hidden') { ?>
204
						<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" border="0" align="left" style="margin-right: 5px" />
205
					<?php } elseif($page['visibility'] == 'none') { ?>
206
						<img src="<?php echo ADMIN_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" align="left" style="margin-right: 5px" />
207
					<?php } elseif($page['visibility'] == 'deleted') { ?>
208
						<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" align="left" style="margin-right: 5px" />
209
					<?php }
210
					echo ($page['page_title']); ?>
211 238 stefan
				</td>
212
				<?php } ?>
213 584 doc
				<td align="left" width="252">
214 442 Ruebenwurz
					<font color="#999999"><?php echo ($page['menu_title']); ?></font>
215 238 stefan
				</td>
216 529 doc
				<td width="20">
217
					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
218
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
219
						<img src="<?php echo ADMIN_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
220
					</a>
221
					<?php } ?>
222 238 stefan
				</td>
223
				<td width="20">
224
					<?php if($page['visibility'] != 'deleted') { ?>
225
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
226
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
227
							<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
228
						</a>
229
						<?php } ?>
230
					<?php } else { ?>
231
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
232
							<img src="<?php echo ADMIN_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
233
						</a>
234
					<?php } ?>
235
				</td>
236 584 doc
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
237 238 stefan
				<td width="20">
238 552 thorn
				<?php
239
				// Work-out if we should show the "manage dates" link
240
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true) {
241
					$query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
242
					if($query_sections->numRows() > 0) {
243
						$mdate_display=false;
244
						while($mdate_res = $query_sections->fetchRow()) {
245
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0') {
246
								$mdate_display=true;
247
								break;
248
							}
249
						}
250
						if($mdate_display==1) {
251
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
252
							?>
253
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
254
							<img src="<?php echo ADMIN_URL."/images/$file"; ?>" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
255
							</a>
256
						<?php } else { ?>
257 584 doc
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
258
							<img src="<?php echo ADMIN_URL; ?>/images/noclock_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
259 552 thorn
						<?php } ?>
260
					<?php } ?>
261
				<?php } ?>
262
				</td>
263
				<td width="20">
264 238 stefan
				<?php if($page['position'] != 1) { ?>
265
					<?php if($page['visibility'] != 'deleted') { ?>
266
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
267
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
268
							<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" />
269
						</a>
270
						<?php } ?>
271
					<?php } ?>
272
				<?php } ?>
273
				</td>
274
				<td width="20">
275
				<?php if($page['position'] != $num_pages) { ?>
276
					<?php if($page['visibility'] != 'deleted') { ?>
277
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
278
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
279
							<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" border="0" alt="v" />
280
						</a>
281
						<?php } ?>
282
					<?php } ?>
283
				<?php } ?>
284
				</td>
285
				<td width="20">
286
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
287
					<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']; ?>">
288
						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
289
					</a>
290
					<?php } ?>
291
				</td>
292
			</tr>
293
			</table>
294
			</li>
295
296
			<?php
297
			// Get subs
298
			$editable_pages=make_list($page['page_id'], $editable_pages);
299
		}
300
301
	}
302
	?>
303
	</ul>
304
	<?php
305
	return $editable_pages;
306
}
307
308
// Generate pages list
309
if($admin->get_permission('pages_view') == true) {
310
	?>
311
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
312
	<tr>
313
		<td>
314
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
315
		</td>
316
		<td align="right">
317
			<?php
318
				// Check if there are any pages that are in trash, and if we should show a link to the trash page
319
				if(PAGE_TRASH == 'separate') {
320
					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
321
					if($query_trash->numRows() > 0) {
322
						?>
323
						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
324
						<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
325
						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
326
						<?php
327
					}
328
				}
329
			?>
330
		</td>
331
	</tr>
332
	</table>
333
	<div class="pages_list">
334 584 doc
	<table cellpadding="0" cellspacing="0" width="720px" border="0">
335 238 stefan
	<tr>
336 584 doc
		<td width="20px">
337 238 stefan
			&nbsp;
338
		</td>
339 584 doc
		<td width="314px">
340 529 doc
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['PAGE_TITLE']; ?>:
341 238 stefan
		</td>
342 584 doc
		<td width="256px" align="left">
343 238 stefan
			<?php echo $TEXT['MENU_TITLE']; ?>:
344
		</td>
345 584 doc
		<td width="130px" align="center">
346 238 stefan
			<?php echo $TEXT['ACTIONS']; ?>:
347
		</td>
348
	</tr>
349
	</table>
350
	<?php
351
	$editable_pages = make_list(0, 0);
352
	?>
353
	</div>
354
	<div class="empty_list">
355
		<?php echo $TEXT['NONE_FOUND']; ?>
356
	</div>
357
	<?php
358
} else {
359
	$editable_pages = 0;
360
}
361
362
// Setup template object
363
$template = new Template(ADMIN_PATH.'/pages');
364
$template->set_file('page', 'template.html');
365
$template->set_block('page', 'main_block', 'main');
366
367
// Figure out if the no pages found message should be shown or not
368
if($editable_pages == 0) {
369
	?>
370
	<style type="text/css">
371
	.pages_list {
372
		display: none;
373
	}
374
	</style>
375
	<?php
376
} else {
377
	?>
378
	<style type="text/css">
379
	.empty_list {
380
		display: none;
381
	}
382
	</style>
383
	<?php
384
}
385
386
// Insert values into the add page form
387
388
// Group list 1
389 546 doc
390
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
391
392 238 stefan
	$get_groups = $database->query($query);
393
	$template->set_block('main_block', 'group_list_block', 'group_list');
394
	// Insert admin group and current group first
395
	$admin_group_name = $get_groups->fetchRow();
396
	$template->set_var(array(
397
									'ID' => 1,
398
									'TOGGLE' => '',
399
									'DISABLED' => ' disabled',
400
									'LINK_COLOR' => '000000',
401
									'CURSOR' => 'default',
402
									'NAME' => $admin_group_name['name'],
403
									'CHECKED' => ' checked'
404
									)
405
							);
406
	$template->parse('group_list', 'group_list_block', true);
407 546 doc
408 238 stefan
	while($group = $get_groups->fetchRow()) {
409 546 doc
		// check if the user is a member of this group
410
		$flag_disabled = '';
411
		$flag_checked =  '';
412
		$flag_cursor =   'pointer';
413
		$flag_color =    '';
414
		if (in_array($group["group_id"], $admin->get_groups_id())) {
415 733 thorn
			$flag_disabled = ''; //' disabled';
416 546 doc
			$flag_checked =  ' checked';
417
			$flag_cursor =   'default';
418
			$flag_color =    '000000';
419
		}
420
421 238 stefan
		// Check if the group is allowed to edit pages
422
		$system_permissions = explode(',', $group['system_permissions']);
423
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
424
			$template->set_var(array(
425
											'ID' => $group['group_id'],
426
											'TOGGLE' => $group['group_id'],
427 546 doc
											'CHECKED' => $flag_checked,
428
											'DISABLED' => $flag_disabled,
429
											'LINK_COLOR' => $flag_color,
430
											'CURSOR' => $flag_checked,
431 238 stefan
											'NAME' => $group['name'],
432
											)
433
									);
434
			$template->parse('group_list', 'group_list_block', true);
435
		}
436
	}
437
// Group list 2
438 546 doc
439
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
440
441 238 stefan
	$get_groups = $database->query($query);
442
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
443
	// Insert admin group and current group first
444
	$admin_group_name = $get_groups->fetchRow();
445
	$template->set_var(array(
446
									'ID' => 1,
447
									'TOGGLE' => '',
448
									'DISABLED' => ' disabled',
449
									'LINK_COLOR' => '000000',
450
									'CURSOR' => 'default',
451
									'NAME' => $admin_group_name['name'],
452
									'CHECKED' => ' checked'
453
									)
454
							);
455
	$template->parse('group_list2', 'group_list_block2', true);
456 546 doc
457 238 stefan
	while($group = $get_groups->fetchRow()) {
458 546 doc
		// check if the user is a member of this group
459
		$flag_disabled = '';
460
		$flag_checked =  '';
461
		$flag_cursor =   'pointer';
462
		$flag_color =    '';
463
		if (in_array($group["group_id"], $admin->get_groups_id())) {
464 733 thorn
			$flag_disabled = ''; //' disabled';
465 546 doc
			$flag_checked =  ' checked';
466
			$flag_cursor =   'default';
467
			$flag_color =    '000000';
468
		}
469
470 238 stefan
		$template->set_var(array(
471
										'ID' => $group['group_id'],
472
										'TOGGLE' => $group['group_id'],
473 546 doc
										'CHECKED' => $flag_checked,
474
										'DISABLED' => $flag_disabled,
475
										'LINK_COLOR' => $flag_color,
476
										'CURSOR' => $flag_cursor,
477 238 stefan
										'NAME' => $group['name'],
478
										)
479
								);
480
		$template->parse('group_list2', 'group_list_block2', true);
481
	}
482
483
// Parent page list
484
$database = new database();
485
function parent_list($parent) {
486
	global $admin, $database, $template;
487
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
488
	$get_pages = $database->query($query);
489
	while($page = $get_pages->fetchRow()) {
490 650 thorn
		if($admin->page_is_visible($page)==false)
491
			continue;
492 238 stefan
		// Stop users from adding pages with a level of more than the set page level limit
493
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
494
			// Get user perms
495
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
496
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
497 546 doc
498
			$in_group = FALSE;
499
			foreach($admin->get_groups_id() as $cur_gid){
500
			    if (in_array($cur_gid, $admin_groups)) {
501
			        $in_group = TRUE;
502
			    }
503
			}
504
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
505 238 stefan
				$can_modify = true;
506
			} else {
507
				$can_modify = false;
508
			}
509
			// Title -'s prefix
510
			$title_prefix = '';
511
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
512
				$template->set_var(array(
513
												'ID' => $page['page_id'],
514 442 Ruebenwurz
												'TITLE' => ($title_prefix.$page['page_title'])
515 238 stefan
												)
516
										);
517
				if($can_modify == true) {
518
					$template->set_var('DISABLED', '');
519
				} else {
520 398 Ruebenwurz
					$template->set_var('DISABLED', ' disabled="disabled" style="color: #aaa;"');
521 238 stefan
				}
522
				$template->parse('page_list2', 'page_list_block2', true);
523
		}
524
		parent_list($page['page_id']);
525
	}
526
}
527
$template->set_block('main_block', 'page_list_block2', 'page_list2');
528
if($admin->get_permission('pages_add_l0') == true) {
529
	$template->set_var(array(
530
									'ID' => '0',
531
									'TITLE' => $TEXT['NONE'],
532
									'SELECTED' => ' selected',
533
									'DISABLED' => ''
534
									)
535
							);
536
	$template->parse('page_list2', 'page_list_block2', true);
537
}
538
parent_list(0);
539
540
// Explode module permissions
541
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
542
// Modules list
543
$template->set_block('main_block', 'module_list_block', 'module_list');
544 384 Ruebenwurz
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
545 238 stefan
if($result->numRows() > 0) {
546
	while ($module = $result->fetchRow()) {
547
		// Check if user is allowed to use this module
548
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
549
			$template->set_var('VALUE', $module['directory']);
550
			$template->set_var('NAME', $module['name']);
551
			if($module['directory'] == 'wysiwyg') {
552
				$template->set_var('SELECTED', ' selected');
553
			} else {
554
				$template->set_var('SELECTED', '');
555
			}
556
			$template->parse('module_list', 'module_list_block', true);
557
		}
558
	}
559
}
560
561
// Insert language headings
562
$template->set_var(array(
563
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
564
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
565
								)
566
						);
567
// Insert language text and messages
568
$template->set_var(array(
569
								'TEXT_TITLE' => $TEXT['TITLE'],
570
								'TEXT_TYPE' => $TEXT['TYPE'],
571
								'TEXT_PARENT' => $TEXT['PARENT'],
572
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
573
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
574
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
575
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
576
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
577
								'TEXT_NONE' => $TEXT['NONE'],
578
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
579
								'TEXT_ADD' => $TEXT['ADD'],
580
								'TEXT_RESET' => $TEXT['RESET'],
581
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
582
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
583
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
584
								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
585
								)
586
						);
587
588
// Insert permissions values
589
if($admin->get_permission('pages_add') != true) {
590
	$template->set_var('DISPLAY_ADD', 'hide');
591
} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
592
	$template->set_var('DISPLAY_ADD', 'hide');
593
}
594
if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
595
	$template->set_var('DISPLAY_INTRO', 'hide');
596
}
597
598
599
// Parse template object
600
$template->parse('main', 'main_block', false);
601
$template->pparse('output', 'page');
602
603
// Print admin
604
$admin->print_footer();
605
606 552 thorn
?>