Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         pages
6
 * @author          Ryan Djurovich, WebsiteBaker Project
7
 * @copyright       2009-2012, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.x
11
 * @requirements    PHP 5.2.2 and higher and higher
12
 * @version         $Id: index.php 1707 2012-08-29 11:12:21Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/admin/pages/index.php $
14
 * @lastmodified    $Date: 2012-08-29 13:12:21 +0200 (Wed, 29 Aug 2012) $
15
 *
16
 */
17

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

    
22
$admin->clearIDKEY();
23

    
24
// Include the WB functions file
25
require_once(WB_PATH.'/framework/functions.php');
26
// eggsurplus: add child pages for a specific page
27
/**/
28

    
29
 ?>
30
<script type="text/javascript" src="<?php print ADMIN_URL;  ?>/pages/eggsurplus.js"></script>
31
<?php
32
// fixes A URI contains impermissible characters or quotes around the URI are not closed.
33
$MESSAGE['PAGES_DELETE_CONFIRM'] = url_encode(  $MESSAGE['PAGES_DELETE_CONFIRM'] );
34

    
35
function set_node ($parent,& $par)
36
{
37
    $retval = '';
38

    
39
	if($par['num_subs'] )
40
	{
41
    $retval .= "\n".'<ul id="p'.$parent.'"';
42
	if ($parent != 0)
43
	{
44
		$retval .= ' class="page_list"';
45
		if (isset ($_COOKIE['p'.$parent]) && $_COOKIE['p'.$parent] == '1')
46
		{
47
			 $retval .= ' style="display:block"';
48
		}
49
	}
50
	$retval .= ">\n";
51
 	}
52

    
53
	return $retval;
54
}
55

    
56
function make_list($parent = 0, $editable_pages = 0) {
57
	// Get objects and vars from outside this function
58
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $par;
59
	static $row,$iLevel,$iOldLevel;
60
	static $aRowLevel = array();
61
    print set_node ($parent,$par);
62

    
63
	// Get page list from database
64
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
65
    $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
66
    $sql .= 'ORDER BY `position` ASC';
67
	$get_pages = $database->query($sql);
68

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

    
111
			// Work out if we should show a plus or not
112
            $sql = 'SELECT `page_id`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$page['page_id'].' ';
113
            $sql .= (PAGE_TRASH != 'inline') ?  'AND `visibility` != \'deleted\' ' : ' ';
114
            // $sql .= ' ORDER BY `position` ASC';
115
        	$get_page_subs = $database->query($sql);
116
			$num_subs = $get_page_subs->numRows();
117
			$par['num_subs'] = $num_subs;
118
/*
119
			if(PAGE_TRASH != 'inline')
120
            {
121
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
122
			} else {
123
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
124
			}
125
*/
126
			if($get_page_subs->numRows() > 0)
127
            {
128
				$display_plus = true;
129
			} else {
130
				$display_plus = false;
131
			}
132
			// Work out how many pages there are for this parent
133
			$num_pages = $get_pages->numRows();
134

    
135

    
136
			$row   = $row ? 0 : 1;
137

    
138
/*
139
// look and set vars  for first run
140
			$iOldLevel = !isset($iOldLevel) ? $page['level'] : $iOldLevel;
141
			$iOldLevel = $iOldLevel < $page['level'] ? $iOldLevel : $page['level'];
142
// look for new sub
143
			if(!isset($aRowLevel[$page['level']]))
144
			{
145
				$row = !$row ? 0 : $aRowLevel[$iOldLevel];
146
				$aRowLevel[$page['level']] = $row ? $row : 0;
147
				$iOldLevel = $page['level'];
148
// look level before
149
			} elseif($iLevel!=$iOldLevel) {
150
				$aRowLevel[$page['level']] = $aRowLevel[$iOldLevel] ? $aRowLevel[$iOldLevel] : $row ;
151
				$iOldLevel = $page['level'];
152
// normal change
153
			} else {
154
				$aRowLevel[$page['level']] = $aRowLevel[$iLevel] ? $aRowLevel[$iLevel] : $row ;
155
				$iLevel = $page['level'];
156
			}
157
// set and save level
158
			$aRowLevel[$page['level']] = $aRowLevel[$page['level']] ? 0 : 1;
159
// final set $row
160
			$row = $aRowLevel[$page['level']];
161
*/
162
			 ?>
163
			<li class="p<?php echo $page['parent'];  ?>">
164
			<table summary="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE'];  ?>" class="pages_view" cellpadding="0" cellspacing="0">
165
			<tr class="row_<?php echo $row  ?>">
166
				<td valign="middle" width="20" style="padding-left: <?php echo $page['level']==0 ? 0 : ($page['level']*25)-pow($page['level'],2);  ?>px;">
167
					<?php
168
					if($display_plus == true) {
169
					 ?>
170
					<a href="javascript:toggle_visibility('p<?php echo $page['page_id'];  ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE'];  ?>">
171
					<span>
172
					<img src="<?php echo THEME_URL;  ?>/images/<?php echo ( isset($_COOKIE['p'.$page['page_id']]) && $_COOKIE['p'.$page['page_id']] == '1') ?'minus' : 'plus';   ?>_16.png" onclick="toggle_plus_minus('<?php echo $page['page_id'];  ?>');" name="plus_minus_<?php echo $page['page_id'];  ?>" alt="+" />
173
					</span>
174

    
175
					</a>
176
					<?php
177
					}
178
					 ?>
179
				</td>
180
				<?php if($admin->get_permission('pages_modify') == true && $can_modify == true) {  ?>
181
				<td class="list_menu_title">
182
					<a href="<?php echo ADMIN_URL;  ?>/pages/modify.php?page_id=<?php echo  $page['page_id'];  ?>" title="<?php echo $TEXT['MODIFY'];  ?>">
183
					<span>
184
						<?php if($page['visibility'] == 'public') {  ?>
185
							<img src="<?php echo THEME_URL;  ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['PUBLIC'];  ?>" class="page_list_rights" />
186
						<?php } elseif($page['visibility'] == 'private') {  ?>
187
							<img src="<?php echo THEME_URL;  ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['PRIVATE'];  ?>" class="page_list_rights" />
188
						<?php } elseif($page['visibility'] == 'registered') {  ?>
189
							<img src="<?php echo THEME_URL;  ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['REGISTERED'];  ?>" class="page_list_rights" />
190
						<?php } elseif($page['visibility'] == 'hidden') {  ?>
191
							<img src="<?php echo THEME_URL;  ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['HIDDEN'];  ?>" class="page_list_rights" />
192
						<?php } elseif($page['visibility'] == 'none') {  ?>
193
							<img src="<?php echo THEME_URL;  ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['NONE'];  ?>" class="page_list_rights" />
194
						<?php } elseif($page['visibility'] == 'deleted') {  ?>
195
							<img src="<?php echo THEME_URL;  ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['DELETED'];  ?>" class="page_list_rights" />
196
						<?php }
197
						echo '<span class="modify_link">'.($page['menu_title']).'</span>';  ?>
198
					</span>
199
					</a>
200
				</td>
201
				<?php } else {  ?>
202
				<td class="list_menu_title">
203
					<span>
204
					<?php if($page['visibility'] == 'public') {  ?>
205
						<img src="<?php echo THEME_URL;  ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['PUBLIC'];  ?>" class="page_list_rights" />
206
					<?php } elseif($page['visibility'] == 'private') {  ?>
207
						<img src="<?php echo THEME_URL;  ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['PRIVATE'];  ?>" class="page_list_rights" />
208
					<?php } elseif($page['visibility'] == 'registered') {  ?>
209
						<img src="<?php echo THEME_URL;  ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['REGISTERED'];  ?>" class="page_list_rights" />
210
					<?php } elseif($page['visibility'] == 'hidden') {  ?>
211
						<img src="<?php echo THEME_URL;  ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['HIDDEN'];  ?>" class="page_list_rights" />
212
					<?php } elseif($page['visibility'] == 'none') {  ?>
213
						<img src="<?php echo THEME_URL;  ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['NONE'];  ?>" class="page_list_rights" />
214
					<?php } elseif($page['visibility'] == 'deleted') {  ?>
215
						<img src="<?php echo THEME_URL;  ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY'];  ?>: <?php echo $TEXT['DELETED'];  ?>" class="page_list_rights" />
216
					<?php }
217
					echo '<span class="bold grey">'.($page['menu_title']).'</span>';  ?>
218
					</span>
219
				</td>
220
				<?php }  ?>
221
				<td class="list_page_title">
222
					<?php echo ($page['page_title']);  ?>
223
				</td>
224
				<td class="list_page_id right">
225
					<?php echo $page['page_id'];  ?>
226
				</td>
227

    
228
				<td class="list_actions">
229
					<?php if($page['visibility'] != 'deleted' && $page['visibility'] != 'none') {  ?>
230
					<a href="<?php echo $admin->page_link($page['link']);  ?>" target="_blank" title="<?php echo $TEXT['VIEW'];  ?>">
231
						<img src="<?php echo THEME_URL;  ?>/images/view_16.png" alt="<?php echo $TEXT['VIEW'];  ?>" />
232
					</a>
233
					<?php }  ?>
234
				</td>
235
				<td class="list_actions">
236
					<?php if($page['visibility'] != 'deleted') {  ?>
237
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) {  ?>
238
						<a href="<?php echo ADMIN_URL;  ?>/pages/settings.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $TEXT['SETTINGS'];  ?>">
239
							<img src="<?php echo THEME_URL;  ?>/images/modify_16.png" alt="<?php echo $TEXT['SETTINGS'];  ?>" />
240
						</a>
241
						<?php }  ?>
242
					<?php } else {  ?>
243
						<a href="<?php echo ADMIN_URL;  ?>/pages/restore.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $TEXT['RESTORE'];  ?>">
244
							<img src="<?php echo THEME_URL;  ?>/images/restore_16.png" alt="<?php echo $TEXT['RESTORE'];  ?>" />
245
						</a>
246
					<?php }  ?>
