Completed
Push — release-2.1 ( 001348...ca7b71 )
by Mathias
18:55
created

ManageBoards.template.php ➔ template_modify_category()   D

Complexity

Conditions 15
Paths 16

Size

Total Lines 99
Code Lines 45

Duplication

Lines 17
Ratio 17.17 %

Importance

Changes 0
Metric Value
cc 15
eloc 45
nc 16
nop 0
dl 17
loc 99
rs 4.9121
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 2017 Simple Machines and individual contributors
8
 * @license http://www.simplemachines.org/about/smf/license.php BSD
9
 *
10
 * @version 2.1 Beta 3
11
 */
12
13
/**
14
 * Template for listing all the current categories and boards.
15
 */
16
function template_main()
0 ignored issues
show
Best Practice introduced by
The function template_main() has been defined more than once; this definition is ignored, only the first definition in Themes/default/BoardIndex.template.php (L56-178) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
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="windowbg2 noup">';
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
68
			echo '
69
					<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;">
70
						<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>
71
						<span class="floatright">
72
							', $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>' : '', '
73
							<a href="', $scripturl, '?action=admin;area=manageboards;move=', $board['id'], '" class="button">', $txt['mboards_move'], '</a>
74
							<a href="', $scripturl, '?action=admin;area=manageboards;sa=board;boardid=', $board['id'], '" class="button">', $txt['mboards_modify'], '</a>
75
						</span><br style="clear: right;">
76
					</li>';
77
78
			if (!empty($board['move_links']))
79
			{
80
81
				echo '
82
					<li class="windowbg" style="padding-', $context['right_to_left'] ? 'right' : 'left', ': ', 5 + 30 * $board['move_links'][0]['child_level'], 'px;">';
83
84
				foreach ($board['move_links'] as $link)
85
					echo '
86
						<a href="', $link['href'], '" class="move_links" title="', $link['label'], '"><span class="generic_icons select_', $link['class'], '" title="', $link['label'], '"></span></a>';
87
88
				echo '
89
					</li>';
90
			}
91
		}
92
93
		// Button to add a new board.
94
		echo '
95
				</ul>
96
				<input type="submit" value="', $txt['mboards_new_board'], '" class="button_submit">
97
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
98
		</form>';
99
	}
100
101
	echo '
102
		</div>
103
	</div>';
104
}
105
106
/**
107
 * Tempalte for editing/adding a category on the forum.
108
 */
