Project

General

Profile

1 1358 Luisehahne
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8 1373 Luisehahne
 * @copyright       2009-2011, Website Baker Org. e.V.
9 1358 Luisehahne
 * @link			http://www.websitebaker2.org/
10
 * @license         http://www.gnu.org/licenses/gpl.html
11
 * @platform        WebsiteBaker 2.8.x
12 1373 Luisehahne
 * @requirements    PHP 5.2.2 and higher and higher
13 1358 Luisehahne
 * @version         $Id$
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 1402 Luisehahne
23
$admin->clearIDKEY();
24
25 1358 Luisehahne
// 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
urlencode function and rawurlencode are mostly based on RFC 1738.
33
However, since 2005 the current RFC in use for URIs standard is RFC 3986.
34
Here is a function to encode URLs according to RFC 3986.
35
*/
36
function url_encode($string) {
37
    $string = html_entity_decode($string,ENT_QUOTES,'UTF-8');
38
    $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
39
    $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
40
    return str_replace($entities, $replacements, rawurlencode($string));
41
}
42
// fixes A URI contains impermissible characters or quotes around the URI are not closed.
43 1428 Luisehahne
$MESSAGE['PAGES_DELETE_CONFIRM'] = url_encode(  $MESSAGE['PAGES_DELETE_CONFIRM'] );
44 1358 Luisehahne
45
function set_node ($parent,& $par)
46
{
47
    $retval = '';
48
49
	if($par['num_subs'] )
50
	{
51
    $retval .= "\n".'<ul id="p'.$parent.'"';
52
	if ($parent != 0)
53
	{
54
		$retval .= ' class="page_list"';
55
		if (isset ($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1')
56
		{
57
			 $retval .= ' style="display:block"';
58
		}
59
	}
60
	$retval .= ">\n";
61
 	}
62
63
	return $retval;
64
}
65
66
function make_list($parent = 0, $editable_pages = 0) {
67
	// Get objects and vars from outside this function
68
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $par;
69
70
    print set_node ($parent,$par);
71
72
	// Get page list from database
73
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
74
    $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
75
    $sql .= 'ORDER BY `position` ASC';
76
	$get_pages = $database->query($sql);
77
78
	// Insert values into main page list
79
	if($get_pages->numRows() > 0)
80
	{
81
		while($page = $get_pages->fetchRow())
82
		{
83
			// Get user perms
84
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
85
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
86
			$in_group = FALSE;
87
			foreach($admin->get_groups_id() as $cur_gid)
88
            {
89
				if (in_array($cur_gid, $admin_groups))
90
                {
91
					$in_group = TRUE;
92
				}
93
			}
94
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users)))
95
            {
96
				if($page['visibility'] == 'deleted')
97
                {
98
					if(PAGE_TRASH == 'inline')
99
                    {
100
						$can_modify = true;
101
						$editable_pages = $editable_pages+1;
102
					} else {
103
						$can_modify = false;
104
					}
105
				} elseif($page['visibility'] != 'deleted')
106
                {
107
					$can_modify = true;
108
					$editable_pages = $editable_pages+1;
109
				}
110
			} else {
111
				if($page['visibility'] == 'private')
112
                {
113
					continue;
114
				}
115
				else {
116
					$can_modify = false;
117
				}
118
			}
119
120
			// Work out if we should show a plus or not
121
            $sql = 'SELECT `page_id`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$page['page_id'].' ';
122
            $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
123
            // $sql .= ' ORDER BY `position` ASC';
124
        	$get_page_subs = $database->query($sql);
125
			$num_subs = $get_page_subs->numRows();
126
			$par['num_subs'] = $num_subs;
127
/*
128
			if(PAGE_TRASH != 'inline')
129
            {
130
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
131
			} else {
132
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
133
			}
134
*/
135
			if($get_page_subs->numRows() > 0)
136
            {
137
				$display_plus = true;
138
			} else {
139
				$display_plus = false;
140
			}
141
			// Work out how many pages there are for this parent
142
			$num_pages = $get_pages->numRows();
143
			?>
144
			<li class="p<?php echo $page['parent']; ?>">
145
			<table summary="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>" class="pages_view" cellpadding="0" cellspacing="0">
146
			<tr>
147
				<td valign="middle" width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
148
					<?php
149
					if($display_plus == true) {
150
					?>
151
					<a href="javascript:toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
152
						<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="+" />
153
					</a>
154
					<?php
155
					}
156
					?>
157
				</td>
158
				<?php if($admin->get_permission('pages_modify') == true && $can_modify == true) { ?>
159
				<td class="list_menu_title">
160 1404 Luisehahne
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo  $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
161 1358 Luisehahne
						<?php if($page['visibility'] == 'public') { ?>
162
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
163
						<?php } elseif($page['visibility'] == 'private') { ?>
164
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
165
						<?php } elseif($page['visibility'] == 'registered') { ?>
166
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
167
						<?php } elseif($page['visibility'] == 'hidden') { ?>
168
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
169
						<?php } elseif($page['visibility'] == 'none') { ?>
170
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
171
						<?php } elseif($page['visibility'] == 'deleted') { ?>
172
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
173
						<?php }
174
						echo '<span class="modify_link">'.($page['menu_title']).'</span>'; ?>
175
					</a>
176
				</td>
177
				<?php } else { ?>
178
				<td class="list_menu_title">
179
					<?php if($page['visibility'] == 'public') { ?>
180
						<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
181
					<?php } elseif($page['visibility'] == 'private') { ?>
182
						<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
183
					<?php } elseif($page['visibility'] == 'registered') { ?>
184
						<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
185
					<?php } elseif($page['visibility'] == 'hidden') { ?>
186
						<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
187
					<?php } elseif($page['visibility'] == 'none') { ?>
188
						<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
189
					<?php } elseif($page['visibility'] == 'deleted') { ?>
190
						<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
191
					<?php }
192
					echo ($page['menu_title']); ?>
193
				</td>
194
				<?php } ?>
195
				<td class="list_page_title">
196
					<?php echo ($page['page_title']); ?>
197
				</td>
198
				<td class="list_page_id">
199
					<?php echo $page['page_id']; ?>
200
				</td>
201
202
				<td class="list_actions">
203
					<?php if($page['visibility'] != 'deleted' && $page['visibility'] != 'none') { ?>
204
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
205
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" alt="<?php echo $TEXT['VIEW']; ?>" />
206
					</a>
207
					<?php } ?>
208
				</td>
209
				<td class="list_actions">
210
					<?php if($page['visibility'] != 'deleted') { ?>
211
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
212 1404 Luisehahne
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
213 1358 Luisehahne
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" alt="<?php echo $TEXT['SETTINGS']; ?>" />
214
						</a>
215
						<?php } ?>
216
					<?php } else { ?>
217 1404 Luisehahne
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
218 1358 Luisehahne
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" alt="<?php echo $TEXT['RESTORE']; ?>" />
219
						</a>
220
					<?php } ?>
221
				</td>
222
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
223
				<td class="list_actions">
224
				<?php
225
				// Work-out if we should show the "manage dates" link
226
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true)
227
                {
228
                    $sql = 'SELECT `publ_start`, `publ_end` FROM `'.TABLE_PREFIX.'sections` ';
229
                    $sql .= 'WHERE `page_id` = '.$page['page_id'].' AND `module` != \'menu_link\' ';
230
					// $query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
231 1416 Luisehahne
					if( ($query_sections = $database->query($sql)) )
232 1358 Luisehahne
                    {
233
						$mdate_display=false;
234
						while($mdate_res = $query_sections->fetchRow())
235
                        {
236
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
237
                            {
238
								$mdate_display=true;
239
								break;
240
							}
241
						}
242
						if($mdate_display==1)
243
                        {
244
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
245
							?>
246 1404 Luisehahne
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
247 1358 Luisehahne
							<img src="<?php echo THEME_URL."/images/$file"; ?>" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
248
							</a>
249
						<?php } else { ?>
250 1404 Luisehahne
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
251 1358 Luisehahne
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
252
						<?php } ?>
253
					<?php } ?>
254
				<?php } ?>