247
				</td>
248
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
249
				<td class="list_actions">
250
				<?php
251
				// Work-out if we should show the "manage dates" link
252
				if( (MANAGE_SECTIONS == true) && $admin->get_permission('pages_add')==true && $can_modify==true)
253
                {
254
                    $sql = 'SELECT `publ_start`, `publ_end` FROM `'.TABLE_PREFIX.'sections` ';
255
                    $sql .= 'WHERE `page_id` = '.$page['page_id'].' AND `module` != \'menu_link\' ';
256
					// $query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
257
					if( ($query_sections = $database->query($sql)) )
258
                    {
259
						$mdate_display=false;
260
						while($mdate_res = $query_sections->fetchRow())
261
                        {
262
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
263
                            {
264
								$mdate_display=true;
265
								break;
266
							}
267
						}
268
						if($mdate_display==1)
269
                        {
270
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
271
							 ?>
272
							<a href="<?php echo ADMIN_URL;  ?>/pages/sections.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $HEADING['MANAGE_SECTIONS'];  ?>">
273
							<img src="<?php echo THEME_URL."/images/$file";  ?>" alt="<?php echo $HEADING['MANAGE_SECTIONS'];  ?>" />
274
							</a>
275
						<?php } else {  ?>
276
							<a href="<?php echo ADMIN_URL;  ?>/pages/sections.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $HEADING['MANAGE_SECTIONS'];  ?>">
277
							<img src="<?php echo THEME_URL;  ?>/images/noclock_16.png" alt="<?php echo $HEADING['MANAGE_SECTIONS'];  ?>" /></a>
278
						<?php }  ?>
279
					<?php }  ?>
280
				<?php }  ?>
