Project

General

Profile

« Previous | Next » 

Revision 1358

Added by Dietmar almost 14 years ago

validation fixes in pages backend theme

View differences:

index.php
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$
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

  
1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          WebsiteBaker Project
7
 * @copyright       2004-2009, Ryan Djurovich
8
 * @copyright       2009-2010, 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 4.3.4 and higher
13
 * @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
// Include the WB functions file
23
require_once(WB_PATH.'/framework/functions.php');
24
// eggsurplus: add child pages for a specific page
25
?>
26
<script type="text/javascript" src="<?php print ADMIN_URL; ?>/pages/eggsurplus.js"></script>
27
<?php
28
/*
29
urlencode function and rawurlencode are mostly based on RFC 1738.
30
However, since 2005 the current RFC in use for URIs standard is RFC 3986.
31
Here is a function to encode URLs according to RFC 3986.
32
*/
33
function url_encode($string) {
34
    $string = html_entity_decode($string,ENT_QUOTES,'UTF-8');
35
    $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
36
    $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
37
    return str_replace($entities, $replacements, rawurlencode($string));
38
}
39
// fixes A URI contains impermissible characters or quotes around the URI are not closed.
40
$MESSAGE['PAGES_DELETE_CONFIRM'] = url_encode( ( $MESSAGE['PAGES_DELETE_CONFIRM']) );
41

  
42
function set_node ($parent,& $par)
43
{
44
    $retval = '';
45

  
46
	if($par['num_subs'] )
47
	{
48
    $retval .= "\n".'<ul id="p'.$parent.'"';
49
	if ($parent != 0)
50
	{
51
		$retval .= ' class="page_list"';
52
		if (isset ($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1')
53
		{
54
			 $retval .= ' style="display:block"';
55
		}
56
	}
57
	$retval .= ">\n";
58
 	}
59

  
60
	return $retval;
61
}
62

  
63
function make_list($parent = 0, $editable_pages = 0) {
64
	// Get objects and vars from outside this function
65
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $par;
66

  
67
    print set_node ($parent,$par);
68

  
69
	// $database = new database();
70

  
71
	// Get page list from database
72
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
73
    $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
74
    $sql .= 'ORDER BY `position` ASC';
75
	$get_pages = $database->query($sql);
76

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

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

  
201
				<td class="list_actions">
202
					<?php if($page['visibility'] != 'deleted' && $page['visibility'] != 'none') { ?>
203
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
204
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" alt="<?php echo $TEXT['VIEW']; ?>" />
205
					</a>
206
					<?php } ?>
207
				</td>
208
				<td class="list_actions">
209
					<?php if($page['visibility'] != 'deleted') { ?>
210
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
211
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
212
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" alt="<?php echo $TEXT['SETTINGS']; ?>" />
213
						</a>
214
						<?php } ?>
215
					<?php } else { ?>
216
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
217
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" alt="<?php echo $TEXT['RESTORE']; ?>" />
218
						</a>
219
					<?php } ?>
220
				</td>
221
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
222
				<td class="list_actions">
223
				<?php
224
				// Work-out if we should show the "manage dates" link
225
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true)
226
                {
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($sql);
231

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

  
234
					if($query_sections->numRows() > 0)
235
                    {
236
						$mdate_display=false;
237
						while($mdate_res = $query_sections->fetchRow())
238
                        {
239
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
240
                            {
241
								$mdate_display=true;
242
								break;
243
							}
244
						}
245
						if($mdate_display==1)
246
                        {
247
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
248
							?>
249
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
250
							<img src="<?php echo THEME_URL."/images/$file"; ?>" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
251
							</a>
252
						<?php } else { ?>
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 THEME_URL; ?>/images/noclock_16.png" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
255
						<?php } ?>
256
					<?php } ?>
257
				<?php } ?>
258
				</td>
259
				<td class="list_actions">
260
				<?php if($page['position'] != 1) { ?>
261
					<?php if($page['visibility'] != 'deleted') { ?>
262
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
263
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
264
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" alt="<?php echo $TEXT['MOVE_UP']; ?>" />
265
						</a>
266
						<?php } ?>
267
					<?php } ?>
268
				<?php } ?>
269
				</td>
270
				<td class="list_actions">
271
				<?php if($page['position'] != $num_pages) { ?>
272
					<?php if($page['visibility'] != 'deleted') { ?>
273
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) { ?>
274
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
275
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" alt="<?php echo $TEXT['MOVE_DOWN']; ?>" />
276
						</a>
277
						<?php } ?>
278
					<?php } ?>
279
				<?php } ?>
280
				</td>
281
				<td class="list_actions">
282
					<?php if($admin->get_permission('pages_delete') == true && $can_modify == true) { ?>
283
					<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']; ?>">
284
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['DELETE']; ?>" />
285
					</a>
286
					<?php } ?>
287
				</td>
288
				<?php
289
				// eggsurplus: Add action to add a page as a child
290
				?>
291
				<td class="list_actions">
292
					<?php if(($admin->get_permission('pages_add')) == (true && $can_modify == true) && ($page['visibility'] != 'deleted')) { ?>
293
					<a href="javascript:add_child_page('<?php echo $page['page_id']; ?>');" title="<?php echo $HEADING['ADD_PAGE']; ?>">
294
						<img src="<?php echo THEME_URL; ?>/images/siteadd.png" name="addpage_<?php echo $page['page_id']; ?>" alt="Add Child Page" />
295
					</a>
296
					<?php } ?>