255
				</td>
256
				<td class="list_actions">
257
				<?php if($page['position'] != 1) { ?>
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_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" alt="<?php echo $TEXT['MOVE_UP']; ?>" />
262
						</a>
263
						<?php } ?>
264
					<?php } ?>
265
				<?php } ?>
266
				</td>
267
				<td class="list_actions">
268
				<?php if($page['position'] != $num_pages) { ?>
269
					<?php if($page['visibility'] != 'deleted') { ?>
270
						<?php if($admin->get_permission('pages_settings') == true && $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" alt="<?php echo $TEXT['MOVE_DOWN']; ?>" />
273
						</a>
274
						<?php } ?>
275
					<?php } ?>
276
				<?php } ?>
277
				</td>
278
				<td class="list_actions">
279 1402 Luisehahne
					<?php if($admin->get_permission('pages_delete') == true && $can_modify == true) { // add IdKey ?>
280 1404 Luisehahne
					<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']; ?>">
281 1358 Luisehahne
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['DELETE']; ?>" />
282
					</a>
283
					<?php } ?>
284
				</td>
285
				<?php
286
				// eggsurplus: Add action to add a page as a child
287
				?>
288
				<td class="list_actions">
289
					<?php if(($admin->get_permission('pages_add')) == (true && $can_modify == true) && ($page['visibility'] != 'deleted')) { ?>
290
					<a href="javascript:add_child_page('<?php echo $page['page_id']; ?>');" title="<?php echo $HEADING['ADD_PAGE']; ?>">
291
						<img src="<?php echo THEME_URL; ?>/images/siteadd.png" name="addpage_<?php echo $page['page_id']; ?>" alt="Add Child Page" />
292
					</a>
293
					<?php } ?>
