Project

General

Profile

1 1009 Ruebenwurz
<?php
2 1277 Luisehahne
/**
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 1009 Ruebenwurz
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 1180 Luisehahne
// 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 1009 Ruebenwurz
29 1180 Luisehahne
30 1009 Ruebenwurz
function make_list($parent, $editable_pages) {
31
	// Get objects and vars from outside this function
32
	global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING, $page_tmp_id;
33
	?>
34
	<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"'; }} ?>>
35
	<?php
36 1277 Luisehahne
	// $database = new database();
37
38 1009 Ruebenwurz
	// Get page list from database
39 1277 Luisehahne
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent;
40
    $sql .= (PAGE_TRASH != 'inline') ?  ' AND `visibility` != "deleted"' : '';
41
    $sql .= ' ORDER BY `position` ASC';
42
	$get_pages = $database->query($sql);
43
/*
44
	if(PAGE_TRASH != 'inline')
45
    {
46
		$sql = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
47 1009 Ruebenwurz
	} else {
48 1277 Luisehahne
		$sql = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
49 1009 Ruebenwurz
	}
50 1277 Luisehahne
*/
51 1009 Ruebenwurz
	// Insert values into main page list
52
	if($get_pages->numRows() > 0) {
53
		while($page = $get_pages->fetchRow()) {
54
			// Get user perms
55
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
56
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
57
			$in_group = FALSE;
58 1277 Luisehahne
			foreach($admin->get_groups_id() as $cur_gid)
59
            {
60
				if (in_array($cur_gid, $admin_groups))
61
                {
62 1009 Ruebenwurz
					$in_group = TRUE;
63
				}
64
			}
65 1277 Luisehahne
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users)))
66
            {
67
				if($page['visibility'] == 'deleted')
68
                {
69
					if(PAGE_TRASH == 'inline')
70
                    {
71 1009 Ruebenwurz
						$can_modify = true;
72
						$editable_pages = $editable_pages+1;
73
					} else {
74
						$can_modify = false;
75
					}
76 1277 Luisehahne
				} elseif($page['visibility'] != 'deleted')
77
                {
78 1009 Ruebenwurz
					$can_modify = true;
79
					$editable_pages = $editable_pages+1;
80
				}
81
			} else {
82 1277 Luisehahne
				if($page['visibility'] == 'private')
83
                {
84 1009 Ruebenwurz
					continue;
85
				}
86
				else {
87
					$can_modify = false;
88
				}
89
			}
90
			// Work out if we should show a plus or not
91 1277 Luisehahne
            $sql = 'SELECT `page_id`,`admin_groups`,`admin_users` FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$page['page_id'];
92
            $sql .= (PAGE_TRASH != 'inline') ?  ' AND `visibility` != "deleted"' : '';
93
            // $sql .= ' ORDER BY `position` ASC';
94
        	$get_page_subs = $database->query($sql);
95
/*
96
			if(PAGE_TRASH != 'inline')
97
            {
98 1009 Ruebenwurz
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
99
			} else {
100
				$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
101
			}
102 1277 Luisehahne
*/
103
			if($get_page_subs->numRows() > 0)
104
            {
105 1009 Ruebenwurz
				$display_plus = true;
106
			} else {
107
				$display_plus = false;
108
			}
109
			// Work out how many pages there are for this parent
110
			$num_pages = $get_pages->numRows();
111
			?>
112
			<li class="p<?php echo $page['parent']; ?>">
113 1128 Ruebenwurz
			<table class="pages_view" border="0" cellpadding="0" cellspacing="0">
114 1009 Ruebenwurz
			<tr>
115 1128 Ruebenwurz
				<td valign="middle" width="20" style="padding-left: <?php if($page['level'] > 0){ echo $page['level']*20; } else { echo '7'; } ?>px;">
116 1009 Ruebenwurz
					<?php
117
					if($display_plus == true) {
118
					?>
119
					<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
120
						<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="+" />
121
					</a>
122
					<?php
123
					}
