Completed
Push — release-2.1 ( cfdc59...af3d3b )
by Jeremy
12:06 queued 05:35
created
Themes/default/Errors.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -328,7 +328,7 @@
 block discarded – undo
328 328
 		foreach ($context['error_info']['backtrace'] as $key => $value)
329 329
 		{
330 330
 			//Check for existing
331
-			if (!property_exists($value,'file') || empty($value->file))
331
+			if (!property_exists($value, 'file') || empty($value->file))
332 332
 				$value->file = $txt['unknown'];
333 333
 			if (!property_exists($value, 'line') || empty($value->line))
334 334
 				$value->line = -1;
Please login to merge, or discard this patch.
Braces   +48 added lines, -33 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 {
24 24
 	global $context, $txt;
25 25
 
26
-	if (!empty($context['simple_action']))
27
-		echo '
26
+	if (!empty($context['simple_action'])) {
27
+			echo '
28 28
 	<strong>
29 29
 		', $context['error_title'], '
30 30
 	</strong><br>
31 31
 	<div ', $context['error_code'], 'class="padding">
32 32
 		', $context['error_message'], '
33 33
 	</div>';
34
-	else
34
+	} else
35 35
 	{
36 36
 		echo '
37 37
 	<div id="fatal_error">
@@ -85,21 +85,23 @@  discard block
 block discarded – undo
85 85
 
86 86
 	$error_types = array();
87 87
 
88
-	foreach ($context['error_types'] as $type => $details)
89
-		$error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>';
88
+	foreach ($context['error_types'] as $type => $details) {
89
+			$error_types[] = ($details['is_selected'] ? '<img src="' . $settings['images_url'] . '/selected.png" alt=""> ' : '') . '<a href="' . $details['url'] . '" ' . ($details['is_selected'] ? 'style="font-weight: bold;"' : '') . ' title="' . $details['description'] . '">' . $details['label'] . '</a>';
90
+	}
90 91
 
91 92
 	echo '
92 93
 						', implode(' | ', $error_types), '
93 94
 					</td>
94 95
 				</tr>';
95 96
 
96
-	if ($context['has_filter'])
97
-		echo '
97
+	if ($context['has_filter']) {
98
+			echo '
98 99
 				<tr>
99 100
 					<td colspan="3" class="windowbg">
100 101
 						<strong>', $txt['applying_filter'], ':</strong> ', $context['filter']['entity'], ' ', $context['filter']['value']['html'], ' [<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', '">', $txt['clear_filter'], '</a>]
101 102
 					</td>
102 103
 				</tr>';
104
+	}
103 105
 
104 106
 	echo '
105 107
 				<tr>
@@ -110,11 +112,12 @@  discard block
 block discarded – undo
110 112
 				</tr>';
111 113
 
112 114
 	// No errors, then show a message
113
-	if (count($context['errors']) == 0)
114
-		echo '
115
+	if (count($context['errors']) == 0) {
116
+			echo '
115 117
 				<tr class="windowbg">
116 118
 					<td class="centertext" colspan="2">', $txt['errlog_no_entries'], '</td>
117 119
 				</tr>';
120
+	}
118 121
 
119 122
 	// We have some errors, must be some mods installed :P
120 123
 	foreach ($context['errors'] as $error)
@@ -128,16 +131,18 @@  discard block
 block discarded – undo
128 131
 							<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? '' : ';desc', $context['has_filter'] ? $context['filter']['href'] : '', '" title="', $txt['reverse_direction'], '"><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></a>
129 132
 							', $error['time'], '<br>';
130 133
 
131
-		if (!empty($error['member']['ip']))
132
-			echo '
134
+		if (!empty($error['member']['ip'])) {
135
+					echo '
133 136
 							<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=ip;value=', $error['member']['ip'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_ip'], '"><span class="generic_icons filter centericon"></span></a>
134 137
 							<strong><a href="', $scripturl, '?action=trackip;searchip=', $error['member']['ip'], '">', $error['member']['ip'], '</a></strong>';
138
+		}
135 139
 
136
-		if ($error['member']['session'] != '')
137
-			echo '
140
+		if ($error['member']['session'] != '') {
141
+					echo '
138 142
 							<br>
139 143
 							<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=session;value=', $error['member']['session'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_session'], '"><span class="generic_icons filter centericon"></span></a>
140 144
 							', $error['member']['session'], '<br>';
145
+		}
141 146
 
142 147
 		echo '
143 148
 						</div>
@@ -152,12 +157,13 @@  discard block
 block discarded – undo
152 157
 							<a href="', $error['url']['html'], '">', $error['url']['html'], '</a>
153 158
 ';
154 159
 
155
-		if (!empty($error['file']))
156
-			echo '
160
+		if (!empty($error['file'])) {
161
+					echo '
157 162
 							<div>
158 163
 								<a href="', $scripturl, '?action=admin;area=logs;sa=errorlog', $context['sort_direction'] == 'down' ? ';desc' : '', ';filter=file;value=', $error['file']['search'], '" title="', $txt['apply_filter'], ': ', $txt['filter_only_file'], '">'
159 164
 				. '					<span class="generic_icons filter"></span></a> ', $error['file']['link'], ' (', $txt['line'], ' ', $error['file']['line'], ')
160 165
 							</div>';
166
+		}
161 167
 
162 168
 		echo '
163 169
 						</div>
@@ -186,9 +192,10 @@  discard block
 block discarded – undo
186 192
 				</div>
187 193
 			</div>';
188 194
 
189
-	if ($context['sort_direction'] == 'down')
190
-		echo '
195
+	if ($context['sort_direction'] == 'down') {
196
+			echo '
191 197
 			<input type="hidden" name="desc" value="1">';
198
+	}
192 199
 
193 200
 	echo '
194 201
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -249,9 +256,10 @@  discard block
 block discarded – undo
249 256
 					$context['error_message'], '
250 257
 				</div>';
251 258
 	
252
-	if (!empty($context['back_link'])) 
253
-		echo '
259
+	if (!empty($context['back_link'])) {
260
+			echo '
254 261
 				<a class="button" href="', $scripturl, $context['back_link'], '">', $txt['back'], '</a>';
262
+	}
255 263
 
256 264
 	echo '
257 265
 				<span style="float: right; margin:.5em;"></span>
@@ -288,25 +296,30 @@  discard block
 block discarded – undo
288 296
 			<div class="windowbg">
289 297
 				<ul class="padding">';
290 298
 
291
-		if (!empty($context['error_info']['error_type']))
292
-			echo '
299
+		if (!empty($context['error_info']['error_type'])) {
300
+					echo '
293 301
 					<li>', $txt['error_type'], ': ', ucfirst($context['error_info']['error_type']), '</li>';
302
+		}
294 303
 
295
-		if (!empty($context['error_info']['message']))
296
-			echo '
304
+		if (!empty($context['error_info']['message'])) {
305
+					echo '
297 306
 					<li>', $txt['error_message'], ': ', $context['error_info']['message'], '</li>';
307
+		}
298 308
 
299
-		if (!empty($context['error_info']['file']))
300
-			echo '
309
+		if (!empty($context['error_info']['file'])) {
310
+					echo '
301 311
 					<li>', $txt['error_file'], ': ', $context['error_info']['file'], '</li>';
312
+		}
302 313
 
303
-		if (!empty($context['error_info']['line']))
304
-			echo '
314
+		if (!empty($context['error_info']['line'])) {
315
+					echo '
305 316
 					<li>', $txt['error_line'], ': ', $context['error_info']['line'], '</li>';
317
+		}
306 318
 
307
-		if (!empty($context['error_info']['url']))
308
-			echo '
319
+		if (!empty($context['error_info']['url'])) {
320
+					echo '
309 321
 					<li>', $txt['error_url'], ': ', $context['error_info']['url'], '</li>';
322
+		}
310 323
 
311 324
 
312 325
 		echo '
@@ -328,10 +341,12 @@  discard block
 block discarded – undo
328 341
 		foreach ($context['error_info']['backtrace'] as $key => $value)
329 342
 		{
330 343
 			//Check for existing
331
-			if (!property_exists($value,'file') || empty($value->file))
332
-				$value->file = $txt['unknown'];
333
-			if (!property_exists($value, 'line') || empty($value->line))
334
-				$value->line = -1;
344
+			if (!property_exists($value,'file') || empty($value->file)) {
345
+							$value->file = $txt['unknown'];
346
+			}
347
+			if (!property_exists($value, 'line') || empty($value->line)) {
348
+							$value->line = -1;
349
+			}
335 350
 
336 351
 				echo '
337 352
 					<li class="backtrace">', sprintf($txt['backtrace_info'], $key, $value->function, $value->file, $value->line, base64_encode($value->file)), '</li>';
Please login to merge, or discard this patch.
Themes/default/Recent.template.php 2 patches
Braces   +77 added lines, -54 removed lines patch added patch discarded remove patch
@@ -26,9 +26,10 @@  discard block
 block discarded – undo
26 26
 		</div>
27 27
 		<div class="pagesection">', $context['page_index'], '</div>';
28 28
 
29
-	if (empty($context['posts']))
30
-		echo '
29
+	if (empty($context['posts'])) {
30
+			echo '
31 31
 		<div class="windowbg">', $txt['no_messages'], '</div>';
32
+	}
32 33
 
33 34
 	foreach ($context['posts'] as $post)
34 35
 	{
@@ -41,28 +42,33 @@  discard block
 block discarded – undo
41 42
 			</div>
42 43
 			<div class="list_posts">', $post['message'], '</div>';
43 44
 
44
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
45
-			echo '
45
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
46
+					echo '
46 47
 			<ul class="quickbuttons">';
48
+		}
47 49
 
48 50
 		// If they *can* reply?
49
-		if ($post['can_reply'])
50
-			echo '
51
+		if ($post['can_reply']) {
52
+					echo '
51 53
 				<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>';
54
+		}
52 55
 
53 56
 		// If they *can* quote?
54
-		if ($post['can_quote'])
55
-			echo '
57
+		if ($post['can_quote']) {
58
+					echo '
56 59
 				<li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
60
+		}
57 61
 
58 62
 		// How about... even... remove it entirely?!
59
-		if ($post['can_delete'])
60
-			echo '
63
+		if ($post['can_delete']) {
64
+					echo '
61 65
 				<li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['remove'], '</a></li>';
66
+		}
62 67
 
63
-		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
64
-			echo '
68
+		if ($post['can_reply'] || $post['can_quote'] || $post['can_delete']) {
69
+					echo '
65 70
 			</ul>';
71
+		}
66 72
 
67 73
 		echo '
68 74
 		</div><!-- $post[css_class] -->';
@@ -83,12 +89,13 @@  discard block
 block discarded – undo
83 89
 	echo '
84 90
 	<div id="recent" class="main_content">';
85 91
 
86
-	if ($context['showCheckboxes'])
87
-		echo '
92
+	if ($context['showCheckboxes']) {
93
+			echo '
88 94
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
89 95
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
90 96
 			<input type="hidden" name="qaction" value="markread">
91 97
 			<input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
98
+	}
92 99
 
93 100
 	if (!empty($context['topics']))
94 101
 	{
@@ -117,11 +124,12 @@  discard block
 block discarded – undo
117 124
 					</div>';
118 125
 
119 126
 		// Show a "select all" box for quick moderation?
120
-		if ($context['showCheckboxes'])
121
-			echo '
127
+		if ($context['showCheckboxes']) {
128
+					echo '
122 129
 					<div class="moderation">
123 130
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
124 131
 					</div>';
132
+		}
125 133
 
126 134
 		echo '
127 135
 				</div><!-- #topic_header -->
@@ -141,17 +149,20 @@  discard block
 block discarded – undo
141 149
 			echo '
142 150
 							<div class="icons floatright">';
143 151
 
144
-			if ($topic['is_locked'])
145
-				echo '
152
+			if ($topic['is_locked']) {
153
+							echo '
146 154
 								<span class="generic_icons lock"></span>';
155
+			}
147 156
 
148
-			if ($topic['is_sticky'])
149
-				echo '
157
+			if ($topic['is_sticky']) {
158
+							echo '
150 159
 								<span class="generic_icons sticky"></span>';
160
+			}
151 161
 
152
-			if ($topic['is_poll'])
153
-				echo '
162
+			if ($topic['is_poll']) {
163
+							echo '
154 164
 								<span class="generic_icons poll"></span>';
165
+			}
155 166
 
156 167
 			echo '
157 168
 							</div>';
@@ -177,19 +188,21 @@  discard block
 block discarded – undo
177 188
 							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
178 189
 						</div>';
179 190
 
180
-			if ($context['showCheckboxes'])
181
-				echo '
191
+			if ($context['showCheckboxes']) {
192
+							echo '
182 193
 						<div class="moderation">
183 194
 							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
184 195
 						</div>';
196
+			}
185 197
 
186 198
 			echo '
187 199
 					</div><!-- $topic[css_class] -->';
188 200
 		}
189 201
 
190
-		if (empty($context['topics']))
191
-			echo '
202
+		if (empty($context['topics'])) {
203
+					echo '
192 204
 					<div style="display: none;"></div>';
205
+		}
193 206
 
194 207
 		echo '
195 208
 				</div><!-- #topic_container -->
@@ -204,25 +217,27 @@  discard block
 block discarded – undo
204 217
 					', $context['page_index'], '
205 218
 				</div>
206 219
 			</div>';
207
-	}
208
-	else
209
-		echo '
220
+	} else {
221
+			echo '
210 222
 			<div class="cat_bar">
211 223
 				<h3 class="catbg centertext">
212 224
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
213 225
 				</h3>
214 226
 			</div>';
227
+	}
215 228
 
216
-	if ($context['showCheckboxes'])
217
-		echo '
229
+	if ($context['showCheckboxes']) {
230
+			echo '
218 231
 		</form>';
232
+	}
219 233
 
220 234
 	echo '
221 235
 	</div><!-- #recent -->';
222 236
 
223
-	if (empty($context['no_topic_listing']))
224
-		template_topic_legend();
225
-}
237
+	if (empty($context['no_topic_listing'])) {
238
+			template_topic_legend();
239
+	}
240
+	}
226 241
 
