1
|
<?php
|
2
|
|
3
|
// $Id: index.php 557 2008-01-18 18:26:46Z thorn $
|
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="232">
|
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
|
|
240
|
<!-- 'MANAGE SECTIONS' BUTTON -->
|
241
|
<td width="20">
|
242
|
<?php
|
243
|
// Work-out if we should show the "manage sections" link
|
244
|
$query_sections = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE page_id = '" . $page['page_id'] . "' AND module = 'menu_link'");
|
245
|
if(($query_sections->numRows() == 0) && (MANAGE_SECTIONS == 'enabled')) {
|
246
|
?>
|
247
|
<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
|
248
|
<img src="<?php echo ADMIN_URL; ?>/images/sections_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
|
249
|
</a>
|
250
|
<?php } ?>
|
251
|
</td>
|
252
|
|
253
|
<!-- 'MANAGE DATES' BUTTON -->
|
254
|
<td width="20">
|
255
|
<?php
|
256
|
// Work-out if we should show the "manage dates" link
|
257
|
if(MANAGE_SECTIONS == 'enabled' && $admin->get_permission('pages_modify')==true && $can_modify==true) {
|
258
|
$query_sections = $database->query("SELECT publ_start, publ_end FROM ".TABLE_PREFIX."sections WHERE page_id = '{$page['page_id']}' AND module != 'menu_link'");
|
259
|
if($query_sections->numRows() > 0) {
|
260
|
$mdate_display=false;
|
261
|
while($mdate_res = $query_sections->fetchRow()) {
|
262
|
if($mdate_res['publ_start']!='0' || $mdate_res['publ_end']!='0') {
|
263
|
$mdate_display=true;
|
264
|
break;
|
265
|
}
|
266
|
}
|
267
|
if($mdate_display==1) {
|
268
|
$file=$admin->page_is_active($page)?"clock_16.png":"clock_red_16.png";
|
269
|
?>
|
270
|
<a href="<?php echo ADMIN_URL; ?>/pages/sections.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $HEADING['MANAGE_SECTIONS']; ?>">
|
271
|
<img src="<?php echo ADMIN_URL."/images/$file"; ?>" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
|
272
|
</a>
|
273
|
<?php } else { ?>
|
274
|
<img src="<?php echo ADMIN_URL; ?>/images/noclock_16.png" border="0" alt="<?php echo $HEADING['MANAGE_SECTIONS']; ?>" />
|
275
|
<?php } ?>
|
276
|
<?php } ?>
|
277
|
<?php } ?>
|
278
|
</td>
|
279
|
<td width="20">
|
280
|
<?php if($page['position'] != 1) { ?>
|
281
|
<?php if($page['visibility'] != 'deleted') { ?>
|
282
|
<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
|
283
|
<a href="<?php echo ADMIN_URL; ?>/pages/move_up.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
|
284
|
<img src="<?php echo ADMIN_URL; ?>/images/up_16.png" border="0" alt="^" />
|
285
|
</a>
|
286
|
<?php } ?>
|
287
|
<?php } ?>
|
288
|
<?php } ?>
|
289
|
</td>
|
290
|
<td width="20">
|
291
|
<?php if($page['position'] != $num_pages) { ?>
|
292
|
<?php if($page['visibility'] != 'deleted') { ?>
|
293
|
<?php if($admin->get_permission('pages_settings') == true AND $can_modify == true) { ?>
|
294
|
<a href="<?php echo ADMIN_URL; ?>/pages/move_down.php?page_id=<?php echo $page['page_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
|
295
|
<img src="<?php echo ADMIN_URL; ?>/images/down_16.png" border="0" alt="v" />
|
296
|
</a>
|
297
|
<?php } ?>
|
298
|
<?php } ?>
|
299
|
<?php } ?>
|
300
|
</td>
|
301
|
<td width="20">
|
302
|
<?php if($admin->get_permission('pages_delete') == true AND $can_modify == true) { ?>
|
303
|
<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']; ?>">
|
304
|
<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" border="0" alt="X" />
|
305
|
</a>
|
306
|
<?php } ?>
|
307
|
</td>
|
308
|
</tr>
|
309
|
</table>
|
310
|
</li>
|
311
|
|
312
|
<?php
|
313
|
// Get subs
|
314
|
$editable_pages=make_list($page['page_id'], $editable_pages);
|
315
|
}
|
316
|
|
317
|
}
|
318
|
?>
|
319
|
</ul>
|
320
|
<?php
|
321
|
return $editable_pages;
|
322
|
}
|
323
|
|
324
|
// Generate pages list
|
325
|
if($admin->get_permission('pages_view') == true) {
|
326
|
?>
|
327
|
<table cellpadding="0" cellspacing="0" width="100%" border="0">
|
328
|
<tr>
|
329
|
<td>
|
330
|
<h2><?php echo $HEADING['MODIFY_DELETE_PAGE']; ?></h2>
|
331
|
</td>
|
332
|
<td align="right">
|
333
|
<?php
|
334
|
// Check if there are any pages that are in trash, and if we should show a link to the trash page
|
335
|
if(PAGE_TRASH == 'separate') {
|
336
|
$query_trash = $database->query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
|
337
|
if($query_trash->numRows() > 0) {
|
338
|
?>
|
339
|
<a href="<?php echo ADMIN_URL; ?>/pages/trash.php">
|
340
|
<img src="<?php echo ADMIN_URL; ?>/images/delete_16.png" alt="<?php echo $TEXT['PAGE_TRASH']; ?>" border="0" />
|
341
|
<?php echo $TEXT['VIEW_DELETED_PAGES']; ?></a>
|
342
|
<?php
|
343
|
}
|
344
|
}
|
345
|
?>
|
346
|
</td>
|
347
|
</tr>
|
348
|
</table>
|
349
|
<div class="pages_list">
|
350
|
<table cellpadding="1" cellspacing="0" width="720" border="0">
|
351
|
<tr>
|
352
|
<td width="20">
|
353
|
|
354
|
</td>
|
355
|
<td>
|
356
|
<?php echo $TEXT['VISIBILITY'] .' / ' .$TEXT['PAGE_TITLE']; ?>:
|
357
|
</td>
|
358
|
<td width="130" align="left">
|
359
|
<?php echo $TEXT['MENU_TITLE']; ?>:
|
360
|
</td>
|
361
|
<td width="255" align="center">
|
362
|
<?php echo $TEXT['ACTIONS']; ?>:
|
363
|
</td>
|
364
|
</tr>
|
365
|
</table>
|
366
|
<?php
|
367
|
$editable_pages = make_list(0, 0);
|
368
|
?>
|
369
|
</div>
|
370
|
<div class="empty_list">
|
371
|
<?php echo $TEXT['NONE_FOUND']; ?>
|
372
|
</div>
|
373
|
<?php
|
374
|
} else {
|
375
|
$editable_pages = 0;
|
376
|
}
|
377
|
|
378
|
// Setup template object
|
379
|
$template = new Template(ADMIN_PATH.'/pages');
|
380
|
$template->set_file('page', 'template.html');
|
381
|
$template->set_block('page', 'main_block', 'main');
|
382
|
|
383
|
// Figure out if the no pages found message should be shown or not
|
384
|
if($editable_pages == 0) {
|
385
|
?>
|
386
|
<style type="text/css">
|
387
|
.pages_list {
|
388
|
display: none;
|
389
|
}
|
390
|
</style>
|
391
|
<?php
|
392
|
} else {
|
393
|
?>
|
394
|
<style type="text/css">
|
395
|
.empty_list {
|
396
|
display: none;
|
397
|
}
|
398
|
</style>
|
399
|
<?php
|
400
|
}
|
401
|
|
402
|
// Insert values into the add page form
|
403
|
|
404
|
// Group list 1
|
405
|
|
406
|
$query = "SELECT * FROM ".TABLE_PREFIX."groups";
|
407
|
|
408
|
$get_groups = $database->query($query);
|
409
|
$template->set_block('main_block', 'group_list_block', 'group_list');
|
410
|
// Insert admin group and current group first
|
411
|
$admin_group_name = $get_groups->fetchRow();
|
412
|
$template->set_var(array(
|
413
|
'ID' => 1,
|
414
|
'TOGGLE' => '',
|
415
|
'DISABLED' => ' disabled',
|
416
|
'LINK_COLOR' => '000000',
|
417
|
'CURSOR' => 'default',
|
418
|
'NAME' => $admin_group_name['name'],
|
419
|
'CHECKED' => ' checked'
|
420
|
)
|
421
|
);
|
422
|
$template->parse('group_list', 'group_list_block', true);
|
423
|
|
424
|
while($group = $get_groups->fetchRow()) {
|
425
|
// check if the user is a member of this group
|
426
|
$flag_disabled = '';
|
427
|
$flag_checked = '';
|
428
|
$flag_cursor = 'pointer';
|
429
|
$flag_color = '';
|
430
|
if (in_array($group["group_id"], $admin->get_groups_id())) {
|
431
|
$flag_disabled = ' disabled';
|
432
|
$flag_checked = ' checked';
|
433
|
$flag_cursor = 'default';
|
434
|
$flag_color = '000000';
|
435
|
}
|
436
|
|
437
|
// Check if the group is allowed to edit pages
|
438
|
$system_permissions = explode(',', $group['system_permissions']);
|
439
|
if(is_numeric(array_search('pages_modify', $system_permissions))) {
|
440
|
$template->set_var(array(
|
441
|
'ID' => $group['group_id'],
|
442
|
'TOGGLE' => $group['group_id'],
|
443
|
'CHECKED' => $flag_checked,
|
444
|
'DISABLED' => $flag_disabled,
|
445
|
'LINK_COLOR' => $flag_color,
|
446
|
'CURSOR' => $flag_checked,
|
447
|
'NAME' => $group['name'],
|
448
|
)
|
449
|
);
|
450
|
$template->parse('group_list', 'group_list_block', true);
|
451
|
}
|
452
|
}
|
453
|
// Group list 2
|
454
|
|
455
|
$query = "SELECT * FROM ".TABLE_PREFIX."groups";
|
456
|
|
457
|
$get_groups = $database->query($query);
|
458
|
$template->set_block('main_block', 'group_list_block2', 'group_list2');
|
459
|
// Insert admin group and current group first
|
460
|
$admin_group_name = $get_groups->fetchRow();
|
461
|
$template->set_var(array(
|
462
|
'ID' => 1,
|
463
|
'TOGGLE' => '',
|
464
|
'DISABLED' => ' disabled',
|
465
|
'LINK_COLOR' => '000000',
|
466
|
'CURSOR' => 'default',
|
467
|
'NAME' => $admin_group_name['name'],
|
468
|
'CHECKED' => ' checked'
|
469
|
)
|
470
|
);
|
471
|
$template->parse('group_list2', 'group_list_block2', true);
|
472
|
|
473
|
while($group = $get_groups->fetchRow()) {
|
474
|
// check if the user is a member of this group
|
475
|
$flag_disabled = '';
|
476
|
$flag_checked = '';
|
477
|
$flag_cursor = 'pointer';
|
478
|
$flag_color = '';
|
479
|
if (in_array($group["group_id"], $admin->get_groups_id())) {
|
480
|
$flag_disabled = ' disabled';
|
481
|
$flag_checked = ' checked';
|
482
|
$flag_cursor = 'default';
|
483
|
$flag_color = '000000';
|
484
|
}
|
485
|
|
486
|
$template->set_var(array(
|
487
|
'ID' => $group['group_id'],
|
488
|
'TOGGLE' => $group['group_id'],
|
489
|
'CHECKED' => $flag_checked,
|
490
|
'DISABLED' => $flag_disabled,
|
491
|
'LINK_COLOR' => $flag_color,
|
492
|
'CURSOR' => $flag_cursor,
|
493
|
'NAME' => $group['name'],
|
494
|
)
|
495
|
);
|
496
|
$template->parse('group_list2', 'group_list_block2', true);
|
497
|
}
|
498
|
|
499
|
// Parent page list
|
500
|
$database = new database();
|
501
|
function parent_list($parent) {
|
502
|
global $admin, $database, $template;
|
503
|
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
|
504
|
$get_pages = $database->query($query);
|
505
|
while($page = $get_pages->fetchRow()) {
|
506
|
// Stop users from adding pages with a level of more than the set page level limit
|
507
|
if($page['level']+1 < PAGE_LEVEL_LIMIT) {
|
508
|
// Get user perms
|
509
|
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
|
510
|
$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
|
511
|
|
512
|
$in_group = FALSE;
|
513
|
foreach($admin->get_groups_id() as $cur_gid){
|
514
|
if (in_array($cur_gid, $admin_groups)) {
|
515
|
$in_group = TRUE;
|
516
|
}
|
517
|
}
|
518
|
if(($in_group) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
|
519
|
$can_modify = true;
|
520
|
} else {
|
521
|
$can_modify = false;
|
522
|
}
|
523
|
// Title -'s prefix
|
524
|
$title_prefix = '';
|
525
|
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
|
526
|
$template->set_var(array(
|
527
|
'ID' => $page['page_id'],
|
528
|
'TITLE' => ($title_prefix.$page['page_title'])
|
529
|
)
|
530
|
);
|
531
|
if($can_modify == true) {
|
532
|
$template->set_var('DISABLED', '');
|
533
|
} else {
|
534
|
$template->set_var('DISABLED', ' disabled="disabled" style="color: #aaa;"');
|
535
|
}
|
536
|
$template->parse('page_list2', 'page_list_block2', true);
|
537
|
}
|
538
|
parent_list($page['page_id']);
|
539
|
}
|
540
|
}
|
541
|
$template->set_block('main_block', 'page_list_block2', 'page_list2');
|
542
|
if($admin->get_permission('pages_add_l0') == true) {
|
543
|
$template->set_var(array(
|
544
|
'ID' => '0',
|
545
|
'TITLE' => $TEXT['NONE'],
|
546
|
'SELECTED' => ' selected',
|
547
|
'DISABLED' => ''
|
548
|
)
|
549
|
);
|
550
|
$template->parse('page_list2', 'page_list_block2', true);
|
551
|
}
|
552
|
parent_list(0);
|
553
|
|
554
|
// Explode module permissions
|
555
|
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
|
556
|
// Modules list
|
557
|
$template->set_block('main_block', 'module_list_block', 'module_list');
|
558
|
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'module' AND function = 'page' order by name");
|
559
|
if($result->numRows() > 0) {
|
560
|
while ($module = $result->fetchRow()) {
|
561
|
// Check if user is allowed to use this module
|
562
|
if(!is_numeric(array_search($module['directory'], $module_permissions))) {
|
563
|
$template->set_var('VALUE', $module['directory']);
|
564
|
$template->set_var('NAME', $module['name']);
|
565
|
if($module['directory'] == 'wysiwyg') {
|
566
|
$template->set_var('SELECTED', ' selected');
|
567
|
} else {
|
568
|
$template->set_var('SELECTED', '');
|
569
|
}
|
570
|
$template->parse('module_list', 'module_list_block', true);
|
571
|
}
|
572
|
}
|
573
|
}
|
574
|
|
575
|
// Insert language headings
|
576
|
$template->set_var(array(
|
577
|
'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
|
578
|
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
|
579
|
)
|
580
|
);
|
581
|
// Insert language text and messages
|
582
|
$template->set_var(array(
|
583
|
'TEXT_TITLE' => $TEXT['TITLE'],
|
584
|
'TEXT_TYPE' => $TEXT['TYPE'],
|
585
|
'TEXT_PARENT' => $TEXT['PARENT'],
|
586
|
'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
|
587
|
'TEXT_PUBLIC' => $TEXT['PUBLIC'],
|
588
|
'TEXT_PRIVATE' => $TEXT['PRIVATE'],
|
589
|
'TEXT_REGISTERED' => $TEXT['REGISTERED'],
|
590
|
'TEXT_HIDDEN' => $TEXT['HIDDEN'],
|
591
|
'TEXT_NONE' => $TEXT['NONE'],
|
592
|
'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
|
593
|
'TEXT_ADD' => $TEXT['ADD'],
|
594
|
'TEXT_RESET' => $TEXT['RESET'],
|
595
|
'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
|
596
|
'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
|
597
|
'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
|
598
|
'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
|
599
|
)
|
600
|
);
|
601
|
|
602
|
// Insert permissions values
|
603
|
if($admin->get_permission('pages_add') != true) {
|
604
|
$template->set_var('DISPLAY_ADD', 'hide');
|
605
|
} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
|
606
|
$template->set_var('DISPLAY_ADD', 'hide');
|
607
|
}
|
608
|
if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
|
609
|
$template->set_var('DISPLAY_INTRO', 'hide');
|
610
|
}
|
611
|
|
612
|
|
613
|
// Parse template object
|
614
|
$template->parse('main', 'main_block', false);
|
615
|
$template->pparse('output', 'page');
|
616
|
|
617
|
// Print admin
|
618
|
$admin->print_footer();
|
619
|
|
620
|
?>
|