Passed
Push — release-2.1 ( 0c2197...207d2d )
by Jeremy
05:47
created

ManageBoards.template.php ➔ template_modify_board()   F

Complexity

Conditions 66
Paths > 20000

Size

Total Lines 450

Duplication

Lines 47
Ratio 10.44 %

Importance

Changes 0
Metric Value
cc 66
nc 884736
nop 0
dl 47
loc 450
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Simple Machines Forum (SMF)
4
 *
5
 * @package SMF
6
 * @author Simple Machines http://www.simplemachines.org
7
 * @copyright 2018 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 Beta 4
11
 */
12
13
/**
14
 * Template for listing all the current categories and boards.
15
 */
16
function template_main()
17
{
18
	global $context, $settings, $scripturl, $txt, $modSettings;
19
20
	// Table header.
21
	echo '
22
	<div id="manage_boards">
23
		<div class="cat_bar">
24
			<h3 class="catbg">', $txt['boardsEdit'], '</h3>
25
		</div>
26
		<div class="windowbg">';
27
28
	if (!empty($context['move_board']))
29
		echo '
30
			<div class="noticebox">
31
				', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=manageboards">', $txt['mboards_cancel_moving'], '</a>]', '
32
			</div>';
33
34
	// No categories so show a label.
35
	if (empty($context['categories']))
36
		echo '
37
			<div class="windowbg centertext">
38
				', $txt['mboards_no_cats'], '
39
			</div>';
40
41
	// Loop through every category, listing the boards in each as we go.
42
	foreach ($context['categories'] as $category)
43
	{
44
		// Link to modify the category.
45
		echo '
46
			<div class="sub_bar">
47
				<h3 class="subbg">
48
					<a href="', $scripturl, '?action=admin;area=manageboards;sa=cat;cat=', $category['id'], '">', $category['name'], '</a> <a href="', $scripturl, '?action=admin;area=manageboards;sa=cat;cat=', $category['id'], '">', $txt['catModify'], '</a>
49
				</h3>
50
			</div>';
51
52
		// Boards table header.
53
		echo '
54
			<form action="', $scripturl, '?action=admin;area=manageboards;sa=newboard;cat=', $category['id'], '" method="post" accept-charset="', $context['character_set'], '">
55
				<ul id="category_', $category['id'], '" class="nolist">';
56
57
		if (!empty($category['move_link']))
58
			echo '
59
					<li><a href="', $category['move_link']['href'], '" title="', $category['move_link']['label'], '"><span class="generic_icons select_above"></span></a></li>';
60
61
		$recycle_board = '<a href="' . $scripturl . '?action=admin;area=manageboards;sa=settings"> <img src="' . $settings['images_url'] . '/post/recycled.png" alt="' . $txt['recycle_board'] . '" title="' . $txt['recycle_board'] . '"></a>';
62
		$redirect_board = '<img src="' . $settings['images_url'] . '/new_redirect.png" alt="' . $txt['redirect_board_desc'] . '" title="' . $txt['redirect_board_desc'] . '">';
63
64
		// List through every board in the category, printing its name and link to modify the board.
65
		foreach ($category['boards'] as $board)
66
		{
67
			echo '
68
					<li', !empty($modSettings['recycle_board']) && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board['id'] ? ' id="recycle_board"' : ' ', ' class="windowbg', $board['is_redirect'] ? ' redirect_board' : '', '" style="padding-' . ($context['right_to_left'] ? 'right' : 'left') . ': ', 5 + 30 * $board['child_level'], 'px;">
69
						<span class="floatleft"><a', $board['move'] ? ' class="red"' : '', ' href="', $scripturl, '?board=', $board['id'], '.0">', $board['name'], '</a>', !empty($modSettings['recycle_board']) && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board['id'] ? $recycle_board : '', $board['is_redirect'] ? $redirect_board : '', '</span>
70
						<span class="floatright">
71
							', $context['can_manage_permissions'] ? '<a href="' . $scripturl . '?action=admin;area=permissions;sa=index;pid=' . $board['permission_profile'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" class="button">' . $txt['mboards_permissions'] . '</a>' : '', '
72
							<a href="', $scripturl, '?action=admin;area=manageboards;move=', $board['id'], '" class="button">', $txt['mboards_move'], '</a>
73
							<a href="', $scripturl, '?action=admin;area=manageboards;sa=board;boardid=', $board['id'], '" class="button">', $txt['mboards_modify'], '</a>
74
						</span><br style="clear: right;">
75
					</li>';
76
77
			if (!empty($board['move_links']))
78
			{
79
				echo '
80
					<li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">';
81
82
				foreach ($board['move_links'] as $link)
83
					echo '
84
						<a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>';
85
86
				echo '
87
					</li>';
88
			}
89
		}
90
91
		// Button to add a new board.
92
		echo '
93
				</ul>
94
				<input type="submit" value="', $txt['mboards_new_board'], '" class="button">
95
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
96
			</form>';
97
	}
98
99
	echo '
100
		</div><!-- .windowbg -->
101
	</div><!-- #manage_boards -->';
102
}
103
104
/**
105
 * Tempalte for editing/adding a category on the forum.
106
 */