227 242
 /**
228 243
  * Template for showing unread replies (eg new replies to topics you've posted in)
@@ -234,12 +249,13 @@  discard block
 block discarded – undo
234 249
 	echo '
235 250
 	<div id="recent">';
236 251
 
237
-	if ($context['showCheckboxes'])
238
-		echo '
252
+	if ($context['showCheckboxes']) {
253
+			echo '
239 254
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
240 255
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
241 256
 			<input type="hidden" name="qaction" value="markread">
242 257
 			<input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';
258
+	}
243 259
 
244 260
 	if (!empty($context['topics']))
245 261
 	{
@@ -268,11 +284,12 @@  discard block
 block discarded – undo
268 284
 					</div>';
269 285
 
270 286
 		// Show a "select all" box for quick moderation?
271
-		if ($context['showCheckboxes'])
272
-			echo '
287
+		if ($context['showCheckboxes']) {
288
+					echo '
273 289
 					<div class="moderation">
274 290
 						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
275 291
 					</div>';
292
+		}
276 293
 
277 294
 		echo '
278 295
 				</div><!-- #topic_header -->
@@ -292,17 +309,20 @@  discard block
 block discarded – undo
292 309
 			echo '
293 310
 							<div class="icons floatright">';
294 311
 
295
-			if ($topic['is_locked'])
296
-				echo '
312
+			if ($topic['is_locked']) {
313
+							echo '
297 314
 								<span class="generic_icons lock"></span>';
315
+			}
298 316
 
299
-			if ($topic['is_sticky'])
300
-				echo '
317
+			if ($topic['is_sticky']) {
318
+							echo '
301 319
 								<span class="generic_icons sticky"></span>';
320
+			}
302 321
 
303
-			if ($topic['is_poll'])
304
-				echo '
322
+			if ($topic['is_poll']) {
323
+							echo '
305 324
 								<span class="generic_icons poll"></span>';
325
+			}
306 326
 
307 327
 			echo '
308 328
 							</div>';
@@ -328,11 +348,12 @@  discard block
 block discarded – undo
328 348
 							', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
329 349
 						</div>';
330 350
 
331
-			if ($context['showCheckboxes'])
332
-				echo '
351
+			if ($context['showCheckboxes']) {
352
+							echo '
333 353
 						<div class="moderation">
334 354
 							<input type="checkbox" name="topics[]" value="', $topic['id'], '">
335 355
 						</div>';
356
+			}
336 357
 
337 358
 			echo '
338 359
 					</div><!-- $topic[css_class] -->';
@@ -349,24 +370,26 @@  discard block
 block discarded – undo
349 370
 					', $context['page_index'], '
350 371
 				</div>
351 372
 			</div>';
352
-	}
353
-	else
354
-		echo '
373
+	} else {
374
+			echo '
355 375
 			<div class="cat_bar">
356 376
 				<h3 class="catbg centertext">
357 377
 					', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['updated_topics_visit_none'], '
358 378
 				</h3>
359 379
 			</div>';
380
+	}
360 381
 
361
-	if ($context['showCheckboxes'])
362
-		echo '
382
+	if ($context['showCheckboxes']) {
383
+			echo '
363 384
 		</form>';
385
+	}
364 386
 
365 387
 	echo '
366 388
 	</div><!-- #recent -->';
367 389
 
368
-	if (empty($context['no_topic_listing']))
369
-		template_topic_legend();
370
-}
390
+	if (empty($context['no_topic_listing'])) {
391
+			template_topic_legend();
392
+	}
393
+	}
371 394
 
372 395
 ?>
373 396
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	<div id="recent" class="main_section">
22 22
 		<div class="cat_bar">
23 23
 			<h3 class="catbg">
24
-				<span class="xx"></span>',$txt['recent_posts'],'
24
+				<span class="xx"></span>',$txt['recent_posts'], '
25 25
 			</h3>
26 26
 		</div>
27 27
 		<div class="pagesection">', $context['page_index'], '</div>';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 							<p class="floatleft">
165 165
 								', $topic['first_post']['started_by'], '
166 166
 							</p>
167
-							', !empty($topic['pages']) ? '<span id="pages'.$topic['first_post']['id'].'" class="topic_pages">'.$topic['pages'].'</span>' : '', '
167
+							', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="topic_pages">' . $topic['pages'] . '</span>' : '', '
168 168
 						</div><!-- .info -->
169 169
 						<div class="board_stats centertext">
170 170
 							<p>
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 							<p class="floatleft">
316 316
 								', $topic['first_post']['started_by'], '
317 317
 							</p>
318
-							', !empty($topic['pages']) ? '<span id="pages'.$topic['first_post']['id'].'" class="topic_pages">'.$topic['pages'].'</span>' : '', '
318
+							', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="topic_pages">' . $topic['pages'] . '</span>' : '', '
319 319
 						</div><!-- .info -->
320 320
 						<div class="board_stats centertext">
321 321
 							<p>
Please login to merge, or discard this patch.
Sources/Subs-Attachments.php 1 patch
Braces   +297 added lines, -224 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 4
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Check if the current directory is still valid or not.
@@ -28,22 +29,24 @@  discard block
 block discarded – undo
28 29
 	global $smcFunc, $boarddir, $modSettings, $context;
29 30
 
30 31
 	// Not pretty, but since we don't want folders created for every post. It'll do unless a better solution can be found.
31
-	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin')
32
-		$doit = true;
33
-	elseif (empty($modSettings['automanage_attachments']))
34
-		return;
35
-	elseif (!isset($_FILES))
36
-		return;
37
-	elseif (isset($_FILES['attachment']))
38
-		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
32
+	if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'admin') {
33
+			$doit = true;
34
+	} elseif (empty($modSettings['automanage_attachments'])) {
35
+			return;
36
+	} elseif (!isset($_FILES)) {
37
+			return;
38
+	} elseif (isset($_FILES['attachment'])) {
39
+			foreach ($_FILES['attachment']['tmp_name'] as $dummy)
39 40
 			if (!empty($dummy))
40 41
 			{
41 42
 				$doit = true;
43
+	}
42 44
 				break;
43 45
 			}
44 46
 
45
-	if (!isset($doit))
46
-		return;
47
+	if (!isset($doit)) {
48
+			return;
49
+	}
47 50
 
48 51
 	$year = date('Y');
49 52
 	$month = date('m');
@@ -54,21 +57,25 @@  discard block
 block discarded – undo
54 57
 
55 58
 	if (!empty($modSettings['attachment_basedirectories']) && !empty($modSettings['use_subdirectories_for_attachments']))
56 59
 	{
57
-			if (!is_array($modSettings['attachment_basedirectories']))
58
-				$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
60
+			if (!is_array($modSettings['attachment_basedirectories'])) {
61
+							$modSettings['attachment_basedirectories'] = $smcFunc['json_decode']($modSettings['attachment_basedirectories'], true);
62
+			}
59 63
 			$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
64
+	} else {
65
+			$base_dir = 0;
60 66
 	}
61
-	else
62
-		$base_dir = 0;
63 67
 
64 68
 	if ($modSettings['automanage_attachments'] == 1)
65 69
 	{
66
-		if (!isset($modSettings['last_attachments_directory']))
67
-			$modSettings['last_attachments_directory'] = array();
68
-		if (!is_array($modSettings['last_attachments_directory']))
69
-			$modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true);
70
-		if (!isset($modSettings['last_attachments_directory'][$base_dir]))
71
-			$modSettings['last_attachments_directory'][$base_dir] = 0;
70
+		if (!isset($modSettings['last_attachments_directory'])) {
71
+					$modSettings['last_attachments_directory'] = array();
72
+		}
73
+		if (!is_array($modSettings['last_attachments_directory'])) {
74
+					$modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true);
75
+		}
76
+		if (!isset($modSettings['last_attachments_directory'][$base_dir])) {
77
+					$modSettings['last_attachments_directory'][$base_dir] = 0;
78
+		}
72 79
 	}
73 80
 
74 81
 	$basedirectory = (!empty($modSettings['use_subdirectories_for_attachments']) ? ($modSettings['basedirectory_for_attachments']) : $boarddir);
@@ -97,12 +104,14 @@  discard block
 block discarded – undo
97 104
 			$updir = '';
98 105
 	}
99 106
 
100
-	if (!is_array($modSettings['attachmentUploadDir']))
101
-		$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
102
-	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir))
103
-		$outputCreation = automanage_attachments_create_directory($updir);
104
-	elseif (in_array($updir, $modSettings['attachmentUploadDir']))
105
-		$outputCreation = true;
107
+	if (!is_array($modSettings['attachmentUploadDir'])) {
108
+			$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
109
+	}
110
+	if (!in_array($updir, $modSettings['attachmentUploadDir']) && !empty($updir)) {
111
+			$outputCreation = automanage_attachments_create_directory($updir);
112
+	} elseif (in_array($updir, $modSettings['attachmentUploadDir'])) {
113
+			$outputCreation = true;
114
+	}
106 115
 
107 116
 	if ($outputCreation)
108 117
 	{
@@ -139,8 +148,9 @@  discard block
 block discarded – undo
139 148
 		$count = count($tree);
140 149
 
141 150
 		$directory = attachments_init_dir($tree, $count);
142
-		if ($directory === false)
143
-			return false;
151
+		if ($directory === false) {
152
+					return false;
153
+		}
144 154
 	}
145 155
 
146 156
 	$directory .= DIRECTORY_SEPARATOR . array_shift($tree);
@@ -168,8 +178,9 @@  discard block
 block discarded – undo
168 178
 	}
169 179
 
170 180
 	// Everything seems fine...let's create the .htaccess
171
-	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess'))
172
-		secureDirectory($updir, true);
181
+	if (!file_exists($directory . DIRECTORY_SEPARATOR . '.htaccess')) {
182
+			secureDirectory($updir, true);
183
+	}
173 184
 
174 185
 	$sep = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? '\/' : DIRECTORY_SEPARATOR;
175 186
 	$updir = rtrim($updir, $sep);
@@ -201,8 +212,9 @@  discard block
 block discarded – undo
201 212
 {
202 213
 	global $smcFunc, $modSettings, $boarddir;
203 214
 
204
-	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1))
205
-		return;
215
+	if (!isset($modSettings['automanage_attachments']) || (!empty($modSettings['automanage_attachments']) && $modSettings['automanage_attachments'] != 1)) {
216
+			return;
217
+	}
206 218
 
207 219
 	$basedirectory = !empty($modSettings['use_subdirectories_for_attachments']) ? $modSettings['basedirectory_for_attachments'] : $boarddir;
208 220
 	// Just to be sure: I don't want directory separators at the end
@@ -214,13 +226,14 @@  discard block
 block discarded – undo
214 226
 	{
215 227
 		$base_dir = array_search($modSettings['basedirectory_for_attachments'], $modSettings['attachment_basedirectories']);
216 228
 		$base_dir = !empty($modSettings['automanage_attachments']) ? $base_dir : 0;
229
+	} else {
230
+			$base_dir = 0;
217 231
 	}
218
-	else
219
-		$base_dir = 0;
220 232
 
221 233
 	// Get the last attachment directory for that base directory
222
-	if (empty($modSettings['last_attachments_directory'][$base_dir]))
223
-		$modSettings['last_attachments_directory'][$base_dir] = 0;
234
+	if (empty($modSettings['last_attachments_directory'][$base_dir])) {
235
+			$modSettings['last_attachments_directory'][$base_dir] = 0;
236
+	}
224 237
 	// And increment it.
225 238
 	$modSettings['last_attachments_directory'][$base_dir]++;
226 239
 
@@ -235,10 +248,10 @@  discard block
 block discarded – undo
235 248
 		$modSettings['last_attachments_directory'] = $smcFunc['json_decode']($modSettings['last_attachments_directory'], true);
236 249
 
237 250
 		return true;
251
+	} else {
252
+			return false;
253
+	}
238 254
 	}
239
-	else
240
-		return false;
241
-}
242 255
 
243 256
 /**
244 257
  * Split a path into a list of all directories and subdirectories
@@ -256,12 +269,13 @@  discard block
 block discarded – undo
256 269
 			* in Windows we need to explode for both \ and /
257 270
 			* while in linux should be safe to explode only for / (aka DIRECTORY_SEPARATOR)
258 271
 	*/
259
-	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
260
-		$tree = preg_split('#[\\\/]#', $directory);
261
-	else
272
+	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
273
+			$tree = preg_split('#[\\\/]#', $directory);
274
+	} else
262 275
 	{
263
-		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR)
264
-			return false;
276
+		if (substr($directory, 0, 1) != DIRECTORY_SEPARATOR) {
277
+					return false;
278
+		}
265 279
 
266 280
 		$tree = explode(DIRECTORY_SEPARATOR, trim($directory, DIRECTORY_SEPARATOR));
267 281
 	}
@@ -285,10 +299,11 @@  discard block
 block discarded – undo
285 299
 		 //Better be sure that the first part of the path is actually a drive letter...
286 300
 		 //...even if, I should check this in the admin page...isn't it?
287 301
 		 //...NHAAA Let's leave space for users' complains! :P
288
-		if (preg_match('/^[a-z]:$/i', $tree[0]))
289
-			$directory = array_shift($tree);
290
-		else
291
-			return false;
302
+		if (preg_match('/^[a-z]:$/i', $tree[0])) {
303
+					$directory = array_shift($tree);
304
+		} else {
305
+					return false;
306
+		}
292 307
 
293 308
 		$count--;
294 309
 	}
@@ -303,18 +318,20 @@  discard block
 block discarded – undo
303 318
 	global $context, $modSettings, $smcFunc, $txt, $user_info;
304 319
 
305 320
 	// Make sure we're uploading to the right place.
306
-	if (!empty($modSettings['automanage_attachments']))
307
-		automanage_attachments_check_directory();
321
+	if (!empty($modSettings['automanage_attachments'])) {
322
+			automanage_attachments_check_directory();
323
+	}
308 324
 
309
-	if (!is_array($modSettings['attachmentUploadDir']))
310
-		$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
325
+	if (!is_array($modSettings['attachmentUploadDir'])) {
326
+			$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
327
+	}
311 328
 
312 329
 	$context['attach_dir'] = $modSettings['attachmentUploadDir'][$modSettings['currentAttachmentUploadDir']];
313 330
 
314 331
 	// Is the attachments folder actualy there?
315
-	if (!empty($context['dir_creation_error']))
316
-		$initial_error = $context['dir_creation_error'];
317
-	elseif (!is_dir($context['attach_dir']))
332
+	if (!empty($context['dir_creation_error'])) {
333
+			$initial_error = $context['dir_creation_error'];
334
+	} elseif (!is_dir($context['attach_dir']))
318 335
 	{
319 336
 		$initial_error = 'attach_folder_warning';
320 337
 		log_error(sprintf($txt['attach_folder_admin_warning'], $context['attach_dir']), 'critical');
@@ -337,12 +354,12 @@  discard block
 block discarded – undo
337 354
 			);
338 355
 			list ($context['attachments']['quantity'], $context['attachments']['total_size']) = $smcFunc['db_fetch_row']($request);
339 356
 			$smcFunc['db_free_result']($request);
340
-		}
341
-		else
342
-			$context['attachments'] = array(
357
+		} else {
358
+					$context['attachments'] = array(
343 359
 				'quantity' => 0,
344 360
 				'total_size' => 0,
345 361
 			);
362
+		}
346 363
 	}
347 364
 
348 365
 	// Hmm. There are still files in session.
@@ -352,39 +369,44 @@  discard block
 block discarded – undo
352 369
 		// Let's try to keep them. But...
353 370
 		$ignore_temp = true;
354 371
 		// If new files are being added. We can't ignore those
355
-		foreach ($_FILES['attachment']['tmp_name'] as $dummy)
356
-			if (!empty($dummy))
372
+		foreach ($_FILES['attachment']['tmp_name'] as $dummy) {
373
+					if (!empty($dummy))
357 374
 			{
358 375
 				$ignore_temp = false;
376
+		}
359 377
 				break;
360 378
 			}
361 379
 
362 380
 		// Need to make space for the new files. So, bye bye.
363 381
 		if (!$ignore_temp)
364 382
 		{
365
-			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment)
366
-				if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
383
+			foreach ($_SESSION['temp_attachments'] as $attachID => $attachment) {
384
+							if (strpos($attachID, 'post_tmp_' . $user_info['id']) !== false)
367 385
 					unlink($attachment['tmp_name']);
386
+			}
368 387
 
369 388
 			$context['we_are_history'] = $txt['error_temp_attachments_flushed'];
370 389
 			$_SESSION['temp_attachments'] = array();
371 390
 		}
372 391
 	}
373 392
 
374
-	if (!isset($_FILES['attachment']['name']))
375
-		$_FILES['attachment']['tmp_name'] = array();
393
+	if (!isset($_FILES['attachment']['name'])) {
394
+			$_FILES['attachment']['tmp_name'] = array();
395
+	}
376 396
 
377
-	if (!isset($_SESSION['temp_attachments']))
378
-		$_SESSION['temp_attachments'] = array();
397
+	if (!isset($_SESSION['temp_attachments'])) {
398
+			$_SESSION['temp_attachments'] = array();
399
+	}
379 400
 
380 401
 	// Remember where we are at. If it's anywhere at all.
381
-	if (!$ignore_temp)
382
-		$_SESSION['temp_attachments']['post'] = array(
402
+	if (!$ignore_temp) {
403
+			$_SESSION['temp_attachments']['post'] = array(
383 404
 			'msg' => !empty($_REQUEST['msg']) ? $_REQUEST['msg'] : 0,
384 405
 			'last_msg' => !empty($_REQUEST['last_msg']) ? $_REQUEST['last_msg'] : 0,
385 406
 			'topic' => !empty($topic) ? $topic : 0,
386 407
 			'board' => !empty($board) ? $board : 0,
387 408
 		);
409
+	}
388 410
 
389 411
 	// If we have an initial error, lets just display it.
390 412
 	if (!empty($initial_error))
@@ -392,9 +414,10 @@  discard block
 block discarded – undo
392 414
 		$_SESSION['temp_attachments']['initial_error'] = $initial_error;
393 415
 
394 416
 		// And delete the files 'cos they ain't going nowhere.
395
-		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
396
-			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
417
+		foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy) {
418
+					if (file_exists($_FILES['attachment']['tmp_name'][$n]))
397 419
 				unlink($_FILES['attachment']['tmp_name'][$n]);
420
+		}
398 421
 
399 422
 		$_FILES['attachment']['tmp_name'] = array();
400 423
 	}
@@ -402,21 +425,24 @@  discard block
 block discarded – undo
402 425
 	// Loop through $_FILES['attachment'] array and move each file to the current attachments folder.
403 426
 	foreach ($_FILES['attachment']['tmp_name'] as $n => $dummy)
404 427
 	{
405
-		if ($_FILES['attachment']['name'][$n] == '')
406
-			continue;
428
+		if ($_FILES['attachment']['name'][$n] == '') {
429
+					continue;
430
+		}
407 431
 
408 432
 		// First, let's first check for PHP upload errors.
409 433
 		$errors = array();
410 434
 		if (!empty($_FILES['attachment']['error'][$n]))
411 435
 		{
412
-			if ($_FILES['attachment']['error'][$n] == 2)
413
-				$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
414
-			elseif ($_FILES['attachment']['error'][$n] == 6)
415
-				log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
416
-			else
417
-				log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
418
-			if (empty($errors))
419
-				$errors[] = 'attach_php_error';
436
+			if ($_FILES['attachment']['error'][$n] == 2) {
437
+							$errors[] = array('file_too_big', array($modSettings['attachmentSizeLimit']));
438
+			} elseif ($_FILES['attachment']['error'][$n] == 6) {
439
+							log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_6'], 'critical');
440
+			} else {
441
+							log_error($_FILES['attachment']['name'][$n] . ': ' . $txt['php_upload_error_' . $_FILES['attachment']['error'][$n]]);
442
+			}
443
+			if (empty($errors)) {
444
+							$errors[] = 'attach_php_error';
445
+			}
420 446
 		}
421 447
 
422 448
 		// Try to move and rename the file before doing any more checks on it.
@@ -426,8 +452,9 @@  discard block
 block discarded – undo
426 452
 		{
427 453
 			// The reported MIME type of the attachment might not be reliable.
428 454
 			// Fortunately, PHP 5.3+ lets us easily verify the real MIME type.
429
-			if (function_exists('mime_content_type'))
430
-				$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
455
+			if (function_exists('mime_content_type')) {
456
+							$_FILES['attachment']['type'][$n] = mime_content_type($_FILES['attachment']['tmp_name'][$n]);
457
+			}
431 458
 
432 459
 			$_SESSION['temp_attachments'][$attachID] = array(
433 460
 				'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -439,16 +466,16 @@  discard block
 block discarded – undo
439 466
 			);
440 467
 
441 468
 			// Move the file to the attachments folder with a temp name for now.
442
-			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName))
443
-				smf_chmod($destName, 0644);
444
-			else
469
+			if (@move_uploaded_file($_FILES['attachment']['tmp_name'][$n], $destName)) {
470
+							smf_chmod($destName, 0644);
471
+			} else
445 472
 			{
446 473
 				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'attach_timeout';
447
-				if (file_exists($_FILES['attachment']['tmp_name'][$n]))
448
-					unlink($_FILES['attachment']['tmp_name'][$n]);
474
+				if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
475
+									unlink($_FILES['attachment']['tmp_name'][$n]);
476
+				}
449 477
 			}