294
				</td>
295
				<?php
296
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
297
				?>
298
299
			</tr>
300
			</table>
301
			<?php
302
			if ( $page['parent'] == 0)
303
            {
304
				$page_tmp_id = $page['page_id'];
305
			}
306
			// Get subs
307
			$editable_pages=make_list($page['page_id'], $editable_pages);
308
            print '</li>'."\n";
309
		}
310
	}
311
	$output = ($par['num_subs'] )? '</ul>'."\n" : '';
312
    $par['num_subs'] = (empty($output) ) ?  1 : $par['num_subs'];
313
    print $output;
314
	return $editable_pages;
315
}
316
317
// Generate pages list
318
if($admin->get_permission('pages_view') == true) {
319
	?>
320
	<div class="jsadmin hide"></div>
321
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0" width="100%">
322
	<tr>
323
		<td>
324
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
325
		</td>
326
		<td align="right"></td>
327
	</tr>
328
	</table>
329
	<div class="pages_list">
330
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0">
331
	<tr class="pages_list_header">
332
		<td class="header_list_menu_title">
333
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE']; ?>:
334
		</td>
335
		<td class="header_list_page_title">
336
			<?php echo $TEXT['PAGE_TITLE']; ?>:
337
		</td>
338
		<td class="header_list_page_id">
339
			ID:
340
		</td>
341
		<td class="header_list_actions">
342
			<?php echo $TEXT['ACTIONS']; ?>:
343
		</td>
344
	</tr>
345
	</table>
346
	<?php
347
    // Work-out if we should check for existing page_code
348
    $field_sql = $database->query("DESCRIBE ".TABLE_PREFIX."pages page_code");
349
    $field_set = $field_sql->numRows();
350
    $par = array();
351
	$par['num_subs'] = 1;
352
	$editable_pages = make_list(0, 0);
353
} else {
354
	$editable_pages = 0;
355
}
356
 ?></div><?php
357 1402 Luisehahne
358 1358 Luisehahne
if(intval($editable_pages) == 0 ) {
359
	?>
360
	<div class="empty_list">
361
		<?php echo $TEXT['NONE_FOUND']; ?>
362
	</div>
363
	<?php
364
}
365
// Setup template object
366
$template = new Template(THEME_PATH.'/templates');
367
$template->set_file('page', 'pages.htt');
368
$template->set_block('page', 'main_block', 'main');
369
// Insert values into the add page form
370
$template->set_var('FTAN', $admin->getFTAN());
371
372
// Group list 1
373
374
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
375
	$get_groups = $database->query($query);
376
	$template->set_block('main_block', 'group_list_block', 'group_list');
377
	// Insert admin group and current group first
378
	$admin_group_name = $get_groups->fetchRow();
379
	$template->set_var(array(
380
									'ID' => 1,
381
									'TOGGLE' => '1',
382
									'DISABLED' => ' disabled="disabled"',
383
									'LINK_COLOR' => '000000',
384
									'CURSOR' => 'default',
385
									'NAME' => $admin_group_name['name'],
386
									'CHECKED' => ' checked="checked"'
387
									)
388
							);
389
	$template->parse('group_list', 'group_list_block', true);
390
391
	while($group = $get_groups->fetchRow()) {
392
		// check if the user is a member of this group
393
		$flag_disabled = '';
394
		$flag_checked =  '';
395
		$flag_cursor =   'pointer';
396
		$flag_color =    '';
397
		if (in_array($group["group_id"], $admin->get_groups_id())) {
398
			$flag_disabled = ''; //' disabled';
399
			$flag_checked =  ' checked="checked"';
400
			$flag_cursor =   'default';
401
			$flag_color =    '000000';
402
		}
403
404
		// Check if the group is allowed to edit pages
405
		$system_permissions = explode(',', $group['system_permissions']);
406
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
407
			$template->set_var(array(
408
											'ID' => $group['group_id'],
409
											'TOGGLE' => $group['group_id'],
410
											'CHECKED' => $flag_checked,
411
											'DISABLED' => $flag_disabled,
412
											'LINK_COLOR' => $flag_color,
413
											'CURSOR' => $flag_checked,
414
											'NAME' => $group['name'],
415
											)
416
									);
417
			$template->parse('group_list', 'group_list_block', true);
418
		}
419
	}
420
// Group list 2
421
422
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
423
424
	$get_groups = $database->query($query);
425
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
426
	// Insert admin group and current group first
427
	$admin_group_name = $get_groups->fetchRow();