281
				</td>
282
				<td class="list_actions">
283
				<?php if($page['position'] != 1) {  ?>
284
					<?php if($page['visibility'] != 'deleted') {  ?>
285
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) {  ?>
286
						<a href="<?php echo ADMIN_URL;  ?>/pages/move_up.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $TEXT['MOVE_UP'];  ?>">
287
							<img src="<?php echo THEME_URL;  ?>/images/up_16.png" alt="<?php echo $TEXT['MOVE_UP'];  ?>" />
288
						</a>
289
						<?php }  ?>
290
					<?php }  ?>
291
				<?php }  ?>
292
				</td>
293
				<td class="list_actions">
294
				<?php if($page['position'] != $num_pages) {  ?>
295
					<?php if($page['visibility'] != 'deleted') {  ?>
296
						<?php if($admin->get_permission('pages_settings') == true && $can_modify == true) {  ?>
297
						<a href="<?php echo ADMIN_URL;  ?>/pages/move_down.php?page_id=<?php echo $page['page_id'];  ?>" title="<?php echo $TEXT['MOVE_DOWN'];  ?>">
298
							<img src="<?php echo THEME_URL;  ?>/images/down_16.png" alt="<?php echo $TEXT['MOVE_DOWN'];  ?>" />
299
						</a>
300
						<?php }  ?>
301
					<?php }  ?>
302
				<?php }  ?>