124
					?>
125
				</td>
126
				<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
127 1148 Luisehahne
				<td class="list_menu_title">
128 1009 Ruebenwurz
					<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
129
						<?php if($page['visibility'] == 'public') { ?>
130
							<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
131
						<?php } elseif($page['visibility'] == 'private') { ?>
132
							<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
133
						<?php } elseif($page['visibility'] == 'registered') { ?>
134
							<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
135
						<?php } elseif($page['visibility'] == 'hidden') { ?>
136
							<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
137
						<?php } elseif($page['visibility'] == 'none') { ?>
138
							<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
139
						<?php } elseif($page['visibility'] == 'deleted') { ?>
140
							<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
141 1180 Luisehahne
						<?php }
142 1148 Luisehahne
						echo '<span class="modify_link">'.($page['menu_title']).'</span>'; ?>
143 1009 Ruebenwurz
					</a>
144
				</td>
145
				<?php } else { ?>
146 1148 Luisehahne
				<td class="list_menu_title">
147 1009 Ruebenwurz
					<?php if($page['visibility'] == 'public') { ?>
148
						<img src="<?php echo THEME_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" class="page_list_rights" />
149
					<?php } elseif($page['visibility'] == 'private') { ?>
150
						<img src="<?php echo THEME_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" class="page_list_rights" />
151
					<?php } elseif($page['visibility'] == 'registered') { ?>
152
						<img src="<?php echo THEME_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" class="page_list_rights" />
153
					<?php } elseif($page['visibility'] == 'hidden') { ?>
154
						<img src="<?php echo THEME_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" class="page_list_rights" />
155
					<?php } elseif($page['visibility'] == 'none') { ?>
156
						<img src="<?php echo THEME_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" class="page_list_rights" />
157
					<?php } elseif($page['visibility'] == 'deleted') { ?>
158
						<img src="<?php echo THEME_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" class="page_list_rights" />
159
					<?php }
160 1148 Luisehahne
					echo ($page['menu_title']); ?>
161 1009 Ruebenwurz
				</td>
162
				<?php } ?>
163 1148 Luisehahne
				<td class="list_page_title">
164
					<?php echo ($page['page_title']); ?>
165 1009 Ruebenwurz
				</td>
166 1128 Ruebenwurz
				<td class="list_page_id">
167
					<?php echo $page['page_id']; ?>
168
				</td>
169 1035 Ruebenwurz
				<td class="list_actions">
170 1009 Ruebenwurz
					<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
171
					<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
172
						<img src="<?php echo THEME_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
173
					</a>
174
					<?php } ?>
175
				</td>
176 1035 Ruebenwurz
				<td class="list_actions">
177 1009 Ruebenwurz
					<?php if($page['visibility'] != 'deleted') { ?>
178
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
179
						<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
180
							<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
181
						</a>
182
						<?php } ?>
183
					<?php } else { ?>
184
						<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
185
							<img src="<?php echo THEME_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
186
						</a>
187
					<?php } ?>
188
				</td>
189
				<!-- MANAGE SECTIONS AND DATES BUTTONS -->
190 1035 Ruebenwurz
				<td class="list_actions">
191 1009 Ruebenwurz
				<?php
192
				// Work-out if we should show the "manage dates" link
193 1277 Luisehahne
				if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true)
