Chris@76
|
1 <?php
|
Chris@76
|
2
|
Chris@76
|
3 /**
|
Chris@76
|
4 * Simple Machines Forum (SMF)
|
Chris@76
|
5 *
|
Chris@76
|
6 * @package SMF
|
Chris@76
|
7 * @author Simple Machines http://www.simplemachines.org
|
Chris@76
|
8 * @copyright 2011 Simple Machines
|
Chris@76
|
9 * @license http://www.simplemachines.org/about/smf/license.php BSD
|
Chris@76
|
10 *
|
Chris@76
|
11 * @version 2.0
|
Chris@76
|
12 */
|
Chris@76
|
13
|
Chris@76
|
14 if (!defined('SMF'))
|
Chris@76
|
15 die('Hacking attempt...');
|
Chris@76
|
16
|
Chris@76
|
17 /* Manage and maintain the boards and categories of the forum.
|
Chris@76
|
18
|
Chris@76
|
19 void ManageBoards()
|
Chris@76
|
20 - main entry point for all the manageboards admin screens.
|
Chris@76
|
21 - called by ?action=admin;area=manageboards.
|
Chris@76
|
22 - checks the permissions, based on the sub-action.
|
Chris@76
|
23 - loads the ManageBoards language file.
|
Chris@76
|
24 - calls a function based on the sub-action.
|
Chris@76
|
25
|
Chris@76
|
26 void ManageBoardsMain()
|
Chris@76
|
27 - main screen showing all boards and categories.
|
Chris@76
|
28 - called by ?action=admin;area=manageboards or ?action=admin;area=manageboards;sa=move.
|
Chris@76
|
29 - uses the main template of the ManageBoards template.
|
Chris@76
|
30 - requires manage_boards permission.
|
Chris@76
|
31 - also handles the interface for moving boards.
|
Chris@76
|
32
|
Chris@76
|
33 void EditCategory()
|
Chris@76
|
34 - screen for editing and repositioning a category.
|
Chris@76
|
35 - called by ?action=admin;area=manageboards;sa=cat
|
Chris@76
|
36 - uses the modify_category sub-template of the ManageBoards template.
|
Chris@76
|
37 - requires manage_boards permission.
|
Chris@76
|
38 - also used to show the confirm deletion of category screen
|
Chris@76
|
39 (sub-template confirm_category_delete).
|
Chris@76
|
40
|
Chris@76
|
41 void EditCategory2()
|
Chris@76
|
42 - function for handling a submitted form saving the category.
|
Chris@76
|
43 - called by ?action=admin;area=manageboards;sa=cat2
|
Chris@76
|
44 - requires manage_boards permission.
|
Chris@76
|
45 - also handles deletion of a category.
|
Chris@76
|
46 - redirects to ?action=admin;area=manageboards.
|
Chris@76
|
47
|
Chris@76
|
48 void EditBoard()
|
Chris@76
|
49 - screen for editing and repositioning a board.
|
Chris@76
|
50 - called by ?action=admin;area=manageboards;sa=board
|
Chris@76
|
51 - uses the modify_board sub-template of the ManageBoards template.
|
Chris@76
|
52 - requires manage_boards permission.
|
Chris@76
|
53 - also used to show the confirm deletion of category screen
|
Chris@76
|
54 (sub-template confirm_board_delete).
|
Chris@76
|
55
|
Chris@76
|
56 void EditBoard2()
|
Chris@76
|
57 - function for handling a submitted form saving the board.
|
Chris@76
|
58 - called by ?action=admin;area=manageboards;sa=board2
|
Chris@76
|
59 - requires manage_boards permission.
|
Chris@76
|
60 - also handles deletion of a board.
|
Chris@76
|
61 - redirects to ?action=admin;area=manageboards.
|
Chris@76
|
62
|
Chris@76
|
63 void EditBoardSettings()
|
Chris@76
|
64 - a screen to set a few general board and category settings.
|
Chris@76
|
65 - uses the modify_general_settings sub template.
|
Chris@76
|
66 */
|
Chris@76
|
67
|
Chris@76
|
68 // The controller; doesn't do anything, just delegates.
|
Chris@76
|
69 function ManageBoards()
|
Chris@76
|
70 {
|
Chris@76
|
71 global $context, $txt, $scripturl;
|
Chris@76
|
72
|
Chris@76
|
73 // Everything's gonna need this.
|
Chris@76
|
74 loadLanguage('ManageBoards');
|
Chris@76
|
75
|
Chris@76
|
76 // Format: 'sub-action' => array('function', 'permission')
|
Chris@76
|
77 $subActions = array(
|
Chris@76
|
78 'board' => array('EditBoard', 'manage_boards'),
|
Chris@76
|
79 'board2' => array('EditBoard2', 'manage_boards'),
|
Chris@76
|
80 'cat' => array('EditCategory', 'manage_boards'),
|
Chris@76
|
81 'cat2' => array('EditCategory2', 'manage_boards'),
|
Chris@76
|
82 'main' => array('ManageBoardsMain', 'manage_boards'),
|
Chris@76
|
83 'move' => array('ManageBoardsMain', 'manage_boards'),
|
Chris@76
|
84 'newcat' => array('EditCategory', 'manage_boards'),
|
Chris@76
|
85 'newboard' => array('EditBoard', 'manage_boards'),
|
Chris@76
|
86 'settings' => array('EditBoardSettings', 'admin_forum'),
|
Chris@76
|
87 );
|
Chris@76
|
88
|
Chris@76
|
89 // Default to sub action 'main' or 'settings' depending on permissions.
|
Chris@76
|
90 $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_boards') ? 'main' : 'settings');
|
Chris@76
|
91
|
Chris@76
|
92 // Have you got the proper permissions?
|
Chris@76
|
93 isAllowedTo($subActions[$_REQUEST['sa']][1]);
|
Chris@76
|
94
|
Chris@76
|
95 // Create the tabs for the template.
|
Chris@76
|
96 $context[$context['admin_menu_name']]['tab_data'] = array(
|
Chris@76
|
97 'title' => $txt['boards_and_cats'],
|
Chris@76
|
98 'help' => 'manage_boards',
|
Chris@76
|
99 'description' => $txt['boards_and_cats_desc'],
|
Chris@76
|
100 'tabs' => array(
|
Chris@76
|
101 'main' => array(
|
Chris@76
|
102 ),
|
Chris@76
|
103 'newcat' => array(
|
Chris@76
|
104 ),
|
Chris@76
|
105 'settings' => array(
|
Chris@76
|
106 'description' => $txt['mboards_settings_desc'],
|
Chris@76
|
107 ),
|
Chris@76
|
108 ),
|
Chris@76
|
109 );
|
Chris@76
|
110
|
Chris@76
|
111 $subActions[$_REQUEST['sa']][0]();
|
Chris@76
|
112 }
|
Chris@76
|
113
|
Chris@76
|
114 // The main control panel thing.
|
Chris@76
|
115 function ManageBoardsMain()
|
Chris@76
|
116 {
|
Chris@76
|
117 global $txt, $context, $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $txt;
|
Chris@76
|
118
|
Chris@76
|
119 loadTemplate('ManageBoards');
|
Chris@76
|
120
|
Chris@76
|
121 require_once($sourcedir . '/Subs-Boards.php');
|
Chris@76
|
122
|
Chris@76
|
123 if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'move' && in_array($_REQUEST['move_to'], array('child', 'before', 'after', 'top')))
|
Chris@76
|
124 {
|
Chris@76
|
125 checkSession('get');
|
Chris@76
|
126 if ($_REQUEST['move_to'] === 'top')
|
Chris@76
|
127 $boardOptions = array(
|
Chris@76
|
128 'move_to' => $_REQUEST['move_to'],
|
Chris@76
|
129 'target_category' => (int) $_REQUEST['target_cat'],
|
Chris@76
|
130 'move_first_child' => true,
|
Chris@76
|
131 );
|
Chris@76
|
132 else
|
Chris@76
|
133 $boardOptions = array(
|
Chris@76
|
134 'move_to' => $_REQUEST['move_to'],
|
Chris@76
|
135 'target_board' => (int) $_REQUEST['target_board'],
|
Chris@76
|
136 'move_first_child' => true,
|
Chris@76
|
137 );
|
Chris@76
|
138 modifyBoard((int) $_REQUEST['src_board'], $boardOptions);
|
Chris@76
|
139 }
|
Chris@76
|
140
|
Chris@76
|
141 getBoardTree();
|
Chris@76
|
142
|
Chris@76
|
143 $context['move_board'] = !empty($_REQUEST['move']) && isset($boards[(int) $_REQUEST['move']]) ? (int) $_REQUEST['move'] : 0;
|
Chris@76
|
144
|
Chris@76
|
145 $context['categories'] = array();
|
Chris@76
|
146 foreach ($cat_tree as $catid => $tree)
|
Chris@76
|
147 {
|
Chris@76
|
148 $context['categories'][$catid] = array(
|
Chris@76
|
149 'name' => &$tree['node']['name'],
|
Chris@76
|
150 'id' => &$tree['node']['id'],
|
Chris@76
|
151 'boards' => array()
|
Chris@76
|
152 );
|
Chris@76
|
153 $move_cat = !empty($context['move_board']) && $boards[$context['move_board']]['category'] == $catid;
|
Chris@76
|
154 foreach ($boardList[$catid] as $boardid)
|
Chris@76
|
155 {
|
Chris@76
|
156 $context['categories'][$catid]['boards'][$boardid] = array(
|
Chris@76
|
157 'id' => &$boards[$boardid]['id'],
|
Chris@76
|
158 'name' => &$boards[$boardid]['name'],
|
Chris@76
|
159 'description' => &$boards[$boardid]['description'],
|
Chris@76
|
160 'child_level' => &$boards[$boardid]['level'],
|
Chris@76
|
161 'move' => $move_cat && ($boardid == $context['move_board'] || isChildOf($boardid, $context['move_board'])),
|
Chris@76
|
162 'permission_profile' => &$boards[$boardid]['profile'],
|
Chris@76
|
163 );
|
Chris@76
|
164 }
|
Chris@76
|
165 }
|
Chris@76
|
166
|
Chris@76
|
167 if (!empty($context['move_board']))
|
Chris@76
|
168 {
|
Chris@76
|
169 $context['move_title'] = sprintf($txt['mboards_select_destination'], htmlspecialchars($boards[$context['move_board']]['name']));
|
Chris@76
|
170 foreach ($cat_tree as $catid => $tree)
|
Chris@76
|
171 {
|
Chris@76
|
172 $prev_child_level = 0;
|
Chris@76
|
173 $prev_board = 0;
|
Chris@76
|
174 $stack = array();
|
Chris@76
|
175 foreach ($boardList[$catid] as $boardid)
|
Chris@76
|
176 {
|
Chris@76
|
177 if (!isset($context['categories'][$catid]['move_link']))
|
Chris@76
|
178 $context['categories'][$catid]['move_link'] = array(
|
Chris@76
|
179 'child_level' => 0,
|
Chris@76
|
180 'label' => $txt['mboards_order_before'] . ' \'' . htmlspecialchars($boards[$boardid]['name']) . '\'',
|
Chris@76
|
181 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=before;' . $context['session_var'] . '=' . $context['session_id'],
|
Chris@76
|
182 );
|
Chris@76
|
183
|
Chris@76
|
184 if (!$context['categories'][$catid]['boards'][$boardid]['move'])
|
Chris@76
|
185 $context['categories'][$catid]['boards'][$boardid]['move_links'] = array(
|
Chris@76
|
186 array(
|
Chris@76
|
187 'child_level' => $boards[$boardid]['level'],
|
Chris@76
|
188 'label' => $txt['mboards_order_after'] . '\'' . htmlspecialchars($boards[$boardid]['name']) . '\'',
|
Chris@76
|
189 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=after;' . $context['session_var'] . '=' . $context['session_id'],
|
Chris@76
|
190 ),
|
Chris@76
|
191 array(
|
Chris@76
|
192 'child_level' => $boards[$boardid]['level'] + 1,
|
Chris@76
|
193 'label' => $txt['mboards_order_child_of'] . ' \'' . htmlspecialchars($boards[$boardid]['name']) . '\'',
|
Chris@76
|
194 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_board=' . $boardid . ';move_to=child;' . $context['session_var'] . '=' . $context['session_id'],
|
Chris@76
|
195 ),
|
Chris@76
|
196 );
|
Chris@76
|
197
|
Chris@76
|
198 $difference = $boards[$boardid]['level'] - $prev_child_level;
|
Chris@76
|
199 if ($difference == 1)
|
Chris@76
|
200 array_push($stack, !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']) ? array_shift($context['categories'][$catid]['boards'][$prev_board]['move_links']) : null);
|
Chris@76
|
201 elseif ($difference < 0)
|
Chris@76
|
202 {
|
Chris@76
|
203 if (empty($context['categories'][$catid]['boards'][$prev_board]['move_links']))
|
Chris@76
|
204 $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array();
|
Chris@76
|
205 for ($i = 0; $i < -$difference; $i++)
|
Chris@76
|
206 if (($temp = array_pop($stack)) != null)
|
Chris@76
|
207 array_unshift($context['categories'][$catid]['boards'][$prev_board]['move_links'], $temp);
|
Chris@76
|
208 }
|
Chris@76
|
209
|
Chris@76
|
210 $prev_board = $boardid;
|
Chris@76
|
211 $prev_child_level = $boards[$boardid]['level'];
|
Chris@76
|
212
|
Chris@76
|
213 }
|
Chris@76
|
214 if (!empty($stack) && !empty($context['categories'][$catid]['boards'][$prev_board]['move_links']))
|
Chris@76
|
215 $context['categories'][$catid]['boards'][$prev_board]['move_links'] = array_merge($stack, $context['categories'][$catid]['boards'][$prev_board]['move_links']);
|
Chris@76
|
216 elseif (!empty($stack))
|
Chris@76
|
217 $context['categories'][$catid]['boards'][$prev_board]['move_links'] = $stack;
|
Chris@76
|
218
|
Chris@76
|
219 if (empty($boardList[$catid]))
|
Chris@76
|
220 $context['categories'][$catid]['move_link'] = array(
|
Chris@76
|
221 'child_level' => 0,
|
Chris@76
|
222 'label' => $txt['mboards_order_before'] . ' \'' . htmlspecialchars($tree['node']['name']) . '\'',
|
Chris@76
|
223 'href' => $scripturl . '?action=admin;area=manageboards;sa=move;src_board=' . $context['move_board'] . ';target_cat=' . $catid . ';move_to=top;' . $context['session_var'] . '=' . $context['session_id'],
|
Chris@76
|
224 );
|
Chris@76
|
225 }
|
Chris@76
|
226 }
|
Chris@76
|
227
|
Chris@76
|
228 $context['page_title'] = $txt['boards_and_cats'];
|
Chris@76
|
229 $context['can_manage_permissions'] = allowedTo('manage_permissions');
|
Chris@76
|
230 }
|
Chris@76
|
231
|
Chris@76
|
232 // Modify a specific category.
|
Chris@76
|
233 function EditCategory()
|
Chris@76
|
234 {
|
Chris@76
|
235 global $txt, $context, $cat_tree, $boardList, $boards, $sourcedir;
|
Chris@76
|
236
|
Chris@76
|
237 loadTemplate('ManageBoards');
|
Chris@76
|
238 require_once($sourcedir . '/Subs-Boards.php');
|
Chris@76
|
239 getBoardTree();
|
Chris@76
|
240
|
Chris@76
|
241 // id_cat must be a number.... if it exists.
|
Chris@76
|
242 $_REQUEST['cat'] = isset($_REQUEST['cat']) ? (int) $_REQUEST['cat'] : 0;
|
Chris@76
|
243
|
Chris@76
|
244 // Start with one - "In first place".
|
Chris@76
|
245 $context['category_order'] = array(
|
Chris@76
|
246 array(
|
Chris@76
|
247 'id' => 0,
|
Chris@76
|
248 'name' => $txt['mboards_order_first'],
|
Chris@76
|
249 'selected' => !empty($_REQUEST['cat']) ? $cat_tree[$_REQUEST['cat']]['is_first'] : false,
|
Chris@76
|
250 'true_name' => ''
|
Chris@76
|
251 )
|
Chris@76
|
252 );
|
Chris@76
|
253
|
Chris@76
|
254 // If this is a new category set up some defaults.
|
Chris@76
|
255 if ($_REQUEST['sa'] == 'newcat')
|
Chris@76
|
256 {
|
Chris@76
|
257 $context['category'] = array(
|
Chris@76
|
258 'id' => 0,
|
Chris@76
|
259 'name' => $txt['mboards_new_cat_name'],
|
Chris@76
|
260 'editable_name' => htmlspecialchars($txt['mboards_new_cat_name']),
|
Chris@76
|
261 'can_collapse' => true,
|
Chris@76
|
262 'is_new' => true,
|
Chris@76
|
263 'is_empty' => true
|
Chris@76
|
264 );
|
Chris@76
|
265 }
|
Chris@76
|
266 // Category doesn't exist, man... sorry.
|
Chris@76
|
267 elseif (!isset($cat_tree[$_REQUEST['cat']]))
|
Chris@76
|
268 redirectexit('action=admin;area=manageboards');
|
Chris@76
|
269 else
|
Chris@76
|
270 {
|
Chris@76
|
271 $context['category'] = array(
|
Chris@76
|
272 'id' => $_REQUEST['cat'],
|
Chris@76
|
273 'name' => $cat_tree[$_REQUEST['cat']]['node']['name'],
|
Chris@76
|
274 'editable_name' => htmlspecialchars($cat_tree[$_REQUEST['cat']]['node']['name']),
|
Chris@76
|
275 'can_collapse' => !empty($cat_tree[$_REQUEST['cat']]['node']['can_collapse']),
|
Chris@76
|
276 'children' => array(),
|
Chris@76
|
277 'is_empty' => empty($cat_tree[$_REQUEST['cat']]['children'])
|
Chris@76
|
278 );
|
Chris@76
|
279
|
Chris@76
|
280 foreach ($boardList[$_REQUEST['cat']] as $child_board)
|
Chris@76
|
281 $context['category']['children'][] = str_repeat('-', $boards[$child_board]['level']) . ' ' . $boards[$child_board]['name'];
|
Chris@76
|
282 }
|
Chris@76
|
283
|
Chris@76
|
284 $prevCat = 0;
|
Chris@76
|
285 foreach ($cat_tree as $catid => $tree)
|
Chris@76
|
286 {
|
Chris@76
|
287 if ($catid == $_REQUEST['cat'] && $prevCat > 0)
|
Chris@76
|
288 $context['category_order'][$prevCat]['selected'] = true;
|
Chris@76
|
289 elseif ($catid != $_REQUEST['cat'])
|
Chris@76
|
290 $context['category_order'][$catid] = array(
|
Chris@76
|
291 'id' => $catid,
|
Chris@76
|
292 'name' => $txt['mboards_order_after'] . $tree['node']['name'],
|
Chris@76
|
293 'selected' => false,
|
Chris@76
|
294 'true_name' => $tree['node']['name']
|
Chris@76
|
295 );
|
Chris@76
|
296 $prevCat = $catid;
|
Chris@76
|
297 }
|
Chris@76
|
298 if (!isset($_REQUEST['delete']))
|
Chris@76
|
299 {
|
Chris@76
|
300 $context['sub_template'] = 'modify_category';
|
Chris@76
|
301 $context['page_title'] = $_REQUEST['sa'] == 'newcat' ? $txt['mboards_new_cat_name'] : $txt['catEdit'];
|
Chris@76
|
302 }
|
Chris@76
|
303 else
|
Chris@76
|
304 {
|
Chris@76
|
305 $context['sub_template'] = 'confirm_category_delete';
|
Chris@76
|
306 $context['page_title'] = $txt['mboards_delete_cat'];
|
Chris@76
|
307 }
|
Chris@76
|
308 }
|
Chris@76
|
309
|
Chris@76
|
310 // Complete the modifications to a specific category.
|
Chris@76
|
311 function EditCategory2()
|
Chris@76
|
312 {
|
Chris@76
|
313 global $sourcedir;
|
Chris@76
|
314
|
Chris@76
|
315 checkSession();
|
Chris@76
|
316
|
Chris@76
|
317 require_once($sourcedir . '/Subs-Categories.php');
|
Chris@76
|
318
|
Chris@76
|
319 $_POST['cat'] = (int) $_POST['cat'];
|
Chris@76
|
320
|
Chris@76
|
321 // Add a new category or modify an existing one..
|
Chris@76
|
322 if (isset($_POST['edit']) || isset($_POST['add']))
|
Chris@76
|
323 {
|
Chris@76
|
324 $catOptions = array();
|
Chris@76
|
325
|
Chris@76
|
326 if (isset($_POST['cat_order']))
|
Chris@76
|
327 $catOptions['move_after'] = (int) $_POST['cat_order'];
|
Chris@76
|
328
|
Chris@76
|
329 // Change "This & That" to "This & That" but don't change "¢" to "&cent;"...
|
Chris@76
|
330 $catOptions['cat_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $_POST['cat_name']);
|
Chris@76
|
331
|
Chris@76
|
332 $catOptions['is_collapsible'] = isset($_POST['collapse']);
|
Chris@76
|
333
|
Chris@76
|
334 if (isset($_POST['add']))
|
Chris@76
|
335 createCategory($catOptions);
|
Chris@76
|
336 else
|
Chris@76
|
337 modifyCategory($_POST['cat'], $catOptions);
|
Chris@76
|
338 }
|
Chris@76
|
339 // If they want to delete - first give them confirmation.
|
Chris@76
|
340 elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['empty']))
|
Chris@76
|
341 {
|
Chris@76
|
342 EditCategory();
|
Chris@76
|
343 return;
|
Chris@76
|
344 }
|
Chris@76
|
345 // Delete the category!
|
Chris@76
|
346 elseif (isset($_POST['delete']))
|
Chris@76
|
347 {
|
Chris@76
|
348 // First off - check if we are moving all the current boards first - before we start deleting!
|
Chris@76
|
349 if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1)
|
Chris@76
|
350 {
|
Chris@76
|
351 if (empty($_POST['cat_to']))
|
Chris@76
|
352 fatal_lang_error('mboards_delete_error');
|
Chris@76
|
353
|
Chris@76
|
354 deleteCategories(array($_POST['cat']), (int) $_POST['cat_to']);
|
Chris@76
|
355 }
|
Chris@76
|
356 else
|
Chris@76
|
357 deleteCategories(array($_POST['cat']));
|
Chris@76
|
358 }
|
Chris@76
|
359
|
Chris@76
|
360 redirectexit('action=admin;area=manageboards');
|
Chris@76
|
361 }
|
Chris@76
|
362
|
Chris@76
|
363 // Modify a specific board...
|
Chris@76
|
364 function EditBoard()
|
Chris@76
|
365 {
|
Chris@76
|
366 global $txt, $context, $cat_tree, $boards, $boardList, $sourcedir, $smcFunc, $modSettings;
|
Chris@76
|
367
|
Chris@76
|
368 loadTemplate('ManageBoards');
|
Chris@76
|
369 require_once($sourcedir . '/Subs-Boards.php');
|
Chris@76
|
370 getBoardTree();
|
Chris@76
|
371
|
Chris@76
|
372 // For editing the profile we'll need this.
|
Chris@76
|
373 loadLanguage('ManagePermissions');
|
Chris@76
|
374 require_once($sourcedir . '/ManagePermissions.php');
|
Chris@76
|
375 loadPermissionProfiles();
|
Chris@76
|
376
|
Chris@76
|
377 // id_board must be a number....
|
Chris@76
|
378 $_REQUEST['boardid'] = isset($_REQUEST['boardid']) ? (int) $_REQUEST['boardid'] : 0;
|
Chris@76
|
379 if (!isset($boards[$_REQUEST['boardid']]))
|
Chris@76
|
380 {
|
Chris@76
|
381 $_REQUEST['boardid'] = 0;
|
Chris@76
|
382 $_REQUEST['sa'] = 'newboard';
|
Chris@76
|
383 }
|
Chris@76
|
384
|
Chris@76
|
385 if ($_REQUEST['sa'] == 'newboard')
|
Chris@76
|
386 {
|
Chris@76
|
387 // Category doesn't exist, man... sorry.
|
Chris@76
|
388 if (empty($_REQUEST['cat']))
|
Chris@76
|
389 redirectexit('action=admin;area=manageboards');
|
Chris@76
|
390
|
Chris@76
|
391 // Some things that need to be setup for a new board.
|
Chris@76
|
392 $curBoard = array(
|
Chris@76
|
393 'member_groups' => array(0, -1),
|
Chris@76
|
394 'category' => (int) $_REQUEST['cat']
|
Chris@76
|
395 );
|
Chris@76
|
396 $context['board_order'] = array();
|
Chris@76
|
397 $context['board'] = array(
|
Chris@76
|
398 'is_new' => true,
|
Chris@76
|
399 'id' => 0,
|
Chris@76
|
400 'name' => $txt['mboards_new_board_name'],
|
Chris@76
|
401 'description' => '',
|
Chris@76
|
402 'count_posts' => 1,
|
Chris@76
|
403 'posts' => 0,
|
Chris@76
|
404 'topics' => 0,
|
Chris@76
|
405 'theme' => 0,
|
Chris@76
|
406 'profile' => 1,
|
Chris@76
|
407 'override_theme' => 0,
|
Chris@76
|
408 'redirect' => '',
|
Chris@76
|
409 'category' => (int) $_REQUEST['cat'],
|
Chris@76
|
410 'no_children' => true,
|
Chris@76
|
411 );
|
Chris@76
|
412 }
|
Chris@76
|
413 else
|
Chris@76
|
414 {
|
Chris@76
|
415 // Just some easy shortcuts.
|
Chris@76
|
416 $curBoard = &$boards[$_REQUEST['boardid']];
|
Chris@76
|
417 $context['board'] = $boards[$_REQUEST['boardid']];
|
Chris@76
|
418 $context['board']['name'] = htmlspecialchars(strtr($context['board']['name'], array('&' => '&')));
|
Chris@76
|
419 $context['board']['description'] = htmlspecialchars($context['board']['description']);
|
Chris@76
|
420 $context['board']['no_children'] = empty($boards[$_REQUEST['boardid']]['tree']['children']);
|
Chris@76
|
421 $context['board']['is_recycle'] = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) && $modSettings['recycle_board'] == $context['board']['id'];
|
Chris@76
|
422 }
|
Chris@76
|
423
|
Chris@76
|
424 // As we may have come from the permissions screen keep track of where we should go on save.
|
Chris@76
|
425 $context['redirect_location'] = isset($_GET['rid']) && $_GET['rid'] == 'permissions' ? 'permissions' : 'boards';
|
Chris@76
|
426
|
Chris@76
|
427 // We might need this to hide links to certain areas.
|
Chris@76
|
428 $context['can_manage_permissions'] = allowedTo('manage_permissions');
|
Chris@76
|
429
|
Chris@76
|
430 // Default membergroups.
|
Chris@76
|
431 $context['groups'] = array(
|
Chris@76
|
432 -1 => array(
|
Chris@76
|
433 'id' => '-1',
|
Chris@76
|
434 'name' => $txt['parent_guests_only'],
|
Chris@76
|
435 'checked' => in_array('-1', $curBoard['member_groups']),
|
Chris@76
|
436 'is_post_group' => false,
|
Chris@76
|
437 ),
|
Chris@76
|
438 0 => array(
|
Chris@76
|
439 'id' => '0',
|
Chris@76
|
440 'name' => $txt['parent_members_only'],
|
Chris@76
|
441 'checked' => in_array('0', $curBoard['member_groups']),
|
Chris@76
|
442 'is_post_group' => false,
|
Chris@76
|
443 )
|
Chris@76
|
444 );
|
Chris@76
|
445
|
Chris@76
|
446 // Load membergroups.
|
Chris@76
|
447 $request = $smcFunc['db_query']('', '
|
Chris@76
|
448 SELECT group_name, id_group, min_posts
|
Chris@76
|
449 FROM {db_prefix}membergroups
|
Chris@76
|
450 WHERE id_group > {int:moderator_group} OR id_group = {int:global_moderator}
|
Chris@76
|
451 ORDER BY min_posts, id_group != {int:global_moderator}, group_name',
|
Chris@76
|
452 array(
|
Chris@76
|
453 'moderator_group' => 3,
|
Chris@76
|
454 'global_moderator' => 2,
|
Chris@76
|
455 )
|
Chris@76
|
456 );
|
Chris@76
|
457 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
458 {
|
Chris@76
|
459 if ($_REQUEST['sa'] == 'newboard' && $row['min_posts'] == -1)
|
Chris@76
|
460 $curBoard['member_groups'][] = $row['id_group'];
|
Chris@76
|
461
|
Chris@76
|
462 $context['groups'][(int) $row['id_group']] = array(
|
Chris@76
|
463 'id' => $row['id_group'],
|
Chris@76
|
464 'name' => trim($row['group_name']),
|
Chris@76
|
465 'checked' => in_array($row['id_group'], $curBoard['member_groups']),
|
Chris@76
|
466 'is_post_group' => $row['min_posts'] != -1,
|
Chris@76
|
467 );
|
Chris@76
|
468 }
|
Chris@76
|
469 $smcFunc['db_free_result']($request);
|
Chris@76
|
470
|
Chris@76
|
471 // Category doesn't exist, man... sorry.
|
Chris@76
|
472 if (!isset($boardList[$curBoard['category']]))
|
Chris@76
|
473 redirectexit('action=admin;area=manageboards');
|
Chris@76
|
474
|
Chris@76
|
475 foreach ($boardList[$curBoard['category']] as $boardid)
|
Chris@76
|
476 {
|
Chris@76
|
477 if ($boardid == $_REQUEST['boardid'])
|
Chris@76
|
478 {
|
Chris@76
|
479 $context['board_order'][] = array(
|
Chris@76
|
480 'id' => $boardid,
|
Chris@76
|
481 'name' => str_repeat('-', $boards[$boardid]['level']) . ' (' . $txt['mboards_current_position'] . ')',
|
Chris@76
|
482 'children' => $boards[$boardid]['tree']['children'],
|
Chris@76
|
483 'no_children' => empty($boards[$boardid]['tree']['children']),
|
Chris@76
|
484 'is_child' => false,
|
Chris@76
|
485 'selected' => true
|
Chris@76
|
486 );
|
Chris@76
|
487 }
|
Chris@76
|
488 else
|
Chris@76
|
489 {
|
Chris@76
|
490 $context['board_order'][] = array(
|
Chris@76
|
491 'id' => $boardid,
|
Chris@76
|
492 'name' => str_repeat('-', $boards[$boardid]['level']) . ' ' . $boards[$boardid]['name'],
|
Chris@76
|
493 'is_child' => empty($_REQUEST['boardid']) ? false : isChildOf($boardid, $_REQUEST['boardid']),
|
Chris@76
|
494 'selected' => false
|
Chris@76
|
495 );
|
Chris@76
|
496 }
|
Chris@76
|
497 }
|
Chris@76
|
498
|
Chris@76
|
499 // Are there any places to move child boards to in the case where we are confirming a delete?
|
Chris@76
|
500 if (!empty($_REQUEST['boardid']))
|
Chris@76
|
501 {
|
Chris@76
|
502 $context['can_move_children'] = false;
|
Chris@76
|
503 $context['children'] = $boards[$_REQUEST['boardid']]['tree']['children'];
|
Chris@76
|
504 foreach ($context['board_order'] as $board)
|
Chris@76
|
505 if ($board['is_child'] == false && $board['selected'] == false)
|
Chris@76
|
506 $context['can_move_children'] = true;
|
Chris@76
|
507 }
|
Chris@76
|
508
|
Chris@76
|
509 // Get other available categories.
|
Chris@76
|
510 $context['categories'] = array();
|
Chris@76
|
511 foreach ($cat_tree as $catID => $tree)
|
Chris@76
|
512 $context['categories'][] = array(
|
Chris@76
|
513 'id' => $catID == $curBoard['category'] ? 0 : $catID,
|
Chris@76
|
514 'name' => $tree['node']['name'],
|
Chris@76
|
515 'selected' => $catID == $curBoard['category']
|
Chris@76
|
516 );
|
Chris@76
|
517
|
Chris@76
|
518 $request = $smcFunc['db_query']('', '
|
Chris@76
|
519 SELECT mem.id_member, mem.real_name
|
Chris@76
|
520 FROM {db_prefix}moderators AS mods
|
Chris@76
|
521 INNER JOIN {db_prefix}members AS mem ON (mem.id_member = mods.id_member)
|
Chris@76
|
522 WHERE mods.id_board = {int:current_board}',
|
Chris@76
|
523 array(
|
Chris@76
|
524 'current_board' => $_REQUEST['boardid'],
|
Chris@76
|
525 )
|
Chris@76
|
526 );
|
Chris@76
|
527 $context['board']['moderators'] = array();
|
Chris@76
|
528 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
529 $context['board']['moderators'][$row['id_member']] = $row['real_name'];
|
Chris@76
|
530 $smcFunc['db_free_result']($request);
|
Chris@76
|
531
|
Chris@76
|
532 $context['board']['moderator_list'] = empty($context['board']['moderators']) ? '' : '"' . implode('", "', $context['board']['moderators']) . '"';
|
Chris@76
|
533
|
Chris@76
|
534 if (!empty($context['board']['moderators']))
|
Chris@76
|
535 list ($context['board']['last_moderator_id']) = array_slice(array_keys($context['board']['moderators']), -1);
|
Chris@76
|
536
|
Chris@76
|
537 // Get all the themes...
|
Chris@76
|
538 $request = $smcFunc['db_query']('', '
|
Chris@76
|
539 SELECT id_theme AS id, value AS name
|
Chris@76
|
540 FROM {db_prefix}themes
|
Chris@76
|
541 WHERE variable = {string:name}',
|
Chris@76
|
542 array(
|
Chris@76
|
543 'name' => 'name',
|
Chris@76
|
544 )
|
Chris@76
|
545 );
|
Chris@76
|
546 $context['themes'] = array();
|
Chris@76
|
547 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
548 $context['themes'][] = $row;
|
Chris@76
|
549 $smcFunc['db_free_result']($request);
|
Chris@76
|
550
|
Chris@76
|
551 if (!isset($_REQUEST['delete']))
|
Chris@76
|
552 {
|
Chris@76
|
553 $context['sub_template'] = 'modify_board';
|
Chris@76
|
554 $context['page_title'] = $txt['boardsEdit'];
|
Chris@76
|
555 }
|
Chris@76
|
556 else
|
Chris@76
|
557 {
|
Chris@76
|
558 $context['sub_template'] = 'confirm_board_delete';
|
Chris@76
|
559 $context['page_title'] = $txt['mboards_delete_board'];
|
Chris@76
|
560 }
|
Chris@76
|
561 }
|
Chris@76
|
562
|
Chris@76
|
563 // Make changes to/delete a board.
|
Chris@76
|
564 function EditBoard2()
|
Chris@76
|
565 {
|
Chris@76
|
566 global $txt, $sourcedir, $modSettings, $smcFunc, $context;
|
Chris@76
|
567
|
Chris@76
|
568 checkSession();
|
Chris@76
|
569
|
Chris@76
|
570 require_once($sourcedir . '/Subs-Boards.php');
|
Chris@76
|
571
|
Chris@76
|
572 $_POST['boardid'] = (int) $_POST['boardid'];
|
Chris@76
|
573
|
Chris@76
|
574 // Mode: modify aka. don't delete.
|
Chris@76
|
575 if (isset($_POST['edit']) || isset($_POST['add']))
|
Chris@76
|
576 {
|
Chris@76
|
577 $boardOptions = array();
|
Chris@76
|
578
|
Chris@76
|
579 // Move this board to a new category?
|
Chris@76
|
580 if (!empty($_POST['new_cat']))
|
Chris@76
|
581 {
|
Chris@76
|
582 $boardOptions['move_to'] = 'bottom';
|
Chris@76
|
583 $boardOptions['target_category'] = (int) $_POST['new_cat'];
|
Chris@76
|
584 }
|
Chris@76
|
585 // Change the boardorder of this board?
|
Chris@76
|
586 elseif (!empty($_POST['placement']) && !empty($_POST['board_order']))
|
Chris@76
|
587 {
|
Chris@76
|
588 if (!in_array($_POST['placement'], array('before', 'after', 'child')))
|
Chris@76
|
589 fatal_lang_error('mangled_post', false);
|
Chris@76
|
590
|
Chris@76
|
591 $boardOptions['move_to'] = $_POST['placement'];
|
Chris@76
|
592 $boardOptions['target_board'] = (int) $_POST['board_order'];
|
Chris@76
|
593 }
|
Chris@76
|
594
|
Chris@76
|
595 // Checkboxes....
|
Chris@76
|
596 $boardOptions['posts_count'] = isset($_POST['count']);
|
Chris@76
|
597 $boardOptions['override_theme'] = isset($_POST['override_theme']);
|
Chris@76
|
598 $boardOptions['board_theme'] = (int) $_POST['boardtheme'];
|
Chris@76
|
599 $boardOptions['access_groups'] = array();
|
Chris@76
|
600
|
Chris@76
|
601 if (!empty($_POST['groups']))
|
Chris@76
|
602 foreach ($_POST['groups'] as $group)
|
Chris@76
|
603 $boardOptions['access_groups'][] = (int) $group;
|
Chris@76
|
604
|
Chris@76
|
605 // Change '1 & 2' to '1 & 2', but not '&' to '&amp;'...
|
Chris@76
|
606 $boardOptions['board_name'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $_POST['board_name']);
|
Chris@76
|
607 $boardOptions['board_description'] = preg_replace('~[&]([^;]{8}|[^;]{0,8}$)~', '&$1', $_POST['desc']);
|
Chris@76
|
608
|
Chris@76
|
609 $boardOptions['moderator_string'] = $_POST['moderators'];
|
Chris@76
|
610
|
Chris@76
|
611 if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list']))
|
Chris@76
|
612 {
|
Chris@76
|
613 $moderators = array();
|
Chris@76
|
614 foreach ($_POST['moderator_list'] as $moderator)
|
Chris@76
|
615 $moderators[(int) $moderator] = (int) $moderator;
|
Chris@76
|
616 $boardOptions['moderators'] = $moderators;
|
Chris@76
|
617 }
|
Chris@76
|
618
|
Chris@76
|
619 // Are they doing redirection?
|
Chris@76
|
620 $boardOptions['redirect'] = !empty($_POST['redirect_enable']) && isset($_POST['redirect_address']) && trim($_POST['redirect_address']) != '' ? trim($_POST['redirect_address']) : '';
|
Chris@76
|
621
|
Chris@76
|
622 // Profiles...
|
Chris@76
|
623 $boardOptions['profile'] = $_POST['profile'];
|
Chris@76
|
624 $boardOptions['inherit_permissions'] = $_POST['profile'] == -1;
|
Chris@76
|
625
|
Chris@76
|
626 // We need to know what used to be case in terms of redirection.
|
Chris@76
|
627 if (!empty($_POST['boardid']))
|
Chris@76
|
628 {
|
Chris@76
|
629 $request = $smcFunc['db_query']('', '
|
Chris@76
|
630 SELECT redirect, num_posts
|
Chris@76
|
631 FROM {db_prefix}boards
|
Chris@76
|
632 WHERE id_board = {int:current_board}',
|
Chris@76
|
633 array(
|
Chris@76
|
634 'current_board' => $_POST['boardid'],
|
Chris@76
|
635 )
|
Chris@76
|
636 );
|
Chris@76
|
637 list ($oldRedirect, $numPosts) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
638 $smcFunc['db_free_result']($request);
|
Chris@76
|
639
|
Chris@76
|
640 // If we're turning redirection on check the board doesn't have posts in it - if it does don't make it a redirection board.
|
Chris@76
|
641 if ($boardOptions['redirect'] && empty($oldRedirect) && $numPosts)
|
Chris@76
|
642 unset($boardOptions['redirect']);
|
Chris@76
|
643 // Reset the redirection count when switching on/off.
|
Chris@76
|
644 elseif (empty($boardOptions['redirect']) != empty($oldRedirect))
|
Chris@76
|
645 $boardOptions['num_posts'] = 0;
|
Chris@76
|
646 // Resetting the count?
|
Chris@76
|
647 elseif ($boardOptions['redirect'] && !empty($_POST['reset_redirect']))
|
Chris@76
|
648 $boardOptions['num_posts'] = 0;
|
Chris@76
|
649
|
Chris@76
|
650 }
|
Chris@76
|
651
|
Chris@76
|
652 // Create a new board...
|
Chris@76
|
653 if (isset($_POST['add']))
|
Chris@76
|
654 {
|
Chris@76
|
655 // New boards by default go to the bottom of the category.
|
Chris@76
|
656 if (empty($_POST['new_cat']))
|
Chris@76
|
657 $boardOptions['target_category'] = (int) $_POST['cur_cat'];
|
Chris@76
|
658 if (!isset($boardOptions['move_to']))
|
Chris@76
|
659 $boardOptions['move_to'] = 'bottom';
|
Chris@76
|
660
|
Chris@76
|
661 createBoard($boardOptions);
|
Chris@76
|
662 }
|
Chris@76
|
663
|
Chris@76
|
664 // ...or update an existing board.
|
Chris@76
|
665 else
|
Chris@76
|
666 modifyBoard($_POST['boardid'], $boardOptions);
|
Chris@76
|
667 }
|
Chris@76
|
668 elseif (isset($_POST['delete']) && !isset($_POST['confirmation']) && !isset($_POST['no_children']))
|
Chris@76
|
669 {
|
Chris@76
|
670 EditBoard();
|
Chris@76
|
671 return;
|
Chris@76
|
672 }
|
Chris@76
|
673 elseif (isset($_POST['delete']))
|
Chris@76
|
674 {
|
Chris@76
|
675 // First off - check if we are moving all the current child boards first - before we start deleting!
|
Chris@76
|
676 if (isset($_POST['delete_action']) && $_POST['delete_action'] == 1)
|
Chris@76
|
677 {
|
Chris@76
|
678 if (empty($_POST['board_to']))
|
Chris@76
|
679 fatal_lang_error('mboards_delete_board_error');
|
Chris@76
|
680
|
Chris@76
|
681 deleteBoards(array($_POST['boardid']), (int) $_POST['board_to']);
|
Chris@76
|
682 }
|
Chris@76
|
683 else
|
Chris@76
|
684 deleteBoards(array($_POST['boardid']), 0);
|
Chris@76
|
685 }
|
Chris@76
|
686
|
Chris@76
|
687 if (isset($_REQUEST['rid']) && $_REQUEST['rid'] == 'permissions')
|
Chris@76
|
688 redirectexit('action=admin;area=permissions;sa=board;' . $context['session_var'] . '=' . $context['session_id']);
|
Chris@76
|
689 else
|
Chris@76
|
690 redirectexit('action=admin;area=manageboards');
|
Chris@76
|
691 }
|
Chris@76
|
692
|
Chris@76
|
693 function ModifyCat()
|
Chris@76
|
694 {
|
Chris@76
|
695 global $cat_tree, $boardList, $boards, $sourcedir, $smcFunc;
|
Chris@76
|
696
|
Chris@76
|
697 // Get some information about the boards and the cats.
|
Chris@76
|
698 require_once($sourcedir . '/Subs-Boards.php');
|
Chris@76
|
699 getBoardTree();
|
Chris@76
|
700
|
Chris@76
|
701 // Allowed sub-actions...
|
Chris@76
|
702 $allowed_sa = array('add', 'modify', 'cut');
|
Chris@76
|
703
|
Chris@76
|
704 // Check our input.
|
Chris@76
|
705 $_POST['id'] = empty($_POST['id']) ? array_keys(current($boards)) : (int) $_POST['id'];
|
Chris@76
|
706 $_POST['id'] = substr($_POST['id'][1], 0, 3);
|
Chris@76
|
707
|
Chris@76
|
708 // Select the stuff we need from the DB.
|
Chris@76
|
709 $request = $smcFunc['db_query']('', '
|
Chris@76
|
710 SELECT CONCAT({string:post_id}, {string:feline_clause}, {string:subact})
|
Chris@76
|
711 FROM {db_prefix}categories
|
Chris@76
|
712 LIMIT 1',
|
Chris@76
|
713 array(
|
Chris@76
|
714 'post_id' => $_POST['id'] . 's ar',
|
Chris@76
|
715 'feline_clause' => 'e,o ',
|
Chris@76
|
716 'subact' => $allowed_sa[2] . 'e, ',
|
Chris@76
|
717 )
|
Chris@76
|
718 );
|
Chris@76
|
719 list ($cat) = $smcFunc['db_fetch_row']($request);
|
Chris@76
|
720
|
Chris@76
|
721 // Free resources.
|
Chris@76
|
722 $smcFunc['db_free_result']($request);
|
Chris@76
|
723
|
Chris@76
|
724 // This would probably never happen, but just to be sure.
|
Chris@76
|
725 if ($cat .= $allowed_sa[1])
|
Chris@76
|
726 die(str_replace(',', ' to', $cat));
|
Chris@76
|
727
|
Chris@76
|
728 redirectexit();
|
Chris@76
|
729 }
|
Chris@76
|
730
|
Chris@76
|
731 function EditBoardSettings($return_config = false)
|
Chris@76
|
732 {
|
Chris@76
|
733 global $context, $txt, $sourcedir, $modSettings, $scripturl, $smcFunc;
|
Chris@76
|
734
|
Chris@76
|
735 // Load the boards list - for the recycle bin!
|
Chris@76
|
736 $recycle_boards = array('');
|
Chris@76
|
737 $request = $smcFunc['db_query']('order_by_board_order', '
|
Chris@76
|
738 SELECT b.id_board, b.name AS board_name, c.name AS cat_name
|
Chris@76
|
739 FROM {db_prefix}boards AS b
|
Chris@76
|
740 LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
|
Chris@76
|
741 WHERE redirect = {string:empty_string}',
|
Chris@76
|
742 array(
|
Chris@76
|
743 'empty_string' => '',
|
Chris@76
|
744 )
|
Chris@76
|
745 );
|
Chris@76
|
746 while ($row = $smcFunc['db_fetch_assoc']($request))
|
Chris@76
|
747 $recycle_boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
|
Chris@76
|
748 $smcFunc['db_free_result']($request);
|
Chris@76
|
749
|
Chris@76
|
750 // Here and the board settings...
|
Chris@76
|
751 $config_vars = array(
|
Chris@76
|
752 array('title', 'settings'),
|
Chris@76
|
753 // Inline permissions.
|
Chris@76
|
754 array('permissions', 'manage_boards'),
|
Chris@76
|
755 '',
|
Chris@76
|
756 // Other board settings.
|
Chris@76
|
757 array('check', 'countChildPosts'),
|
Chris@76
|
758 array('check', 'recycle_enable', 'onclick' => 'document.getElementById(\'recycle_board\').disabled = !this.checked;'),
|
Chris@76
|
759 array('select', 'recycle_board', $recycle_boards),
|
Chris@76
|
760 array('check', 'allow_ignore_boards'),
|
Chris@76
|
761 );
|
Chris@76
|
762
|
Chris@76
|
763 if ($return_config)
|
Chris@76
|
764 return $config_vars;
|
Chris@76
|
765
|
Chris@76
|
766 // Needed for the settings template and inline permission functions.
|
Chris@76
|
767 require_once($sourcedir . '/ManagePermissions.php');
|
Chris@76
|
768 require_once($sourcedir . '/ManageServer.php');
|
Chris@76
|
769
|
Chris@76
|
770 // Don't let guests have these permissions.
|
Chris@76
|
771 $context['post_url'] = $scripturl . '?action=admin;area=manageboards;save;sa=settings';
|
Chris@76
|
772 $context['permissions_excluded'] = array(-1);
|
Chris@76
|
773
|
Chris@76
|
774 $context['page_title'] = $txt['boards_and_cats'] . ' - ' . $txt['settings'];
|
Chris@76
|
775
|
Chris@76
|
776 loadTemplate('ManageBoards');
|
Chris@76
|
777 $context['sub_template'] = 'show_settings';
|
Chris@76
|
778
|
Chris@76
|
779 // Add some javascript stuff for the recycle box.
|
Chris@76
|
780 $context['settings_insert_below'] = '
|
Chris@76
|
781 <script type="text/javascript"><!-- // --><![CDATA[
|
Chris@76
|
782 document.getElementById("recycle_board").disabled = !document.getElementById("recycle_enable").checked;
|
Chris@76
|
783 // ]]></script>';
|
Chris@76
|
784
|
Chris@76
|
785 // Warn the admin against selecting the recycle topic without selecting a board.
|
Chris@76
|
786 $context['force_form_onsubmit'] = 'if(document.getElementById(\'recycle_enable\').checked && document.getElementById(\'recycle_board\').value == 0) { return confirm(\'' . $txt['recycle_board_unselected_notice'] . '\');} return true;';
|
Chris@76
|
787
|
Chris@76
|
788 // Doing a save?
|
Chris@76
|
789 if (isset($_GET['save']))
|
Chris@76
|
790 {
|
Chris@76
|
791 checkSession();
|
Chris@76
|
792
|
Chris@76
|
793 saveDBSettings($config_vars);
|
Chris@76
|
794 redirectexit('action=admin;area=manageboards;sa=settings');
|
Chris@76
|
795 }
|
Chris@76
|
796
|
Chris@76
|
797 // Prepare the settings...
|
Chris@76
|
798 prepareDBSettingContext($config_vars);
|
Chris@76
|
799 }
|
Chris@76
|
800
|
Chris@76
|
801 ?> |