303
				</td>
304
				<td class="list_actions">
305
					<?php if($admin->get_permission('pages_delete') == true && $can_modify == true) { // add IdKey  ?>
306
					<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'];  ?>">
307
						<img src="<?php echo THEME_URL;  ?>/images/delete_16.png" alt="<?php echo $TEXT['DELETE'];  ?>" />
308
					</a>
309
					<?php }  ?>
310
				</td>
311
				<?php
312
				// eggsurplus: Add action to add a page as a child
313
				 ?>
314
				<td class="list_actions">
315
					<?php if(($admin->get_permission('pages_add')) == true && ($can_modify == true) && ($page['visibility'] != 'deleted')) {  ?>
316
					<a href="javascript:add_child_page('<?php echo $page['page_id'];  ?>');" title="<?php echo $HEADING['ADD_CHILD_PAGE'];  ?>">
317
						<img src="<?php echo THEME_URL;  ?>/images/siteadd.png" name="addpage_<?php echo $page['page_id'];  ?>" alt="Add Child Page" />
318
					</a>
319
					<?php }  ?>
320
				</td>
321
				<?php
322
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
323
				 ?>
324
			</tr>
325
			</table>
326
			<?php
327
			if ( $page['parent'] == 0)
328
            {
329
				$page_tmp_id = $page['page_id'];
330
			}
331
			// Get subs
332
			$editable_pages=make_list($page['page_id'], $editable_pages);
333
            print '</li>'."\n";
334
		}
335
	}
336
	$output = ($par['num_subs'] )? '</ul>'."\n" : '';
337
    $par['num_subs'] = (empty($output) ) ?  1 : $par['num_subs'];
338
    print $output;
339
	return $editable_pages;
340
}
341

    
342
// Generate pages list
343
if($admin->get_permission('pages_view') == true) {
344
	 ?>
345
	<div class="jsadmin hide"></div>
346
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE'];  ?>" cellpadding="0" cellspacing="0" width="100%">
347
	<tr>
348
		<td>
349
			<h2 class="left"><?php echo $HEADING['MODIFY_DELETE_PAGE'];  ?></h2>
350
		</td>
351
		<td align="right"></td>
352
	</tr>
353
	</table>
354
	<div class="pages_list">
355
	<table summary="<?php echo $HEADING['MODIFY_DELETE_PAGE'];  ?>" cellpadding="0" cellspacing="0">
356
	<tr class="pages_list_header">
357
		<td class="header_list_menu_title">
358
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE'];  ?>:
359
		</td>
360
		<td class="header_list_page_title">
361
			<?php echo $TEXT['PAGE_TITLE'];  ?>:
362
		</td>
363
		<td class="header_list_page_id">
364
			PID
365
		</td>
366
		<td class="header_list_actions">
367
			<?php echo $TEXT['ACTIONS'];  ?>:
368
		</td>
369
	</tr>
370
	</table>
371
	<?php
372
	// Work-out if we should check for existing page_code
373
	$field_set = $database->field_exists(TABLE_PREFIX.'pages', 'page_code');
374

    
375
    $par = array();
376
	$par['num_subs'] = 1;
377
	$editable_pages = make_list(0, 0);
378
} else {
379
	$editable_pages = 0;
380
}
381
  ?></div><?php
382

    
383
if(intval($editable_pages) == 0 ) {
384
	 ?>
385
	<div class="empty_list">
386
		<?php echo $TEXT['NONE_FOUND'];  ?>
387
	</div>
388
	<?php
389
}
390
// Setup template object, parse vars to it, then parse it
391
// Create new template object
392
$template = new Template(dirname($admin->correct_theme_source('pages.htt')),'keep');
393
// $template->debug = true;
394
$template->set_file('page', 'pages.htt');
395
$template->set_block('page', 'main_block', 'main');
396
// Insert values into the add page form
397
$template->set_var('FTAN', $admin->getFTAN());
398

    
399
// Group list 1
400

    
401
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
402
	$get_groups = $database->query($query);
403
	$template->set_block('main_block', 'group_list_block', 'group_list');
404
	// Insert admin group and current group first