428
	$template->set_var(array(
429
									'ID' => 1,
430
									'TOGGLE' => '1',
431
									'DISABLED' => ' disabled="disabled"',
432
									'LINK_COLOR' => '000000',
433
									'CURSOR' => 'default',
434
									'NAME' => $admin_group_name['name'],
435
									'CHECKED' => ' checked="checked"'
436
									)
437
							);
438
	$template->parse('group_list2', 'group_list_block2', true);
439
440
	while($group = $get_groups->fetchRow()) {
441
		// check if the user is a member of this group
442
		$flag_disabled = '';
443
		$flag_checked =  '';
444
		$flag_cursor =   'pointer';
445
		$flag_color =    '';
446
		if (in_array($group["group_id"], $admin->get_groups_id())) {
447
			$flag_disabled = ''; //' disabled';
448
			$flag_checked =  ' checked="checked"';
449
			$flag_cursor =   'default';
450
			$flag_color =    '000000';
451
		}
452
453
		$template->set_var(array(
454
										'ID' => $group['group_id'],
455
										'TOGGLE' => $group['group_id'],
456
										'CHECKED' => $flag_checked,
457
										'DISABLED' => $flag_disabled,
458
										'LINK_COLOR' => $flag_color,
459
										'CURSOR' => $flag_cursor,
460
										'NAME' => $group['name'],
461
										)
462
								);
463
		$template->parse('group_list2', 'group_list_block2', true);
464
	}
465
466
467
// Parent page list
468
// $database = new database();
469
function parent_list($parent)
470
{
471
	global $admin, $database, $template, $field_set;
472
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
473
	$get_pages = $database->query($query);
474
	while($page = $get_pages->fetchRow()) {
475
		if($admin->page_is_visible($page)==false)
476
			continue;
477
		// if parent = 0 set flag_icon
478
		$template->set_var('FLAG_ROOT_ICON',' none ');
479
		if( $page['parent'] == 0 && $field_set) {
480
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
481
		}
482
		// Stop users from adding pages with a level of more than the set page level limit
483
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
484
			// Get user perms
485
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
486
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
487
488
			$in_group = FALSE;
489
			foreach($admin->get_groups_id() as $cur_gid) {
490
				if (in_array($cur_gid, $admin_groups)) {
491
					$in_group = TRUE;
492
				}
493
			}
494
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users))) {
495
				$can_modify = true;
496
			} else {
497
				$can_modify = false;
498
			}
499
			// Title -'s prefix
500
			$title_prefix = '';
501
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
502
				$template->set_var(array(
503
										'ID' => $page['page_id'],
504
										'TITLE' => ($title_prefix.$page['menu_title']),
505
										'MENU-TITLE' => ($title_prefix.$page['menu_title']),
506
										'PAGE-TITLE' => ($title_prefix.$page['page_title'])
507
										));
508
				if($can_modify == true) {
509
					$template->set_var('DISABLED', '');
510
				} else {
511
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
512
				}
513
				$template->parse('page_list2', 'page_list_block2', true);
514
		}
515
		parent_list($page['page_id']);
516
	}
517
}
518
$template->set_block('main_block', 'page_list_block2', 'page_list2');
519
if($admin->get_permission('pages_add_l0') == true) {
520
	$template->set_var(array(
521
									'ID' => '0',
522
									'TITLE' => $TEXT['NONE'],
523
									'SELECTED' => ' selected="selected"',
524
									'DISABLED' => ''
525
									)
526
							);
527
	$template->parse('page_list2', 'page_list_block2', true);
528
}
529
parent_list(0);
530
531
// Explode module permissions
532
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
533
// Modules list
534
$template->set_block('main_block', 'module_list_block', 'module_list');
535
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
536
if($result->numRows() > 0) {
537
	while ($module = $result->fetchRow()) {
538
		// Check if user is allowed to use this module
539
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
540
			$template->set_var('VALUE', $module['directory']);
541
			$template->set_var('NAME', $module['name']);
542
			if($module['directory'] == 'wysiwyg') {
543
				$template->set_var('SELECTED', ' selected="selected"');
544
			} else {
545
				$template->set_var('SELECTED', '');
546
			}
547
			$template->parse('module_list', 'module_list_block', true);
548
		}
549
	}
550
}
551
552
// Insert urls
553
$template->set_var(array(
554
								'THEME_URL' => THEME_URL,
555
								'WB_URL' => WB_URL,
556
								'WB_PATH' => WB_PATH,
557
								'ADMIN_URL' => ADMIN_URL,
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 && $editable_pages == 0) {
592
	$template->set_var('DISPLAY_ADD', 'hide');
593
}
594
if($admin->get_permission('pages_intro') != true || 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
// include the required file for Javascript admin
604
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
605
{
606
	include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
607
}
608
609
// Print admin
610
$admin->print_footer();
611
612 1009 Ruebenwurz
?>