194
                {
195
196
                    $sql = 'SELECT `publ_start`, `publ_end` FROM `'.TABLE_PREFIX.'sections`';
197
                    $sql .= ' WHERE `page_id` = '.$page['page_id'].' AND `module` != "menu_link"';
198
                    $query_sections = $database->query($sql);
199
200
					// $query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
201
202
					if($query_sections->numRows() > 0)
203
                    {
204 1009 Ruebenwurz
						$mdate_display=false;
205 1277 Luisehahne
						while($mdate_res = $query_sections->fetchRow())
206
                        {
207
							if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0')
208
                            {
209 1009 Ruebenwurz
								$mdate_display=true;
210
								break;
211
							}
212
						}
213 1277 Luisehahne
						if($mdate_display==1)
214
                        {
215 1009 Ruebenwurz
							$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
216
							?>
217
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
218 1277 Luisehahne
							<img src="<?php echo THEME_URL."/images/$file"; ?>" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
219 1009 Ruebenwurz
							</a>
220
						<?php } else { ?>
221
							<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
222 1277 Luisehahne
							<img src="<?php echo THEME_URL; ?>/images/noclock_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
223 1009 Ruebenwurz
						<?php } ?>
224
					<?php } ?>
225
				<?php } ?>
226
				</td>
227 1035 Ruebenwurz
				<td class="list_actions">
228 1009 Ruebenwurz
				<?php if($page['position'] != 1) { ?>
229
					<?php if($page['visibility'] != 'deleted') { ?>
230
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
231
						<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
232 1078 Ruebenwurz
							<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="<?php echo $TEXT['MOVE_UP']; ?>" />
233 1009 Ruebenwurz
						</a>
234
						<?php } ?>
235
					<?php } ?>
236
				<?php } ?>
237
				</td>
238 1035 Ruebenwurz
				<td class="list_actions">
239 1009 Ruebenwurz
				<?php if($page['position'] != $num_pages) { ?>
240
					<?php if($page['visibility'] != 'deleted') { ?>
241
						<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
242
						<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
243 1078 Ruebenwurz
							<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="<?php echo $TEXT['MOVE_DOWN']; ?>" />
244 1009 Ruebenwurz
						</a>
245
						<?php } ?>
246
					<?php } ?>
247
				<?php } ?>
248
				</td>
249 1035 Ruebenwurz
				<td class="list_actions">
250 1009 Ruebenwurz
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
251
					<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']; ?>">
252 1078 Ruebenwurz
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="<?php echo $TEXT['DELETE']; ?>" />
253 1009 Ruebenwurz
					</a>
254
					<?php } ?>
255
				</td>
256 1180 Luisehahne
				<?php
257
				// eggsurplus: Add action to add a page as a child
258
				?>
259
				<td class="list_actions">
260
					<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
261
					<a href="javascript:add_child_page('<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['ADD']; ?>">
262
						<img src="<?php echo THEME_URL; ?>/images/plus_16.png" name="addpage_<?php echo $page['page_id']; ?>" border="0" alt="Add Child Page" />
263
					</a>
264
					<?php } ?>
265
				</td>
266
				<?php
267
				// end [IC] jeggers 2009/10/14: Add action to add a page as a child
268
				?>
269
270 1009 Ruebenwurz
			</tr>
271
			</table>
272
			</li>
273
			<?php
274 1277 Luisehahne
			if ( $page['parent'] = 0)
275
            {
276 1009 Ruebenwurz
				$page_tmp_id = $page['page_id'];
277
			}
278
			// Get subs
279
			$editable_pages=make_list($page['page_id'], $editable_pages);
280
		}
281
	}
282
	?>
283
	</ul>
284
	<?php
285
	return $editable_pages;