107
function template_modify_category()
108
{
109
	global $context, $scripturl, $txt;
110
111
	// Print table header.
112
	echo '
113
	<div id="manage_boards">
114
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=cat2" method="post" accept-charset="', $context['character_set'], '">
115
			<input type="hidden" name="cat" value="', $context['category']['id'], '">
116
			<div class="cat_bar">
117
				<h3 class="catbg">
118
					', isset($context['category']['is_new']) ? $txt['mboards_new_cat_name'] : $txt['catEdit'], '
119
				</h3>
120
			</div>
121
			<div class="windowbg">
122
				<dl class="settings">';
123
124
	// If this isn't the only category, let the user choose where this category should be positioned down the board index.
125
	if (count($context['category_order']) > 1)
126
	{
127
		echo '
128
					<dt><strong>', $txt['order'], ':</strong></dt>
129
					<dd>
130
						<select name="cat_order">';
131
132
		// Print every existing category into a select box.
133
		foreach ($context['category_order'] as $order)
134
			echo '
135
							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
136
		echo '
137
						</select>
138
					</dd>';
139
	}
140
141
	// Allow the user to edit the category name and/or choose whether you can collapse the category.
142
	echo '
143
					<dt>
144
						<strong>', $txt['full_name'], ':</strong><br>
145
						<span class="smalltext">', $txt['name_on_display'], '</span>
146
					</dt>
147
					<dd>
148
						<input type="text" name="cat_name" value="', $context['category']['editable_name'], '" size="30" tabindex="', $context['tabindex']++, '">
149
					</dd>
150
					<dt>
151
						<strong>', $txt['mboards_description'], '</strong><br>
152
						<span class="smalltext">', str_replace('{allowed_tags}', implode(', ', $context['description_allowed_tags']), $txt['mboards_cat_description_desc']), '</span>
153
					</dt>
154
					<dd>
155
						<textarea name="cat_desc" rows="3" cols="35">', $context['category']['description'], '</textarea>
156
					</dd>
157
					<dt>
158
						<strong>', $txt['collapse_enable'], '</strong><br>
159
						<span class="smalltext">', $txt['collapse_desc'], '</span>
160
					</dt>
161
					<dd>
162
						<input type="checkbox" name="collapse"', $context['category']['can_collapse'] ? ' checked' : '', ' tabindex="', $context['tabindex']++, '">
163
					</dd>';
164
165
	// Show any category settings added by mods using the 'integrate_edit_category' hook.
166
	if (!empty($context['custom_category_settings']) && is_array($context['custom_category_settings']))
167
	{
168
		foreach ($context['custom_category_settings'] as $catset_id => $catset)
169
		{
170
			if (!empty($catset['dt']) && !empty($catset['dd']))
171
				echo '
172
					<dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '">
173
						', $catset['dt'], '
174
					</dt>
175
					<dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '>
176
						', $catset['dd'], '
177
					</dd>';
178
		}
179
	}
180
181
	// Table footer.
182
	echo '
183
				</dl>';
184
185
	if (isset($context['category']['is_new']))
186
		echo '
187
				<input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">';
188
	else
189
		echo '
190
				<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button">
191
				<input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button you_sure">';
192
	echo '
193
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
194
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
195
196
	// If this category is empty we don't bother with the next confirmation screen.
197
	if ($context['category']['is_empty'])
198
		echo '
199
				<input type="hidden" name="empty" value="1">';
200
201
	echo '
202
			</div><!-- .windowbg -->
203
		</form>
204
	</div><!-- #manage_boards -->';
205
}
206
207
/**
208
 * A template to confirm if a user wishes to delete a category - and whether they want to save the boards.
209
 */
