Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2011, Website Baker Org. e.V.
9
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12
 * @requirements    PHP 5.2.2 and higher
13
 * @version         $Id: index.php 1357 2010-12-27 19:50:23Z FrankH $
14
 * @filesource		$HeadURL:  $
15
 * @lastmodified    $Date:  $
16
 *
17
 */
18

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

    
23
$ftan = $admin->getFTAN(2);
24

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

    
32

    
33
function make_list($parent, $editable_pages) {
34
	// Get objects and vars from outside this function
35
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $page_tmp_id;
36
	?>
37
	<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"'; }} ?>>
38
	<?php
39
	// $database = new database();
40

    
41
	// Get page list from database
42
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
43
    $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
44
    $sql .= 'ORDER BY `position` ASC';
45
	$get_pages = $database->query($sql);
46
/*
47
	if(PAGE_TRASH != 'inline')
48
    {
49
		$sql = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
50
	} else {
51
		$sql = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
52
	}
53
*/
54
	// Insert values into main page list
55
	if($get_pages->numRows() > 0) {
56
		while($page = $get_pages->fetchRow()) {
57
			// Get user perms
58
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
59
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
60
			$in_group = FALSE;
61
			foreach($admin->get_groups_id() as $cur_gid)
62
            {
63
				if (in_array($cur_gid, $admin_groups))
64
                {
65
					$in_group = TRUE;
66
				}
67
			}
68
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users)))
69
            {
70
				if($page['visibility'] == 'deleted')
71
                {
72
					if(PAGE_TRASH == 'inline')
73
                    {
74
						$can_modify = true;
75
						$editable_pages = $editable_pages+1;
76
					} else {
77
						$can_modify = false;
78
					}
79
				} elseif($page['visibility'] != 'deleted')
80
                {
81
					$can_modify = true;
82
					$editable_pages = $editable_pages+1;
83
				}
84
			} else {
85
				if($page['visibility'] == 'private')
86
                {
87
					continue;
88
				}
89
				else {
90
					$can_modify = false;
91
				}
92
			}
93
			// Work out if we should show a plus or not
94
            $sql = 'SELECT `page_id`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$page['page_id'].' ';
95
            $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
96
            // $sql .= ' ORDER BY `position` ASC';
97
        	$get_page_subs = $database->query($sql);
98
/*
99
			if(PAGE_TRASH != 'inline')
100
            {
101
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
102
			} else {
103
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
104
			}
105
*/
106
			if($get_page_subs->numRows() > 0)
107
            {
108
				$display_plus = true;
109
			} else {
110
				$display_plus = false;
111
			}
112
			// Work out how many pages there are for this parent
113
			$num_pages = $get_pages->numRows();
114
			?>
115
			<li class="p<?php echo $page['parent']; ?>">
116
			<table class="pages_view" border="0" cellpadding="0" cellspacing="0">
117
			<tr>
118
				<td valign="middle" width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
119
					<?php
120
					if($display_plus == true) {
121
					?>
122
					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
123
						<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="+" />
124
					</a>
125
					<?php
126
					}
127
					?>
128
				</td>
129
				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
130
				<td class="list_menu_title">
131
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']."&amp;$ftan"; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
132
						<?php if($page['visibility'] == 'public') { ?>
133
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
134
						<?php } elseif($page['visibility'] == 'private') { ?>
135
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
136
						<?php } elseif($page['visibility'] == 'registered') { ?>
137
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
138
						<?php } elseif($page['visibility'] == 'hidden') { ?>
139
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
140
						<?php } elseif($page['visibility'] == 'none') { ?>
141
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
142
						<?php } elseif($page['visibility'] == 'deleted') { ?>
143
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
144
						<?php }
145
						echo '<span class="modify_link">'.($page['menu_title']).'</span>'; ?>
146
					</a>
147
				</td>
148
				<?php } else { ?>
149
				<td class="list_menu_title">
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 ($page['menu_title']); ?>
164
				</td>
165
				<?php } ?>
166
				<td class="list_page_title">
167
					<?php echo ($page['page_title']); ?>
168
				</td>
169
				<td class="list_page_id">
