1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Copyright (C) 2008-2011 FluxBB |
---|
5 | * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB |
---|
6 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
---|
7 | */ |
---|
8 | |
---|
9 | // Tell header.php to use the admin template |
---|
10 | define('PUN_ADMIN_CONSOLE', 1); |
---|
11 | |
---|
12 | define('PUN_ROOT', dirname(__FILE__).'/'); |
---|
13 | require PUN_ROOT.'include/common.php'; |
---|
14 | require PUN_ROOT.'include/common_admin.php'; |
---|
15 | |
---|
16 | |
---|
17 | if ($pun_user['g_id'] != PUN_ADMIN) |
---|
18 | message($lang_common['No permission']); |
---|
19 | |
---|
20 | // Load the admin_forums.php language file |
---|
21 | require PUN_ROOT.'lang/'.$admin_language.'/admin_forums.php'; |
---|
22 | |
---|
23 | // Add a "default" forum |
---|
24 | if (isset($_POST['add_forum'])) |
---|
25 | { |
---|
26 | confirm_referrer('admin_forums.php'); |
---|
27 | |
---|
28 | $add_to_cat = intval($_POST['add_to_cat']); |
---|
29 | if ($add_to_cat < 1) |
---|
30 | message($lang_common['Bad request']); |
---|
31 | |
---|
32 | $db->query('INSERT INTO '.$db->prefix.'forums (forum_name, cat_id) VALUES(\''.$db->escape($lang_admin_forums['New forum']).'\', '.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error()); |
---|
33 | |
---|
34 | // Regenerate the quick jump cache |
---|
35 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
36 | require PUN_ROOT.'include/cache.php'; |
---|
37 | |
---|
38 | generate_quickjump_cache(); |
---|
39 | |
---|
40 | redirect('admin_forums.php', $lang_admin_forums['Forum added redirect']); |
---|
41 | } |
---|
42 | |
---|
43 | // Delete a forum |
---|
44 | else if (isset($_GET['del_forum'])) |
---|
45 | { |
---|
46 | confirm_referrer('admin_forums.php'); |
---|
47 | |
---|
48 | $forum_id = intval($_GET['del_forum']); |
---|
49 | if ($forum_id < 1) |
---|
50 | message($lang_common['Bad request']); |
---|
51 | |
---|
52 | if (isset($_POST['del_forum_comply'])) // Delete a forum with all posts |
---|
53 | { |
---|
54 | @set_time_limit(0); |
---|
55 | |
---|
56 | // Prune all posts and topics |
---|
57 | prune($forum_id, 1, -1); |
---|
58 | |
---|
59 | // Locate any "orphaned redirect topics" and delete them |
---|
60 | $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error()); |
---|
61 | $num_orphans = $db->num_rows($result); |
---|
62 | |
---|
63 | if ($num_orphans) |
---|
64 | { |
---|
65 | for ($i = 0; $i < $num_orphans; ++$i) |
---|
66 | $orphans[] = $db->result($result, $i); |
---|
67 | |
---|
68 | $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); |
---|
69 | } |
---|
70 | |
---|
71 | // Delete the forum and any forum specific group permissions |
---|
72 | $db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error()); |
---|
73 | $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); |
---|
74 | |
---|
75 | // Delete any subscriptions for this forum |
---|
76 | $db->query('DELETE FROM '.$db->prefix.'forum_subscriptions WHERE forum_id='.$forum_id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error()); |
---|
77 | |
---|
78 | // Regenerate the quick jump cache |
---|
79 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
80 | require PUN_ROOT.'include/cache.php'; |
---|
81 | |
---|
82 | generate_quickjump_cache(); |
---|
83 | |
---|
84 | redirect('admin_forums.php', $lang_admin_forums['Forum deleted redirect']); |
---|
85 | } |
---|
86 | else // If the user hasn't confirmed the delete |
---|
87 | { |
---|
88 | $result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); |
---|
89 | $forum_name = pun_htmlspecialchars($db->result($result)); |
---|
90 | |
---|
91 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
---|
92 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
93 | require PUN_ROOT.'header.php'; |
---|
94 | |
---|
95 | generate_admin_menu('forums'); |
---|
96 | |
---|
97 | ?> |
---|
98 | <div class="blockform"> |
---|
99 | <h2><span><?php echo $lang_admin_forums['Confirm delete head'] ?></span></h2> |
---|
100 | <div class="box"> |
---|
101 | <form method="post" action="admin_forums.php?del_forum=<?php echo $forum_id ?>"> |
---|
102 | <div class="inform"> |
---|
103 | <fieldset> |
---|
104 | <legend><?php echo $lang_admin_forums['Confirm delete subhead'] ?></legend> |
---|
105 | <div class="infldset"> |
---|
106 | <p><?php printf($lang_admin_forums['Confirm delete info'], $forum_name) ?></p> |
---|
107 | <p class="warntext"><?php echo $lang_admin_forums['Confirm delete warn'] ?></p> |
---|
108 | </div> |
---|
109 | </fieldset> |
---|
110 | </div> |
---|
111 | <p class="buttons"><input type="submit" name="del_forum_comply" value="<?php echo $lang_admin_common['Delete'] ?>" /><a href="javascript:history.go(-1)"><?php echo $lang_admin_common['Go back'] ?></a></p> |
---|
112 | </form> |
---|
113 | </div> |
---|
114 | </div> |
---|
115 | <div class="clearer"></div> |
---|
116 | </div> |
---|
117 | <?php |
---|
118 | |
---|
119 | require PUN_ROOT.'footer.php'; |
---|
120 | } |
---|
121 | } |
---|
122 | |
---|
123 | // Update forum positions |
---|
124 | else if (isset($_POST['update_positions'])) |
---|
125 | { |
---|
126 | confirm_referrer('admin_forums.php'); |
---|
127 | |
---|
128 | foreach ($_POST['position'] as $forum_id => $disp_position) |
---|
129 | { |
---|
130 | $disp_position = trim($disp_position); |
---|
131 | if ($disp_position == '' || preg_match('%[^0-9]%', $disp_position)) |
---|
132 | message($lang_admin_forums['Must be integer message']); |
---|
133 | |
---|
134 | $db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); |
---|
135 | } |
---|
136 | |
---|
137 | // Regenerate the quick jump cache |
---|
138 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
139 | require PUN_ROOT.'include/cache.php'; |
---|
140 | |
---|
141 | generate_quickjump_cache(); |
---|
142 | |
---|
143 | redirect('admin_forums.php', $lang_admin_forums['Forums updated redirect']); |
---|
144 | } |
---|
145 | |
---|
146 | else if (isset($_GET['edit_forum'])) |
---|
147 | { |
---|
148 | $forum_id = intval($_GET['edit_forum']); |
---|
149 | if ($forum_id < 1) |
---|
150 | message($lang_common['Bad request']); |
---|
151 | |
---|
152 | // Update group permissions for $forum_id |
---|
153 | if (isset($_POST['save'])) |
---|
154 | { |
---|
155 | confirm_referrer('admin_forums.php'); |
---|
156 | |
---|
157 | // Start with the forum details |
---|
158 | $forum_name = pun_trim($_POST['forum_name']); |
---|
159 | $forum_desc = pun_linebreaks(pun_trim($_POST['forum_desc'])); |
---|
160 | $cat_id = intval($_POST['cat_id']); |
---|
161 | $sort_by = intval($_POST['sort_by']); |
---|
162 | $redirect_url = isset($_POST['redirect_url']) ? trim($_POST['redirect_url']) : null; |
---|
163 | |
---|
164 | if ($forum_name == '') |
---|
165 | message($lang_admin_forums['Must enter name message']); |
---|
166 | |
---|
167 | if ($cat_id < 1) |
---|
168 | message($lang_common['Bad request']); |
---|
169 | |
---|
170 | $forum_desc = ($forum_desc != '') ? '\''.$db->escape($forum_desc).'\'' : 'NULL'; |
---|
171 | $redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL'; |
---|
172 | |
---|
173 | $db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error()); |
---|
174 | |
---|
175 | // Now let's deal with the permissions |
---|
176 | if (isset($_POST['read_forum_old'])) |
---|
177 | { |
---|
178 | $result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error()); |
---|
179 | while ($cur_group = $db->fetch_assoc($result)) |
---|
180 | { |
---|
181 | $read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]); |
---|
182 | $post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0'; |
---|
183 | $post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0'; |
---|
184 | |
---|
185 | // Check if the new settings differ from the old |
---|
186 | if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']]) |
---|
187 | { |
---|
188 | // If the new settings are identical to the default settings for this group, delete it's row in forum_perms |
---|
189 | if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics']) |
---|
190 | $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); |
---|
191 | else |
---|
192 | { |
---|
193 | // Run an UPDATE and see if it affected a row, if not, INSERT |
---|
194 | $db->query('UPDATE '.$db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); |
---|
195 | if (!$db->affected_rows()) |
---|
196 | $db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error()); |
---|
197 | } |
---|
198 | } |
---|
199 | } |
---|
200 | } |
---|
201 | |
---|
202 | // Regenerate the quick jump cache |
---|
203 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
204 | require PUN_ROOT.'include/cache.php'; |
---|
205 | |
---|
206 | generate_quickjump_cache(); |
---|
207 | |
---|
208 | redirect('admin_forums.php', $lang_admin_forums['Forum updated redirect']); |
---|
209 | } |
---|
210 | else if (isset($_POST['revert_perms'])) |
---|
211 | { |
---|
212 | confirm_referrer('admin_forums.php'); |
---|
213 | |
---|
214 | $db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error()); |
---|
215 | |
---|
216 | // Regenerate the quick jump cache |
---|
217 | if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) |
---|
218 | require PUN_ROOT.'include/cache.php'; |
---|
219 | |
---|
220 | generate_quickjump_cache(); |
---|
221 | |
---|
222 | redirect('admin_forums.php?edit_forum='.$forum_id, $lang_admin_forums['Perms reverted redirect']); |
---|
223 | } |
---|
224 | |
---|
225 | // Fetch forum info |
---|
226 | $result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); |
---|
227 | if (!$db->num_rows($result)) |
---|
228 | message($lang_common['Bad request']); |
---|
229 | |
---|
230 | $cur_forum = $db->fetch_assoc($result); |
---|
231 | |
---|
232 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
---|
233 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
234 | require PUN_ROOT.'header.php'; |
---|
235 | |
---|
236 | generate_admin_menu('forums'); |
---|
237 | |
---|
238 | ?> |
---|
239 | <div class="blockform"> |
---|
240 | <h2><span><?php echo $lang_admin_forums['Edit forum head'] ?></span></h2> |
---|
241 | <div class="box"> |
---|
242 | <form id="edit_forum" method="post" action="admin_forums.php?edit_forum=<?php echo $forum_id ?>"> |
---|
243 | <p class="submittop"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" tabindex="6" /></p> |
---|
244 | <div class="inform"> |
---|
245 | <fieldset> |
---|
246 | <legend><?php echo $lang_admin_forums['Edit details subhead'] ?></legend> |
---|
247 | <div class="infldset"> |
---|
248 | <table class="aligntop" cellspacing="0"> |
---|
249 | <tr> |
---|
250 | <th scope="row"><?php echo $lang_admin_forums['Forum name label'] ?></th> |
---|
251 | <td><input type="text" name="forum_name" size="35" maxlength="80" value="<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?>" tabindex="1" /></td> |
---|
252 | </tr> |
---|
253 | <tr> |
---|
254 | <th scope="row"><?php echo $lang_admin_forums['Forum description label'] ?></th> |
---|
255 | <td><textarea name="forum_desc" rows="3" cols="50" tabindex="2"><?php echo pun_htmlspecialchars($cur_forum['forum_desc']) ?></textarea></td> |
---|
256 | </tr> |
---|
257 | <tr> |
---|
258 | <th scope="row"><?php echo $lang_admin_forums['Category label'] ?></th> |
---|
259 | <td> |
---|
260 | <select name="cat_id" tabindex="3"> |
---|
261 | <?php |
---|
262 | |
---|
263 | $result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); |
---|
264 | while ($cur_cat = $db->fetch_assoc($result)) |
---|
265 | { |
---|
266 | $selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : ''; |
---|
267 | echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'"'.$selected.'>'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n"; |
---|
268 | } |
---|
269 | |
---|
270 | ?> |
---|
271 | </select> |
---|
272 | </td> |
---|
273 | </tr> |
---|
274 | <tr> |
---|
275 | <th scope="row"><?php echo $lang_admin_forums['Sort by label'] ?></th> |
---|
276 | <td> |
---|
277 | <select name="sort_by" tabindex="4"> |
---|
278 | <option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Last post'] ?></option> |
---|
279 | <option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Topic start'] ?></option> |
---|
280 | <option value="2"<?php if ($cur_forum['sort_by'] == '2') echo ' selected="selected"' ?>><?php echo $lang_admin_forums['Subject'] ?></option> |
---|
281 | </select> |
---|
282 | </td> |
---|
283 | </tr> |
---|
284 | <tr> |
---|
285 | <th scope="row"><?php echo $lang_admin_forums['Redirect label'] ?></th> |
---|
286 | <td><?php echo ($cur_forum['num_topics']) ? $lang_admin_forums['Redirect help'] : '<input type="text" name="redirect_url" size="45" maxlength="100" value="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" tabindex="5" />'; ?></td> |
---|
287 | </tr> |
---|
288 | </table> |
---|
289 | </div> |
---|
290 | </fieldset> |
---|
291 | </div> |
---|
292 | <div class="inform"> |
---|
293 | <fieldset> |
---|
294 | <legend><?php echo $lang_admin_forums['Group permissions subhead'] ?></legend> |
---|
295 | <div class="infldset"> |
---|
296 | <p><?php printf($lang_admin_forums['Group permissions info'], '<a href="admin_groups.php">'.$lang_admin_common['User groups'].'</a>') ?></p> |
---|
297 | <table id="forumperms" cellspacing="0"> |
---|
298 | <thead> |
---|
299 | <tr> |
---|
300 | <th class="atcl"> </th> |
---|
301 | <th><?php echo $lang_admin_forums['Read forum label'] ?></th> |
---|
302 | <th><?php echo $lang_admin_forums['Post replies label'] ?></th> |
---|
303 | <th><?php echo $lang_admin_forums['Post topics label'] ?></th> |
---|
304 | </tr> |
---|
305 | </thead> |
---|
306 | <tbody> |
---|
307 | <?php |
---|
308 | |
---|
309 | $result = $db->query('SELECT g.g_id, g.g_title, g.g_read_board, g.g_post_replies, g.g_post_topics, fp.read_forum, fp.post_replies, fp.post_topics FROM '.$db->prefix.'groups AS g LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id='.$forum_id.') WHERE g.g_id!='.PUN_ADMIN.' ORDER BY g.g_id') or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error()); |
---|
310 | |
---|
311 | $cur_index = 7; |
---|
312 | |
---|
313 | while ($cur_perm = $db->fetch_assoc($result)) |
---|
314 | { |
---|
315 | $read_forum = ($cur_perm['read_forum'] != '0') ? true : false; |
---|
316 | $post_replies = (($cur_perm['g_post_replies'] == '0' && $cur_perm['post_replies'] == '1') || ($cur_perm['g_post_replies'] == '1' && $cur_perm['post_replies'] != '0')) ? true : false; |
---|
317 | $post_topics = (($cur_perm['g_post_topics'] == '0' && $cur_perm['post_topics'] == '1') || ($cur_perm['g_post_topics'] == '1' && $cur_perm['post_topics'] != '0')) ? true : false; |
---|
318 | |
---|
319 | // Determine if the current settings differ from the default or not |
---|
320 | $read_forum_def = ($cur_perm['read_forum'] == '0') ? false : true; |
---|
321 | $post_replies_def = (($post_replies && $cur_perm['g_post_replies'] == '0') || (!$post_replies && ($cur_perm['g_post_replies'] == '' || $cur_perm['g_post_replies'] == '1'))) ? false : true; |
---|
322 | $post_topics_def = (($post_topics && $cur_perm['g_post_topics'] == '0') || (!$post_topics && ($cur_perm['g_post_topics'] == '' || $cur_perm['g_post_topics'] == '1'))) ? false : true; |
---|
323 | |
---|
324 | ?> |
---|
325 | <tr> |
---|
326 | <th class="atcl"><?php echo pun_htmlspecialchars($cur_perm['g_title']) ?></th> |
---|
327 | <td<?php if (!$read_forum_def) echo ' class="nodefault"'; ?>> |
---|
328 | <input type="hidden" name="read_forum_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($read_forum) ? '1' : '0'; ?>" /> |
---|
329 | <input type="checkbox" name="read_forum_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($read_forum) ? ' checked="checked"' : ''; ?><?php echo ($cur_perm['g_read_board'] == '0') ? ' disabled="disabled"' : ''; ?> tabindex="<?php echo $cur_index++ ?>" /> |
---|
330 | </td> |
---|
331 | <td<?php if (!$post_replies_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>> |
---|
332 | <input type="hidden" name="post_replies_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_replies) ? '1' : '0'; ?>" /> |
---|
333 | <input type="checkbox" name="post_replies_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_replies) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> tabindex="<?php echo $cur_index++ ?>" /> |
---|
334 | </td> |
---|
335 | <td<?php if (!$post_topics_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>> |
---|
336 | <input type="hidden" name="post_topics_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_topics) ? '1' : '0'; ?>" /> |
---|
337 | <input type="checkbox" name="post_topics_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_topics) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> tabindex="<?php echo $cur_index++ ?>" /> |
---|
338 | </td> |
---|
339 | </tr> |
---|
340 | <?php |
---|
341 | |
---|
342 | } |
---|
343 | |
---|
344 | ?> |
---|
345 | </tbody> |
---|
346 | </table> |
---|
347 | <div class="fsetsubmit"><input type="submit" name="revert_perms" value="<?php echo $lang_admin_forums['Revert to default'] ?>" tabindex="<?php echo $cur_index++ ?>" /></div> |
---|
348 | </div> |
---|
349 | </fieldset> |
---|
350 | </div> |
---|
351 | <p class="submitend"><input type="submit" name="save" value="<?php echo $lang_admin_common['Save changes'] ?>" tabindex="<?php echo $cur_index++ ?>" /></p> |
---|
352 | </form> |
---|
353 | </div> |
---|
354 | </div> |
---|
355 | <div class="clearer"></div> |
---|
356 | </div> |
---|
357 | |
---|
358 | <?php |
---|
359 | |
---|
360 | require PUN_ROOT.'footer.php'; |
---|
361 | } |
---|
362 | |
---|
363 | $page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Forums']); |
---|
364 | define('PUN_ACTIVE_PAGE', 'admin'); |
---|
365 | require PUN_ROOT.'header.php'; |
---|
366 | |
---|
367 | generate_admin_menu('forums'); |
---|
368 | |
---|
369 | ?> |
---|
370 | <div class="blockform"> |
---|
371 | <h2><span><?php echo $lang_admin_forums['Add forum head'] ?></span></h2> |
---|
372 | <div class="box"> |
---|
373 | <form method="post" action="admin_forums.php?action=adddel"> |
---|
374 | <div class="inform"> |
---|
375 | <fieldset> |
---|
376 | <legend><?php echo $lang_admin_forums['Create new subhead'] ?></legend> |
---|
377 | <div class="infldset"> |
---|
378 | <table class="aligntop" cellspacing="0"> |
---|
379 | <tr> |
---|
380 | <th scope="row"><?php echo $lang_admin_forums['Add forum label'] ?><div><input type="submit" name="add_forum" value="<?php echo $lang_admin_forums['Add forum'] ?>" tabindex="2" /></div></th> |
---|
381 | <td> |
---|
382 | <select name="add_to_cat" tabindex="1"> |
---|
383 | <?php |
---|
384 | |
---|
385 | $result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error()); |
---|
386 | if ($db->num_rows($result) > 0) |
---|
387 | { |
---|
388 | while ($cur_cat = $db->fetch_assoc($result)) |
---|
389 | echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n"; |
---|
390 | } |
---|
391 | else |
---|
392 | echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="0" disabled="disabled">'.$lang_admin_forums['No categories exist'].'</option>'."\n"; |
---|
393 | |
---|
394 | ?> |
---|
395 | </select> |
---|
396 | <span><?php echo $lang_admin_forums['Add forum help'] ?></span> |
---|
397 | </td> |
---|
398 | </tr> |
---|
399 | </table> |
---|
400 | </div> |
---|
401 | </fieldset> |
---|
402 | </div> |
---|
403 | </form> |
---|
404 | </div> |
---|
405 | <?php |
---|
406 | |
---|
407 | // Display all the categories and forums |
---|
408 | $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error()); |
---|
409 | |
---|
410 | if ($db->num_rows($result) > 0) |
---|
411 | { |
---|
412 | |
---|
413 | ?> |
---|
414 | <h2 class="block2"><span><?php echo $lang_admin_forums['Edit forums head'] ?></span></h2> |
---|
415 | <div class="box"> |
---|
416 | <form id="edforum" method="post" action="admin_forums.php?action=edit"> |
---|
417 | <p class="submittop"><input type="submit" name="update_positions" value="<?php echo $lang_admin_forums['Update positions'] ?>" tabindex="3" /></p> |
---|
418 | <?php |
---|
419 | |
---|
420 | $cur_index = 4; |
---|
421 | |
---|
422 | $cur_category = 0; |
---|
423 | while ($cur_forum = $db->fetch_assoc($result)) |
---|
424 | { |
---|
425 | if ($cur_forum['cid'] != $cur_category) // A new category since last iteration? |
---|
426 | { |
---|
427 | if ($cur_category != 0) |
---|
428 | echo "\t\t\t\t\t\t\t".'</tbody>'."\n\t\t\t\t\t\t\t".'</table>'."\n\t\t\t\t\t\t".'</div>'."\n\t\t\t\t\t".'</fieldset>'."\n\t\t\t\t".'</div>'."\n"; |
---|
429 | |
---|
430 | ?> |
---|
431 | <div class="inform"> |
---|
432 | <fieldset> |
---|
433 | <legend><?php echo $lang_admin_forums['Category subhead'] ?> <?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></legend> |
---|
434 | <div class="infldset"> |
---|
435 | <table cellspacing="0"> |
---|
436 | <thead> |
---|
437 | <tr> |
---|
438 | <th class="tcl"><?php echo $lang_admin_common['Action'] ?></th> |
---|
439 | <th class="tc2"><?php echo $lang_admin_forums['Position label'] ?></th> |
---|
440 | <th class="tcr"><?php echo $lang_admin_forums['Forum label'] ?></th> |
---|
441 | </tr> |
---|
442 | </thead> |
---|
443 | <tbody> |
---|
444 | <?php |
---|
445 | |
---|
446 | $cur_category = $cur_forum['cid']; |
---|
447 | } |
---|
448 | |
---|
449 | ?> |
---|
450 | <tr> |
---|
451 | <td class="tcl"><a href="admin_forums.php?edit_forum=<?php echo $cur_forum['fid'] ?>" tabindex="<?php echo $cur_index++ ?>"><?php echo $lang_admin_forums['Edit link'] ?></a> | <a href="admin_forums.php?del_forum=<?php echo $cur_forum['fid'] ?>" tabindex="<?php echo $cur_index++ ?>"><?php echo $lang_admin_forums['Delete link'] ?></a></td> |
---|
452 | <td class="tc2"><input type="text" name="position[<?php echo $cur_forum['fid'] ?>]" size="3" maxlength="3" value="<?php echo $cur_forum['disp_position'] ?>" tabindex="<?php echo $cur_index++ ?>" /></td> |
---|
453 | <td class="tcr"><strong><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></strong></td> |
---|
454 | </tr> |
---|
455 | <?php |
---|
456 | |
---|
457 | } |
---|
458 | |
---|
459 | ?> |
---|
460 | </tbody> |
---|
461 | </table> |
---|
462 | </div> |
---|
463 | </fieldset> |
---|
464 | </div> |
---|
465 | <p class="submitend"><input type="submit" name="update_positions" value="<?php echo $lang_admin_forums['Update positions'] ?>" tabindex="<?php echo $cur_index++ ?>" /></p> |
---|
466 | </form> |
---|
467 | </div> |
---|
468 | <?php |
---|
469 | |
---|
470 | } |
---|
471 | |
---|
472 | ?> |
---|
473 | </div> |
---|
474 | <div class="clearer"></div> |
---|
475 | </div> |
---|
476 | <?php |
---|
477 | |
---|
478 | require PUN_ROOT.'footer.php'; |
---|