1
|
<?php
|
2
|
|
3
|
// $Id: index.php 584 2008-01-21 19:49:32Z doc $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2008, Ryan Djurovich
|
9
|
|
10
|
Website Baker is free software; you can redistribute it and/or modify
|
11
|
it under the terms of the GNU General Public License as published by
|
12
|
the Free Software Foundation; either version 2 of the License, or
|
13
|
(at your option) any later version.
|
14
|
|
15
|
Website Baker is distributed in the hope that it will be useful,
|
16
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
GNU General Public License for more details.
|
19
|
|
20
|
You should have received a copy of the GNU General Public License
|
21
|
along with Website Baker; if not, write to the Free Software
|
22
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
|
24
|
*/
|
25
|
|
26
|
require('../../config.php');
|
27
|
require_once(WB_PATH.'/framework/class.admin.php');
|
28
|
$admin = new admin('Pages', 'pages');
|
29
|
// Include the WB functions file
|
30
|
require_once(WB_PATH.'/framework/functions.php');
|
31
|
|
32
|
?>
|
33
|
<!-- Addition for remembering expanded state of pages -->
|
34
|
<script language="JavaScript">
|
35
|
function writeSessionCookie (cookieName, cookieValue) {
|
36
|
document.cookie = escape(cookieName) + "=" + escape(cookieValue) + ";";
|
37
|
}
|
38
|
</script>
|
39
|
<!-- End addition -->
|
40
|
|
41
|
<script type="text/javascript" language="javascript">
|
42
|
function toggle_viewers() {
|
43
|
if(document.add.visibility.value == 'private') {
|
44
|
document.getElementById('private_viewers').style.display = 'block';
|
45
|
document.getElementById('registered_viewers').style.display = 'none';
|
46
|
} else if(document.add.visibility.value == 'registered') {
|
47
|
document.getElementById('private_viewers').style.display = 'none';
|
48
|
document.getElementById('registered_viewers').style.display = 'block';
|
49
|
} else {
|
50
|
document.getElementById('private_viewers').style.display = 'none';
|
51
|
document.getElementById('registered_viewers').style.display = 'none';
|
52
|
}
|
53
|
}
|
54
|
function toggle_visibility(id){
|
55
|
if(document.getElementById(id).style.display == "block") {
|
56
|
document.getElementById(id).style.display = "none";
|
57
|
writeSessionCookie (id, "0");//Addition for remembering expanded state of pages
|
58
|
} else {
|
59
|
document.getElementById(id).style.display = "block";
|
60
|
writeSessionCookie (id, "1");//Addition for remembering expanded state of pages
|
61
|
}
|
62
|
}
|
63
|
var plus = new Image;
|
64
|
plus.src = "<?php echo ADMIN_URL; ?>/images/plus_16.png";
|
65
|
var minus = new Image;
|
66
|
minus.src = "<?php echo ADMIN_URL; ?>/images/minus_16.png";
|
67
|
function toggle_plus_minus(id) {
|
68
|
var img_src = document.images['plus_minus_' + id].src;
|
69
|
if(img_src == plus.src) {
|
70
|
document.images['plus_minus_' + id].src = minus.src;
|
71
|
} else {
|
72
|
document.images['plus_minus_' + id].src = plus.src;
|
73
|
}
|
74
|
}
|
75
|
</script>
|
76
|
|
77
|
<style type="text/css">
|
78
|
.pages_list img {
|
79
|
display: block;
|
80
|
}
|
81
|
ul, li {
|
82
|
list-style: none;
|
83
|
margin: 0;
|
84
|
padding: 0;
|
85
|
}
|
86
|
.page_list {
|
87
|
display: none;
|
88
|
}
|
89
|
</style>
|
90
|
|
91
|
<noscript>
|
92
|
<style type="text/css">
|
93
|
.page_list {
|
94
|
display: block;
|
95
|
}
|
96
|
</style>
|
97
|
</noscript>
|
98
|
<?php
|
99
|
|
100
|
function make_list($parent, $editable_pages) {
|
101
|
// Get objects and vars from outside this function
|
102
|
global $admin, $template, $database, $TEXT, $MESSAGE, $HEADING;
|
103
|
?>
|
104
|
<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;"'; }} ?>>
|
105
|
<?php
|
106
|
// Get page list from database
|
107
|
$database = new database();
|
108
|
if(PAGE_TRASH != 'inline') {
|
109
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility != 'deleted' ORDER BY position ASC";
|
110
|
} else {
|
111
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
|
112
|
}
|
113
|
$get_pages = $database->query($query);
|
114
|
|
115
|
// Insert values into main page list
|
116
|
if($get_pages->numRows() > 0) {
|
117
|
while($page = $get_pages->fetchRow()) {
|
118
|
// Get user perms
|
119
|
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
|
120
|
$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
|
121
|
|
122
|
$in_group = FALSE;
|
123
|
foreach($admin->get_groups_id() as $cur_gid){
|
124
|
if (in_array($cur_gid, $admin_groups)) {
|
125
|
$in_group = TRUE;
|
126
|
}
|
127
|
}
|
128
|
if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
|
129
|
if($page['visibility'] == 'deleted') {
|
130
|
if(PAGE_TRASH == 'inline') {
|
131
|
$can_modify = true;
|
132
|
$editable_pages = $editable_pages+1;
|
133
|
} else {
|
134
|
$can_modify = false;
|
135
|
}
|
136
|
} elseif($page['visibility'] != 'deleted') {
|
137
|
$can_modify = true;
|
138
|
$editable_pages = $editable_pages+1;
|
139
|
}
|
140
|
} else {
|
141
|
if($page['visibility'] == 'private') {
|
142
|
continue;
|
143
|
}
|
144
|
else {
|
145
|
$can_modify = false;
|
146
|
}
|
147
|
}
|
148
|
|
149
|
// Work out if we should show a plus or not
|
150
|
if(PAGE_TRASH != 'inline') {
|
151
|
$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."' AND visibility!='deleted'");
|
152
|
} else {
|
153
|
$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
|
154
|
}
|
155
|
if($get_page_subs->numRows() > 0) {
|
156
|
$display_plus = true;
|
157
|
} else {
|
158
|
$display_plus = false;
|
159
|
}
|
160
|
|
161
|
// Work out how many pages there are for this parent
|
162
|
$num_pages = $get_pages->numRows();
|
163
|
?>
|
164
|
|
165
|
<li id="p<?php echo $page['parent']; ?>" style="padding: 2px 0px 2px 0px;">
|
166
|
<table width="720" cellpadding="1" cellspacing="0" border="0" style="background-color: #F0F0F0;">
|
167
|
<tr>
|
168
|
<td width="20" style="padding-left: <?php echo $page['level']*20; ?>px;">
|
169
|
<?php
|
170
|
if($display_plus == true) {
|
171
|
?>
|
172
|
<a href="javascript: toggle_visibility('p<?php echo $page['page_id']; ?>');" title="<?php echo $TEXT['EXPAND'].'/'.$TEXT['COLLAPSE']; ?>">
|
173
|
<img src="<?php echo ADMIN_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="+" />
|
174
|
</a>
|
175
|
<?php
|
176
|
}
|
177
|
?>
|
178
|
</td>
|
179
|
<?php if($admin->get_permission('pages_modify') == true AND $can_modify == true) { ?>
|
180
|
<td>
|
181
|
<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
|
182
|
<?php if($page['visibility'] == 'public') { ?>
|
183
|
<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" align="left" style="margin-right: 5px" />
|
184
|
<?php } elseif($page['visibility'] == 'private') { ?>
|
185
|
<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" align="left" style="margin-right: 5px" />
|
186
|
<?php } elseif($page['visibility'] == 'registered') { ?>
|
187
|
<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" align="left" style="margin-right: 5px" />
|
188
|
<?php } elseif($page['visibility'] == 'hidden') { ?>
|
189
|
<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" border="0" align="left" style="margin-right: 5px" />
|
190
|
<?php } elseif($page['visibility'] == 'none') { ?>
|
191
|
<img src="<?php echo ADMIN_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" align="left" style="margin-right: 5px" />
|
192
|
<?php } elseif($page['visibility'] == 'deleted') { ?>
|
193
|
<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" align="left" style="margin-right: 5px" />
|
194
|
<?php }
|
195
|
echo ($page['page_title']); ?>
|
196
|
</a>
|
197
|
</td>
|
198
|
<?php } else { ?>
|
199
|
<td>
|
200
|
<?php if($page['visibility'] == 'public') { ?>
|
201
|
<img src="<?php echo ADMIN_URL; ?>/images/visible_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PUBLIC']; ?>" border="0" align="left" style="margin-right: 5px" />
|
202
|
<?php } elseif($page['visibility'] == 'private') { ?>
|
203
|
<img src="<?php echo ADMIN_URL; ?>/images/private_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['PRIVATE']; ?>" border="0" align="left" style="margin-right: 5px" />
|
204
|
<?php } elseif($page['visibility'] == 'registered') { ?>
|
205
|
<img src="<?php echo ADMIN_URL; ?>/images/keys_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['REGISTERED']; ?>" border="0" align="left" style="margin-right: 5px" />
|
206
|
<?php } elseif($page['visibility'] == 'hidden') { ?>
|
207
|
<img src="<?php echo ADMIN_URL; ?>/images/hidden_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['HIDDEN']; ?>" border="0" align="left" style="margin-right: 5px" />
|
208
|
<?php } elseif($page['visibility'] == 'none') { ?>
|
209
|
<img src="<?php echo ADMIN_URL; ?>/images/none_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['NONE']; ?>" border="0" align="left" style="margin-right: 5px" />
|
210
|
<?php } elseif($page['visibility'] == 'deleted') { ?>
|
211
|
<img src="<?php echo ADMIN_URL; ?>/images/deleted_16.png" alt="<?php echo $TEXT['VISIBILITY']; ?>: <?php echo $TEXT['DELETED']; ?>" border="0" align="left" style="margin-right: 5px" />
|
212
|
<?php }
|
213
|
echo ($page['page_title']); ?>
|
214
|
</td>
|
215
|
<?php } ?>
|
216
|
<td align="left" width="252">
|
217
|
<font color="#999999"><?php echo ($page['menu_title']); ?></font>
|
218
|
</td>
|
219
|
<td width="20">
|
220
|
<?php if($page['visibility'] != 'deleted' AND $page['visibility'] != 'none') { ?>
|
221
|
<a href="<?php echo $admin->page_link($page['link']); ?>" target="_blank" title="<?php echo $TEXT['VIEW']; ?>">
|
222
|
<img src="<?php echo ADMIN_URL; ?>/images/view_16.png" border="0" alt="<?php echo $TEXT['VIEW']; ?>" />
|
223
|
</a>
|
224
|
<?php } ?>
|
225
|
</td>
|
226
|
<td width="20">
|
227
|
<?php if($page['visibility'] != 'deleted') { ?>
|
228
|
<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
|
229
|
<a href="<?php echo ADMIN_URL; ?>/pages/settings.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['SETTINGS']; ?>">
|
230
|
<img src="<?php echo ADMIN_URL; ?>/images/modify_16.png" border="0" alt="<?php echo $TEXT['SETTINGS']; ?>" />
|
231
|
</a>
|
232
|
<?php } ?>
|
233
|
<?php } else { ?>
|
234
|
<a href="<?php echo ADMIN_URL; ?>/pages/restore.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['RESTORE']; ?>">
|
235
|
<img src="<?php echo ADMIN_URL; ?>/images/restore_16.png" border="0" alt="<?php echo $TEXT['RESTORE']; ?>" />
|
236
|
</a>
|
237
|
<?php } ?>
|
238
|
</td>
|
239
|
<!-- MANAGE SECTIONS AND DATES BUTTONS -->
|
240
|
<td width="20">
|
241
|
<?php
|
242
|
// Work-out if we should show the "manage dates" link
|
243
|
if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true) {
|
244
|
$query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
|
245
|
if($query_sections->numRows() > 0) {
|
246
|
$mdate_display=false;
|
247
|
while($mdate_res = $query_sections->fetchRow()) {
|
248
|
if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0') {
|
249
|
$mdate_display=true;
|
250
|
break;
|
251
|
}
|
252
|
}
|
253
|
if($mdate_display==1) {
|
254
|
$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
|
255
|
?>
|
256
|
<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
|
257
|
<img src="<?php echo ADMIN_URL."/images/$file"; ?>" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
|
258
|
</a>
|
259
|
<?php } else { ?>
|
260
|
<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
|
261
|
<img src="<?php echo ADMIN_URL; ?>/images/noclock_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" /></a>
|
262
|
<?php } ?>
|
263
|
<?php } ?>
|
264
|
<?php } ?>
|
265
|
</td>
|
266
|
<td width="20">
|
267
|
<?php if($page['position'] != 1) { ?>
|
268
|
<?php if($page['visibility'] != 'deleted') { ?>
|
269
|
<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
|
270
|
<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
|
271
|
<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" />
|
272
|
</a>
|
273
|
<?php } ?>
|
274
|
<?php } ?>
|
275
|
<?php } ?>
|
276
|
</td>
|
277
|
<td width="20">
|
278
|
<?php if($page['position'] != $num_pages) { ?>
|
279
|
<?php if($page['visibility'] != 'deleted') { ?>
|
280
|
<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
|
281
|
<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
|
282
|
<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" border="0" alt="v" />
|
283
|
</a>
|
284
|
<?php } ?>
|
285
|
<?php } ?>
|
286
|
<?php } ?>
|
287
|
</td>
|
288
|
<td width="20">
|
289
|
<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
|
290
|
<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']; ?>">
|
291
|
<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
|
292
|
</a>
|
293
|
<?php } ?>
|
294
|
</td>
|
295
|
</tr>
|
296
|
</table>
|
297
|
</li>
|
298
|
|
299
|
<?php
|
300
|
// Get subs
|
301
|
$editable_pages=make_list($page['page_id'], $editable_pages);
|
302
|
}
|
303
|
|
304
|
}
|
305
|
?>
|
306
|
</ul>
|
307
|
<?php
|
308
|
return $editable_pages;
|
309
|
}
|
310
|
|
311
|
// Generate pages list
|
312
|
if($admin->get_permission('pages_view') == true) {
|
313
|
?>
|
314
|
<table cellpadding="0" cellspacing="0" width="100%" border="0">
|
315
|
<tr>
|
316
|
<td>
|
317
|
<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
|
318
|
</td>
|
319
|
<td align="right">
|
320
|
<?php
|
321
|
// Check if there are any pages that are in trash, and if we should show a link to the trash page
|
322
|
if(PAGE_TRASH == 'separate') {
|
323
|
$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
|
324
|
if($query_trash->numRows() > 0) {
|
325
|
?>
|
326
|
<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
|
327
|
<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
|
328
|
<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
|
329
|
<?php
|
330
|
}
|
331
|
}
|
332
|
?>
|
333
|
</td>
|
334
|
</tr>
|
335
|
</table>
|
336
|
<div class="pages_list">
|
337
|
<table cellpadding="0" cellspacing="0" width="720px" border="0">
|
338
|
<tr>
|
339
|
<td width="20px">
|
340
|
|
341
|
</td>
|
342
|
<td width="314px">
|
343
|
<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['PAGE_TITLE']; ?>:
|
344
|
</td>
|
345
|
<td width="256px" align="left">
|
346
|
<?php echo $TEXT['MENU_TITLE']; ?>:
|
347
|
</td>
|
348
|
<td width="130px" align="center">
|
349
|
<?php echo $TEXT['ACTIONS']; ?>:
|
350
|
</td>
|
351
|
</tr>
|
352
|
</table>
|
353
|
<?php
|
354
|
$editable_pages = make_list(0, 0);
|
355
|
?>
|
356
|
</div>
|
357
|
<div class="empty_list">
|
358
|
<?php echo $TEXT['NONE_FOUND']; ?>
|
359
|
</div>
|
360
|
<?php
|
361
|
} else {
|
362
|
$editable_pages = 0;
|
363
|
}
|
364
|
|
365
|
// Setup template object
|
366
|
$template = new Template(ADMIN_PATH.'/pages');
|
367
|
$template->set_file('page', 'template.html');
|
368
|
$template->set_block('page', 'main_block', 'main');
|
369
|
|
370
|
// Figure out if the no pages found message should be shown or not
|
371
|
if($editable_pages == 0) {
|
372
|
?>
|
373
|
<style type="text/css">
|
374
|
.pages_list {
|
375
|
display: none;
|
376
|
}
|
377
|
</style>
|
378
|
<?php
|
379
|
} else {
|
380
|
?>
|
381
|
<style type="text/css">
|
382
|
.empty_list {
|
383
|
display: none;
|
384
|
}
|
385
|
</style>
|
386
|
<?php
|
387
|
}
|
388
|
|
389
|
// Insert values into the add page form
|
390
|
|
391
|
// Group list 1
|
392
|
|
393
|
$query = "SELECT * FROM ".TABLE_PREFIX."groups";
|
394
|
|
395
|
$get_groups = $database->query($query);
|
396
|
$template->set_block('main_block', 'group_list_block', 'group_list');
|
397
|
// Insert admin group and current group first
|
398
|
$admin_group_name = $get_groups->fetchRow();
|
399
|
$template->set_var(array(
|
400
|
'ID' => 1,
|
401
|
'TOGGLE' => '',
|
402
|
'DISABLED' => ' disabled',
|
403
|
'LINK_COLOR' => '000000',
|
404
|
'CURSOR' => 'default',
|
405
|
'NAME' => $admin_group_name['name'],
|
406
|
'CHECKED' => ' checked'
|
407
|
)
|
408
|
);
|
409
|
$template->parse('group_list', 'group_list_block', true);
|
410
|
|
411
|
while($group = $get_groups->fetchRow()) {
|
412
|
// check if the user is a member of this group
|
413
|
$flag_disabled = '';
|
414
|
$flag_checked = '';
|
415
|
$flag_cursor = 'pointer';
|
416
|
$flag_color = '';
|
417
|
if (in_array($group["group_id"], $admin->get_groups_id())) {
|
418
|
$flag_disabled = ' disabled';
|
419
|
$flag_checked = ' checked';
|
420
|
$flag_cursor = 'default';
|
421
|
$flag_color = '000000';
|
422
|
}
|
423
|
|
424
|
// Check if the group is allowed to edit pages
|
425
|
$system_permissions = explode(',', $group['system_permissions']);
|
426
|
if(is_numeric(array_search('pages_modify', $system_permissions))) {
|
427
|
$template->set_var(array(
|
428
|
'ID' => $group['group_id'],
|
429
|
'TOGGLE' => $group['group_id'],
|
430
|
'CHECKED' => $flag_checked,
|
431
|
'DISABLED' => $flag_disabled,
|
432
|
'LINK_COLOR' => $flag_color,
|
433
|
'CURSOR' => $flag_checked,
|
434
|
'NAME' => $group['name'],
|
435
|
)
|
436
|
);
|
437
|
$template->parse('group_list', 'group_list_block', true);
|
438
|
}
|
439
|
}
|
440
|
// Group list 2
|
441
|
|
442
|
$query = "SELECT * FROM ".TABLE_PREFIX."groups";
|
443
|
|
444
|
$get_groups = $database->query($query);
|
445
|
$template->set_block('main_block', 'group_list_block2', 'group_list2');
|
446
|
// Insert admin group and current group first
|
447
|
$admin_group_name = $get_groups->fetchRow();
|
448
|
$template->set_var(array(
|
449
|
'ID' => 1,
|
450
|
'TOGGLE' => '',
|
451
|
'DISABLED' => ' disabled',
|
452
|
'LINK_COLOR' => '000000',
|
453
|
'CURSOR' => 'default',
|
454
|
'NAME' => $admin_group_name['name'],
|
455
|
'CHECKED' => ' checked'
|
456
|
)
|
457
|
);
|
458
|
$template->parse('group_list2', 'group_list_block2', true);
|
459
|
|
460
|
while($group = $get_groups->fetchRow()) {
|
461
|
// check if the user is a member of this group
|
462
|
$flag_disabled = '';
|
463
|
$flag_checked = '';
|
464
|
$flag_cursor = 'pointer';
|
465
|
$flag_color = '';
|
466
|
if (in_array($group["group_id"], $admin->get_groups_id())) {
|
467
|
$flag_disabled = ' disabled';
|
468
|
$flag_checked = ' checked';
|
469
|
$flag_cursor = 'default';
|
470
|
$flag_color = '000000';
|
471
|
}
|
472
|
|
473
|
$template->set_var(array(
|
474
|
'ID' => $group['group_id'],
|
475
|
'TOGGLE' => $group['group_id'],
|
476
|
'CHECKED' => $flag_checked,
|
477
|
'DISABLED' => $flag_disabled,
|
478
|
'LINK_COLOR' => $flag_color,
|
479
|
'CURSOR' => $flag_cursor,
|
480
|
'NAME' => $group['name'],
|
481
|
)
|
482
|
);
|
483
|
$template->parse('group_list2', 'group_list_block2', true);
|
484
|
}
|
485
|
|
486
|
// Parent page list
|
487
|
$database = new database();
|
488
|
function parent_list($parent) {
|
489
|
global $admin, $database, $template;
|
490
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
|
491
|
$get_pages = $database->query($query);
|
492
|
while($page = $get_pages->fetchRow()) {
|
493
|
// Stop users from adding pages with a level of more than the set page level limit
|
494
|
if($page['level']+1 < PAGE_LEVEL_LIMIT) {
|
495
|
// Get user perms
|
496
|
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
|
497
|
$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
|
498
|
|
499
|
$in_group = FALSE;
|
500
|
foreach($admin->get_groups_id() as $cur_gid){
|
501
|
if (in_array($cur_gid, $admin_groups)) {
|
502
|
$in_group = TRUE;
|
503
|
}
|
504
|
}
|
505
|
if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
|
506
|
$can_modify = true;
|
507
|
} else {
|
508
|
$can_modify = false;
|
509
|
}
|
510
|
// Title -'s prefix
|
511
|
$title_prefix = '';
|
512
|
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
|
513
|
$template->set_var(array(
|
514
|
'ID' => $page['page_id'],
|
515
|
'TITLE' => ($title_prefix.$page['page_title'])
|
516
|
)
|
517
|
);
|
518
|
if($can_modify == true) {
|
519
|
$template->set_var('DISABLED', '');
|
520
|
} else {
|
521
|
$template->set_var('DISABLED', ' disabled="disabled" style="color: #aaa;"');
|
522
|
}
|
523
|
$template->parse('page_list2', 'page_list_block2', true);
|
524
|
}
|
525
|
parent_list($page['page_id']);
|
526
|
}
|
527
|
}
|
528
|
$template->set_block('main_block', 'page_list_block2', 'page_list2');
|
529
|
if($admin->get_permission('pages_add_l0') == true) {
|
530
|
$template->set_var(array(
|
531
|
'ID' => '0',
|
532
|
'TITLE' => $TEXT['NONE'],
|
533
|
'SELECTED' => ' selected',
|
534
|
'DISABLED' => ''
|
535
|
)
|
536
|
);
|
537
|
$template->parse('page_list2', 'page_list_block2', true);
|
538
|
}
|
539
|
parent_list(0);
|
540
|
|
541
|
// Explode module permissions
|
542
|
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
543
|
// Modules list
|
544
|
$template->set_block('main_block', 'module_list_block', 'module_list');
|
545
|
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
|
546
|
if($result->numRows() > 0) {
|
547
|
while ($module = $result->fetchRow()) {
|
548
|
// Check if user is allowed to use this module
|
549
|
if(!is_numeric(array_search($module['directory'], $module_permissions))) {
|
550
|
$template->set_var('VALUE', $module['directory']);
|
551
|
$template->set_var('NAME', $module['name']);
|
552
|
if($module['directory'] == 'wysiwyg') {
|
553
|
$template->set_var('SELECTED', ' selected');
|
554
|
} else {
|
555
|
$template->set_var('SELECTED', '');
|
556
|
}
|
557
|
$template->parse('module_list', 'module_list_block', true);
|
558
|
}
|
559
|
}
|
560
|
}
|
561
|
|
562
|
// Insert language headings
|
563
|
$template->set_var(array(
|
564
|
'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
|
565
|
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
|
566
|
)
|
567
|
);
|
568
|
// Insert language text and messages
|
569
|
$template->set_var(array(
|
570
|
'TEXT_TITLE' => $TEXT['TITLE'],
|
571
|
'TEXT_TYPE' => $TEXT['TYPE'],
|
572
|
'TEXT_PARENT' => $TEXT['PARENT'],
|
573
|
'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
|
574
|
'TEXT_PUBLIC' => $TEXT['PUBLIC'],
|
575
|
'TEXT_PRIVATE' => $TEXT['PRIVATE'],
|
576
|
'TEXT_REGISTERED' => $TEXT['REGISTERED'],
|
577
|
'TEXT_HIDDEN' => $TEXT['HIDDEN'],
|
578
|
'TEXT_NONE' => $TEXT['NONE'],
|
579
|
'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
|
580
|
'TEXT_ADD' => $TEXT['ADD'],
|
581
|
'TEXT_RESET' => $TEXT['RESET'],
|
582
|
'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
|
583
|
'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
|
584
|
'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
|
585
|
'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
|
586
|
)
|
587
|
);
|
588
|
|
589
|
// Insert permissions values
|
590
|
if($admin->get_permission('pages_add') != true) {
|
591
|
$template->set_var('DISPLAY_ADD', 'hide');
|
592
|
} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
|
593
|
$template->set_var('DISPLAY_ADD', 'hide');
|
594
|
}
|
595
|
if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
|
596
|
$template->set_var('DISPLAY_INTRO', 'hide');
|
597
|
}
|
598
|
|
599
|
|
600
|
// Parse template object
|
601
|
$template->parse('main', 'main_block', false);
|
602
|
$template->pparse('output', 'page');
|
603
|
|
604
|
// Print admin
|
605
|
$admin->print_footer();
|
606
|
|
607
|
?>
|