450
-		}
451
-		else
478
+		} else
452 479
 		{
453 480
 			$_SESSION['temp_attachments'][$attachID] = array(
454 481
 				'name' => $smcFunc['htmlspecialchars'](basename($_FILES['attachment']['name'][$n])),
@@ -456,12 +483,14 @@  discard block
 block discarded – undo
456 483
 				'errors' => $errors,
457 484
 			);
458 485
 
459
-			if (file_exists($_FILES['attachment']['tmp_name'][$n]))
460
-				unlink($_FILES['attachment']['tmp_name'][$n]);
486
+			if (file_exists($_FILES['attachment']['tmp_name'][$n])) {
487
+							unlink($_FILES['attachment']['tmp_name'][$n]);
488
+			}
461 489
 		}
462 490
 		// If there's no errors to this point. We still do need to apply some additional checks before we are finished.
463
-		if (empty($_SESSION['temp_attachments'][$attachID]['errors']))
464
-			attachmentChecks($attachID);
491
+		if (empty($_SESSION['temp_attachments'][$attachID]['errors'])) {
492
+					attachmentChecks($attachID);
493
+		}
465 494
 	}
466 495
 	// Mod authors, finally a hook to hang an alternate attachment upload system upon
467 496
 	// Upload to the current attachment folder with the file name $attachID or 'post_tmp_' . $user_info['id'] . '_' . md5(mt_rand())
@@ -488,21 +517,20 @@  discard block
 block discarded – undo
488 517
 	global $modSettings, $context, $sourcedir, $smcFunc;
489 518
 
490 519
 	// No data or missing data .... Not necessarily needed, but in case a mod author missed something.
491
-	if (empty($_SESSION['temp_attachments'][$attachID]))
492
-		$error = '$_SESSION[\'temp_attachments\'][$attachID]';
493
-
494
-	elseif (empty($attachID))
495
-		$error = '$attachID';
496
-
497
-	elseif (empty($context['attachments']))
498
-		$error = '$context[\'attachments\']';
499
-
500
-	elseif (empty($context['attach_dir']))
501
-		$error = '$context[\'attach_dir\']';
520
+	if (empty($_SESSION['temp_attachments'][$attachID])) {
521
+			$error = '$_SESSION[\'temp_attachments\'][$attachID]';
522
+	} elseif (empty($attachID)) {
523
+			$error = '$attachID';
524
+	} elseif (empty($context['attachments'])) {
525
+			$error = '$context[\'attachments\']';
526
+	} elseif (empty($context['attach_dir'])) {
527
+			$error = '$context[\'attach_dir\']';
528
+	}
502 529
 
503 530
 	// Let's get their attention.
504
-	if (!empty($error))
505
-		fatal_lang_error('attach_check_nag', 'debug', array($error));
531
+	if (!empty($error)) {
532
+			fatal_lang_error('attach_check_nag', 'debug', array($error));
533
+	}
506 534
 
507 535
 	// Just in case this slipped by the first checks, we stop it here and now
508 536
 	if ($_SESSION['temp_attachments'][$attachID]['size'] == 0)
@@ -531,8 +559,9 @@  discard block
 block discarded – undo
531 559
 			$size = @getimagesize($_SESSION['temp_attachments'][$attachID]['tmp_name']);
532 560
 			if (!(empty($size)) && ($size[2] != $old_format))
533 561
 			{
534
-				if (isset($context['valid_image_types'][$size[2]]))
535
-					$_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]];
562
+				if (isset($context['valid_image_types'][$size[2]])) {
563
+									$_SESSION['temp_attachments'][$attachID]['type'] = 'image/' . $context['valid_image_types'][$size[2]];
564
+				}
536 565
 			}
537 566
 		}
538 567
 	}
@@ -586,42 +615,48 @@  discard block
 block discarded – undo
586 615
 				// Or, let the user know that it ain't gonna happen.
587 616
 				else
588 617
 				{
589
-					if (isset($context['dir_creation_error']))
590
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
591
-					else
592
-						$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
618
+					if (isset($context['dir_creation_error'])) {
619
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = $context['dir_creation_error'];
620
+					} else {
621
+											$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
622
+					}
593 623
 				}
624
+			} else {
625
+							$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
594 626
 			}
595
-			else
596
-				$_SESSION['temp_attachments'][$attachID]['errors'][] = 'ran_out_of_space';
597 627
 		}
598 628
 	}
599 629
 
600 630
 	// Is the file too big?
601 631
 	$context['attachments']['total_size'] += $_SESSION['temp_attachments'][$attachID]['size'];
602
-	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024)
603
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
632
+	if (!empty($modSettings['attachmentSizeLimit']) && $_SESSION['temp_attachments'][$attachID]['size'] > $modSettings['attachmentSizeLimit'] * 1024) {
633
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('file_too_big', array(comma_format($modSettings['attachmentSizeLimit'], 0)));
634
+	}
604 635
 
605 636
 	// Check the total upload size for this post...
606
-	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024)
607
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
637
+	if (!empty($modSettings['attachmentPostLimit']) && $context['attachments']['total_size'] > $modSettings['attachmentPostLimit'] * 1024) {
638
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attach_max_total_file_size', array(comma_format($modSettings['attachmentPostLimit'], 0), comma_format($modSettings['attachmentPostLimit'] - (($context['attachments']['total_size'] - $_SESSION['temp_attachments'][$attachID]['size']) / 1024), 0)));
639
+	}
608 640
 
609 641
 	// Have we reached the maximum number of files we are allowed?
610 642
 	$context['attachments']['quantity']++;
611 643
 
612 644
 	// Set a max limit if none exists
613
-	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50)
614
-		$modSettings['attachmentNumPerPostLimit'] = 50;
645
+	if (empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] >= 50) {
646
+			$modSettings['attachmentNumPerPostLimit'] = 50;
647
+	}
615 648
 
616
-	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit'])
617
-		$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
649
+	if (!empty($modSettings['attachmentNumPerPostLimit']) && $context['attachments']['quantity'] > $modSettings['attachmentNumPerPostLimit']) {
650
+			$_SESSION['temp_attachments'][$attachID]['errors'][] = array('attachments_limit_per_post', array($modSettings['attachmentNumPerPostLimit']));
651
+	}
618 652
 
619 653
 	// File extension check
620 654
 	if (!empty($modSettings['attachmentCheckExtensions']))
621 655
 	{
622 656
 		$allowed = explode(',', strtolower($modSettings['attachmentExtensions']));
623
-		foreach ($allowed as $k => $dummy)
624
-			$allowed[$k] = trim($dummy);
657
+		foreach ($allowed as $k => $dummy) {
658
+					$allowed[$k] = trim($dummy);
659
+		}
625 660
 
626 661
 		if (!in_array(strtolower(substr(strrchr($_SESSION['temp_attachments'][$attachID]['name'], '.'), 1)), $allowed))
627 662
 		{
@@ -633,10 +668,12 @@  discard block
 block discarded – undo
633 668
 	// Undo the math if there's an error
634 669
 	if (!empty($_SESSION['temp_attachments'][$attachID]['errors']))
635 670
 	{
636
-		if (isset($context['dir_size']))
637
-			$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
638
-		if (isset($context['dir_files']))
639
-			$context['dir_files']--;
671
+		if (isset($context['dir_size'])) {
672
+					$context['dir_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
673
+		}
674
+		if (isset($context['dir_files'])) {
675
+					$context['dir_files']--;
676
+		}
640 677
 		$context['attachments']['total_size'] -= $_SESSION['temp_attachments'][$attachID]['size'];
641 678
 		$context['attachments']['quantity']--;
642 679
 		return false;
@@ -668,12 +705,14 @@  discard block
 block discarded – undo
668 705
 	if (empty($attachmentOptions['mime_type']) && $attachmentOptions['width'])
669 706
 	{
670 707
 		// Got a proper mime type?
671
-		if (!empty($size['mime']))
672
-			$attachmentOptions['mime_type'] = $size['mime'];
708
+		if (!empty($size['mime'])) {
709
+					$attachmentOptions['mime_type'] = $size['mime'];
710
+		}
673 711
 
674 712
 		// Otherwise a valid one?
675
-		elseif (isset($context['valid_image_types'][$size[2]]))
676
-			$attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]];
713
+		elseif (isset($context['valid_image_types'][$size[2]])) {
714
+					$attachmentOptions['mime_type'] = 'image/' . $context['valid_image_types'][$size[2]];
715
+		}
677 716
 	}
678 717
 
679 718
 	// It is possible we might have a MIME type that isn't actually an image but still have a size.
@@ -685,15 +724,17 @@  discard block
 block discarded – undo
685 724
 	}
686 725
 
687 726
 	// Get the hash if no hash has been given yet.
688
-	if (empty($attachmentOptions['file_hash']))
689
-		$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);
727
+	if (empty($attachmentOptions['file_hash'])) {
728
+			$attachmentOptions['file_hash'] = getAttachmentFilename($attachmentOptions['name'], false, null, true);
729
+	}
690 730
 
691 731
 	// Assuming no-one set the extension let's take a look at it.
692 732
 	if (empty($attachmentOptions['fileext']))
693 733
 	{
694 734
 		$attachmentOptions['fileext'] = strtolower(strrpos($attachmentOptions['name'], '.') !== false ? substr($attachmentOptions['name'], strrpos($attachmentOptions['name'], '.') + 1) : '');
695
-		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name'])
696
-			$attachmentOptions['fileext'] = '';
735
+		if (strlen($attachmentOptions['fileext']) > 8 || '.' . $attachmentOptions['fileext'] == $attachmentOptions['name']) {
736
+					$attachmentOptions['fileext'] = '';
737
+		}
697 738
 	}
698 739
 
699 740
 	// Last chance to change stuff!
@@ -702,8 +743,9 @@  discard block
 block discarded – undo
702 743
 	// Make sure the folder is valid...
703 744
 	$tmp = is_array($modSettings['attachmentUploadDir']) ? $modSettings['attachmentUploadDir'] : $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
704 745
 	$folders = array_keys($tmp);
705
-	if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders))
706
-		$attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir'];
746
+	if (empty($attachmentOptions['id_folder']) || !in_array($attachmentOptions['id_folder'], $folders)) {
747
+			$attachmentOptions['id_folder'] = $modSettings['currentAttachmentUploadDir'];
748
+	}
707 749
 
708 750
 	$attachmentOptions['id'] = $smcFunc['db_insert']('',
709 751
 		'{db_prefix}attachments',
@@ -734,8 +776,8 @@  discard block
 block discarded – undo
734 776
 	rename($attachmentOptions['tmp_name'], $attachmentOptions['destination']);
735 777
 
736 778
 	// If it's not approved then add to the approval queue.
737
-	if (!$attachmentOptions['approved'])
738
-		$smcFunc['db_insert']('',
779
+	if (!$attachmentOptions['approved']) {
780
+			$smcFunc['db_insert']('',
739 781
 			'{db_prefix}approval_queue',
740 782
 			array(
741 783
 				'id_attach' => 'int', 'id_msg' => 'int',
@@ -745,9 +787,11 @@  discard block
 block discarded – undo
745 787
 			),
746 788
 			array()
747 789
 		);
790
+	}
748 791
 
749
-	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height'])))
750
-		return true;
792
+	if (empty($modSettings['attachmentThumbnails']) || (empty($attachmentOptions['width']) && empty($attachmentOptions['height']))) {
793
+			return true;
794
+	}
751 795
 
752 796
 	// Like thumbnails, do we?
753 797
 	if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && ($attachmentOptions['width'] > $modSettings['attachmentThumbWidth'] || $attachmentOptions['height'] > $modSettings['attachmentThumbHeight']))
@@ -758,13 +802,15 @@  discard block
 block discarded – undo
758 802
 			$size = @getimagesize($attachmentOptions['destination'] . '_thumb');
759 803
 			list ($thumb_width, $thumb_height) = $size;
760 804
 
761
-			if (!empty($size['mime']))
762
-				$thumb_mime = $size['mime'];
763
-			elseif (isset($context['valid_image_types'][$size[2]]))
764
-				$thumb_mime = 'image/' . $context['valid_image_types'][$size[2]];
805
+			if (!empty($size['mime'])) {
806
+							$thumb_mime = $size['mime'];
807
+			} elseif (isset($context['valid_image_types'][$size[2]])) {
808
+							$thumb_mime = 'image/' . $context['valid_image_types'][$size[2]];
809
+			}
765 810
 			// Lord only knows how this happened...
766
-			else
767
-				$thumb_mime = '';
811
+			else {
812
+							$thumb_mime = '';
813
+			}
768 814
 
769 815
 			$thumb_filename = $attachmentOptions['name'] . '_thumb';
770 816
 			$thumb_size = filesize($attachmentOptions['destination'] . '_thumb');
@@ -844,15 +890,17 @@  discard block
 block discarded – undo
844 890
 	global $smcFunc;
845 891
 
846 892
 	// Oh, come on!
847
-	if (empty($attachIDs) || empty($msgID))
848
-		return false;
893
+	if (empty($attachIDs) || empty($msgID)) {
894
+			return false;
895
+	}
849 896
 
850 897
 	// "I see what is right and approve, but I do what is wrong."
851 898
 	call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID));
852 899
 
853 900
 	// One last check
854
-	if (empty($attachIDs))
855
-		return false;
901
+	if (empty($attachIDs)) {
902
+			return false;
903
+	}
856 904
 
857 905
 	// Perform.
858 906
 	$smcFunc['db_query']('', '
@@ -880,8 +928,9 @@  discard block
 block discarded – undo
880 928
 	global $board, $modSettings, $context, $scripturl, $smcFunc;
881 929
 
882 930
 	// Meh...
883
-	if (empty($attachID))
884
-		return 'attachments_no_data_loaded';
931
+	if (empty($attachID)) {
932
+			return 'attachments_no_data_loaded';
933
+	}
885 934
 
886 935
 	// Make it easy.
887 936
 	$msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0;
@@ -890,20 +939,23 @@  discard block
 block discarded – undo
890 939
 	$externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID));
891 940
 
892 941
 	// "I am innocent of the blood of this just person: see ye to it."
893
-	if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse)))
894
-		return $externalParse;
942
+	if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) {
943
+			return $externalParse;
944
+	}
895 945
 
896 946
 	//Are attachments enable?
897
-	if (empty($modSettings['attachmentEnable']))
898
-		return 'attachments_not_enable';
947
+	if (empty($modSettings['attachmentEnable'])) {
948
+			return 'attachments_not_enable';
949
+	}
899 950
 
900 951
 	// Previewing much? no msg ID has been set yet.
901 952
 	if (!empty($context['preview_message']))
902 953
 	{
903 954
 		$allAttachments = getAttachsByMsg(0);
904 955
 
905
-		if (empty($allAttachments[0][$attachID]))
906
-			return 'attachments_no_data_loaded';
956
+		if (empty($allAttachments[0][$attachID])) {
957
+					return 'attachments_no_data_loaded';
958
+		}
907 959
 
908 960
 		$attachLoaded = loadAttachmentContext(0, $allAttachments);
909 961
 
@@ -915,57 +967,66 @@  discard block
 block discarded – undo
915 967
 		$attachContext['link'] = '<a href="' . $scripturl . '?action=dlattach;attach=' . $attachID . ';type=preview' . (empty($attachContext['is_image']) ? ';file' : '') . '">' . $smcFunc['htmlspecialchars']($attachContext['name']) . '</a>';
916 968
 
917 969
 		// Fix the thumbnail too, if the image has one.
918
-		if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb']))
919
-			$attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview';
970
+		if (!empty($attachContext['thumbnail']) && !empty($attachContext['thumbnail']['has_thumb'])) {
971
+					$attachContext['thumbnail']['href'] = $scripturl . '?action=dlattach;attach=' . $attachContext['thumbnail']['id'] . ';image;type=preview';
972
+		}
920 973
 
921 974
 		return $attachContext;
922 975
 	}
923 976
 
924 977
 	// There is always the chance someone else has already done our dirty work...
925 978
 	// If so, all pertinent checks were already done. Hopefully...
926
-	if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID]))
927
-		return $context['current_attachments'][$attachID];
979
+	if (!empty($context['current_attachments']) && !empty($context['current_attachments'][$attachID])) {
980
+			return $context['current_attachments'][$attachID];
981
+	}
928 982
 
929 983
 	// If we are lucky enough to be in $board's scope then check it!
930
-	if (!empty($board) && !allowedTo('view_attachments', $board))
931
-		return 'attachments_not_allowed_to_see';
984
+	if (!empty($board) && !allowedTo('view_attachments', $board)) {
985
+			return 'attachments_not_allowed_to_see';
986
+	}
932 987
 
933 988
 	// Get the message info associated with this particular attach ID.
