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