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