109
function template_modify_category()
110
{
111
	global $context, $scripturl, $txt;
112
113
	// Print table header.
114
	echo '
115
	<div id="manage_boards">
116
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=cat2" method="post" accept-charset="', $context['character_set'], '">
117
			<input type="hidden" name="cat" value="', $context['category']['id'], '">
118
				<div class="cat_bar">
119
					<h3 class="catbg">
120
						', isset($context['category']['is_new']) ? $txt['mboards_new_cat_name'] : $txt['catEdit'], '
121
					</h3>
122
				</div>
123
				<div class="windowbg2 noup">
124
					<dl class="settings">';
125
126
	// If this isn't the only category, let the user choose where this category should be positioned down the board index.
127
	if (count($context['category_order']) > 1)
128
	{
129
		echo '
130
					<dt><strong>', $txt['order'], ':</strong></dt>
131
					<dd>
132
						<select name="cat_order">';
133
134
		// Print every existing category into a select box.
135 View Code Duplication
		foreach ($context['category_order'] as $order)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
136
			echo '
137
							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
138
		echo '
139
						</select>
140
					</dd>';
141
	}
142
143
	// Allow the user to edit the category name and/or choose whether you can collapse the category.
144
	echo '
145
					<dt>
146
						<strong>', $txt['full_name'], ':</strong><br>
147
						<span class="smalltext">', $txt['name_on_display'], '</span>
148
					</dt>
149
					<dd>
150
						<input type="text" name="cat_name" value="', $context['category']['editable_name'], '" size="30" tabindex="', $context['tabindex']++, '" class="input_text">
151
					</dd>
152
					<dt>
153
						<strong>', $txt['mboards_description'], '</strong><br>
154
						<span class="smalltext">', str_replace('{allowed_tags}', implode(', ', $context['description_allowed_tags']), $txt['mboards_cat_description_desc']), '</span>
155
					</dt>
156
					<dd>
157
						<textarea name="cat_desc" rows="3" cols="35" style="width: 99%;">', $context['category']['description'], '</textarea>
158
					</dd>
159
					<dt>
160
							<strong>', $txt['collapse_enable'], '</strong><br>
161
						<span class="smalltext">', $txt['collapse_desc'], '</span>
162
					</dt>
163
					<dd>
164
						<input type="checkbox" name="collapse"', $context['category']['can_collapse'] ? ' checked' : '', ' tabindex="', $context['tabindex']++, '" class="input_check">
165
					</dd>';
166
167
	// Show any category settings added by mods using the 'integrate_edit_category' hook.
168 View Code Duplication
	if (!empty($context['custom_category_settings']) && is_array($context['custom_category_settings']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
169
	{
170
		foreach ($context['custom_category_settings'] as $catset_id => $catset)
171
		{
172
			if (!empty($catset['dt']) && !empty($catset['dd']))
173
				echo '
174
						<dt class="clear', !is_numeric($catset_id) ? ' catset_' . $catset_id : '', '">
175
							', $catset['dt'], '
176
						</dt>
177
						<dd', !is_numeric($catset_id) ? ' class="catset_' . $catset_id . '"' : '', '>
178
							', $catset['dd'], '
179
						</dd>';
180
		}
181
	}
182
183
	// Table footer.
184
	echo '
185
				</dl>';
186
187
	if (isset($context['category']['is_new']))
188
		echo '
189
					<input type="submit" name="add" value="', $txt['mboards_add_cat_button'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit">';
190
	else
191
		echo '
192
					<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.cat_name);" tabindex="', $context['tabindex']++, '" class="button_submit">
193
					<input type="submit" name="delete" value="', $txt['mboards_delete_cat'], '" data-confirm="', $txt['catConfirm'], '" class="button_submit you_sure">';
194
	echo '
195
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
196
					<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">';
197
198
	// If this category is empty we don't bother with the next confirmation screen.
199
	if ($context['category']['is_empty'])
200
		echo '
201
					<input type="hidden" name="empty" value="1">';
202
203
	echo '
204
			</div>
205
		</form>
206
	</div>';
207
}
208
209
/**
210
 * A template to confirm if a user wishes to delete a category - and whether they want to save the boards.
211
 */
212
function template_confirm_category_delete()
213
{
214
	global $context, $scripturl, $txt;
215
216
	// Print table header.
217
	echo '
218
	<div id="manage_boards" class="roundframe">
219
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=cat2" method="post" accept-charset="', $context['character_set'], '">
220
			<input type="hidden" name="cat" value="', $context['category']['id'], '">
221
			<div class="cat_bar">
222
				<h3 class="catbg">', $txt['mboards_delete_cat'], '</h3>
223
			</div>
224
			<div class="windowbg">
225
				<p>', $txt['mboards_delete_cat_contains'], ':</p>
226
				<ul>';
227
228
	foreach ($context['category']['children'] as $child)
229
		echo '
230
					<li>', $child, '</li>';
231
232
	echo '
233
				</ul>
234
			</div>
235
			<div class="cat_bar">
236
				<h3 class="catbg">', $txt['mboards_delete_what_do'], '</h3>
237
			</div>
238
			<div class="windowbg">
239
				<p>
240
					<label for="delete_action0"><input type="radio" id="delete_action0" name="delete_action" value="0" class="input_radio" checked>', $txt['mboards_delete_option1'], '</label><br>
241
					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', count($context['category_order']) == 1 ? ' disabled' : '', '>', $txt['mboards_delete_option2'], '</label>:
242
					<select name="cat_to"', count($context['category_order']) == 1 ? ' disabled' : '', '>';
243
244
	foreach ($context['category_order'] as $cat)
245
		if ($cat['id'] != 0)
246
			echo '
247
						<option value="', $cat['id'], '">', $cat['true_name'], '</option>';
248
249
	echo '
250
					</select>
251
				</p>
252
				<input type="submit" name="delete" value="', $txt['mboards_delete_confirm'], '" class="button_submit">
253
				<input type="submit" name="cancel" value="', $txt['mboards_delete_cancel'], '" class="button_submit">
254
				<input type="hidden" name="confirmation" value="1">
255
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
256
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '">
257
			</div>
258
		</form>
259
	</div>';
260
}
261
262
/**
263
 * Below is the template for adding/editing a board on the forum.
264
 */
265
function template_modify_board()
266
{
267
	global $context, $scripturl, $txt, $modSettings;
268
269
	// The main table header.
270
	echo '
271
	<div id="manage_boards">
272
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=board2" method="post" accept-charset="', $context['character_set'], '">
273
			<input type="hidden" name="boardid" value="', $context['board']['id'], '">
274
			<div class="cat_bar">
275
				<h3 class="catbg">
276
					', isset($context['board']['is_new']) ? $txt['mboards_new_board_name'] : $txt['boardsEdit'], '
277
				</h3>
278
			</div>
279
			<div class="windowbg2 noup">
280
				<dl class="settings">';
281
282
	// Option for choosing the category the board lives in.
283
	echo '
284
285
					<dt>
286
						<strong>', $txt['mboards_category'], ':</strong>
287
288
					</dt>
289
					<dd>
290
						<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 == \'\';}">';
291
		foreach ($context['categories'] as $category)
292
			echo '
293
							<option', $category['selected'] ? ' selected' : '', ' value="', $category['id'], '">', $category['name'], '</option>';
294
		echo '
295
						</select>
296
					</dd>';
297
298
	// If this isn't the only board in this category let the user choose where the board is to live.
299
	if ((isset($context['board']['is_new']) && count($context['board_order']) > 0) || count($context['board_order']) > 1)
300
	{
301
		echo '
302
					<dt>
303
						<strong>', $txt['order'], ':</strong>
304
					</dt>
305
					<dd>';
306
307
	// The first select box gives the user the option to position it before, after or as a child of another board.
308
	echo '
309
						<select id="order" name="placement" onchange="this.form.board_order.disabled = this.options[this.selectedIndex].value == \'\';">
310
							', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '', '
311
							<option value="after">' . $txt['mboards_order_after'] . '...</option>
312
							<option value="child">' . $txt['mboards_order_child_of'] . '...</option>
313
							<option value="before">' . $txt['mboards_order_before'] . '...</option>
314
						</select>';
315
316
	// The second select box lists all the boards in the category.
317
	echo '
318
						<select id="board_order" name="board_order"', !isset($context['board']['is_new']) ? ' disabled' : '', '>
319
							', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '';
320 View Code Duplication
	foreach ($context['board_order'] as $order)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
321
		echo '
322
							<option', $order['selected'] ? ' selected' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
323
	echo '
324
						</select>
325
					</dd>';
326
	}
327
328
	// Options for board name and description.
329
	echo '
330
					<dt>
331
						<strong>', $txt['full_name'], ':</strong><br>
332
						<span class="smalltext">', $txt['name_on_display'], '</span>
333
					</dt>
334
					<dd>
335
						<input type="text" name="board_name" value="', $context['board']['name'], '" size="30" class="input_text">
336
					</dd>
337
					<dt>
338
						<strong>', $txt['mboards_description'], ':</strong><br>
339
						<span class="smalltext">', str_replace('{allowed_tags}', implode(', ', $context['description_allowed_tags']), $txt['mboards_description_desc']), '</span>
340
					</dt>
341
					<dd>
342
						<textarea name="desc" rows="3" cols="35" style="width:99%;">', $context['board']['description'], '</textarea>
343
					</dd>
344
					<dt>
345
						<strong>', $txt['permission_profile'], ':</strong><br>
346
						<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>
347
					</dt>
348
					<dd>
349
						<select name="profile">';
350
351
	if (isset($context['board']['is_new']))
352
		echo '
353
							<option value="-1">[', $txt['permission_profile_inherit'], ']</option>';
354
355 View Code Duplication
	foreach ($context['profiles'] as $id => $profile)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
356
		echo '
357
							<option value="', $id, '"', $id == $context['board']['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
358
359
	echo '
360
						</select>
361
					</dd>
362
					<dt>
363
						<strong>', $txt['mboards_groups'], ':</strong><br>
364
						<span class="smalltext">', empty($modSettings['deny_boards_access']) ? $txt['mboards_groups_desc'] : $txt['boardsaccess_option_desc'], '</span>';
365
366
	echo '
367
					</dt>
368
					<dd>';
369
370
	if (!empty($modSettings['deny_boards_access']))
371
		echo '
372
						<table>
373
							<tr>
374
								<td></td>
375
								<th>', $txt['permissions_option_on'], '</th>
376
								<th>', $txt['permissions_option_off'], '</th>
377
								<th>', $txt['permissions_option_deny'], '</th>
378
							</tr>';
379
380
	// List all the membergroups so the user can choose who may access this board.
381
	foreach ($context['groups'] as $group)
382
		if (empty($modSettings['deny_boards_access']))
383
			echo '
384
						<label for="groups_', $group['id'], '">
385
							<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' : ''), ' class="input_check">
386
							<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'] . '"' : ''), '>
387
								', $group['name'], '
388
							</span>
389
						</label><br>';
390
		else
391
			echo '
392
							<tr>
393
								<td>
394
									<label for="groups_', $group['id'], '_a">
395
										<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'] . '"' : ''), '>
396
											', $group['name'], '
397
										</span>
398
									</label>
399
								</td>
400
								<td>
401
									<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' : ''), ' class="input_radio">
402
								</td>
403
								<td>
404
									<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' : ''), ' class="input_radio">
405
								</td>
406
								<td>
407
									<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' : ''), ' class="input_radio">
408
								</td>
409
								<td></td>
410
							</tr>';
411
412
	if (empty($modSettings['deny_boards_access']))
413
		echo '
414
						<span class="select_all_box">
415
							<em>', $txt['check_all'], '</em> <input type="checkbox" class="input_check" onclick="invertAll(this, this.form, \'groups[\');">
416
						</span>
417
						<br><br>
418
					</dd>';
419
	else
420
		echo '
421
							<tr class="select_all_box">
422
								<td>
423
								</td>
424
								<td>
425
									<input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'allow\');">
426
								</td>
427
								<td>
428
									<input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'ignore\');">
429
								</td>
430
								<td>
431
									<input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'deny\');">
432
								</td>
433
								<td>
434
									<em>', $txt['check_all'], '</em>
435
								</td>
436
							</tr>
437
						</table>
438
					</dd>';
439
440
	// Options to choose moderators, specify as announcement board and choose whether to count posts here.
441
	echo '
442
					<dt>
443
						<strong>', $txt['mboards_moderators'], ':</strong><br>
444
						<span class="smalltext">', $txt['mboards_moderators_desc'], '</span><br>
445
					</dt>
446
					<dd>
447
						<input type="text" name="moderators" id="moderators" value="', $context['board']['moderator_list'], '" size="30" class="input_text">
448
						<div id="moderator_container"></div>
449
					</dd>
450
					<dt>
451
						<strong>', $txt['mboards_moderator_groups'], ':</strong><br>
452
						<span class="smalltext">', $txt['mboards_moderator_groups_desc'], '</span><br>
453
					</dt>
454
					<dd>
455
						<input type="text" name="moderator_groups" id="moderator_groups" value="', $context['board']['moderator_groups_list'], '" size="30" class="input_text">
456
						<div id="moderator_group_container"></div>
457
					</dd>
458
				</dl>
459
				<script>
460
					$(document).ready(function () {
461
						$(".select_all_box").each(function () {
462
							$(this).removeClass(\'select_all_box\');
463
						});
464
					});
465
				</script>
466
				<hr>';
467
468
	if (empty($context['board']['is_recycle']) && empty($context['board']['topics']))
469
	{
470
		echo '
471
				<dl class="settings">
472
					<dt>
473
						<strong', $context['board']['topics'] ? ' style="color: gray;"' : '', '>', $txt['mboards_redirect'], ':</strong><br>
474
						<span class="smalltext">', $txt['mboards_redirect_desc'], '</span><br>
475
					</dt>
476
					<dd>
477
						<input type="checkbox" id="redirect_enable" name="redirect_enable"', $context['board']['redirect'] != '' ? ' checked' : '', ' onclick="refreshOptions();" class="input_check">
478
					</dd>
479
				</dl>
480
481
				<div id="redirect_address_div">
482
					<dl class="settings">
483
						<dt>
484
							<strong>', $txt['mboards_redirect_url'], ':</strong><br>
485
							<span class="smalltext">', $txt['mboards_redirect_url_desc'], '</span><br>
486
						</dt>
487
						<dd>
488
							<input type="text" name="redirect_address" value="', $context['board']['redirect'], '" size="40" class="input_text">
489
						</dd>
490
					</dl>
491
				</div>';
492
493
		if ($context['board']['redirect'])
494
			echo '
495
				<div id="reset_redirect_div">
496
					<dl class="settings">
497
						<dt>
498
							<strong>', $txt['mboards_redirect_reset'], ':</strong><br>
499
							<span class="smalltext">', $txt['mboards_redirect_reset_desc'], '</span><br>
500
						</dt>
501
						<dd>
502
							<input type="checkbox" name="reset_redirect" class="input_check">
503
							<em>(', sprintf($txt['mboards_current_redirects'], $context['board']['posts']), ')</em>
504
						</dd>
505
					</dl>
506
				</div>';
507
	}
508
509
	echo '
510
				<div id="count_posts_div">
511
					<dl class="settings">
512
						<dt>
513
							<strong>', $txt['mboards_count_posts'], ':</strong><br>
514
							<span class="smalltext">', $txt['mboards_count_posts_desc'], '</span><br>
515
						</dt>
516
						<dd>
517
							<input type="checkbox" name="count"', $context['board']['count_posts'] ? ' checked' : '', ' class="input_check">
518
						</dd>
519
					</dl>
520
				</div>';
521
522
	// Here the user can choose to force this board to use a theme other than the default theme for the forum.
523
	echo '
524
				<div id="board_theme_div">
525
					<dl class="settings">
526
						<dt>
527
							<strong>', $txt['mboards_theme'], ':</strong><br>
528
							<span class="smalltext">', $txt['mboards_theme_desc'], '</span><br>
529
						</dt>
530
						<dd>
531
							<select name="boardtheme" id="boardtheme" onchange="refreshOptions();">
532
								<option value="0"', $context['board']['theme'] == 0 ? ' selected' : '', '>', $txt['mboards_theme_default'], '</option>';
533
534 View Code Duplication
	foreach ($context['themes'] as $theme)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
535
		echo '
536
									<option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
537
538
	echo '
539
							</select>
540
						</dd>
541
					</dl>
542
				</div>
543
				<div id="override_theme_div">
544
					<dl class="settings">
545
						<dt>
546
							<strong>', $txt['mboards_override_theme'], ':</strong><br>
547
							<span class="smalltext">', $txt['mboards_override_theme_desc'], '</span><br>
548
						</dt>
549
						<dd>
550
							<input type="checkbox" name="override_theme"', $context['board']['override_theme'] ? ' checked' : '', ' class="input_check">
551
						</dd>
552
					</dl>
553
				</div>';
554
555
	// Show any board settings added by mods using the 'integrate_edit_board' hook.
556 View Code Duplication
	if (!empty($context['custom_board_settings']) && is_array($context['custom_board_settings']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
557
	{
558
		echo '
559
				<hr>
560
				<div id="custom_board_settings">
561
					<dl class="settings">';
562
563
		foreach ($context['custom_board_settings'] as $cbs_id => $cbs)
564
		{
565
			if (!empty($cbs['dt']) && !empty($cbs['dd']))
566
				echo '
567
						<dt class="clear', !is_numeric($cbs_id) ? ' cbs_' . $cbs_id : '', '">
568
							', $cbs['dt'], '
569
						</dt>
570
						<dd', !is_numeric($cbs_id) ? ' class="cbs_' . $cbs_id . '"' : '', '>
571
							', $cbs['dd'], '
572
						</dd>';
573
		}
574
575
		echo '
576
					</dl>
577
				</div>';
578
	}
579
580
	if (!empty($context['board']['is_recycle']))
581
		echo '
582
				<div class="noticebox">', $txt['mboards_recycle_disabled_delete'], '</div>';
583
584
	echo '
585
				<input type="hidden" name="rid" value="', $context['redirect_location'], '">
586
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
587
				<input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '">';
588
589
	// If this board has no children don't bother with the next confirmation screen.
590
	if ($context['board']['no_children'])
591
		echo '
592
				<input type="hidden" name="no_children" value="1">';
593
594
	if (isset($context['board']['is_new']))
595
		echo '
596
				<input type="hidden" name="cur_cat" value="', $context['board']['category'], '">
597
				<input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">';
598
	else
599
		echo '
600
				<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit">';
601
602
	if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle']))
603
		echo '
604
				<input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" data-confirm="', $txt['boardConfirm'], '" class="button_submit you_sure">';
605
	echo '
606
			</div>
607
		</form>
608
	</div>
609
610
<script>
611
	var oModeratorSuggest = new smc_AutoSuggest({
612
		sSelf: \'oModeratorSuggest\',
613
		sSessionId: smf_session_id,
614
		sSessionVar: smf_session_var,
615
		sSuggestId: \'moderators\',
616
		sControlId: \'moderators\',
617
		sSearchType: \'member\',
618
		bItemList: true,
619
		sPostName: \'moderator_list\',
620
		sURLMask: \'action=profile;u=%item_id%\',
621
		sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
622
		sItemListContainerId: \'moderator_container\',
623
		aListItems: [';
624
625 View Code Duplication
	foreach ($context['board']['moderators'] as $id_member => $member_name)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
626
		echo '
627
					{
628
						sItemId: ', JavaScriptEscape($id_member), ',
629
						sItemName: ', JavaScriptEscape($member_name), '
630
					}', $id_member == $context['board']['last_moderator_id'] ? '' : ',';
631
632
	echo '
633
		]
634
	});
635
636
	var oModeratorGroupSuggest = new smc_AutoSuggest({
637
		sSelf: \'oModeratorGroupSuggest\',
638
		sSessionId: smf_session_id,
639
		sSessionVar: smf_session_var,
640
		sSuggestId: \'moderator_groups\',
641
		sControlId: \'moderator_groups\',
642
		sSearchType: \'membergroups\',
643
		bItemList: true,
644
		sPostName: \'moderator_group_list\',
645
		sURLMask: \'action=groups;sa=members;group=%item_id%\',
646
		sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
647
		sItemListContainerId: \'moderator_group_container\',
648
		aListItems: [';
649
650
	foreach ($context['board']['moderator_groups'] as $id_group => $group_name)
651
		echo '
652
					{
653
						sItemId: ', JavaScriptEscape($id_group), ',
654
						sItemName: ', JavaScriptEscape($group_name), '
655
					}', $id_group == $context['board']['last_moderator_group_id'] ? '' : ',';
656
657
		echo '
658
			]
659
		});
660
</script>';
661
662
	// Javascript for deciding what to show.
663
	echo '
664
	<script>
665
		function refreshOptions()
666
		{
667
			var redirect = document.getElementById("redirect_enable");
668
			var redirectEnabled = redirect ? redirect.checked : false;
669
			var nonDefaultTheme = document.getElementById("boardtheme").value == 0 ? false : true;
670
671
			// What to show?
672
			document.getElementById("override_theme_div").style.display = redirectEnabled || !nonDefaultTheme ? "none" : "";
673
			document.getElementById("board_theme_div").style.display = redirectEnabled ? "none" : "";
674
			document.getElementById("count_posts_div").style.display = redirectEnabled ? "none" : "";';
675
676 View Code Duplication
	if (!$context['board']['topics'] && empty($context['board']['is_recycle']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
677
	{
678
		echo '
679
			document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";';
680
681
		if ($context['board']['redirect'])
682
			echo '
683
			document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";';
684
	}
685
686
	// Include any JavaScript added by mods using the 'integrate_edit_board' hook.
687
	if (!empty($context['custom_refreshOptions']) && is_array($context['custom_refreshOptions']))
688
	{
689
		foreach ($context['custom_refreshOptions'] as $refreshOption)
690
			echo '
691
			', $refreshOption;
692
	}
693
694
	echo '
695
		}
696
		refreshOptions();
697
	</script>';
698
}
699
700
/**
701
 * A template used when a user is deleting a board with child boards in it - to see what they want to do with them.
702
 */
703
function template_confirm_board_delete()
704
{
705
	global $context, $scripturl, $txt;
706
707
	// Print table header.
708
	echo '
709
	<div id="manage_boards" class="roundframe">
710
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=board2" method="post" accept-charset="', $context['character_set'], '">
711
			<input type="hidden" name="boardid" value="', $context['board']['id'], '">
712
713
			<div class="cat_bar">
714
				<h3 class="catbg">', $txt['mboards_delete_board'], '</h3>
715
			</div>
716
			<div class="windowbg">
717
				<p>', $txt['mboards_delete_board_contains'], '</p>
718
					<ul>';
719
720
	foreach ($context['children'] as $child)
721
		echo '
722
						<li>', $child['node']['name'], '</li>';
723
724
	echo '
725
					</ul>
726
			</div>
727
			<div class="cat_bar">
728
				<h3 class="catbg">', $txt['mboards_delete_what_do'], '</h3>
729
			</div>
730
			<div class="windowbg">
731
				<p>
732
					<label for="delete_action0"><input type="radio" id="delete_action0" name="delete_action" value="0" class="input_radio" checked>', $txt['mboards_delete_board_option1'], '</label><br>
733
					<label for="delete_action1"><input type="radio" id="delete_action1" name="delete_action" value="1" class="input_radio"', empty($context['can_move_children']) ? ' disabled' : '', '>', $txt['mboards_delete_board_option2'], '</label>:
734
					<select name="board_to"', empty($context['can_move_children']) ? ' disabled' : '', '>';
735
736
	foreach ($context['board_order'] as $board)
737 View Code Duplication
		if ($board['id'] != $context['board']['id'] && empty($board['is_child']))
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
738
			echo '
739
						<option value="', $board['id'], '">', $board['name'], '</option>';
740
741
	echo '
742
					</select>
743
				</p>
744
				<input type="submit" name="delete" value="', $txt['mboards_delete_confirm'], '" class="button_submit">
745
				<input type="submit" name="cancel" value="', $txt['mboards_delete_cancel'], '" class="button_submit">
746
				<input type="hidden" name="confirmation" value="1">
747
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
748
				<input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '"
749
			</div>
750
		</form>
751
	</div>';
752
}
753
754
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...