286
}
287
288
// Generate pages list
289
if($admin->get_permission('pages_view') == true) {
290
	?>
291
	<div class="jsadmin hide"></div>
292
	<table cellpadding="0" cellspacing="0" width="100%" border="0">
293
	<tr>
294
		<td>
295
			<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
296
		</td>
297
		<td align="right">
298
			<?php
299
				// Check if there are any pages that are in trash, and if we should show a link to the trash page
300
				if(PAGE_TRASH == 'separate') {
301
					$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
302
					if($query_trash->numRows() > 0) {
303
						?>
304
						<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
305
						<img src="<?php echo THEME_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
306
						<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
307
						<?php
308
					}
309
				}
310
			?>
311
		</td>
312
	</tr>
313
	</table>
314
	<div class="pages_list">
315
	<table cellpadding="0" cellspacing="0" border="0">
316
	<tr>
317 1148 Luisehahne
		<td class="header_list_menu_title">
318
			<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['MENU_TITLE']; ?>:
319
		</td>
320 1035 Ruebenwurz
		<td class="header_list_page_title">
321 1148 Luisehahne
			<?php echo $TEXT['PAGE_TITLE']; ?>:
322 1009 Ruebenwurz
		</td>
323 1128 Ruebenwurz
		<td class="header_list_page_id">
324
			ID:
325
		</td>
326 1035 Ruebenwurz
		<td class="header_list_actions">
327 1009 Ruebenwurz
			<?php echo $TEXT['ACTIONS']; ?>:
328 1035 Ruebenwurz
		</td>
329 1009 Ruebenwurz
	</tr>
330
	</table>
331
	<?php
332 1187 Luisehahne
    // Work-out if we should check for existing page_code
333
    $field_sql = $database->query("DESCRIBE ".TABLE_PREFIX."pages page_code");
334
    $field_set = $field_sql->numRows();
335
336 1009 Ruebenwurz
	$page_tmp_id = 0;
337
	$editable_pages = make_list(0, 0);
338
	?>
339
	</div>
340
	<div class="empty_list">
341
		<?php echo $TEXT['NONE_FOUND']; ?>
342
	</div>
343
	<?php
344
} else {
345
	$editable_pages = 0;
346
}
347
348
// Setup template object
349
$template = new Template(THEME_PATH.'/templates');
350
$template->set_file('page', 'pages.htt');
351
$template->set_block('page', 'main_block', 'main');
352
353
// Figure out if the no pages found message should be shown or not
354
if($editable_pages == 0) {
355
	?>
356
	<style type="text/css">
357
	.pages_list {
358
		display: none;
359
	}
360
	</style>
361
	<?php
362
} else {
363
	?>
364
	<style type="text/css">
365
	.empty_list {
366
		display: none;
367
	}
368
	</style>
369
	<?php
370
}
371
372
// Insert values into the add page form
373
374
// Group list 1
375
376
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
377
	$get_groups = $database->query($query);
378
	$template->set_block('main_block', 'group_list_block', 'group_list');
379
	// Insert admin group and current group first
380
	$admin_group_name = $get_groups->fetchRow();
381
	$template->set_var(array(
382
									'ID' => 1,
383
									'TOGGLE' => '',
384
									'DISABLED' => ' disabled="disabled"',
385
									'LINK_COLOR' => '000000',
386
									'CURSOR' => 'default',
387
									'NAME' => $admin_group_name['name'],
388 1069 Ruebenwurz
									'CHECKED' => ' checked="checked"'
389 1009 Ruebenwurz
									)
390
							);
391
	$template->parse('group_list', 'group_list_block', true);
392
393
	while($group = $get_groups->fetchRow()) {
394
		// check if the user is a member of this group
395
		$flag_disabled = '';
396
		$flag_checked =  '';
397
		$flag_cursor =   'pointer';
398
		$flag_color =    '';
399
		if (in_array($group["group_id"], $admin->get_groups_id())) {
400
			$flag_disabled = ''; //' disabled';
401
			$flag_checked =  ' checked="checked"';
402
			$flag_cursor =   'default';
403
			$flag_color =    '000000';
404
		}
405
406
		// Check if the group is allowed to edit pages
407
		$system_permissions = explode(',', $group['system_permissions']);
408
		if(is_numeric(array_search('pages_modify', $system_permissions))) {
409
			$template->set_var(array(
410
											'ID' => $group['group_id'],
411
											'TOGGLE' => $group['group_id'],
412
											'CHECKED' => $flag_checked,
413
											'DISABLED' => $flag_disabled,
414
											'LINK_COLOR' => $flag_color,
415
											'CURSOR' => $flag_checked,
416
											'NAME' => $group['name'],
417
											)
418
									);
419
			$template->parse('group_list', 'group_list_block', true);
420
		}
421
	}