210
function template_confirm_category_delete()
211
{
212
	global $context, $scripturl, $txt;
213
214
	// Print table header.
215
	echo '
216
	<div id="manage_boards" class="roundframe">
217
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=cat2" method="post" accept-charset="', $context['character_set'], '">
218
			<input type="hidden" name="cat" value="', $context['category']['id'], '">
219
			<div class="cat_bar">
220
				<h3 class="catbg">', $txt['mboards_delete_cat'], '</h3>
221
			</div>
222
			<div class="windowbg">
223
				<p>', $txt['mboards_delete_cat_contains'], ':</p>
224
				<ul>';
225
226
	foreach ($context['category']['children'] as $child)
227
		echo '
228
					<li>', $child, '</li>';
229
230
	echo '
231
				</ul>
232
			</div>
233
			<div class="cat_bar">
234
				<h3 class="catbg">', $txt['mboards_delete_what_do'], '</h3>
235
			</div>
236
			<div class="windowbg">
237
				<p>
238
					<label for="delete_action0"><input type="radio" id="delete_action0" name="delete_action" value="0" checked>', $txt['mboards_delete_option1'], '</label><br>
239
					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>:
240
					<select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>';
241
242
	foreach ($context['category_order'] as $cat)
243
		if ($cat['id'] != 0)
244
			echo '
245
						<option value="', $cat['id'], '">', $cat['true_name'], '</option>';
246
247
	echo '
248
					</select>
249
				</p>
250
				<input type="submit" name="delete" value="', $txt['mboards_delete_confirm'], '" class="button">
251
				<input type="submit" name="cancel" value="', $txt['mboards_delete_cancel'], '" class="button">
252
				<input type="hidden" name="confirmation" value="1">
253
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
254
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">
255
			</div><!-- .windowbg -->
256
		</form>
257
	</div><!-- #manage_boards -->';
258
}
259
260
/**
261
 * Below is the template for adding/editing a board on the forum.
262
 */