934 989
 	$attachInfo = getAttachMsgInfo($attachID);
935 990
 
936 991
 	// There is always the chance this attachment no longer exists or isn't associated to a message anymore...
937
-	if (empty($attachInfo) || empty($attachInfo['msg']))
938
-		return 'attachments_no_msg_associated';
992
+	if (empty($attachInfo) || empty($attachInfo['msg'])) {
993
+			return 'attachments_no_msg_associated';
994
+	}
939 995
 
940 996
 	// Hold it! got the info now check if you can see this attachment.
941
-	if (!allowedTo('view_attachments', $attachInfo['board']))
942
-		return 'attachments_not_allowed_to_see';
997
+	if (!allowedTo('view_attachments', $attachInfo['board'])) {
998
+			return 'attachments_not_allowed_to_see';
999
+	}
943 1000
 
944 1001
 	$allAttachments = getAttachsByMsg($attachInfo['msg']);
945 1002
 	$attachContext = $allAttachments[$attachInfo['msg']][$attachID];
946 1003
 
947 1004
 	// No point in keep going further.
948
-	if (!allowedTo('view_attachments', $attachContext['board']))
949
-		return 'attachments_not_allowed_to_see';
1005
+	if (!allowedTo('view_attachments', $attachContext['board'])) {
1006
+			return 'attachments_not_allowed_to_see';
1007
+	}
950 1008
 
951 1009
 	// Load this particular attach's context.
952
-	if (!empty($attachContext))
953
-		$attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments);
1010
+	if (!empty($attachContext)) {
1011
+			$attachLoaded = loadAttachmentContext($attachContext['id_msg'], $allAttachments);
1012
+	}
954 1013
 
955 1014
 	// One last check, you know, gotta be paranoid...
956
-	else
957
-		return 'attachments_no_data_loaded';
1015
+	else {
1016
+			return 'attachments_no_data_loaded';
1017
+	}
958 1018
 
959 1019
 	// This is the last "if" I promise!
960
-	if (empty($attachLoaded))
961
-		return 'attachments_no_data_loaded';
962
-
963
-	else
964
-		$attachContext = $attachLoaded[$attachID];
1020
+	if (empty($attachLoaded)) {
1021
+			return 'attachments_no_data_loaded';
1022
+	} else {
1023
+			$attachContext = $attachLoaded[$attachID];
1024
+	}
965 1025
 
966 1026
 	// You may or may not want to show this under the post.
967
-	if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID]))
968
-		$context['show_attach_under_post'][$attachID] = $attachID;
1027
+	if (!empty($modSettings['dont_show_attach_under_post']) && !isset($context['show_attach_under_post'][$attachID])) {
1028
+			$context['show_attach_under_post'][$attachID] = $attachID;
1029
+	}
969 1030
 
970 1031
 	// Last minute changes?
971 1032
 	call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext));
@@ -985,8 +1046,9 @@  discard block
 block discarded – undo
985 1046
 {
986 1047
 	global $smcFunc, $modSettings;
987 1048
 
988
-	if (empty($attachIDs))
989
-		return array();
1049
+	if (empty($attachIDs)) {
1050
+			return array();
1051
+	}
990 1052
 
991 1053
 	$return = array();
992 1054
 
@@ -1002,11 +1064,12 @@  discard block
 block discarded – undo
1002 1064
 		)
1003 1065
 	);
1004 1066
 
1005
-	if ($smcFunc['db_num_rows']($request) != 1)
1006
-		return array();
1067
+	if ($smcFunc['db_num_rows']($request) != 1) {
1068
+			return array();
1069
+	}
1007 1070
 
1008
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1009
-		$return[$row['id_attach']] = array(
1071
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1072
+			$return[$row['id_attach']] = array(
1010 1073
 			'name' => $smcFunc['htmlspecialchars']($row['filename']),
1011 1074
 			'size' => $row['size'],
1012 1075
 			'attachID' => $row['id_attach'],
@@ -1015,6 +1078,7 @@  discard block
 block discarded – undo
1015 1078
 			'mime_type' => $row['mime_type'],
1016 1079
 			'thumb' => $row['id_thumb'],
1017 1080
 		);
1081
+	}
1018 1082
 	$smcFunc['db_free_result']($request);
1019 1083
 
1020 1084
 	return $return;
@@ -1031,8 +1095,9 @@  discard block
 block discarded – undo
1031 1095
 {
1032 1096
 	global $smcFunc;
1033 1097
 
1034
-	if (empty($attachID))
1035
-		return array();
1098
+	if (empty($attachID)) {
1099
+			return array();
1100
+	}
1036 1101
 
1037 1102
 	$request = $smcFunc['db_query']('', '
1038 1103
 		SELECT a.id_msg AS msg, m.id_topic AS topic, m.id_board AS board
@@ -1045,8 +1110,9 @@  discard block
 block discarded – undo
1045 1110
 		)
1046 1111
 	);
1047 1112
 
1048
-	if ($smcFunc['db_num_rows']($request) != 1)
1049
-		return array();
1113
+	if ($smcFunc['db_num_rows']($request) != 1) {
1114
+			return array();
1115
+	}
1050 1116
 
1051 1117
 	$row = $smcFunc['db_fetch_assoc']($request);
1052 1118
 	$smcFunc['db_free_result']($request);
@@ -1087,8 +1153,9 @@  discard block
 block discarded – undo
1087 1153
 		$temp = array();
1088 1154
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1089 1155
 		{
1090
-			if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1091
-				continue;
1156
+			if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1157
+							continue;
1158
+			}
1092 1159
 
1093 1160
 			$temp[$row['id_attach']] = $row;
1094 1161
 		}
@@ -1117,8 +1184,9 @@  discard block
 block discarded – undo
1117 1184
 {
1118 1185
 	global $modSettings, $txt, $scripturl, $sourcedir, $smcFunc;
1119 1186
 
1120
-	if (empty($attachments) || empty($attachments[$id_msg]))
1121
-		return array();
1187
+	if (empty($attachments) || empty($attachments[$id_msg])) {
1188
+			return array();
1189
+	}
1122 1190
 
1123 1191
 	// Set up the attachment info - based on code by Meriadoc.
1124 1192
 	$attachmentData = array();
@@ -1142,11 +1210,13 @@  discard block
 block discarded – undo
1142 1210
 			);
1143 1211
 
1144 1212
 			// If something is unapproved we'll note it so we can sort them.
1145
-			if (!$attachment['approved'])
1146
-				$have_unapproved = true;
1213
+			if (!$attachment['approved']) {
1214
+							$have_unapproved = true;
1215
+			}
1147 1216
 
1148
-			if (!$attachmentData[$i]['is_image'])
1149
-				continue;
1217
+			if (!$attachmentData[$i]['is_image']) {
1218
+							continue;
1219
+			}
1150 1220
 
1151 1221
 			$attachmentData[$i]['real_width'] = $attachment['width'];
1152 1222
 			$attachmentData[$i]['width'] = $attachment['width'];
@@ -1167,11 +1237,11 @@  discard block
 block discarded – undo
1167 1237
 						// So what folder are we putting this image in?
1168 1238
 						if (!empty($modSettings['currentAttachmentUploadDir']))
1169 1239
 						{
1170
-							if (!is_array($modSettings['attachmentUploadDir']))
1171
-								$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1240
+							if (!is_array($modSettings['attachmentUploadDir'])) {
1241
+															$modSettings['attachmentUploadDir'] = $smcFunc['json_decode']($modSettings['attachmentUploadDir'], true);
1242
+							}
1172 1243
 							$id_folder_thumb = $modSettings['currentAttachmentUploadDir'];
1173
-						}
1174
-						else
1244
+						} else
1175 1245
 						{
1176 1246
 							$id_folder_thumb = 1;
1177 1247
 						}
@@ -1185,10 +1255,11 @@  discard block
 block discarded – undo
1185 1255
 						$thumb_ext = isset($context['valid_image_types'][$size[2]]) ? $context['valid_image_types'][$size[2]] : '';
1186 1256
 
1187 1257
 						// Figure out the mime type.
1188
-						if (!empty($size['mime']))
1189
-							$thumb_mime = $size['mime'];
1190
-						else
1191
-							$thumb_mime = 'image/' . $thumb_ext;
1258
+						if (!empty($size['mime'])) {
1259
+													$thumb_mime = $size['mime'];
1260
+						} else {
1261
+													$thumb_mime = 'image/' . $thumb_ext;
1262
+						}
1192 1263
 
1193 1264
 						$thumb_filename = $attachment['filename'] . '_thumb';
1194 1265
 						$thumb_hash = getAttachmentFilename($thumb_filename, false, null, true);
@@ -1236,11 +1307,12 @@  discard block
 block discarded – undo
1236 1307
 				}
1237 1308
 			}
1238 1309
 
1239
-			if (!empty($attachment['id_thumb']))
1240
-				$attachmentData[$i]['thumbnail'] = array(
1310
+			if (!empty($attachment['id_thumb'])) {
1311
+							$attachmentData[$i]['thumbnail'] = array(
1241 1312
 					'id' => $attachment['id_thumb'],
1242 1313
 					'href' => $scripturl . '?action=dlattach;topic=' . $attachment['topic'] . '.0;attach=' . $attachment['id_thumb'] . ';image',
1243 1314
 				);
1315
+			}
1244 1316
 			$attachmentData[$i]['thumbnail']['has_thumb'] = !empty($attachment['id_thumb']);
1245 1317
 
1246 1318
 			// If thumbnails are disabled, check the maximum size of the image.
@@ -1250,30 +1322,31 @@  discard block
 block discarded – undo
1250 1322
 				{
1251 1323
 					$attachmentData[$i]['width'] = $modSettings['max_image_width'];
1252 1324
 					$attachmentData[$i]['height'] = floor($attachment['height'] * $modSettings['max_image_width'] / $attachment['width']);
1253
-				}
1254
-				elseif (!empty($modSettings['max_image_width']))
1325
+				} elseif (!empty($modSettings['max_image_width']))
1255 1326
 				{
1256 1327
 					$attachmentData[$i]['width'] = floor($attachment['width'] * $modSettings['max_image_height'] / $attachment['height']);
1257 1328
 					$attachmentData[$i]['height'] = $modSettings['max_image_height'];
1258 1329
 				}
1259
-			}
1260
-			elseif ($attachmentData[$i]['thumbnail']['has_thumb'])
1330
+			} elseif ($attachmentData[$i]['thumbnail']['has_thumb'])
1261 1331
 			{
1262 1332
 				// If the image is too large to show inline, make it a popup.
1263
-				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height'])))
1264
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
1265
-				else
1266
-					$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
1333
+				if (((!empty($modSettings['max_image_width']) && $attachmentData[$i]['real_width'] > $modSettings['max_image_width']) || (!empty($modSettings['max_image_height']) && $attachmentData[$i]['real_height'] > $modSettings['max_image_height']))) {
1334
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return reqWin(\'' . $attachmentData[$i]['href'] . ';image\', ' . ($attachment['width'] + 20) . ', ' . ($attachment['height'] + 20) . ', true);';
1335
+				} else {
1336
+									$attachmentData[$i]['thumbnail']['javascript'] = 'return expandThumb(' . $attachment['id_attach'] . ');';
1337
+				}
1267 1338
 			}
1268 1339
 
1269
-			if (!$attachmentData[$i]['thumbnail']['has_thumb'])
1270
-				$attachmentData[$i]['downloads']++;
1340
+			if (!$attachmentData[$i]['thumbnail']['has_thumb']) {
1341
+							$attachmentData[$i]['downloads']++;
1342
+			}
1271 1343
 		}
1272 1344
 	}
1273 1345
 
1274 1346
 	// Do we need to instigate a sort?
1275
-	if ($have_unapproved)
1276
-		usort($attachmentData, 'approved_attach_sort');
1347
+	if ($have_unapproved) {
1348
+			usort($attachmentData, 'approved_attach_sort');
1349
+	}
1277 1350
 
1278 1351
 	return $attachmentData;
1279 1352
 }
Please login to merge, or discard this patch.
Themes/default/Search.template.php 1 patch
Braces   +75 added lines, -55 removed lines patch added patch discarded remove patch
@@ -20,17 +20,19 @@  discard block
 block discarded – undo
20 20
 	echo '
21 21
 	<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">';
22 22
 
23
-	if (!empty($context['search_errors']))
24
-		echo '
23
+	if (!empty($context['search_errors'])) {
24
+			echo '
25 25
 		<div class="errorbox">
26 26
 			', implode('<br>', $context['search_errors']['messages']), '
27 27
 		</div>';
28
+	}
28 29
 
29
-	if (!empty($context['search_ignored']))
30
-		echo '
30
+	if (!empty($context['search_ignored'])) {
31
+			echo '
31 32
 		<div class="noticebox">
32 33
 			', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
33 34
 		</div>';
35
+	}
34 36
 
35 37
 	echo '
36 38
 		<div class="cat_bar">
@@ -48,9 +50,10 @@  discard block
 block discarded – undo
48 50
 				<dd>
49 51
 					<input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">';
50 52
 
51
-	if (empty($modSettings['search_simple_fulltext']))
52
-		echo '
53
+	if (empty($modSettings['search_simple_fulltext'])) {
54
+			echo '
53 55
 					<br><em class="smalltext">', $txt['search_example'], '</em>';
56
+	}
54 57
 
55 58
 	echo '
56 59
 				</dd>
@@ -114,21 +117,23 @@  discard block
 block discarded – undo
114 117
 			<input type="hidden" name="advanced" value="1">';
115 118
 
116 119
 	// Require an image to be typed to save spamming?
117
-	if ($context['require_verification'])
118
-		echo '
120
+	if ($context['require_verification']) {
121
+			echo '
119 122
 			<p>
120 123
 				<strong>', $txt['verification'], ':</strong>
121 124
 				', template_control_verification($context['visual_verification_id'], 'all'), '
122 125
 			</p>';
126
+	}
123 127
 
124 128
 	// If $context['search_params']['topic'] is set, that means we're searching just one topic.
125
-	if (!empty($context['search_params']['topic']))
126
-		echo '
129
+	if (!empty($context['search_params']['topic'])) {
130
+			echo '
127 131
 			<p>
128 132
 				', $txt['search_specific_topic'], ' &quot;', $context['search_topic']['link'], '&quot;.
129 133
 			</p>
130 134
 			<input type="hidden" name="topic" value="', $context['search_topic']['id'], '">
131 135
 			<input type="submit" name="b_search" value="', $txt['search'], '" class="button">';
136
+	}
132 137
 
133 138
 	echo '
134 139
 		</div>';
@@ -238,17 +243,19 @@  discard block
 block discarded – undo
238 243
 		<div class="roundframe">';
239 244
 
240 245
 		// Did they make any typos or mistakes, perhaps?
241
-		if (isset($context['did_you_mean']))
242
-			echo '
246
+		if (isset($context['did_you_mean'])) {
247
+					echo '
243 248
 			<p>
244 249
 				', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.
245 250
 			</p>';
251
+		}
246 252
 
247
-		if (!empty($context['search_ignored']))
248
-			echo '
253
+		if (!empty($context['search_ignored'])) {
254
+					echo '
249 255
 			<p>
250 256
 				', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '
251 257
 			</p>';
258
+		}
252 259
 
253 260
 		echo '
254 261
 			<form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
@@ -271,10 +278,11 @@  discard block
 block discarded – undo
271 278
 					<input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '">
272 279
 				</div>';
273 280
 
274
-		if (!empty($context['search_params']['brd']))
275
-			foreach ($context['search_params']['brd'] as $board_id)
281
+		if (!empty($context['search_params']['brd'])) {
282
+					foreach ($context['search_params']['brd'] as $board_id)
276 283
 				echo '
277 284
 				<input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">';
285
+		}
278 286
 
279 287
 		echo '
280 288
 			</form>
@@ -285,18 +293,20 @@  discard block
 block discarded – undo
285 293
 	if ($context['compact'])
286 294
 	{
287 295
 		// Quick moderation set to checkboxes? Oh, how fun :/
288
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
289
-			echo '
296
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
297
+					echo '
290 298
 	<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">';
299
+		}
291 300
 
292 301
 		echo '
293 302
 		<div class="cat_bar">
294 303
 			<h3 class="catbg">
295 304
 				<span class="floatright">';
296 305
 
297
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1)
298
-			echo '
306
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
307
+					echo '
299 308
 					<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">';
309
+		}
300 310
 		echo '
301 311
 				</span>
302 312
 				<span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], '
@@ -304,15 +314,15 @@  discard block
 block discarded – undo
304 314
 		</div>';
305 315
 
306 316
 		// Was anything even found?
307
-		if (!empty($context['topics']))
308
-			echo '
317
+		if (!empty($context['topics'])) {
318
+					echo '
309 319
 		<div class="pagesection">
310 320
 			<span>', $context['page_index'], '</span>
311 321
 		</div>';
312
-
313
-		else
314
-			echo '
322
+		} else {
323
+					echo '
315 324
 		<div class="roundframe noup">', $txt['find_no_results'], '</div>';
325
+		}
316 326
 
317 327
 		// While we have results to show ...
318 328
 		while ($topic = $context['get_topics']())
@@ -335,31 +345,35 @@  discard block
 block discarded – undo
335 345
 					echo '
336 346
 				<span class="floatright">';
337 347
 