405
	$admin_group_name = $get_groups->fetchRow();
406
	$template->set_var(array(
407
									'ID' => 1,
408
									'TOGGLE' => '1',
409
									'DISABLED' => ' disabled="disabled"',
410
									'LINK_COLOR' => '000000',
411
									'CURSOR' => 'default',
412
									'NAME' => $admin_group_name['name'],
413
									'CHECKED' => ' checked="checked"'
414
									)
415
							);
416
	$template->parse('group_list', 'group_list_block', true);
417

    
418
	while($group = $get_groups->fetchRow()) {
419
		// check if the user is a member of this group
420
		$flag_disabled = '';
421
		$flag_checked =  '';
422
		$flag_cursor =   'pointer';
423
		$flag_color =    '';
424
		if (in_array($group["group_id"], $admin->get_groups_id())) {
425
			$flag_disabled = ''; //' disabled';
426
			$flag_checked =  ' checked="checked"';
427
			$flag_cursor =   'default';
428
			$flag_color =    '000000';
429
		}
430

    
431
		// Check if the group is allowed to edit pages
432
		$system_permissions = explode(',', $group['system_permissions']);
433
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
434
			$template->set_var(array(
435
											'ID' => $group['group_id'],
436
											'TOGGLE' => $group['group_id'],
437
											'CHECKED' => $flag_checked,
438
											'DISABLED' => $flag_disabled,
439
											'LINK_COLOR' => $flag_color,
440
											'CURSOR' => $flag_checked,
441
											'NAME' => $group['name'],
442
											)
443
									);
444
			$template->parse('group_list', 'group_list_block', true);
445
		}
446
	}
447
// Group list 2
448

    
449
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
450

    
451
	$get_groups = $database->query($query);
452
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
453
	// Insert admin group and current group first
454
	$admin_group_name = $get_groups->fetchRow();
455
	$template->set_var(array(
456
									'ID' => 1,
457
									'TOGGLE' => '1',
458
									'DISABLED' => ' disabled="disabled"',
459
									'LINK_COLOR' => '000000',
460
									'CURSOR' => 'default',
461
									'NAME' => $admin_group_name['name'],
462
									'CHECKED' => ' checked="checked"'
463
									)
464
							);
465
	$template->parse('group_list2', 'group_list_block2', true);
466

    
467
	while($group = $get_groups->fetchRow()) {
468
		// check if the user is a member of this group
469
		$flag_disabled = '';
470
		$flag_checked =  '';
471
		$flag_cursor =   'pointer';
472
		$flag_color =    '';
473
		if (in_array($group["group_id"], $admin->get_groups_id())) {
474
			$flag_disabled = ''; //' disabled';
475
			$flag_checked =  ' checked="checked"';
476
			$flag_cursor =   'default';
477
			$flag_color =    '000000';
478
		}
479

    
480
		$template->set_var(array(
481
										'ID' => $group['group_id'],
482
										'TOGGLE' => $group['group_id'],
483
										'CHECKED' => $flag_checked,
484
										'DISABLED' => $flag_disabled,
485
										'LINK_COLOR' => $flag_color,
486
										'CURSOR' => $flag_cursor,
487
										'NAME' => $group['name'],
488
										)
489
								);
490
		$template->parse('group_list2', 'group_list_block2', true);
491
	}
492

    
493

    
494
// Parent page list
495
// $database = new database();
496
function parent_list($parent)
497
{
498
	global $admin, $database, $template, $field_set;
499
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
500
	$get_pages = $database->query($query);
501
	while($page = $get_pages->fetchRow()) {
502
		if($admin->page_is_visible($page)==false)
503
			continue;
504
		// if parent = 0 set flag_icon
505
		$template->set_var('FLAG_ROOT_ICON',' none ');
506
		if( $page['parent'] == 0 && $field_set) {
507
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
508
		}
509
		// Stop users from adding pages with a level of more than the set page level limit
510
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
511
			// Get user perms
512
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
513
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
514

    
515
			$in_group = FALSE;
516
			foreach($admin->get_groups_id() as $cur_gid) {
517
				if (in_array($cur_gid, $admin_groups)) {
518
					$in_group = TRUE;
519
				}
520
			}
521
			if(($in_group) || is_numeric(array_search($admin->get_user_id(), $admin_users))) {
522
				$can_modify = true;
523
			} else {
524
				$can_modify = false;
525
			}
526
			// Title -'s prefix
527
			$title_prefix = '';
528
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - - &nbsp;'; }
529
				$template->set_var(array(
530
										'ID' => $page['page_id'],
531
										'TITLE' => ($title_prefix.$page['menu_title']),
532
										'MENU-TITLE' => ($title_prefix.$page['menu_title']),
533
										'PAGE-TITLE' => ($title_prefix.$page['page_title'])
534
										));
535
				if($can_modify == true) {
536
					$template->set_var('DISABLED', '');
537
				} else {
538
					$template->set_var('DISABLED', ' disabled="disabled" class="disabled"');
539
				}
540
				$template->parse('page_list2', 'page_list_block2', true);
541
		}
542
		parent_list($page['page_id']);
543
	}