263
function template_modify_board()
264
{
265
	global $context, $scripturl, $txt, $modSettings;
266
267
	// The main table header.
268
	echo '
269
	<div id="manage_boards">
270
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=board2" method="post" accept-charset="', $context['character_set'], '">
271
			<input type="hidden" name="boardid" value="', $context['board']['id'], '">
272
			<div class="cat_bar">
273
				<h3 class="catbg">
274
					', isset($context['board']['is_new']) ? $txt['mboards_new_board_name'] : $txt['boardsEdit'], '
275
				</h3>
276
			</div>
277
			<div class="windowbg">
278
				<dl class="settings">';
279
280
	// Option for choosing the category the board lives in.
281
	echo '
282
					<dt>
283
						<strong>', $txt['mboards_category'], ':</strong>
284
					</dt>
285
					<dd>
286
						<select name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">';
287
288
	foreach ($context['categories'] as $category)
289
		echo '
290
							<option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>';
291
	echo '
292
						</select>
293
					</dd>';
294
295
	// If this isn't the only board in this category let the user choose where the board is to live.
296
	if ((isset($context['board']['is_new']) && count($context['board_order']) > 0) || count($context['board_order']) > 1)
297
	{
298
		echo '
299
					<dt>
300
						<strong>', $txt['order'], ':</strong>
301
					</dt>
302
					<dd>';
303
304
		// The first select box gives the user the option to position it before, after or as a child of another board.
305
		echo '
306
						<select id="order" name="placement" onchange="this.form.board_order.disabled = this.options[this.selectedIndex].value == \'\';">
307
							', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '', '
308
							<option value="after">' . $txt['mboards_order_after'] . '...</option>
309
							<option value="child">' . $txt['mboards_order_child_of'] . '...</option>
310
							<option value="before">' . $txt['mboards_order_before'] . '...</option>
311
						</select>';
312
313
		// The second select box lists all the boards in the category.
314
		echo '
315
						<select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '>
316
							', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '';
317
318
		foreach ($context['board_order'] as $order)
319
			echo '
320
							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
321
		echo '
322
						</select>
323
					</dd>';
324
	}
325
326
	// Options for board name and description.
327
	echo '
328
					<dt>
329
						<strong>', $txt['full_name'], ':</strong><br>
330
						<span class="smalltext">', $txt['name_on_display'], '</span>
331
					</dt>
332
					<dd>
333
						<input type="text" name="board_name" value="', $context['board']['name'], '" size="30">
334
					</dd>
335
					<dt>
336
						<strong>', $txt['mboards_description'], ':</strong><br>
337
						<span class="smalltext">', str_replace('{allowed_tags}', implode(', ', $context['description_allowed_tags']), $txt['mboards_description_desc']), '</span>
338
					</dt>
339
					<dd>
340
						<textarea name="desc" rows="3" cols="35">', $context['board']['description'], '</textarea>
341
					</dd>
342
					<dt>
343
						<strong>', $txt['permission_profile'], ':</strong><br>
344
						<span class="smalltext">', $context['can_manage_permissions'] ? sprintf($txt['permission_profile_desc'], $scripturl . '?action=admin;area=permissions;sa=profiles;' . $context['session_var'] . '=' . $context['session_id']) : strip_tags($txt['permission_profile_desc']), '</span>
345
					</dt>
346
					<dd>
347
						<select name="profile">';
348
349
	if (isset($context['board']['is_new']))
350
		echo '
351
							<option value="-1">[', $txt['permission_profile_inherit'], ']</option>';
352
353
	foreach ($context['profiles'] as $id => $profile)
354
		echo '
355
							<option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
356
357
	echo '
358
						</select>
359
					</dd>
360
					<dt>
361
						<strong>', $txt['mboards_groups'], ':</strong><br>
362
						<span class="smalltext">', empty($modSettings['deny_boards_access']) ? $txt['mboards_groups_desc'] : $txt['boardsaccess_option_desc'], '</span>';
363
364
	echo '
365
					</dt>
366
					<dd>';
367
368
	if (!empty($modSettings['deny_boards_access']))
369
		echo '
370
						<table>
371
							<tr>
372
								<td></td>
373
								<th>', $txt['permissions_option_on'], '</th>
374
								<th>', $txt['permissions_option_off'], '</th>
375
								<th>', $txt['permissions_option_deny'], '</th>
376
							</tr>';
377
378
	// List all the membergroups so the user can choose who may access this board.
379
	foreach ($context['groups'] as $group)
380
		if (empty($modSettings['deny_boards_access']))
381
			echo '
382
						<label for="groups_', $group['id'], '">
383
							<input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), '>
384
							<span', $group['is_post_group'] ? ' class="post_group" title="' . $txt['mboards_groups_post_group'] . '"' : ($group['id'] == 0 ? ' class="regular_members" title="' . $txt['mboards_groups_regular_members'] . '"' : ''), '>
385
								', $group['name'], '
386
							</span>
387
						</label><br>';
388
		else
389
			echo '
390
							<tr>
391
								<td>
392
									<label for="groups_', $group['id'], '_a">
393
										<span', $group['is_post_group'] ? ' class="post_group" title="' . $txt['mboards_groups_post_group'] . '"' : ($group['id'] == 0 ? ' class="regular_members" title="' . $txt['mboards_groups_regular_members'] . '"' : ''), '>
394
											', $group['name'], '
395
										</span>
396
									</label>
397
								</td>
398
								<td>
399
									<input type="radio" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '_a"', in_array($group['id'], $context['board_managers']) ? ' checked disabled' : ($group['allow'] ? ' checked' : ''), '>
400
								</td>
401
								<td>
402
									<input type="radio" name="groups[', $group['id'], ']" value="ignore" id="groups_', $group['id'], '_x"', in_array($group['id'], $context['board_managers']) ? ' disabled' : (!$group['allow'] && !$group['deny'] ? ' checked' : ''), '>
403
								</td>
404
								<td>
405
									<input type="radio" name="groups[', $group['id'], ']" value="deny" id="groups_', $group['id'], '_d"', in_array($group['id'], $context['board_managers']) ? ' disabled' : ($group['deny'] ? ' checked' : ''), '>
406
								</td>
407
								<td></td>
408
							</tr>';
409
410
	if (empty($modSettings['deny_boards_access']))
411
		echo '
412
						<span class="select_all_box">
413
							<em>', $txt['check_all'], '</em> <input type="checkbox" onclick="invertAll(this, this.form, \'groups[\');">
414
						</span>
415
						<br><br>