338
-					if ($options['display_quick_mod'] == 1)
339
-						echo '
348
+					if ($options['display_quick_mod'] == 1) {
349
+											echo '
340 350
 					<input type="checkbox" name="topics[]" value="', $topic['id'], '">';
341
-
342
-					else
351
+					} else
343 352
 					{
344
-						if ($topic['quick_mod']['remove'])
345
-							echo '
353
+						if ($topic['quick_mod']['remove']) {
354
+													echo '
346 355
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>';
356
+						}
347 357
 
348
-						if ($topic['quick_mod']['lock'])
349
-							echo '
358
+						if ($topic['quick_mod']['lock']) {
359
+													echo '
350 360
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>';
361
+						}
351 362
 
352
-						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove'])
353
-							echo '
363
+						if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
364
+													echo '
354 365
 					<br>';
366
+						}
355 367
 
356
-						if ($topic['quick_mod']['sticky'])
357
-							echo '
368
+						if ($topic['quick_mod']['sticky']) {
369
+													echo '
358 370
 					<a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>';
371
+						}
359 372
 
360
-						if ($topic['quick_mod']['move'])
361
-							echo '
373
+						if ($topic['quick_mod']['move']) {
374
+													echo '
362 375
 					<a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>';
376
+						}
363 377
 					}
364 378
 
365 379
 					echo '
@@ -369,20 +383,22 @@  discard block
 block discarded – undo
369 383
 			echo '
370 384
 			</div><!-- .block -->';
371 385
 
372
-				if ($message['body_highlighted'] != '')
373
-					echo '
386
+				if ($message['body_highlighted'] != '') {
387
+									echo '
374 388
 				<div class="list_posts double_height">', $message['body_highlighted'], '</div>';
389
+				}
375 390
 			}
376 391
 
377 392
 			echo '
378 393
 		</div><!-- $topic[css_class] -->';
379 394
 		}
380 395
 
381
-		if (!empty($context['topics']))
382
-			echo '
396
+		if (!empty($context['topics'])) {
397
+					echo '
383 398
 		<div class="pagesection">
384 399
 			<span>', $context['page_index'], '</span>
385 400
 		</div>';
401
+		}
386 402
 
387 403
 		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
388 404
 		{
@@ -391,17 +407,19 @@  discard block
 block discarded – undo
391 407
 			<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
392 408
 				<option value="">--------</option>';
393 409
 
394
-			foreach ($context['qmod_actions'] as $qmod_action)
395
-				if ($context['can_' . $qmod_action])
410
+			foreach ($context['qmod_actions'] as $qmod_action) {
411
+							if ($context['can_' . $qmod_action])
396 412
 					echo '
397 413
 				<option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>';
414
+			}
398 415
 
399 416
 			echo '
400 417
 			</select>';
401 418
 
402
-			if ($context['can_move'])
403
-				echo '
419
+			if ($context['can_move']) {
420
+							echo '
404 421
 			<span id="quick_mod_jump_to"></span>';
422
+			}
405 423
 
406 424
 			echo '
407 425
 			<input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '">
@@ -410,12 +428,12 @@  discard block
 block discarded – undo
410 428
 		}
411 429
 
412 430
 
413
-		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']))
414
-			echo '
431
+		if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) {
432
+					echo '
415 433
 		<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
416 434
 	</form>';
417
-	}
418
-	else
435
+		}
436
+	} else
419 437
 	{
420 438
 		echo '
421 439
 	<div class="cat_bar">
@@ -427,9 +445,10 @@  discard block
 block discarded – undo
427 445
 		<span>', $context['page_index'], '</span>
428 446
 	</div>';
429 447
 
430
-		if (empty($context['topics']))
431
-			echo '
448
+		if (empty($context['topics'])) {
449
+					echo '
432 450
 	<div class="information">(', $txt['search_no_results'], ')</div>';
451
+		}
433 452
 
434 453
 		while ($topic = $context['get_topics']())
435 454
 		{
@@ -464,8 +483,8 @@  discard block
 block discarded – undo
464 483
 	<div class="smalltext righttext" id="search_jump_to"></div>
465 484
 	<script>';
466 485
 
467
-	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move'])
468
-		echo '
486
+	if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
487
+			echo '
469 488
 		if (typeof(window.XMLHttpRequest) != "undefined")
470 489
 			aJumpTo[aJumpTo.length] = new JumpTo({
471 490
 				sContainerId: "quick_mod_jump_to",
@@ -480,6 +499,7 @@  discard block
 block discarded – undo
480 499
 				bDisabled: true,
481 500
 				sCustomName: "move_to"
482 501
 			});';
502
+	}
483 503
 
484 504
 	echo '
485 505
 		if (typeof(window.XMLHttpRequest) != "undefined")
Please login to merge, or discard this patch.
Themes/default/Poll.template.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 		}
39 39
 	</script>';
40 40
 
41
-	if (!empty($context['poll_error']['messages']))
42
-		echo '
41
+	if (!empty($context['poll_error']['messages'])) {
42
+			echo '
43 43
 			<div class="errorbox">
44 44
 				<dl class="poll_error">
45 45
 					<dt>
@@ -50,6 +50,7 @@  discard block
 block discarded – undo
50 50
 					</dt>
51 51
 				</dl>
52 52
 			</div>';
53
+	}
53 54
 
54 55
 	// Start the main poll form.
55 56
 	echo '
@@ -79,8 +80,9 @@  discard block
 block discarded – undo
79 80
 								<input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" size="80" maxlength="255">';
80 81
 
81 82
 		// Does this option have a vote count yet, or is it new?
82
-		if ($choice['votes'] != -1)
83
-			echo ' (', $choice['votes'], ' ', $txt['votes'], ')';
83
+		if ($choice['votes'] != -1) {
84
+					echo ' (', $choice['votes'], ' ', $txt['votes'], ')';
85
+		}
84 86
 
85 87
 		echo '
86 88
 							</dd>';
@@ -118,14 +120,15 @@  discard block
 block discarded – undo
118 120
 								<input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked' : '', '>
119 121
 							</dd>';
120 122
 
121
-		if ($context['poll']['guest_vote_allowed'])
122
-			echo '
123
+		if ($context['poll']['guest_vote_allowed']) {
124
+					echo '
123 125
 							<dt>
124 126
 								<label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
125 127
 							</dt>
126 128
 							<dd>
127 129
 								<input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll']['guest_vote']) ? ' checked' : '', '>
128 130
 							</dd>';
131
+		}
129 132
 	}
130 133
 
131 134
 	echo '
@@ -141,12 +144,13 @@  discard block
 block discarded – undo
141 144
 					</fieldset>';
142 145
 
143 146
 	// If this is an edit, we can allow them to reset the vote counts.
144
-	if ($context['is_edit'])
145
-		echo '
147
+	if ($context['is_edit']) {
148
+			echo '
146 149
 					<fieldset id="poll_reset">
147 150
 						<legend>', $txt['reset_votes'], '</legend>
148 151
 						<input type="checkbox" name="resetVoteCount" value="on"> ' . $txt['reset_votes_check'] . '
149 152
 					</fieldset>';
153
+	}
150 154
 	echo '
151 155
 					<input type="submit" name="post" value="', $txt['save'], '" onclick="return submitThisOnce(this);" accesskey="s" class="button">
152 156
 				</div><!-- .roundframe -->
Please login to merge, or discard this patch.
Themes/default/Themes.template.php 1 patch
Braces   +121 added lines, -92 removed lines patch added patch discarded remove patch
@@ -51,9 +51,10 @@  discard block
 block discarded – undo
51 51
 					<dd>
52 52
 						<div id="known_themes_list">';
53 53
 
54
-	foreach ($context['themes'] as $theme)
55
-		echo '
54
+	foreach ($context['themes'] as $theme) {
55
+			echo '
56 56
 							<label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', '> ', $theme['name'], '</label><br>';
57
+	}
57 58
 
58 59
 	echo '
59 60
 						</div>
@@ -70,9 +71,10 @@  discard block
 block discarded – undo
70 71
 						<select name="options[theme_guests]" id="theme_guests">';
71 72
 
72 73
 	// Put an option for each theme in the select box.
73
-	foreach ($context['themes'] as $theme)
74
-		echo '
74
+	foreach ($context['themes'] as $theme) {
75
+			echo '
75 76
 							<option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
77
+	}
76 78
 
77 79
 	echo '
78 80
 						</select>
@@ -87,9 +89,10 @@  discard block
 block discarded – undo
87 89
 							<option value="0">', $txt['theme_forum_default'], '</option>';
88 90
 
89 91
 	// Same thing, this time for changing the theme of everyone.
90
-	foreach ($context['themes'] as $theme)
91
-		echo '
92
+	foreach ($context['themes'] as $theme) {
93
+			echo '
92 94
 							<option value="', $theme['id'], '">', $theme['name'], '</option>';
95
+	}
93 96
 
94 97
 	echo '
95 98
 						</select>
@@ -183,11 +186,12 @@  discard block
 block discarded – undo
183 186
 	global $context, $scripturl, $txt;
184 187
 
185 188
 	// Show a nice confirmation message.
186
-	if (isset($_GET['done']))
187
-		echo '
189
+	if (isset($_GET['done'])) {
190
+			echo '
188 191
 	<div class="infobox">
189 192
 		', $txt['theme_confirmed_' . $_GET['done']], '
190 193
 	</div>';
194
+	}
191 195
 
192 196
 	echo '
193 197
 		<div class="cat_bar">
@@ -344,11 +348,12 @@  discard block
 block discarded – undo
344 348
 		if (empty($setting) || !is_array($setting))
345 349
 		{
346 350
 			// Insert a separator (unless this is the first item in the list)
347
-			if ($i !== $first_option_key)
348
-				echo '
351
+			if ($i !== $first_option_key) {
352
+							echo '
349 353
 				</dl>
350 354
 				<hr>
351 355
 				<dl class="settings">';
356
+			}
352 357
 
353 358
 			// Should we give a name to this section?
354 359
 			if (is_string($setting) && !empty($setting))
@@ -357,9 +362,9 @@  discard block
 block discarded – undo
357 362
 				echo '
358 363
 					<dt><strong>' . $setting . '</strong></dt>
359 364
 					<dd></dd>';
365
+			} else {
366
+							$titled_section = false;
360 367
 			}
361
-			else
362
-				$titled_section = false;
363 368
 
364 369
 			continue;
365 370
 		}
@@ -368,8 +373,8 @@  discard block
 block discarded – undo
368 373
 					<dt>';
369 374
 
370 375
 		// Show the change option box?
371
-		if ($context['theme_options_reset'])
372
-			echo '
376
+		if ($context['theme_options_reset']) {
377
+					echo '
373 378
 						<span class="floatleft">
374 379
 							<select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;">
375 380
 								<option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option>
@@ -377,23 +382,26 @@  discard block
 block discarded – undo
377 382
 								<option value="2">', $txt['themeadmin_reset_options_default'], '</option>
378 383
 							</select>
379 384
 						</span>';
385
+		}
380 386
 
381 387
 		echo '
382 388
 						<label for="options_', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
383 389
 
384
-		if (isset($setting['description']))
385
-			echo '
390
+		if (isset($setting['description'])) {
391
+					echo '
386 392
 						<br>
387 393
 						<span class="smalltext">', $setting['description'], '</span>';
394
+		}
388 395
 		echo '
389 396
 					</dt>';
390 397
 
391 398
 		// Display checkbox options
392
-		if ($setting['type'] == 'checkbox')
393
-			echo '
399
+		if ($setting['type'] == 'checkbox') {
400
+					echo '
394 401
 					<dd>
395 402
 						<input type="hidden" name="' . (!empty($setting['default']) ? 'default_' : '') . 'options[' . $setting['id'] . ']" value="0">
396 403
 						<input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', $context['theme_options_reset'] ? ' disabled' : '', ' value="1" class="floatleft">';
404
+		}
397 405
 
398 406
 		// How about selection lists, we all love them
399 407
 		elseif ($setting['type'] == 'list')
@@ -402,9 +410,10 @@  discard block
 block discarded – undo
402 410
 					<dd>
403 411
 						<select class="floatleft" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '"', $context['theme_options_reset'] ? ' disabled' : '', '>';
404 412
 
405
-			foreach ($setting['options'] as $value => $label)
406
-				echo '
413
+			foreach ($setting['options'] as $value => $label) {
414
+							echo '
407 415
 							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
416
+			}
408 417
 
409 418
 			echo '
410 419
 						</select>';
@@ -423,14 +432,13 @@  discard block
 block discarded – undo
423 432
 
424 433
 				echo '
425 434
 						<input type="number"', $min . $max . $step;
426
-			}
427
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
428
-				echo'
435
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
436
+							echo'
429 437
 						<input type="url"';
430
-
431
-			else
432
-				echo '
438
+			} else {
439
+							echo '
433 440
 						<input type="text"';
441
+			}
434 442
 
435 443
 			echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : '', $context['theme_options_reset'] ? ' disabled' : '', '>';
436 444
 		}
@@ -468,8 +476,8 @@  discard block
 block discarded – undo
468 476
 			<div class="windowbg">';
469 477
 
470 478
 	// @todo Why can't I edit the default theme popup.
471
-	if ($context['theme_settings']['theme_id'] != 1)
472
-		echo '
479
+	if ($context['theme_settings']['theme_id'] != 1) {
480
+			echo '
473 481
 				<div class="title_bar">
474 482
 					<h3 class="titlebg config_hd">
475 483
 						', $txt['theme_edit'], '
@@ -485,6 +493,7 @@  discard block
 block discarded – undo
485 493
 						</li>
486 494
 					</ul>
487 495
 				</div>';
496
+	}
488 497
 
489 498
 	echo '
490 499
 				<div class="title_bar">
@@ -535,9 +544,10 @@  discard block
 block discarded – undo
535 544
 					<dd>
536 545
 						<select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">';
537 546
 
538
-		foreach ($context['theme_variants'] as $key => $variant)
539
-			echo '
547
+		foreach ($context['theme_variants'] as $key => $variant) {
548
+					echo '
540 549
 							<option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
550
+		}
541 551
 
542 552
 		echo '
543 553
 						</select>
@@ -571,11 +581,12 @@  discard block
 block discarded – undo
571 581
 		if (empty($setting) || !is_array($setting))
572 582
 		{
573 583
 			// We don't need a separator before the first list element
574
-			if ($i !== $first_setting_key)
575
-				echo '
584
+			if ($i !== $first_setting_key) {
585
+							echo '
576 586
 				</dl>
577 587
 				<hr>
578 588
 				<dl class="settings">';
589
+			}
579 590
 
580 591
 			// Add a fake heading?
581 592
 			if (is_string($setting) && !empty($setting))
@@ -584,9 +595,9 @@  discard block
 block discarded – undo
584 595
 				echo '
585 596
 					<dt><strong>' . $setting . '</strong></dt>
586 597
 					<dd></dd>';
598
+			} else {
599
+							$titled_section = false;
587 600
 			}
588
-			else
589
-				$titled_section = false;
590 601
 
591 602
 			continue;
592 603
 		}
@@ -595,20 +606,22 @@  discard block
 block discarded – undo
595 606
 					<dt>
596 607
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>:';
597 608
 
598
-		if (isset($setting['description']))
599
-			echo '<br>
609
+		if (isset($setting['description'])) {
610
+					echo '<br>
600 611
 						<span class="smalltext">', $setting['description'], '</span>';
612
+		}
601 613
 
602 614
 		echo '
603 615
 					</dt>';
604 616
 
605 617
 		// A checkbox?
606
-		if ($setting['type'] == 'checkbox')
607
-			echo '
618
+		if ($setting['type'] == 'checkbox') {
619
+					echo '
608 620
 					<dd>
609 621
 						<input type="hidden" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" value="0">
610 622
 						<input type="checkbox" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '"', !empty($setting['value']) ? ' checked' : '', ' value="1">
611 623
 					</dd>';
624
+		}
612 625
 
613 626
 		// A list with options?
614 627
 		elseif ($setting['type'] == 'list')
@@ -617,9 +630,10 @@  discard block
 block discarded – undo
617 630
 					<dd>
618 631
 						<select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">';
619 632
 
620
-			foreach ($setting['options'] as $value => $label)
621
-				echo '
633
+			foreach ($setting['options'] as $value => $label) {
634
+							echo '
622 635
 							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
636
+			}
623 637
 
624 638
 			echo '
625 639
 						</select>
@@ -647,14 +661,13 @@  discard block
 block discarded – undo
647 661
 
648 662
 				echo '
649 663
 						<input type="number"', $min . $max . $step;
650
-			}
651
-			elseif (isset($setting['type']) && $setting['type'] == 'url')
652
-				echo'
664
+			} elseif (isset($setting['type']) && $setting['type'] == 'url') {
665
+							echo'
653 666
 						<input type="url"';
654
-
655
-			else
656
-				echo '
667
+			} else {
668
+							echo '
657 669
 						<input type="text"';
670
+			}
658 671
 
659 672
 			echo ' name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="options_', $setting['id'], '" value="', $setting['value'], '"', $setting['type'] == 'number' ? ' size="5"' : (empty($settings['size']) ? ' size="40"' : ' size="' . $setting['size'] . '"'), '>
660 673
 					</dd>';
@@ -726,9 +739,10 @@  discard block
 block discarded – undo
726 739
 					<label for="variant', $theme['id'], '"><strong>', $theme['pick_label'], '</strong></label>:
727 740
 					<select id="variant', $theme['id'], '" name="vrt[', $theme['id'], ']" onchange="changeVariant', $theme['id'], '(this.value);">';
728 741
 