170
					<?php echo $page['page_id']; ?>
171
				</td>
172
				<td class="list_actions">
173
					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
174
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
175
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
176
					</a>
177
					<?php } ?>
178
				</td>
179
				<td class="list_actions">
180
					<?php if($page['visibility'] != 'deleted') { ?>
181
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
182
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']."&amp;$ftan"; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
183
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
184
						</a>
185
						<?php } ?>
186
					<?php } else { ?>
187
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']."&amp;$ftan"; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
188
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
189
						</a>
190
					<?php } ?>
191
				</td>
192
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
193
				<td class="list_actions">
194
				<?php
195
				// Work-out if we should show the "manage dates" link
196
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true)
197
                {
198

    
199
                    $sql = 'SELECT `publ_start`, `publ_end` FROM `'.TABLE_PREFIX.'sections` ';
200
                    $sql .= 'WHERE `page_id` = '.$page['page_id'].' AND `module` != \'menu_link\' ';
201
                    $query_sections = $database->query($sql);
202

    
203
					// $query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
204

    
205
					if($query_sections->numRows() > 0)
206
                    {
207
						$mdate_display=false;
208
						while($mdate_res = $query_sections->fetchRow())
209
                        {
210
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
211
                            {
212
								$mdate_display=true;
213
								break;
214
							}
215
						}
216
						if($mdate_display==1)
217
                        {
218
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
219
							?>
220
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']."&amp;$ftan"; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
221
							<img src="<?php echo THEME_URL."/images/$file"; ?>" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
222
							</a>
223
						<?php } else { ?>
224
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']."&amp;$ftan"; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
225
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
226
						<?php } ?>
227
					<?php } ?>
228
				<?php } ?>
229
				</td>
230
				<td class="list_actions">
231
				<?php if($page['position'] != 1) { ?>
232
					<?php if($page['visibility'] != 'deleted') { ?>
233
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
234
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']."&amp;$ftan"; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
235
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="<?php echo $TEXT['MOVE_UP']; ?>" />
236
						</a>
237
						<?php } ?>
238
					<?php } ?>
239
				<?php } ?>
240
				</td>
241
				<td class="list_actions">
242
				<?php if($page['position'] != $num_pages) { ?>
243
					<?php if($page['visibility'] != 'deleted') { ?>
244
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
245
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']."&amp;$ftan"; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
246
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="<?php echo $TEXT['MOVE_DOWN']; ?>" />
247
						</a>
248
						<?php } ?>
249
					<?php } ?>
250
				<?php } ?>
251
				</td>
252
				<td class="list_actions">
253
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
254
					<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']."&amp;$ftan"; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
255
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="<?php echo $TEXT['DELETE']; ?>" />
256
					</a>
257
					<?php } ?>
258
				</td>
259
				<?php
260
				// eggsurplus: Add action to add a page as a child
261
				?>
262
				<td class="list_actions">
263
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
264
					<a href="javascript:add_child_page('<?php echo $page['page_id']; ?>');" title="<?php echo $HEADING['ADD_PAGE']; ?>">
265
						<img src="<?php echo THEME_URL; ?>/images/siteadd.png" name="addpage_<?php echo $page['page_id']; ?>" border="0" alt="Add Child Page" />
266
					</a>
267
					<?php } ?>
268
				</td>
269
				<?php
270
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
271
				?>
272

    
273
			</tr>
274
			</table>
275
			</li>
276
			<?php
277
			if ( $page['parent'] = 0)
278
            {
279
				$page_tmp_id = $page['page_id'];
280
			}
281
			// Get subs
282
			$editable_pages=make_list($page['page_id'], $editable_pages);
283
		}
284
	}
285
	?>
286
	</ul>
287
	<?php
288
	return $editable_pages;