422
// Group list 2
423
424
	$query = "SELECT * FROM ".TABLE_PREFIX."groups";
425
426
	$get_groups = $database->query($query);
427
	$template->set_block('main_block', 'group_list_block2', 'group_list2');
428
	// Insert admin group and current group first
429
	$admin_group_name = $get_groups->fetchRow();
430
	$template->set_var(array(
431
									'ID' => 1,
432
									'TOGGLE' => '',
433
									'DISABLED' => ' disabled="disabled"',
434
									'LINK_COLOR' => '000000',
435
									'CURSOR' => 'default',
436
									'NAME' => $admin_group_name['name'],
437 1069 Ruebenwurz
									'CHECKED' => ' checked="checked"'
438 1009 Ruebenwurz
									)
439
							);
440
	$template->parse('group_list2', 'group_list_block2', true);
441
442
	while($group = $get_groups->fetchRow()) {
443
		// check if the user is a member of this group
444
		$flag_disabled = '';
445
		$flag_checked =  '';
446
		$flag_cursor =   'pointer';
447
		$flag_color =    '';
448
		if (in_array($group["group_id"], $admin->get_groups_id())) {
449
			$flag_disabled = ''; //' disabled';
450
			$flag_checked =  ' checked="checked"';
451
			$flag_cursor =   'default';
452
			$flag_color =    '000000';
453
		}
454
455
		$template->set_var(array(
456
										'ID' => $group['group_id'],
457
										'TOGGLE' => $group['group_id'],
458
										'CHECKED' => $flag_checked,
459
										'DISABLED' => $flag_disabled,
460
										'LINK_COLOR' => $flag_color,
461
										'CURSOR' => $flag_cursor,
462
										'NAME' => $group['name'],
463
										)
464
								);
465
		$template->parse('group_list2', 'group_list_block2', true);
466
	}
467
468 1187 Luisehahne
469 1009 Ruebenwurz
// Parent page list
470 1277 Luisehahne
// $database = new database();
471
function parent_list($parent)
472
{
473 1187 Luisehahne
	global $admin, $database, $template, $field_set;
474 1009 Ruebenwurz
	$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
475
	$get_pages = $database->query($query);
476
	while($page = $get_pages->fetchRow()) {
477
		if($admin->page_is_visible($page)==false)
478
			continue;
479
		// if parent = 0 set flag_icon
480
		$template->set_var('FLAG_ROOT_ICON',' none ');
481 1187 Luisehahne
		if( $page['parent'] == 0 && $field_set) {
482 1009 Ruebenwurz
			$template->set_var('FLAG_ROOT_ICON','url('.THEME_URL.'/images/flags/'.strtolower($page['language']).'.png)');
483
		}
484
		// Stop users from adding pages with a level of more than the set page level limit
485
		if($page['level']+1 < PAGE_LEVEL_LIMIT) {
486
			// Get user perms
487
			$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
488
			$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
489
490
			$in_group = FALSE;
491
			foreach($admin->get_groups_id() as $cur_gid) {
492
				if (in_array($cur_gid, $admin_groups)) {
493
					$in_group = TRUE;
494
				}
495
			}
496
			if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
497
				$can_modify = true;
498
			} else {
499
				$can_modify = false;
500
			}
501
			// Title -'s prefix
502
			$title_prefix = '';
503
			for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
504
				$template->set_var(array(
505
												'ID' => $page['page_id'],
506 1187 Luisehahne
												'TITLE' => ($title_prefix.$page['menu_title']),
507
												'MENU-TITLE' => ($title_prefix.$page['menu_title']),
508
												'PAGE-TITLE' => ($title_prefix.$page['page_title'])
509 1009 Ruebenwurz
												)
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 AND $editable_pages == 0) {
595
	$template->set_var('DISPLAY_ADD', 'hide');
596
}
597
if($admin->get_permission('pages_intro') != true OR 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
// Print admin
607
$admin->print_footer();
608
609
?>