729
-			foreach ($theme['variants'] as $key => $variant)
730
-				echo '
742
+			foreach ($theme['variants'] as $key => $variant) {
743
+							echo '
731 744
 						<option value="', $key, '"', $theme['selected_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
745
+			}
732 746
 
733 747
 			echo '
734 748
 					</select>
@@ -805,21 +819,23 @@  discard block
 block discarded – undo
805 819
 		<div class="windowbg">';
806 820
 
807 821
 	// Oops! there was an error :(
808
-	if (!empty($context['error_message']))
809
-		echo '
822
+	if (!empty($context['error_message'])) {
823
+			echo '
810 824
 			<p>
811 825
 				', $context['error_message'], '
812 826
 			</p>';
827
+	}
813 828
 
814 829
 	// Not much to show except a link back...
815
-	else
816
-		echo '
830
+	else {
831
+			echo '
817 832
 			<p>
818 833
 				<a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], '
819 834
 			</p>
820 835
 			<p>
821 836
 				<a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a>
822 837
 			</p>';
838
+	}
823 839
 
824 840
 	echo '
825 841
 		</div><!-- .windowbg -->';
@@ -884,11 +900,12 @@  discard block
 block discarded – undo
884 900
 					<span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span>
885 901
 					<span class="floatright">';
886 902
 
887
-		if ($template['can_copy'])
888
-			echo '
903
+		if ($template['can_copy']) {
904
+					echo '
889 905
 						<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
890
-		else
891
-			echo $txt['themeadmin_edit_no_copy'];
906
+		} else {
907
+					echo $txt['themeadmin_edit_no_copy'];
908
+		}
892 909
 
893 910
 		echo '
894 911
 					</span>
@@ -907,11 +924,12 @@  discard block
 block discarded – undo
907 924
 {
908 925
 	global $context, $txt;
909 926
 
910
-	if (!empty($context['browse_title']))
911
-		echo '
927
+	if (!empty($context['browse_title'])) {
928
+			echo '
912 929
 		<div class="cat_bar">
913 930
 			<h3 class="catbg">', $context['browse_title'], '</h3>
914 931
 		</div>';
932
+	}
915 933
 
916 934
 	echo '
917 935
 		<table class="table_grid tborder">
@@ -930,16 +948,15 @@  discard block
 block discarded – undo
930 948
 				<tr class="windowbg">
931 949
 					<td>';
932 950
 
933
-		if ($file['is_editable'])
934
-			echo '
951
+		if ($file['is_editable']) {
952
+					echo '
935 953
 						<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
936
-
937
-		elseif ($file['is_directory'])
938
-			echo '
954
+		} elseif ($file['is_directory']) {
955
+					echo '
939 956
 						<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>';
940
-
941
-		else
942
-			echo $file['filename'];
957
+		} else {
958
+					echo $file['filename'];
959
+		}
943 960
 
944 961
 		echo '
945 962
 					</td>
@@ -960,11 +977,12 @@  discard block
 block discarded – undo
960 977
 {
961 978
 	global $context, $settings, $scripturl, $txt;
962 979
 
963
-	if ($context['session_error'])
964
-		echo '
980
+	if ($context['session_error']) {
981
+			echo '
965 982
 	<div class="errorbox">
966 983
 		', $txt['error_session_timeout'], '
967 984
 	</div>';
985
+	}
968 986
 
969 987
 	// From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com.
970 988
 	echo '
@@ -1027,17 +1045,18 @@  discard block
 block discarded – undo
1027 1045
 					{
1028 1046
 					';
1029 1047
 
1030
-	if (isBrowser('is_ie'))
1031
-		echo '
1048
+	if (isBrowser('is_ie')) {
1049
+			echo '
1032 1050
 						var sheets = frames["css_preview_box"].document.styleSheets;
1033 1051
 						for (var j = 0; j < sheets.length; j++)
1034 1052
 						{
1035 1053
 							if (sheets[j].id == "css_preview_box")
1036 1054
 								sheets[j].cssText = document.forms.stylesheetForm.entire_file.value;
1037 1055
 						}';
1038
-	else
1039
-		echo '
1056
+	} else {
1057
+			echo '
1040 1058
 						setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);';
1059
+	}
1041 1060
 	echo '
1042 1061
 					}
1043 1062
 					catch (e)
@@ -1089,9 +1108,10 @@  discard block
 block discarded – undo
1089 1108
 			</div>
1090 1109
 			<div class="windowbg">';
1091 1110
 
1092
-	if (!$context['allow_save'])
1093
-		echo '
1111
+	if (!$context['allow_save']) {
1112
+			echo '
1094 1113
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1114
+	}
1095 1115
 
1096 1116
 	echo '
1097 1117
 				<textarea class="edit_file" name="entire_file" cols="80" rows="20" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea>
@@ -1105,9 +1125,10 @@  discard block
 block discarded – undo
1105 1125
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1106 1126
 
1107 1127
 	// Hopefully it exists.
1108
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1109
-		echo '
1128
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1129
+			echo '
1110 1130
 			<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1131
+	}
1111 1132
 
1112 1133
 	echo '
1113 1134
 		</form>';
@@ -1120,18 +1141,20 @@  discard block
 block discarded – undo
1120 1141
 {
1121 1142
 	global $context, $scripturl, $txt;
1122 1143
 
1123
-	if ($context['session_error'])
1124
-		echo '
1144
+	if ($context['session_error']) {
1145
+			echo '
1125 1146
 	<div class="errorbox">
1126 1147
 		', $txt['error_session_timeout'], '
1127 1148
 	</div>';
1149
+	}
1128 1150
 
1129
-	if (isset($context['parse_error']))
1130
-		echo '
1151
+	if (isset($context['parse_error'])) {
1152
+			echo '
1131 1153
 	<div class="errorbox">
1132 1154
 		', $txt['themeadmin_edit_error'], '
1133 1155
 		<div><pre>', $context['parse_error'], '</pre></div>
1134 1156
 	</div>';
1157
+	}
1135 1158
 
1136 1159
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1137 1160
 	echo '
@@ -1141,16 +1164,18 @@  discard block
 block discarded – undo
1141 1164
 			</div>
1142 1165
 			<div class="windowbg">';
1143 1166
 
1144
-	if (!$context['allow_save'])
1145
-		echo '
1167
+	if (!$context['allow_save']) {
1168
+			echo '
1146 1169
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1170
+	}
1147 1171
 
1148
-	foreach ($context['file_parts'] as $part)
1149
-		echo '
1172
+	foreach ($context['file_parts'] as $part) {
1173
+			echo '
1150 1174
 				<label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br>
1151 1175
 				<div class="centertext">
1152 1176
 					<textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea>
1153 1177
 				</div>';
1178
+	}
1154 1179
 
1155 1180
 	echo '
1156 1181
 				<div class="padding righttext">
@@ -1159,9 +1184,10 @@  discard block
 block discarded – undo
1159 1184
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1160 1185
 
1161 1186
 	// Hopefully it exists.
1162
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1163
-		echo '
1187
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1188
+			echo '
1164 1189
 					<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1190
+	}
1165 1191
 
1166 1192
 	echo '
1167 1193
 				</div><!-- .righttext -->
@@ -1176,18 +1202,20 @@  discard block
 block discarded – undo
1176 1202
 {
1177 1203
 	global $context, $scripturl, $txt;
1178 1204
 
1179
-	if ($context['session_error'])
1180
-		echo '
1205
+	if ($context['session_error']) {
1206
+			echo '
1181 1207
 	<div class="errorbox">
1182 1208
 		', $txt['error_session_timeout'], '
1183 1209
 	</div>';
1210
+	}
1184 1211
 
1185 1212
 	// Is this file writeable?
1186
-	if (!$context['allow_save'])
1187
-		echo '
1213
+	if (!$context['allow_save']) {
1214
+			echo '
1188 1215
 	<div class="errorbox">
1189 1216
 		', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '
1190 1217
 	</div>';
1218
+	}
1191 1219
 
1192 1220
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1193 1221
 	echo '
@@ -1202,9 +1230,10 @@  discard block
 block discarded – undo
1202 1230
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1203 1231
 
1204 1232
 	// Hopefully it exists.
1205
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1206
-		echo '
1233
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1234
+			echo '
1207 1235
 				<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1236
+	}
1208 1237
 
1209 1238
 	echo '
1210 1239
 			</div><!-- .windowbg -->
Please login to merge, or discard this patch.
Themes/default/ManagePaid.template.php 1 patch
Braces   +63 added lines, -45 removed lines patch added patch discarded remove patch
@@ -20,9 +20,10 @@  discard block
 block discarded – undo
20 20
 	echo '
21 21
 	<form action="', $scripturl, '?action=admin;area=paidsubscribe;sa=modify;sid=', $context['sub_id'], '" method="post">';
22 22
 
23
-	if (!empty($context['disable_groups']))
24
-		echo '
23
+	if (!empty($context['disable_groups'])) {
24
+			echo '
25 25
 		<div class="noticebox">', $txt['paid_mod_edit_note'], '</div>';
26
+	}
26 27
 
27 28
 		echo '
28 29
 		<div class="cat_bar">
@@ -66,9 +67,10 @@  discard block
 block discarded – undo
66 67
 						<option value="0"', $context['sub']['prim_group'] == 0 ? ' selected' : '', '>', $txt['paid_mod_no_group'], '</option>';
67 68
 
68 69
 	// Put each group into the box.
69
-	foreach ($context['groups'] as $id => $name)
70
-		echo '
70
+	foreach ($context['groups'] as $id => $name) {
71
+			echo '
71 72
 						<option value="', $id, '"', $context['sub']['prim_group'] == $id ? ' selected' : '', '>', $name, '</option>';
73
+	}
72 74
 
73 75
 	echo '
74 76
 					</select>
@@ -80,12 +82,13 @@  discard block
 block discarded – undo
80 82
 				<dd>';
81 83
 
82 84
 	// Put a checkbox in for each group
83
-	foreach ($context['groups'] as $id => $name)
84
-		echo '
85
+	foreach ($context['groups'] as $id => $name) {
86
+			echo '
85 87
 					<label for="addgroup_', $id, '">
86 88
 						<input type="checkbox" id="addgroup_', $id, '" name="addgroup[', $id, ']"', in_array($id, $context['sub']['add_groups']) ? ' checked' : '', !empty($context['disable_groups']) ? ' disabled' : '', '>
87 89
 						<span class="smalltext">', $name, '</span>
88 90
 					</label><br>';
91
+	}
89 92
 
90 93
 	echo '
91 94
 				</dd>
@@ -230,8 +233,8 @@  discard block
 block discarded – undo
230 233
 			<dl class="settings">';
231 234
 
232 235
 	// Do we need a username?
233
-	if ($context['action_type'] == 'add')
234
-		echo '
236
+	if ($context['action_type'] == 'add') {
237
+			echo '
235 238
 				<dt>
236 239
 					<strong>', $txt['paid_username'], ':</strong><br>
237 240
 					<span class="smalltext">', $txt['one_username'], '</span>
@@ -239,6 +242,7 @@  discard block
 block discarded – undo
239 242
 				<dd>
240 243
 					<input type="text" name="name" id="name_control" value="', $context['sub']['username'], '" size="30">
241 244
 				</dd>';
245
+	}
242 246
 
243 247
 	echo '
244 248
 				<dt>
@@ -256,9 +260,10 @@  discard block
 block discarded – undo
256 260
 				<select name="year" id="year" onchange="generateDays();">';
257 261
 
258 262
 	// Show a list of all the years we allow...
259
-	for ($year = 2005; $year <= 2030; $year++)
260
-		echo '
263
+	for ($year = 2005; $year <= 2030; $year++) {
264
+			echo '
261 265
 					<option value="', $year, '"', $year == $context['sub']['start']['year'] ? ' selected' : '', '>', $year, '</option>';
266
+	}
262 267
 
263 268
 	echo '
264 269
 				</select>&nbsp;
@@ -266,9 +271,10 @@  discard block
 block discarded – undo
266 271
 				<select name="month" id="month" onchange="generateDays();">';
267 272
 
268 273
 	// There are 12 months per year - ensure that they all get listed.
269
-	for ($month = 1; $month <= 12; $month++)
270
-		echo '
274
+	for ($month = 1; $month <= 12; $month++) {
275
+			echo '
271 276
 					<option value="', $month, '"', $month == $context['sub']['start']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
277
+	}
272 278
 
273 279
 	echo '
274 280
 				</select>&nbsp;
@@ -276,9 +282,10 @@  discard block
 block discarded – undo
276 282
 				<select name="day" id="day">';
277 283
 
278 284
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
279
-	for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++)
280
-		echo '
285
+	for ($day = 1; $day <= $context['sub']['start']['last_day']; $day++) {
286
+			echo '
281 287
 					<option value="', $day, '"', $day == $context['sub']['start']['day'] ? ' selected' : '', '>', $day, '</option>';
288
+	}
282 289
 
283 290
 	echo '
284 291
 				</select>
@@ -290,9 +297,10 @@  discard block
 block discarded – undo
290 297
 				<select name="yearend" id="yearend" onchange="generateDays(\'end\');">';
291 298
 
292 299
 	// Show a list of all the years we allow...
293
-	for ($year = 2005; $year <= 2030; $year++)
294
-		echo '
300
+	for ($year = 2005; $year <= 2030; $year++) {
301
+			echo '
295 302
 					<option value="', $year, '"', $year == $context['sub']['end']['year'] ? ' selected' : '', '>', $year, '</option>';
303
+	}
296 304
 
297 305
 	echo '
298 306
 				</select>&nbsp;
@@ -300,9 +308,10 @@  discard block
 block discarded – undo
300 308
 				<select name="monthend" id="monthend" onchange="generateDays(\'end\');">';
301 309
 
302 310
 	// There are 12 months per year - ensure that they all get listed.
303
-	for ($month = 1; $month <= 12; $month++)
304
-		echo '
311
+	for ($month = 1; $month <= 12; $month++) {
312
+			echo '
305 313
 					<option value="', $month, '"', $month == $context['sub']['end']['month'] ? ' selected' : '', '>', $txt['months'][$month], '</option>';
314
+	}
306 315
 
307 316
 	echo '
308 317
 				</select>&nbsp;
@@ -310,9 +319,10 @@  discard block
 block discarded – undo
310 319
 				<select name="dayend" id="dayend">';
311 320
 
312 321
 	// This prints out all the days in the current month - this changes dynamically as we switch months.
313
-	for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++)
314
-		echo '
322
+	for ($day = 1; $day <= $context['sub']['end']['last_day']; $day++) {
323
+			echo '
315 324
 					<option value="', $day, '"', $day == $context['sub']['end']['day'] ? ' selected' : '', '>', $day, '</option>';
325
+	}
316 326
 
317 327
 	echo '
318 328
 				</select>
@@ -351,8 +361,8 @@  discard block
 block discarded – undo
351 361
 	<div class="windowbg">
352 362
 		<ul>';
353 363
 
354
-		foreach ($context['pending_payments'] as $id => $payment)
355
-			echo '
364
+		foreach ($context['pending_payments'] as $id => $payment) {
365
+					echo '
356 366
 			<li>
357 367
 				', $payment['desc'], '
358 368
 				<span class="floatleft">
@@ -362,6 +372,7 @@  discard block
 block discarded – undo
362 372
 					<a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;lid=', $context['log_id'], ';pending=', $id, ';remove">', $txt['pending_payments_remove'], '</a>
363 373
 				</span>
364 374
 			</li>';
375
+		}
365 376
 
366 377
 		echo '
367 378
 		</ul>';
@@ -385,12 +396,12 @@  discard block
 block discarded – undo
385 396
 				<h3 class="catbg">', $txt['subscriptions'], '</h3>
386 397
 			</div>';
387 398
 
388
-	if (empty($context['subscriptions']))
389
-		echo '
399
+	if (empty($context['subscriptions'])) {
400
+			echo '
390 401
 			<div class="information">
391 402
 				', $txt['paid_subs_none'], '
392 403
 			</div>';
393
-	else
404
+	} else
394 405
 	{
395 406
 		echo '
396 407
 			<div class="information">
@@ -401,8 +412,9 @@  discard block
 block discarded – undo
401 412
 		foreach ($context['subscriptions'] as $id => $subscription)
402 413
 		{
403 414
 			// Ignore the inactive ones...
404
-			if (empty($subscription['active']))
405
-				continue;
415
+			if (empty($subscription['active'])) {
416
+							continue;
417
+			}
406 418
 
407 419
 			echo '
408 420
 			<div class="cat_bar">
@@ -412,9 +424,10 @@  discard block
 block discarded – undo
412 424
 				<p><strong>', $subscription['name'], '</strong></p>
413 425
 				<p class="smalltext">', $subscription['desc'], '</p>';
414 426
 
415
-			if (!$subscription['flexible'])
416
-				echo '
427
+			if (!$subscription['flexible']) {
428
+							echo '
417 429
 				<div><strong>', $txt['paid_duration'], ':</strong> ', $subscription['length'], '</div>';
430
+			}
418 431
 
419 432
 			if ($context['user']['is_owner'])
420 433
 			{
@@ -427,24 +440,25 @@  discard block
 block discarded – undo
427 440
 				<select name="cur[', $subscription['id'], ']">';
428 441
 
429 442
 					// Print out the costs for this one.
430
-					foreach ($subscription['costs'] as $duration => $value)
431
-						echo '
443
+					foreach ($subscription['costs'] as $duration => $value) {
444
+											echo '
432 445
 					<option value="', $duration, '">', sprintf($modSettings['paid_currency_symbol'], $value), '/', $txt[$duration], '</option>';
446
+					}
433 447
 
434 448
 					echo '
435 449
 				</select>';
436
-				}
437
-				else
438
-					echo '
450
+				} else {
451
+									echo '
439 452
 				', sprintf($modSettings['paid_currency_symbol'], $subscription['costs']['fixed']);
453
+				}
440 454
 
441 455
 				echo '
442 456
 				<hr>
443 457
 				<input type="submit" name="sub_id[', $subscription['id'], ']" value="', $txt['paid_order'], '" class="button">';
444
-			}
445
-			else
446
-				echo '
458
+			} else {
459
+							echo '
447 460
 				<a href="', $scripturl, '?action=admin;area=paidsubscribe;sa=modifyuser;sid=', $subscription['id'], ';uid=', $context['member']['id'], (empty($context['current'][$subscription['id']]) ? '' : ';lid=' . $context['current'][$subscription['id']]['id']), '">', empty($context['current'][$subscription['id']]) ? $txt['paid_admin_add'] : $txt['paid_edit_subscription'], '</a>';
461
+			}
448 462
 