544
}
545
$template->set_block('main_block', 'page_list_block2', 'page_list2');
546
if($admin->get_permission('pages_add_l0') == true) {
547
	$template->set_var(array(
548
						'ID' => '0',
549
						'TITLE' => $TEXT['NONE'],
550
						'SELECTED' => ' selected="selected"',
551
						'DISABLED' => ''
552
					)
553
				);
554
	$template->parse('page_list2', 'page_list_block2', true);
555
}
556
parent_list(0);
557

    
558
// Explode module permissions
559
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
560
// Modules list
561
$template->set_block('main_block', 'module_list_block', 'module_list');
562
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
563
if($result->numRows() > 0) {
564
	while ($module = $result->fetchRow()) {
565
		// Check if user is allowed to use this module
566
		if(!is_numeric(array_search($module['directory'], $module_permissions))) {
567
			$template->set_var('VALUE', $module['directory']);
568
			$template->set_var('NAME', $module['name']);
569
			if($module['directory'] == 'wysiwyg') {
570
				$template->set_var('SELECTED', ' selected="selected"');
571
			} else {
572
				$template->set_var('SELECTED', '');
573
			}
574
			$template->parse('module_list', 'module_list_block', true);
575
		}
576
	}
577
}
578

    
579
// Insert urls
580
$template->set_var(array(
581
								'THEME_URL' => THEME_URL,
582
								'WB_URL' => WB_URL,
583
								'ADMIN_URL' => ADMIN_URL,
584
								)
585
						);
586

    
587
// Insert language headings
588
$template->set_var(array(
589
								'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
590
								'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
591
								)
592
						);
593
// Insert language text and messages
594
$template->set_var(array(
595
								'TEXT_TITLE' => $TEXT['TITLE'],
596
								'TEXT_TYPE' => $TEXT['TYPE'],
597
								'TEXT_PARENT' => $TEXT['PARENT'],
598
								'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
599
								'TEXT_PUBLIC' => $TEXT['PUBLIC'],
600
								'TEXT_PRIVATE' => $TEXT['PRIVATE'],
601
								'TEXT_REGISTERED' => $TEXT['REGISTERED'],
602
								'TEXT_HIDDEN' => $TEXT['HIDDEN'],
603
								'TEXT_NONE' => $TEXT['NONE'],
604
								'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
605
								'TEXT_ADD' => $TEXT['ADD'],
606
								'TEXT_RESET' => $TEXT['RESET'],
607
								'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
608
								'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
609
								'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
610
								'INTRO_LINK' => $MESSAGE['PAGES_INTRO_LINK'],
611
								)
612
						);
613

    
614
// Insert permissions values
615
if($admin->get_permission('pages_add') != true) {
616
	$template->set_var('DISPLAY_ADD', 'hide');
617
} elseif($admin->get_permission('pages_add_l0') != true && $editable_pages == 0) {
618
	$template->set_var('DISPLAY_ADD', 'hide');
619
}
620
if($admin->get_permission('pages_intro') != true || INTRO_PAGE != 'enabled') {
621
	$template->set_var('DISPLAY_INTRO', 'hide');
622
}
623

    
624

    
625
// Parse template object
626
$template->parse('main', 'main_block', false);
627
$template->pparse('output', 'page');
628

    
629
// include the required file for Javascript admin
630
if(file_exists(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php'))
631
{
632
	include(WB_PATH.'/modules/jsadmin/jsadmin_backend_include.php');
633
}
634

    
635
// Print admin
636
$admin->print_footer();
(6-6/22)