289
}
290

    
291
// Generate pages list
292
if($admin->get_permission('pages_view') == true) {
293
	?>
294
	<div class="jsadmin hide"></div>
295
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
296
	<tr>
297
		<td>
298
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
299
		</td>
300
		<td align="right">
301
			<?php
302
				// Check if there are any pages that are in trash, and if we should show a link to the trash page
303
				if(PAGE_TRASH == 'separate') {
304
					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
305
					if($query_trash->numRows() > 0) {
306
						?>
307
						<a href="<?php echo ADMIN_URL."/pages/trash.php?$ftan"; ?>">
308
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
309
						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
310
						<?php
311
					}
312
				}
313
			?>
314
		</td>
315
	</tr>
316
	</table>
317
	<div class="pages_list">
318
	<table cellpadding="0" cellspacing="0" border="0">
319
	<tr>
320
		<td class="header_list_menu_title">
321
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE']; ?>:
322
		</td>
323
		<td class="header_list_page_title">
324
			<?php echo $TEXT['PAGE_TITLE']; ?>:
325
		</td>
326
		<td class="header_list_page_id">
327
			ID:
328
		</td>		
329
		<td class="header_list_actions">
330
			<?php echo $TEXT['ACTIONS']; ?>:
331
		</td>
332
	</tr>
333
	</table>
334
	<?php
335
    // Work-out if we should check for existing page_code
336
    $field_sql = $database->query("DESCRIBE ".TABLE_PREFIX."pages page_code");
337
    $field_set = $field_sql->numRows();
338

    
339
	$page_tmp_id = 0;
340
	$editable_pages = make_list(0, 0);
341
	?>
342
	</div>
343
	<div class="empty_list">
344
		<?php echo $TEXT['NONE_FOUND']; ?>
345
	</div>
346
	<?php
347
} else {
348
	$editable_pages = 0;
349
}
350

    
351
// Setup template object
352
$template = new Template(THEME_PATH.'/templates');
353
$template->set_file('page', 'pages.htt');
354
$template->set_block('page', 'main_block', 'main');
355
$template->set_var('FTAN', $admin->getFTAN());
356

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

    
376
// Insert values into the add page form
377

    
378
// Group list 1
379

    
380
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
381
	$get_groups = $database->query($query);
382
	$template->set_block('main_block', 'group_list_block', 'group_list');
383
	// Insert admin group and current group first
384
	$admin_group_name = $get_groups->fetchRow();
385
	$template->set_var(array(
386
									'ID' => 1,
387
									'TOGGLE' => '',
388
									'DISABLED' => ' disabled="disabled"',
389
									'LINK_COLOR' => '000000',
390
									'CURSOR' => 'default',
391
									'NAME' => $admin_group_name['name'],
392
									'CHECKED' => ' checked="checked"'
393
									)
394
							);
395
	$template->parse('group_list', 'group_list_block', true);
396

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

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

    
428
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
429

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

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

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

    
472

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

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

    
559
// Insert urls
560
$template->set_var(array(
561
								'THEME_URL' => THEME_URL,
562
								'WB_URL' => WB_URL,
563
								'WB_PATH' => WB_PATH,
564
								'ADMIN_URL' => ADMIN_URL,
565
								)
566
						);
567

    
568
// Insert language headings
569
$template->set_var(array(
570
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
571
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
572
								)
573
						);
574
// Insert language text and messages
575
$template->set_var(array(
576
								'TEXT_TITLE' => $TEXT['TITLE'],
577
								'TEXT_TYPE' => $TEXT['TYPE'],
578
								'TEXT_PARENT' => $TEXT['PARENT'],
579
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
580
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
581
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
582
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
583
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
584
								'TEXT_NONE' => $TEXT['NONE'],
585
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
586
								'TEXT_ADD' => $TEXT['ADD'],
587
								'TEXT_RESET' => $TEXT['RESET'],
588
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
589
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
590
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
591
								'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
592
								)
593
						);
594

    
595
// Insert permissions values
596
if($admin->get_permission('pages_add') != true) {
597
	$template->set_var('DISPLAY_ADD', 'hide');
598
} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
599
	$template->set_var('DISPLAY_ADD', 'hide');
600
}
601
if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
602
	$template->set_var('DISPLAY_INTRO', 'hide');
603
}
604

    
605

    
606
// Parse template object
607
$template->parse('main', 'main_block', false);
608
$template->pparse('output', 'page');
609

    
610
// Print admin 
611
$admin->print_footer();
612

    
613
?>
(5-5/21)