449 463
 			echo '
450 464
 			</div><!-- .windowbg -->';
@@ -471,18 +485,19 @@  discard block
 block discarded – undo
471 485
 			</thead>
472 486
 			<tbody>';
473 487
 
474
-	if (empty($context['current']))
475
-		echo '
488
+	if (empty($context['current'])) {
489
+			echo '
476 490
 				<tr class="windowbg">
477 491
 					<td colspan="4">
478 492
 						', $txt['paid_none_yet'], '
479 493
 					</td>
480 494
 				</tr>';
495
+	}
481 496
 
482 497
 	foreach ($context['current'] as $sub)
483 498
 	{
484
-		if (!$sub['hide'])
485
-			echo '
499
+		if (!$sub['hide']) {
500
+					echo '
486 501
 				<tr class="windowbg">
487 502
 					<td>
488 503
 						', ($context['user']['is_admin'] ? '<a href="' . $scripturl . '?action=admin;area=paidsubscribe;sa=modifyuser;lid=' . $sub['id'] . '">' . $sub['name'] . '</a>' : $sub['name']), '
@@ -493,6 +508,7 @@  discard block
 block discarded – undo
493 508
 					<td>', $sub['start'], '</td>
494 509
 					<td>', $sub['end'], '</td>
495 510
 				</tr>';
511
+		}
496 512
 	}
497 513
 
498 514
 	echo '
@@ -544,15 +560,17 @@  discard block
 block discarded – undo
544 560
 			', $gateway['desc'], '<br>
545 561
 			<form action="', $gateway['form'], '" method="post">';
546 562
 
547
-		if (!empty($gateway['javascript']))
548
-			echo '
563
+		if (!empty($gateway['javascript'])) {
564
+					echo '
549 565
 				<script>
550 566
 					', $gateway['javascript'], '
551 567
 				</script>';
568
+		}
552 569
 
553
-		foreach ($gateway['hidden'] as $name => $value)
554
-			echo '
570
+		foreach ($gateway['hidden'] as $name => $value) {
571
+					echo '
555 572
 				<input type="hidden" id="', $gateway['id'], '_', $name, '" name="', $name, '" value="', $value, '">';
573
+		}
556 574
 
557 575
 		echo '
558 576
 				<br>
Please login to merge, or discard this patch.
Themes/default/ManagePermissions.template.php 1 patch
Braces   +170 added lines, -128 removed lines patch added patch discarded remove patch
@@ -19,26 +19,28 @@  discard block
 block discarded – undo
19 19
 	global $context, $settings, $scripturl, $txt, $modSettings;
20 20
 
21 21
 	// Not allowed to edit?
22
-	if (!$context['can_modify'])
23
-		echo '
22
+	if (!$context['can_modify']) {
23
+			echo '
24 24
 	<div class="errorbox">
25 25
 		', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
26 26
 	</div>';
27
+	}
27 28
 
28 29
 	echo '
29 30
 	<div id="admin_form_wrapper">
30 31
 		<form action="', $scripturl, '?action=admin;area=permissions;sa=quick" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" id="permissionForm">';
31 32
 
32
-	if (!empty($context['profile']))
33
-		echo '
33
+	if (!empty($context['profile'])) {
34
+			echo '
34 35
 			<div class="cat_bar">
35 36
 				<h3 class="catbg">', $txt['permissions_for_profile'], ': &quot;', $context['profile']['name'], '&quot;</h3>
36 37
 			</div>';
37
-	else
38
-		echo '
38
+	} else {
39
+			echo '
39 40
 			<div class="cat_bar">
40 41
 				<h3 class="catbg">', $txt['permissions_title'], '</h3>
41 42
 			</div>';
43
+	}
42 44
 
43 45
 	echo '
44 46
 			<table class="table_grid">
@@ -47,13 +49,14 @@  discard block
 block discarded – undo
47 49
 						<th>', $txt['membergroups_name'], '</th>
48 50
 						<th class="small_table">', $txt['membergroups_members_top'], '</th>';
49 51
 
50
-	if (empty($modSettings['permission_enable_deny']))
51
-		echo '
52
+	if (empty($modSettings['permission_enable_deny'])) {
53
+			echo '
52 54
 						<th class="small_table">', $txt['membergroups_permissions'], '</th>';
53
-	else
54
-		echo '
55
+	} else {
56
+			echo '
55 57
 						<th class="small_table">', $txt['permissions_allowed'], '</th>
56 58
 						<th class="small_table">', $txt['permissions_denied'], '</th>';
59
+	}
57 60
 
58 61
 	echo '
59 62
 						<th class="small_table">', $context['can_modify'] ? $txt['permissions_modify'] : $txt['permissions_view'], '</th>
@@ -71,26 +74,28 @@  discard block
 block discarded – undo
71 74
 						<td>
72 75
 							', !empty($group['help']) ? ' <a class="help" href="' . $scripturl . '?action=helpadmin;help=' . $group['help'] . '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="' . $txt['help'] . '"></span></a> ' : '<img class="icon" src="' . $settings['images_url'] . '/blank.png" alt="' . $txt['help'] . '">', '<span>', $group['name'], '</span>';
73 76
 
74
-		if (!empty($group['children']))
75
-			echo '
77
+		if (!empty($group['children'])) {
78
+					echo '
76 79
 							<br>
77 80
 							<span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
81
+		}
78 82
 
79 83
 		echo '
80 84
 						</td>
81 85
 						<td>', $group['can_search'] ? $group['link'] : $group['num_members'], '</td>';
82 86
 
83
-		if (empty($modSettings['permission_enable_deny']))
84
-			echo '
87
+		if (empty($modSettings['permission_enable_deny'])) {
88
+					echo '
85 89
 						<td>', $group['num_permissions']['allowed'], '</td>';
86
-		else
87
-			echo '
90
+		} else {
91
+					echo '
88 92
 						<td ', $group['id'] == 1 ? ' style="font-style: italic;"' : '', '>
89 93
 							', $group['num_permissions']['allowed'], '
90 94
 						</td>
91 95
 						<td ', $group['id'] == 1 || $group['id'] == -1 ? ' style="font-style: italic;"' : (!empty($group['num_permissions']['denied']) ? ' class="red"' : ''), '>
92 96
 							', $group['num_permissions']['denied'], '
93 97
 						</td>';
98
+		}
94 99
 
95 100
 		echo '
96 101
 						<td>
@@ -141,10 +146,11 @@  discard block
 block discarded – undo
141 146
 							<select name="copy_from">
142 147
 								<option value="empty">(', $txt['permissions_select_membergroup'], ')</option>';
143 148
 
144
-		foreach ($context['groups'] as $group)
145
-			if ($group['id'] != 1)
149
+		foreach ($context['groups'] as $group) {
150
+					if ($group['id'] != 1)
146 151
 				echo '
147 152
 								<option value="', $group['id'], '">', $group['name'], '</option>';
153
+		}
148 154
 
149 155
 		echo '
150 156
 							</select>
@@ -154,9 +160,10 @@  discard block
 block discarded – undo
154 160
 								<option value="add">', $txt['permissions_add'], '...</option>
155 161
 								<option value="clear">', $txt['permissions_remove'], '...</option>';
156 162
 
157
-		if (!empty($modSettings['permission_enable_deny']))
158
-			echo '
163
+		if (!empty($modSettings['permission_enable_deny'])) {
164
+					echo '
159 165
 								<option value="deny">', $txt['permissions_deny'], '...</option>';
166
+		}
160 167
 
161 168
 		echo '
162 169
 							</select>
@@ -167,31 +174,35 @@  discard block
 block discarded – undo
167 174
 
168 175
 		foreach ($context['permissions'] as $permissionType)
169 176
 		{
170
-			if ($permissionType['id'] == 'membergroup' && !empty($context['profile']))
171
-				continue;
177
+			if ($permissionType['id'] == 'membergroup' && !empty($context['profile'])) {
178
+							continue;
179
+			}
172 180
 
173 181
 			foreach ($permissionType['columns'] as $column)
174 182
 			{
175 183
 				foreach ($column as $permissionGroup)
176 184
 				{
177
-					if ($permissionGroup['hidden'])
178
-						continue;
185
+					if ($permissionGroup['hidden']) {
186
+											continue;
187
+					}
179 188
 
180 189
 					echo '
181 190
 								<option value="" disabled>[', $permissionGroup['name'], ']</option>';
182 191
 
183 192
 					foreach ($permissionGroup['permissions'] as $perm)
184 193
 					{
185
-						if ($perm['hidden'])
186
-							continue;
194
+						if ($perm['hidden']) {
195
+													continue;
196
+						}
187 197
 
188
-						if ($perm['has_own_any'])
189
-							echo '
198
+						if ($perm['has_own_any']) {
199
+													echo '
190 200
 								<option value="', $permissionType['id'], '/', $perm['own']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['own']['name'], ')</option>
191 201
 								<option value="', $permissionType['id'], '/', $perm['any']['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], ' (', $perm['any']['name'], ')</option>';
192
-						else
193
-							echo '
202
+						} else {
203
+													echo '
194 204
 								<option value="', $permissionType['id'], '/', $perm['id'], '">&nbsp;&nbsp;&nbsp;', $perm['name'], '</option>';
205
+						}
195 206
 					}
196 207
 				}
197 208
 			}
@@ -256,9 +267,10 @@  discard block
 block discarded – undo
256 267
 				}
257 268
 			</script>';
258 269
 
259
-		if (!empty($context['profile']))
260
-			echo '
270
+		if (!empty($context['profile'])) {
271
+					echo '
261 272
 			<input type="hidden" name="pid" value="', $context['profile']['id'], '">';
273
+		}
262 274
 
263 275
 		echo '
264 276
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -302,9 +314,10 @@  discard block
 block discarded – undo
302 314
 					<h3 class="subbg">', $category['name'], '</h3>
303 315
 				</div>';
304 316
 
305
-		if (!empty($category['boards']))
306
-			echo '
317
+		if (!empty($category['boards'])) {
318
+					echo '
307 319
 				<ul class="perm_boards flow_hidden">';
320
+		}
308 321
 
309 322
 		foreach ($category['boards'] as $board)
310 323
 		{
@@ -320,33 +333,36 @@  discard block
 block discarded – undo
320 333
 				echo '
321 334
 							<select name="boardprofile[', $board['id'], ']">';
322 335
 
323
-				foreach ($context['profiles'] as $id => $profile)
324
-					echo '
336
+				foreach ($context['profiles'] as $id => $profile) {
337
+									echo '
325 338
 								<option value="', $id, '"', $id == $board['profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
339
+				}
326 340
 
327 341
 				echo '
328 342
 							</select>';
329
-			}
330
-			else
331
-				echo '
343
+			} else {
344
+							echo '
332 345
 							<a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $board['profile'], ';', $context['session_var'], '=', $context['session_id'], '">', $board['profile_name'], '</a>';
346
+			}
333 347
 
334 348
 			echo '
335 349
 						</span>
336 350
 					</li>';
337 351
 		}
338 352
 
339
-		if (!empty($category['boards']))
340
-			echo '
353
+		if (!empty($category['boards'])) {
354
+					echo '
341 355
 				</ul>';
356
+		}
342 357
 	}
343 358
 
344
-	if ($context['edit_all'])
345
-		echo '
359
+	if ($context['edit_all']) {
360
+			echo '
346 361
 				<input type="submit" name="save_changes" value="', $txt['save'], '" class="button">';
347
-	else
348
-		echo '
362
+	} else {
363
+			echo '
349 364
 				<a class="button" href="', $scripturl, '?action=admin;area=permissions;sa=board;edit;', $context['session_var'], '=', $context['session_id'], '">', $txt['permissions_board_all'], '</a>';
365
+	}
350 366
 
351 367
 	echo '
352 368
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -385,12 +401,13 @@  discard block
 block discarded – undo
385 401
 					<tr class="windowbg">
386 402
 						<td>';
387 403
 
388
-		if (!empty($context['show_rename_boxes']) && $profile['can_edit'])
389
-			echo '
404
+		if (!empty($context['show_rename_boxes']) && $profile['can_edit']) {
405
+					echo '
390 406
 							<input type="text" name="rename_profile[', $profile['id'], ']" value="', $profile['name'], '">';
391
-		else
392
-			echo '
407
+		} else {
408
+					echo '
393 409
 							<a href="', $scripturl, '?action=admin;area=permissions;sa=index;pid=', $profile['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $profile['name'], '</a>';
410
+		}
394 411
 
395 412
 		echo '
396 413
 						</td>
@@ -410,9 +427,10 @@  discard block
 block discarded – undo
410 427
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
411 428
 				<input type="hidden" name="', $context['admin-mpp_token_var'], '" value="', $context['admin-mpp_token'], '">';
412 429
 
413
-	if ($context['can_edit_something'])
414
-		echo '
430
+	if ($context['can_edit_something']) {
431
+			echo '
415 432
 				<input type="submit" name="rename" value="', empty($context['show_rename_boxes']) ? $txt['permissions_profile_rename'] : $txt['permissions_commit'], '" class="button">';
433
+	}
416 434
 
417 435
 	echo '
418 436
 				<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" class="button" ', !empty($context['show_rename_boxes']) ? ' style="display:none"' : '', '>
@@ -437,9 +455,10 @@  discard block
 block discarded – undo
437 455
 					<dd>
438 456
 						<select name="copy_from">';
439 457
 
440
-	foreach ($context['profiles'] as $id => $profile)
441
-		echo '
458
+	foreach ($context['profiles'] as $id => $profile) {
459
+			echo '
442 460
 							<option value="', $id, '">', $profile['name'], '</option>';
461
+	}
443 462
 
444 463
 	echo '
445 464
 						</select>
@@ -461,13 +480,13 @@  discard block
 block discarded – undo
461 480
 	global $context, $scripturl, $txt, $modSettings;
462 481
 
463 482
 	// Cannot be edited?
464
-	if (!$context['profile']['can_modify'])
465
-		echo '
483
+	if (!$context['profile']['can_modify']) {
484
+			echo '
466 485
 	<div class="errorbox">
467 486
 		', sprintf($txt['permission_cannot_edit'], $scripturl . '?action=admin;area=permissions;sa=profiles'), '
468 487
 	</div>';
469
-	else
470
-		echo '
488
+	} else {
489
+			echo '
471 490
 	<script>
472 491
 		window.smf_usedDeny = false;
473 492
 
@@ -479,26 +498,29 @@  discard block
 block discarded – undo
479 498
 				return true;
480 499
 		}
481 500
 	</script>';
501
+	}
482 502
 
483 503
 	echo '
484 504
 		<form id="permissions" action="', $scripturl, '?action=admin;area=permissions;sa=modify2;group=', $context['group']['id'], ';pid=', $context['profile']['id'], '" method="post" accept-charset="', $context['character_set'], '" name="permissionForm" onsubmit="return warnAboutDeny();">';
485 505
 
486
-	if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1)
487
-		echo '
506
+	if (!empty($modSettings['permission_enable_deny']) && $context['group']['id'] != -1) {
507
+			echo '
488 508
 			<div class="information">
489 509
 				', $txt['permissions_option_desc'], '
490 510
 			</div>';
511
+	}
491 512
 
492 513
 	echo '
493 514
 			<div class="cat_bar">
494 515
 				<h3 class="catbg">';
495 516
 
496
-	if ($context['permission_type'] == 'board')
497
-		echo '
517
+	if ($context['permission_type'] == 'board') {
518
+			echo '
498 519
 				', $txt['permissions_local_for'], ' &quot;', $context['group']['name'], '&quot; ', $txt['permissions_on'], ' &quot;', $context['profile']['name'], '&quot;';
499
-	else
500
-		echo '
520
+	} else {
521
+			echo '
501 522
 				', $context['permission_type'] == 'membergroup' ? $txt['permissions_general'] : $txt['permissions_board'], ' - &quot;', $context['group']['name'], '&quot;';
523
+	}
502 524
 	echo '
503 525
 				</h3>
504 526
 			</div>';
@@ -521,15 +543,17 @@  discard block
 block discarded – undo
521 543
 		template_modify_group_display('board');
522 544
 	}
523 545
 
524
-	if ($context['profile']['can_modify'])
525
-		echo '
546
+	if ($context['profile']['can_modify']) {
547
+			echo '
526 548
 			<div class="padding">
527 549
 				<input type="submit" value="', $txt['permissions_commit'], '" class="button">
528 550
 			</div>';
551
+	}
529 552
 