416
					</dd>';
417
	else
418
		echo '
419
							<tr class="select_all_box">
420
								<td>
421
								</td>
422
								<td>
423
									<input type="radio" name="select_all" onclick="selectAllRadio(this, this.form, \'groups\', \'allow\');">
424
								</td>
425
								<td>
426
									<input type="radio" name="select_all" onclick="selectAllRadio(this, this.form, \'groups\', \'ignore\');">
427
								</td>
428
								<td>
429
									<input type="radio" name="select_all" onclick="selectAllRadio(this, this.form, \'groups\', \'deny\');">
430
								</td>
431
								<td>
432
									<em>', $txt['check_all'], '</em>
433
								</td>
434
							</tr>
435
						</table>
436
					</dd>';
437
438
	// Options to choose moderators, specify as announcement board and choose whether to count posts here.
439
	echo '
440
					<dt>
441
						<strong>', $txt['mboards_moderators'], ':</strong><br>
442
						<span class="smalltext">', $txt['mboards_moderators_desc'], '</span><br>
443
					</dt>
444
					<dd>
445
						<input type="text" name="moderators" id="moderators" value="', $context['board']['moderator_list'], '" size="30">
446
						<div id="moderator_container"></div>
447
					</dd>
448
					<dt>
449
						<strong>', $txt['mboards_moderator_groups'], ':</strong><br>
450
						<span class="smalltext">', $txt['mboards_moderator_groups_desc'], '</span><br>
451
					</dt>
452
					<dd>
453
						<input type="text" name="moderator_groups" id="moderator_groups" value="', $context['board']['moderator_groups_list'], '" size="30">
454
						<div id="moderator_group_container"></div>
455
					</dd>
456
				</dl>
457
				<script>