297
				</td>
298
				<?php
299
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
300
				?>
301

  
302
			</tr>
303
			</table>
304
			<?php
305
			if ( $page['parent'] == 0)
306
            {
307
				$page_tmp_id = $page['page_id'];
308
			}
309
			// Get subs
310
			$editable_pages=make_list($page['page_id'], $editable_pages);
311
            print '</li>'."\n";
312
		}
313
	}
314
	$output = ($par['num_subs'] )? '</ul>'."\n" : '';
315
    $par['num_subs'] = (empty($output) ) ?  1 : $par['num_subs'];
316
    print $output;
317
	return $editable_pages;
318
}
319

  
320
// Generate pages list
321
if($admin->get_permission('pages_view') == true) {
322
	?>
323
	<div class="jsadmin hide"></div>
324
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0" width="100%">
325
	<tr>
326
		<td>
327
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
328
		</td>
329
		<td align="right"></td>
330
	</tr>
331
	</table>
332
	<div class="pages_list">
333
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE']; ?>" cellpadding="0" cellspacing="0">
334
	<tr class="pages_list_header">
335
		<td class="header_list_menu_title">
336
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE']; ?>:
337
		</td>
338
		<td class="header_list_page_title">
339
			<?php echo $TEXT['PAGE_TITLE']; ?>:
340
		</td>
341
		<td class="header_list_page_id">
342
			ID:
343
		</td>
344
		<td class="header_list_actions">
345
			<?php echo $TEXT['ACTIONS']; ?>:
346
		</td>
347
	</tr>
348
	</table>
349
	<?php
350
    // Work-out if we should check for existing page_code
351
    $field_sql = $database->query("DESCRIBE ".TABLE_PREFIX."pages page_code");
352
    $field_set = $field_sql->numRows();
353

  
354
    $par = array();
355
	$par['num_subs'] = 1;
356
	$editable_pages = make_list(0, 0);
357
} else {
358
	$editable_pages = 0;
359
}
360
 ?></div><?php
361
if(intval($editable_pages) == 0 ) {
362
	?>
363
	<div class="empty_list">
364
		<?php echo $TEXT['NONE_FOUND']; ?>
365
	</div>
366
	<?php
367
}
368
// Setup template object
369
$template = new Template(THEME_PATH.'/templates');
370
$template->set_file('page', 'pages.htt');
371
$template->set_block('page', 'main_block', 'main');
372
// Insert values into the add page form
373
$template->set_var('FTAN', $admin->getFTAN());
374

  
375
// Group list 1
376

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

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

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

  
425
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
426

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

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

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

  
469

  
470
// Parent page list
471
// $database = new database();
472
function parent_list($parent)
473
{
474
	global $admin, $database, $template, $field_set;
475
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
476
	$get_pages = $database->query($query);
477
	while($page = $get_pages->fetchRow()) {
478
		if($admin->page_is_visible($page)==false)
479
			continue;
480
		// if parent = 0 set flag_icon
481
		$template->set_var('FLAG_ROOT_ICON',' none ');
482
		if( $page['parent'] == 0 && $field_set) {
483
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
484
		}
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) || 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['menu_title']),
508
										'MENU-TITLE' => ($title_prefix.$page['menu_title']),
509
										'PAGE-TITLE' => ($title_prefix.$page['page_title'])
510
										));
511
				if($can_modify == true) {
512
					$template->set_var('DISABLED', '');
513
				} else {
514
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
515
				}
516
				$template->parse('page_list2', 'page_list_block2', true);
517
		}
518
		parent_list($page['page_id']);
519
	}
520
}
521
$template->set_block('main_block', 'page_list_block2', 'page_list2');
522
if($admin->get_permission('pages_add_l0') == true) {
523
	$template->set_var(array(
524
									'ID' => '0',
525
									'TITLE' => $TEXT['NONE'],
526
									'SELECTED' => ' selected="selected"',
527
									'DISABLED' => ''
528
									)
529
							);
530
	$template->parse('page_list2', 'page_list_block2', true);
531
}
532
parent_list(0);
533

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

  
555
// Insert urls
556
$template->set_var(array(
557
								'THEME_URL' => THEME_URL,
558
								'WB_URL' => WB_URL,
559
								'WB_PATH' => WB_PATH,
560
								'ADMIN_URL' => ADMIN_URL,
561
								)
562
						);
563

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

  
591
// Insert permissions values
592
if($admin->get_permission('pages_add') != true) {
593
	$template->set_var('DISPLAY_ADD', 'hide');
594
} elseif($admin->get_permission('pages_add_l0') != true && $editable_pages == 0) {
595
	$template->set_var('DISPLAY_ADD', 'hide');
596
}
597
if($admin->get_permission('pages_intro') != true || INTRO_PAGE != 'enabled') {
598
	$template->set_var('DISPLAY_INTRO', 'hide');
599
}
600

  
601

  
602
// Parse template object
603
$template->parse('main', 'main_block', false);
604
$template->pparse('output', 'page');
605

  
606
// include the required file for Javascript admin
607
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
608
{
609
	include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
610
}
611

  
612
// Print admin
613
$admin->print_footer();
614

  
613 615
?>

Also available in: Unified diff