530
-	foreach ($context['hidden_perms'] as $hidden_perm)
531
-		echo '
553
+	foreach ($context['hidden_perms'] as $hidden_perm) {
554
+			echo '
532 555
 			<input type="hidden" name="perm[', $hidden_perm[0], '][', $hidden_perm[1], ']" value="', $hidden_perm[2], '">';
556
+	}
533 557
 
534 558
 	echo '
535 559
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -556,17 +580,19 @@  discard block
 block discarded – undo
556 580
 
557 581
 		foreach ($column as $permissionGroup)
558 582
 		{
559
-			if (empty($permissionGroup['permissions']))
560
-				continue;
583
+			if (empty($permissionGroup['permissions'])) {
584
+							continue;
585
+			}
561 586
 
562 587
 			// Are we likely to have something in this group to display or is it all hidden?
563 588
 			$has_display_content = false;
564 589
 			if (!$permissionGroup['hidden'])
565 590
 			{
566 591
 				// Before we go any further check we are going to have some data to print otherwise we just have a silly heading.
567
-				foreach ($permissionGroup['permissions'] as $permission)
568
-					if (!$permission['hidden'])
592
+				foreach ($permissionGroup['permissions'] as $permission) {
593
+									if (!$permission['hidden'])
569 594
 						$has_display_content = true;
595
+				}
570 596
 
571 597
 				if ($has_display_content)
572 598
 				{
@@ -575,10 +601,11 @@  discard block
 block discarded – undo
575 601
 							<th></th>
576 602
 							<th', $context['group']['id'] == -1 ? ' colspan="2"' : '', ' class="smalltext">', $permissionGroup['name'], '</th>';
577 603
 
578
-					if ($context['group']['id'] != -1)
579
-						echo '
604
+					if ($context['group']['id'] != -1) {
605
+											echo '
580 606
 							<th>', $txt['permissions_option_own'], '</th>
581 607
 							<th>', $txt['permissions_option_any'], '</th>';
608
+					}
582 609
 
583 610
 					echo '
584 611
 						</tr>';
@@ -601,17 +628,18 @@  discard block
 block discarded – undo
601 628
 						// Guests can't do their own thing.
602 629
 						if ($context['group']['id'] != -1)
603 630
 						{
604
-							if (empty($modSettings['permission_enable_deny']))
605
-								echo '
631
+							if (empty($modSettings['permission_enable_deny'])) {
632
+															echo '
606 633
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']"', $permission['own']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" id="', $permission['own']['id'], '_on" ', $disable_field, '>';
607
-							else
634
+							} else
608 635
 							{
609 636
 								echo '
610 637
 								<select name="perm[', $permission_type['id'], '][', $permission['own']['id'], ']" ', $disable_field, '>';
611 638
 
612
-								foreach (array('on', 'off', 'deny') as $c)
613
-									echo '
639
+								foreach (array('on', 'off', 'deny') as $c) {
640
+																	echo '
614 641
 									<option ', $permission['own']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
642
+								}
615 643
 								echo '
616 644
 								</select>';
617 645
 							}
@@ -621,39 +649,41 @@  discard block
 block discarded – undo
621 649
 							<td>';
622 650
 						}
623 651
 
624
-						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
625
-							echo '
652
+						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) {
653
+													echo '
626 654
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']"', $permission['any']['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '>';
627
-						else
655
+						} else
628 656
 						{
629 657
 							echo '
630 658
 								<select name="perm[', $permission_type['id'], '][', $permission['any']['id'], ']" ', $disable_field, '>';
631 659
 
632
-							foreach (array('on', 'off', 'deny') as $c)
633
-								echo '
660
+							foreach (array('on', 'off', 'deny') as $c) {
661
+															echo '
634 662
 									<option ', $permission['any']['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
663
+							}
635 664
 							echo '
636 665
 								</select>';
637 666
 						}
638
-					}
639
-					else
667
+					} else
640 668
 					{
641
-						if ($context['group']['id'] != -1)
642
-							echo '
669
+						if ($context['group']['id'] != -1) {
670
+													echo '
643 671
 							</td>
644 672
 							<td>';
673
+						}
645 674
 
646
-						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1)
647
-							echo '
675
+						if (empty($modSettings['permission_enable_deny']) || $context['group']['id'] == -1) {
676
+													echo '
648 677
 								<input type="checkbox" name="perm[', $permission_type['id'], '][', $permission['id'], ']"', $permission['select'] == 'on' ? ' checked="checked"' : '', ' value="on" ', $disable_field, '>';
649
-						else
678
+						} else
650 679
 						{
651 680
 							echo '
652 681
 								<select name="perm[', $permission_type['id'], '][', $permission['id'], ']" ', $disable_field, '>';
653 682
 
654
-							foreach (array('on', 'off', 'deny') as $c)
655
-								echo '
683
+							foreach (array('on', 'off', 'deny') as $c) {
684
+															echo '
656 685
 									<option ', $permission['select'] == $c ? ' selected' : '', ' value="', $c, '">', $txt['permissions_option_' . $c], '</option>';
686
+							}
657 687
 							echo '
658 688
 								</select>';
659 689
 						}
@@ -685,11 +715,11 @@  discard block
 block discarded – undo
685 715
 											<fieldset id="', $context['current_permission'], '">
686 716
 												<legend><a href="javascript:void(0);" onclick="document.getElementById(\'', $context['current_permission'], '\').style.display = \'none\';document.getElementById(\'', $context['current_permission'], '_groups_link\').style.display = \'block\'; return false;" class="toggle_up"> ', $txt['avatar_select_permission'], '</a></legend>';
687 717
 
688
-	if (empty($modSettings['permission_enable_deny']))
689
-		echo '
718
+	if (empty($modSettings['permission_enable_deny'])) {
719
+			echo '
690 720
 												<ul>';
691
-	else
692
-		echo '
721
+	} else {
722
+			echo '
693 723
 												<div class="information">', $txt['permissions_option_desc'], '</div>
694 724
 												<dl class="settings">
695 725
 													<dt>
@@ -699,47 +729,52 @@  discard block
 block discarded – undo
699 729
 													</dt>
700 730
 													<dd>
701 731
 													</dd>';
732
+	}
702 733
 
703 734
 	foreach ($context['member_groups'] as $group)
704 735
 	{
705
-		if (!empty($modSettings['permission_enable_deny']))
706
-			echo '
736
+		if (!empty($modSettings['permission_enable_deny'])) {
737
+					echo '
707 738
 													<dt>';
708
-		else
709
-			echo '
739
+		} else {
740
+					echo '
710 741
 													<li>';
742
+		}
711 743
 
712
-		if (empty($modSettings['permission_enable_deny']))
713
-			echo '
744
+		if (empty($modSettings['permission_enable_deny'])) {
745
+					echo '
714 746
 														<input type="checkbox" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '>';
715
-		else
716
-			echo '
747
+		} else {
748
+					echo '
717 749
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="on"', $group['status'] == 'on' ? ' checked' : '', '></span>
718 750
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="off"', $group['status'] == 'off' ? ' checked' : '', '></span>
719 751
 														<span class="perms"><input type="radio" name="', $context['current_permission'], '[', $group['id'], ']" value="deny"', $group['status'] == 'deny' ? ' checked' : '', '></span>';
752
+		}
720 753
 
721
-		if (!empty($modSettings['permission_enable_deny']))
722
-			echo '
754
+		if (!empty($modSettings['permission_enable_deny'])) {
755
+					echo '
723 756
 													</dt>
724 757
 													<dd>
725 758
 														<span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
726 759
 													</dd>';
727
-		else
728
-			echo '
760
+		} else {
761
+					echo '
729 762
 														<span', $group['is_postgroup'] ? ' style="font-style: italic;"' : '', '>', $group['name'], '</span>
730 763
 													</li>';
764
+		}
731 765
 	}
732 766
 
733
-	if (empty($modSettings['permission_enable_deny']))
734
-		echo '
767
+	if (empty($modSettings['permission_enable_deny'])) {
768
+			echo '
735 769
 													<li>
736 770
 														<input type="checkbox" onclick="invertAll(this, this.form, \''. $context['current_permission'] . '[\');">
737 771
 														<span>', $txt['check_all'], '</span>
738 772
 													</li>
739 773
 												</ul>';
740
-	else
741
-		echo '
774
+	} else {
775
+			echo '
742 776
 												</dl>';
777
+	}
743 778
 
744 779
 	echo '
745 780
 											</fieldset>
@@ -779,9 +814,10 @@  discard block
 block discarded – undo
779 814
 	if (!empty($modSettings['postmod_active']))
780 815
 	{
781 816
 		// Got advanced permissions - if so warn!
782
-		if (!empty($modSettings['permission_enable_deny']))
783
-			echo '
817
+		if (!empty($modSettings['permission_enable_deny'])) {
818
+					echo '
784 819
 							<div class="information">', $txt['permissions_post_moderation_deny_note'], '</div>';
820
+		}
785 821
 
786 822
 		echo '
787 823
 							<div class="padding">
@@ -796,10 +832,11 @@  discard block
 block discarded – undo
796 832
 									', $txt['permissions_post_moderation_select'], ':
797 833
 									<select name="pid" onchange="document.forms.postmodForm.submit();">';
798 834
 
799
-		foreach ($context['profiles'] as $profile)
800
-			if ($profile['can_modify'])
835
+		foreach ($context['profiles'] as $profile) {
836
+					if ($profile['can_modify'])
801 837
 				echo '
802 838
 										<option value="', $profile['id'], '"', $profile['id'] == $context['current_profile'] ? ' selected' : '', '>', $profile['name'], '</option>';
839
+		}
803 840
 
804 841
 		echo '
805 842
 									</select>
@@ -820,11 +857,12 @@  discard block
 block discarded – undo
820 857
 											', $txt['permissions_post_moderation_replies_any'], '
821 858
 										</th>';
822 859
 
823
-		if ($modSettings['attachmentEnable'] == 1)
824
-			echo '
860
+		if ($modSettings['attachmentEnable'] == 1) {
861
+					echo '
825 862
 										<th class="centercol" colspan="3">
826 863
 											', $txt['permissions_post_moderation_attachments'], '
827 864
 										</th>';
865
+		}
828 866
 
829 867
 		echo '
830 868
 									</tr>
@@ -842,11 +880,12 @@  discard block
 block discarded – undo
842 880
 										<th><span class="generic_icons post_moderation_moderate"></span></th>
843 881
 										<th><span class="generic_icons post_moderation_deny"></span></th>';
844 882
 
845
-		if ($modSettings['attachmentEnable'] == 1)
846
-			echo '
883
+		if ($modSettings['attachmentEnable'] == 1) {
884
+					echo '
847 885
 										<th><span class="generic_icons post_moderation_allow"></span></th>
848 886
 										<th><span class="generic_icons post_moderation_moderate"></span></th>
849 887
 										<th><span class="generic_icons post_moderation_deny"></span></th>';
888
+		}
850 889
 
851 890
 		echo '
852 891
 									</tr>
@@ -860,10 +899,11 @@  discard block
 block discarded – undo
860 899
 										<td class="half_table">
861 900
 											<span ', ($group['color'] ? 'style="color: ' . $group['color'] . '"' : ''), '>', $group['name'], '</span>';
862 901
 
863
-				if (!empty($group['children']))
864
-					echo '
902
+				if (!empty($group['children'])) {
903
+									echo '
865 904
 											<br>
866 905
 											<span class="smalltext">', $txt['permissions_includes_inherited'], ': &quot;', implode('&quot;, &quot;', $group['children']), '&quot;</span>';
906
+				}
867 907
 
868 908
 				echo '
869 909
 										</td>
@@ -878,11 +918,11 @@  discard block
 block discarded – undo
878 918
 										</td>';
879 919
 
880 920
 				// Guests can't have "own" permissions
881
-				if ($group['id'] == '-1')
882
-					echo '
921
+				if ($group['id'] == '-1') {
922
+									echo '
883 923
 										<td colspan="3"></td>';
884
-				else
885
-					echo '
924
+				} else {
925
+									echo '
886 926
 										<td class="centercol">
887 927
 											<input type="radio" name="replies_own[', $group['id'], ']" value="allow"', $group['replies_own'] == 'allow' ? ' checked' : '', '>
888 928
 										</td>
@@ -892,6 +932,7 @@  discard block
 block discarded – undo
892 932
 										<td class="centercol">
893 933
 											<input type="radio" name="replies_own[', $group['id'], ']" value="disallow"', $group['replies_own'] == 'disallow' ? ' checked' : '', '>
894 934
 										</td>';
935
+				}
895 936
 
896 937
 				echo '
897 938
 										<td class="centercol">
@@ -904,8 +945,8 @@  discard block
 block discarded – undo
904 945
 											<input type="radio" name="replies_any[', $group['id'], ']" value="disallow"', $group['replies_any'] == 'disallow' ? ' checked' : '', '>
905 946
 										</td>';
906 947
 
907
-				if ($modSettings['attachmentEnable'] == 1)
908
-					echo '
948
+				if ($modSettings['attachmentEnable'] == 1) {
949
+									echo '
909 950
 										<td class="centercol">
910 951
 											<input type="radio" name="attachment[', $group['id'], ']" value="allow"', $group['attachment'] == 'allow' ? ' checked' : '', '>
911 952
 										</td>
@@ -915,6 +956,7 @@  discard block
 block discarded – undo
915 956
 										<td class="centercol">
916 957
 											<input type="radio" name="attachment[', $group['id'], ']" value="disallow"', $group['attachment'] == 'disallow' ? ' checked' : '', '>
917 958
 										</td>';
959
+				}
918 960
 
919 961
 				echo '
920 962
 									</tr>';
Please login to merge, or discard this patch.
Themes/default/ManageNews.template.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,9 +18,10 @@  discard block
 block discarded – undo
18 18
 	global $context, $txt, $scripturl;
19 19
 
20 20
 	// Are we done sending the newsletter?
21
-	if (!empty($context['newsletter_sent']))
22
-		echo '
21
+	if (!empty($context['newsletter_sent'])) {
22
+			echo '
23 23
 	<div class="infobox">', $txt['admin_news_newsletter_' . $context['newsletter_sent']], '</div>';
24
+	}
24 25
 
25 26
 	echo '
26 27
 		<form action="', $scripturl, '?action=admin;area=news;sa=mailingcompose" method="post" id="admin_newsletters" class="flow_hidden" accept-charset="', $context['character_set'], '">
@@ -38,9 +39,10 @@  discard block
 block discarded – undo
38 39
 					</dt>
39 40
 					<dd>';
40 41
 
41
-	foreach ($context['groups'] as $group)
42
-		echo '
42
+	foreach ($context['groups'] as $group) {
43
+			echo '
43 44
 						<label for="groups_', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups_', $group['id'], '" value="', $group['id'], '" checked> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>';
45
+	}
44 46
 
45 47
 	echo '
46 48
 						<br>
@@ -79,9 +81,10 @@  discard block
 block discarded – undo
79 81
 						</dt>
80 82
 						<dd>';
81 83
 
82
-	foreach ($context['groups'] as $group)
83
-		echo '
84
+	foreach ($context['groups'] as $group) {
85
+			echo '
84 86
 							<label for="exclude_groups_', $group['id'], '"><input type="checkbox" name="exclude_groups[', $group['id'], ']" id="exclude_groups_', $group['id'], '" value="', $group['id'], '"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>';
87
+	}
85 88
 
86 89
 	echo '
87 90
 							<br>
@@ -225,9 +228,10 @@  discard block
 block discarded – undo
225 228
 				<div id="bbcBox_message"></div>';
226 229
 
227 230
 	// What about smileys?
228
-	if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
229
-		echo '
231
+	if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
232
+			echo '
230 233
 				<div id="smileyBox_message"></div>';
234
+	}
231 235
 
232 236
 	// Show BBC buttons, smileys and textbox.
233 237
 	echo '
@@ -248,9 +252,10 @@  discard block
 block discarded – undo
248 252
 			<input type="hidden" name="email_force" value="', $context['email_force'], '">
249 253
 			<input type="hidden" name="total_emails" value="', $context['total_emails'], '">';
250 254
 
251
-	foreach ($context['recipients'] as $key => $values)
252
-		echo '
255
+	foreach ($context['recipients'] as $key => $values) {
256
+			echo '
253 257
 			<input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">';
258
+	}
254 259
 
255 260
 	echo '
256 261
 			<script>';
@@ -404,9 +409,10 @@  discard block
 block discarded – undo
404 409
 				<input type="hidden" name="parse_html" value="', $context['parse_html'], '">';
405 410
 
406 411
 	// All the things we must remember!
407
-	foreach ($context['recipients'] as $key => $values)
408
-		echo '
412
+	foreach ($context['recipients'] as $key => $values) {
413
+			echo '
409 414
 				<input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">';
415
+	}
410 416
 
411 417
 	echo '
412 418
 			</div><!-- .windowbg -->
@@ -438,9 +444,10 @@  discard block
 block discarded – undo
438 444
 {
439 445
 	global $context, $txt;
440 446
 
441
-	if (!empty($context['saved_successful']))
442
-		echo '
447
+	if (!empty($context['saved_successful'])) {
448
+			echo '
443 449
 			<div class="infobox">', $txt['settings_saved'], '</div>';
450
+	}
444 451
 
445 452
 	template_show_list('news_lists');
446 453
 }
Please login to merge, or discard this patch.