458
					$(document).ready(function () {
459
						$(".select_all_box").each(function () {
460
							$(this).removeClass(\'select_all_box\');
461
						});
462
					});
463
				</script>
464
				<hr>';
465
466
	if (empty($context['board']['is_recycle']) && empty($context['board']['topics']))
467
	{
468
		echo '
469
				<dl class="settings">
470
					<dt>
471
						<strong', $context['board']['topics'] ? ' style="color: gray;"' : '', '>', $txt['mboards_redirect'], ':</strong><br>
472
						<span class="smalltext">', $txt['mboards_redirect_desc'], '</span><br>
473
					</dt>
474
					<dd>
475
						<input type="checkbox" id="redirect_enable" name="redirect_enable"', $context['board']['redirect'] != '' ? ' checked' : '', ' onclick="refreshOptions();">
476
					</dd>
477
				</dl>
478
479
				<div id="redirect_address_div">
480
					<dl class="settings">
481
						<dt>
482
							<strong>', $txt['mboards_redirect_url'], ':</strong><br>
483
							<span class="smalltext">', $txt['mboards_redirect_url_desc'], '</span><br>
484
						</dt>
485
						<dd>
486
							<input type="text" name="redirect_address" value="', $context['board']['redirect'], '" size="40">
487
						</dd>
488
					</dl>
489
				</div>';
490
491
		if ($context['board']['redirect'])
492
			echo '
493
				<div id="reset_redirect_div">
494
					<dl class="settings">
495
						<dt>
496
							<strong>', $txt['mboards_redirect_reset'], ':</strong><br>
497
							<span class="smalltext">', $txt['mboards_redirect_reset_desc'], '</span><br>
498
						</dt>
499
						<dd>
500
							<input type="checkbox" name="reset_redirect">
501
							<em>(', sprintf($txt['mboards_current_redirects'], $context['board']['posts']), ')</em>
502
						</dd>
503
					</dl>
504
				</div>';
505
	}
506
507
	echo '
508
				<div id="count_posts_div">
509
					<dl class="settings">
510
						<dt>
511
							<strong>', $txt['mboards_count_posts'], ':</strong><br>
512
							<span class="smalltext">', $txt['mboards_count_posts_desc'], '</span><br>
513
						</dt>
514
						<dd>
515
							<input type="checkbox" name="count"', $context['board']['count_posts'] ? ' checked' : '', '>
516
						</dd>
517
					</dl>
518
				</div>';
519
520
	// Here the user can choose to force this board to use a theme other than the default theme for the forum.
521
	echo '
522
				<div id="board_theme_div">
523
					<dl class="settings">
524
						<dt>
525
							<strong>', $txt['mboards_theme'], ':</strong><br>
526
							<span class="smalltext">', $txt['mboards_theme_desc'], '</span><br>
527
						</dt>
528
						<dd>
529
							<select name="boardtheme" id="boardtheme" onchange="refreshOptions();">
530
								<option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>';
531
532
	foreach ($context['themes'] as $theme)
533
		echo '
534
									<option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
535
536
	echo '
537
							</select>
538
						</dd>
539
					</dl>
540
				</div><!-- #board_theme_div -->
541
				<div id="override_theme_div">
542
					<dl class="settings">
543
						<dt>
544
							<strong>', $txt['mboards_override_theme'], ':</strong><br>
545
							<span class="smalltext">', $txt['mboards_override_theme_desc'], '</span><br>
546
						</dt>
547
						<dd>
548
							<input type="checkbox" name="override_theme"', $context['board']['override_theme'] ? ' checked' : '', '>
549
						</dd>
550
					</dl>
551
				</div>';
552
553
	// Show any board settings added by mods using the 'integrate_edit_board' hook.
554
	if (!empty($context['custom_board_settings']) && is_array($context['custom_board_settings']))
555
	{
556
		echo '
557
				<hr>
558
				<div id="custom_board_settings">
559
					<dl class="settings">';
560
561
		foreach ($context['custom_board_settings'] as $cbs_id => $cbs)
562
		{
563
			if (!empty($cbs['dt']) && !empty($cbs['dd']))
564
				echo '
565
						<dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '">
566
							', $cbs['dt'], '
567
						</dt>
568
						<dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '>
569
							', $cbs['dd'], '
570
						</dd>';
571
		}
572
573
		echo '
574
					</dl>
575
				</div>';
576
	}
577
578
	if (!empty($context['board']['is_recycle']))
579
		echo '
580
				<div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>';
581
582
	echo '
583
				<input type="hidden" name="rid" value="', $context['redirect_location'], '">
584
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
585
				<input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">';
586
587
	// If this board has no children don't bother with the next confirmation screen.
588
	if ($context['board']['no_children'])
589
		echo '
590
				<input type="hidden" name="no_children" value="1">';
591
592
	if (isset($context['board']['is_new']))
593
		echo '
594
				<input type="hidden" name="cur_cat" value="', $context['board']['category'], '">
595
				<input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">';
596
	else
597
		echo '
598
				<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button">';
599
600
	if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle']))
601
		echo '
602
				<input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button you_sure">';
603
	echo '
604
			</div><!-- .windowbg -->
605
		</form>
606
	</div><!-- #manage_boards -->
607
608
	<script>
609
		var oModeratorSuggest = new smc_AutoSuggest({
610
			sSelf: \'oModeratorSuggest\',
611
			sSessionId: smf_session_id,
612
			sSessionVar: smf_session_var,
613
			sSuggestId: \'moderators\',
614
			sControlId: \'moderators\',
615
			sSearchType: \'member\',
616
			bItemList: true,
617
			sPostName: \'moderator_list\',
618
			sURLMask: \'action=profile;u=%item_id%\',
619
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
620
			sItemListContainerId: \'moderator_container\',
621
			aListItems: [';
622
623
	foreach ($context['board']['moderators'] as $id_member => $member_name)
624
		echo '
625
				{
626
					sItemId: ', JavaScriptEscape($id_member), ',
627
					sItemName: ', JavaScriptEscape($member_name), '
628
				}', $id_member == $context['board']['last_moderator_id'] ? '' : ',';
629
630
	echo '
631
			]
632
		});
633
634
		var oModeratorGroupSuggest = new smc_AutoSuggest({
635
			sSelf: \'oModeratorGroupSuggest\',
636
			sSessionId: smf_session_id,
637
			sSessionVar: smf_session_var,
638
			sSuggestId: \'moderator_groups\',
639
			sControlId: \'moderator_groups\',
640
			sSearchType: \'membergroups\',
641
			bItemList: true,
642
			sPostName: \'moderator_group_list\',
643
			sURLMask: \'action=groups;sa=members;group=%item_id%\',
644
			sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
645
			sItemListContainerId: \'moderator_group_container\',
646
			aListItems: [';
647
648
	foreach ($context['board']['moderator_groups'] as $id_group => $group_name)
649
		echo '
650
				{
651
					sItemId: ', JavaScriptEscape($id_group), ',
652
					sItemName: ', JavaScriptEscape($group_name), '
653
				}', $id_group == $context['board']['last_moderator_group_id'] ? '' : ',';
654
655
		echo '
656
			]
657
		});
658
	</script>';
659
660
	// Javascript for deciding what to show.
661
	echo '
662
	<script>
663
		function refreshOptions()
664
		{
665
			var redirect = document.getElementById("redirect_enable");
666
			var redirectEnabled = redirect ? redirect.checked : false;
667
			var nonDefaultTheme = document.getElementById("boardtheme").value == 0 ? false : true;
668
669
			// What to show?
670
			
671
			if(redirectEnabled || !nonDefaultTheme) 
672
				document.getElementById("override_theme_div").classList.add(\'hidden\'); 
673
			else 
674
				document.getElementById("override_theme_div").classList.remove(\'hidden\');
675
			
676
			if(redirectEnabled) {
677
				document.getElementById("board_theme_div").classList.add(\'hidden\');
678
				document.getElementById("count_posts_div").classList.add(\'hidden\');
679
			} else {
680
				document.getElementById("board_theme_div").classList.remove(\'hidden\');
681
				document.getElementById("count_posts_div").classList.remove(\'hidden\');
682
			}';
683
684
	if (!$context['board']['topics'] && empty($context['board']['is_recycle']))
685
	{
686
		echo '
687
			if(redirectEnabled)
688
				document.getElementById("redirect_address_div").classList.remove(\'hidden\');
689
			else 
690
				document.getElementById("redirect_address_div").classList.add(\'hidden\');';
691
692
		if ($context['board']['redirect'])
693
			echo '
694
			if(redirectEnabled)
695
				document.getElementById("reset_redirect_div").classList.remove(\'hidden\');
696
			else 
697
				document.getElementById("reset_redirect_div").classList.add(\'hidden\');';
698
	}
699
700
	// Include any JavaScript added by mods using the 'integrate_edit_board' hook.
701
	if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions']))
702
	{
703
		foreach ($context['custom_refreshOptions'] as $refreshOption)
704
			echo '
705
			', $refreshOption;
706
	}
707
708
	echo '
709
		}
710
		refreshOptions();
711
	</script>';
712
}
713
714
/**
715
 * A template used when a user is deleting a board with child boards in it - to see what they want to do with them.
716
 */
717
function template_confirm_board_delete()
718
{
719
	global $context, $scripturl, $txt;
720
721
	// Print table header.
722
	echo '
723
	<div id="manage_boards" class="roundframe">
724
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=board2" method="post" accept-charset="', $context['character_set'], '">
725
			<input type="hidden" name="boardid" value="', $context['board']['id'], '">
726
727
			<div class="cat_bar">
728
				<h3 class="catbg">', $txt['mboards_delete_board'], '</h3>
729
			</div>
730
			<div class="windowbg">
731
				<p>', $txt['mboards_delete_board_contains'], '</p>
732
				<ul>';
733
734
	foreach ($context['children'] as $child)
735
		echo '
736
					<li>', $child['node']['name'], '</li>';
737
738
	echo '
739
				</ul>
740
			</div>
741
			<div class="cat_bar">
742
				<h3 class="catbg">', $txt['mboards_delete_what_do'], '</h3>
743
			</div>
744
			<div class="windowbg">
745
				<p>
746
					<label for="delete_action0"><input type="radio" id="delete_action0" name="delete_action" value="0" checked>', $txt['mboards_delete_board_option1'], '</label><br>
747
					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>:
748
					<select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>';
749
750
	foreach ($context['board_order'] as $board)
751
		if ($board['id'] != $context['board']['id'] && empty($board['is_child']))
752
			echo '
753
						<option value="', $board['id'], '">', $board['name'], '</option>';
754
755
	echo '
756
					</select>
757
				</p>
758
				<input type="submit" name="delete" value="', $txt['mboards_delete_confirm'], '" class="button">
759
				<input type="submit" name="cancel" value="', $txt['mboards_delete_cancel'], '" class="button">
760
				<input type="hidden" name="confirmation" value="1">
761
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
762
				<input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">
763
			</div><!-- .windowbg -->
764
		</form>
765
	</div><!-- #manage_boards -->';
766
}
767
768
?>