Completed
Push — release-2.1 ( 723428...aa21c4 )
by Mathias
14s
created
Sources/Notify.php 1 patch
Braces   +23 added lines, -20 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
  * Turn off/on notification for a particular board.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	is_not_guest();
35 36
 
36 37
 	// You have to specify a board to turn notifications on!
37
-	if (empty($board))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($board)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// No subaction: find out what to do.
41 43
 	if (isset($_GET['mode']))
@@ -48,16 +50,16 @@  discard block
 block discarded – undo
48 50
 		require_once($sourcedir . '/Subs-Notify.php');
49 51
 		setNotifyPrefs($user_info['id'], array('board_notify_' . $board => $alertPref));
50 52
 
51
-		if ($mode > 1)
52
-			// Turn notification on.  (note this just blows smoke if it's already on.)
53
+		if ($mode > 1) {
54
+					// Turn notification on.  (note this just blows smoke if it's already on.)
53 55
 			$smcFunc['db_insert']('ignore',
54 56
 				'{db_prefix}log_notify',
55 57
 				array('id_member' => 'int', 'id_board' => 'int'),
56 58
 				array($user_info['id'], $board),
57 59
 				array('id_member', 'id_board')
58 60
 			);
59
-		else
60
-			$smcFunc['db_query']('', '
61
+		} else {
62
+					$smcFunc['db_query']('', '
61 63
 				DELETE FROM {db_prefix}log_notify
62 64
 				WHERE id_member = {int:current_member}
63 65
 				AND id_board = {int:current_board}',
@@ -66,6 +68,7 @@  discard block
 block discarded – undo
66 68
 					'current_member' => $user_info['id'],
67 69
 				)
68 70
 			);
71
+		}
69 72
 
70 73
 	}
71 74
 
@@ -81,10 +84,10 @@  discard block
 block discarded – undo
81 84
 			),
82 85
 		);
83 86
 		$context['sub_template'] = 'generic_xml';
87
+	} else {
88
+			redirectexit('board=' . $board . '.' . $_REQUEST['start']);
89
+	}
84 90
 	}
85
-	else
86
-		redirectexit('board=' . $board . '.' . $_REQUEST['start']);
87
-}
88 91
 
89 92
 /**
90 93
  * Turn off/on unread replies subscription for a topic as well as sets individual topic's alert preferences
@@ -108,8 +111,9 @@  discard block
 block discarded – undo
108 111
 			$mode = (int) $_GET['mode'];
109 112
 			$alertPref = $mode <= 1 ? 0 : ($mode == 2 ? 1 : 3);
110 113
 
111
-			if (empty($mode))
112
-				$mode = 1;
114
+			if (empty($mode)) {
115
+							$mode = 1;
116
+			}
113 117
 
114 118
 			$request = $smcFunc['db_query']('', '
115 119
 				SELECT id_member, id_topic, id_msg, unwatched
@@ -132,8 +136,7 @@  discard block
 block discarded – undo
132 136
 					'id_msg' => 0,
133 137
 					'unwatched' => empty($mode) ? 1 : 0,
134 138
 				);
135
-			}
136
-			else
139
+			} else
137 140
 			{
138 141
 				$insert = false;
139 142
 				$log['unwatched'] = empty($mode) ? 1 : 0;
@@ -160,9 +163,8 @@  discard block
 block discarded – undo
160 163
 					array($user_info['id'], $log['id_topic']),
161 164
 					array('id_member', 'id_board')
162 165
 				);
163
-			}
164
-			else
165
-				$smcFunc['db_query']('', '
166
+			} else {
167
+							$smcFunc['db_query']('', '
166 168
 					DELETE FROM {db_prefix}log_notify
167 169
 					WHERE id_topic = {int:topic}
168 170
 						AND id_member = {int:member}',
@@ -170,6 +172,7 @@  discard block
 block discarded – undo
170 172
 						'topic' => $log['id_topic'],
171 173
 						'member' => $user_info['id'],
172 174
 					));
175
+			}
173 176
 
174 177
 		}
175 178
 	}
@@ -186,9 +189,9 @@  discard block
 block discarded – undo
186 189
 			),
187 190
 		);
188 191
 		$context['sub_template'] = 'generic_xml';
192
+	} else {
193
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
194
+	}
189 195
 	}
190
-	else
191
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
192
-}
193 196
 
194 197
 ?>
195 198
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ShowAttachments.php 1 patch
Braces   +59 added lines, -52 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Shows an avatar based on $_GET['attach']
@@ -35,11 +36,11 @@  discard block
 block discarded – undo
35 36
 
36 37
 	if (!empty($modSettings['enableCompressedOutput']) && !headers_sent() && ob_get_length() == 0)
37 38
 	{
38
-		if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler')
39
-			$modSettings['enableCompressedOutput'] = 0;
40
-
41
-		else
42
-			ob_start('ob_gzhandler');
39
+		if (@ini_get('zlib.output_compression') == '1' || @ini_get('output_handler') == 'ob_gzhandler') {
40
+					$modSettings['enableCompressedOutput'] = 0;
41
+		} else {
42
+					ob_start('ob_gzhandler');
43
+		}
43 44
 	}
44 45
 
45 46
 	if (empty($modSettings['enableCompressedOutput']))
@@ -71,8 +72,9 @@  discard block
 block discarded – undo
71 72
 	}
72 73
 
73 74
 	// Use cache when possible.
74
-	if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null)
75
-		list($file, $thumbFile) = $cache;
75
+	if (($cache = cache_get_data('attachment_lookup_id-' . $attachId)) != null) {
76
+			list($file, $thumbFile) = $cache;
77
+	}
76 78
 
77 79
 	// Get the info from the DB.
78 80
 	if (empty($file) || empty($thumbFile) && !empty($file['id_thumb']))
@@ -80,10 +82,9 @@  discard block
 block discarded – undo
80 82
 		// Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request.
81 83
 		$attachRequest = null;
82 84
 		call_integration_hook('integrate_download_request', array(&$attachRequest));
83
-		if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest))
84
-			$request = $attachRequest;
85
-
86
-		else
85
+		if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) {
86
+					$request = $attachRequest;
87
+		} else
87 88
 		{
88 89
 			// Make sure this attachment is on this board and load its info while we are at it.
89 90
 			$request = $smcFunc['db_query']('', '
@@ -176,13 +177,15 @@  discard block
 block discarded – undo
176 177
 		}
177 178
 
178 179
 		// Cache it.
179
-		if (!empty($file) || !empty($thumbFile))
180
-			cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900));
180
+		if (!empty($file) || !empty($thumbFile)) {
181
+					cache_put_data('attachment_lookup_id-' . $file['id_attach'], array($file, $thumbFile), mt_rand(850, 900));
182
+		}
181 183
 	}
182 184
 
183 185
 	// Replace the normal file with its thumbnail if it has one!
184
-	if (!empty($showThumb) && !empty($thumbFile))
185
-		$file = $thumbFile;
186
+	if (!empty($showThumb) && !empty($thumbFile)) {
187
+			$file = $thumbFile;
188
+	}
186 189
 
187 190
 	// No point in a nicer message, because this is supposed to be an attachment anyway...
188 191
 	if (!file_exists($file['filePath']))
@@ -232,8 +235,8 @@  discard block
 block discarded – undo
232 235
 	}
233 236
 
234 237
 	// Update the download counter (unless it's a thumbnail or resuming an incomplete download).
235
-	if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0)
236
-		$smcFunc['db_query']('attach_download_increase', '
238
+	if ($file['attachment_type'] != 3 && empty($showThumb) && $range === 0) {
239
+			$smcFunc['db_query']('attach_download_increase', '
237 240
 			UPDATE LOW_PRIORITY {db_prefix}attachments
238 241
 			SET downloads = downloads + 1
239 242
 			WHERE id_attach = {int:id_attach}',
@@ -241,12 +244,14 @@  discard block
 block discarded – undo
241 244
 				'id_attach' => $attachId,
242 245
 			)
243 246
 		);
247
+	}
244 248
 
245 249
 	// Send the attachment headers.
246 250
 	header('Pragma: ');
247 251
 
248
-	if (!isBrowser('gecko'))
249
-		header('Content-Transfer-Encoding: binary');
252
+	if (!isBrowser('gecko')) {
253
+			header('Content-Transfer-Encoding: binary');
254
+	}
250 255
 
251 256
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
252 257
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($file['filePath'])) . ' GMT');
@@ -255,18 +260,19 @@  discard block
 block discarded – undo
255 260
 	header('ETag: ' . $eTag);
256 261
 
257 262
 	// Make sure the mime type warrants an inline display.
258
-	if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0)
259
-		unset($_REQUEST['image']);
263
+	if (isset($_REQUEST['image']) && !empty($file['mime_type']) && strpos($file['mime_type'], 'image/') !== 0) {
264
+			unset($_REQUEST['image']);
265
+	}
260 266
 
261 267
 	// Does this have a mime type?
262
-	elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff'))))
263
-		header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp')));
264
-
265
-	else
268
+	elseif (!empty($file['mime_type']) && (isset($_REQUEST['image']) || !in_array($file['fileext'], array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) {
269
+			header('Content-Type: ' . strtr($file['mime_type'], array('image/bmp' => 'image/x-ms-bmp')));
270
+	} else
266 271
 	{
267 272
 		header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
268
-		if (isset($_REQUEST['image']))
269
-			unset($_REQUEST['image']);
273
+		if (isset($_REQUEST['image'])) {
274
+					unset($_REQUEST['image']);
275
+		}
270 276
 	}
271 277
 
272 278
 	// Convert the file to UTF-8, cuz most browsers dig that.
@@ -274,24 +280,22 @@  discard block
 block discarded – undo
274 280
 	$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
275 281
 
276 282
 	// Different browsers like different standards...
277
-	if (isBrowser('firefox'))
278
-		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
279
-
280
-	elseif (isBrowser('opera'))
281
-		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
282
-
283
-	elseif (isBrowser('ie'))
284
-		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
285
-
286
-	else
287
-		header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
283
+	if (isBrowser('firefox')) {
284
+			header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
285
+	} elseif (isBrowser('opera')) {
286
+			header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
287
+	} elseif (isBrowser('ie')) {
288
+			header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
289
+	} else {
290
+			header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
291
+	}
288 292
 
289 293
 	// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
290
-	if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff')))
291
-		header('Cache-Control: no-cache');
292
-
293
-	else
294
-		header('Cache-Control: max-age=' . (525600 * 60) . ', private');
294
+	if (!isset($_REQUEST['image']) && in_array($file['fileext'], array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) {
295
+			header('Cache-Control: no-cache');
296
+	} else {
297
+			header('Cache-Control: max-age=' . (525600 * 60) . ', private');
298
+	}
295 299
 
296 300
 	// Multipart and resuming support
297 301
 	if (isset($_SERVER['HTTP_RANGE']))
@@ -299,9 +303,9 @@  discard block
 block discarded – undo
299 303
 		header("HTTP/1.1 206 Partial Content");
300 304
 		header("Content-Length: $new_length");
301 305
 		header("Content-Range: bytes $range-$range_end/$size");
306
+	} else {
307
+			header("Content-Length: " . $size);
302 308
 	}
303
-	else
304
-		header("Content-Length: " . $size);
305 309
 
306 310
 
307 311
 	// Try to buy some time...
@@ -310,8 +314,9 @@  discard block
 block discarded – undo
310 314
 	// For multipart/resumable downloads, send the requested chunk(s) of the file
311 315
 	if (isset($_SERVER['HTTP_RANGE']))
312 316
 	{
313
-		while (@ob_get_level() > 0)
314
-			@ob_end_clean();
317
+		while (@ob_get_level() > 0) {
318
+					@ob_end_clean();
319
+		}
315 320
 
316 321
 		// 40 kilobytes is a good-ish amount
317 322
 		$chunksize = 40 * 1024;
@@ -335,8 +340,9 @@  discard block
 block discarded – undo
335 340
 	elseif ($size > 4194304)
336 341
 	{
337 342
 		// Forcibly end any output buffering going on.
338
-		while (@ob_get_level() > 0)
339
-			@ob_end_clean();
343
+		while (@ob_get_level() > 0) {
344
+					@ob_end_clean();
345
+		}
340 346
 
341 347
 		$fp = fopen($file['filePath'], 'rb');
342 348
 		while (!feof($fp))
@@ -348,8 +354,9 @@  discard block
 block discarded – undo
348 354
 	}
349 355
 
350 356
 	// On some of the less-bright hosts, readfile() is disabled.  It's just a faster, more byte safe, version of what's in the if.
351
-	elseif (@readfile($file['filePath']) === null)
352
-		echo file_get_contents($file['filePath']);
357
+	elseif (@readfile($file['filePath']) === null) {
358
+			echo file_get_contents($file['filePath']);
359
+	}
353 360
 
354 361
 	die();
355 362
 }
Please login to merge, or discard this patch.
Sources/MoveTopic.php 1 patch
Braces   +101 added lines, -72 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
  * This function allows to move a topic, making sure to ask the moderator
@@ -32,8 +33,9 @@  discard block
 block discarded – undo
32 33
 {
33 34
 	global $txt, $board, $topic, $user_info, $context, $language, $scripturl, $smcFunc, $modSettings, $sourcedir;
34 35
 
35
-	if (empty($topic))
36
-		fatal_lang_error('no_access', false);
36
+	if (empty($topic)) {
37
+			fatal_lang_error('no_access', false);
38
+	}
37 39
 
38 40
 	$request = $smcFunc['db_query']('', '
39 41
 		SELECT t.id_member_started, ms.subject, t.approved
@@ -49,8 +51,9 @@  discard block
 block discarded – undo
49 51
 	$smcFunc['db_free_result']($request);
50 52
 
51 53
 	// Can they see it - if not approved?
52
-	if ($modSettings['postmod_active'] && !$context['is_approved'])
53
-		isAllowedTo('approve_posts');
54
+	if ($modSettings['postmod_active'] && !$context['is_approved']) {
55
+			isAllowedTo('approve_posts');
56
+	}
54 57
 
55 58
 	// Permission check!
56 59
 	// @todo
@@ -59,9 +62,9 @@  discard block
 block discarded – undo
59 62
 		if ($id_member_started == $user_info['id'])
60 63
 		{
61 64
 			isAllowedTo('move_own');
65
+		} else {
66
+					isAllowedTo('move_any');
62 67
 		}
63
-		else
64
-			isAllowedTo('move_any');
65 68
 	}
66 69
 
67 70
 	$context['move_any'] = $user_info['is_admin'] || $modSettings['topic_move_any'];
@@ -83,11 +86,13 @@  discard block
 block discarded – undo
83 86
 		'not_redirection' => true,
84 87
 	);
85 88
 
86
-	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board)
87
-		$options['selected_board'] = $_SESSION['move_to_topic'];
89
+	if (!empty($_SESSION['move_to_topic']) && $_SESSION['move_to_topic'] != $board) {
90
+			$options['selected_board'] = $_SESSION['move_to_topic'];
91
+	}
88 92
 
89
-	if (!$context['move_any'])
90
-		$options['included_boards'] = $boards;
93
+	if (!$context['move_any']) {
94
+			$options['included_boards'] = $boards;
95
+	}
91 96
 
92 97
 	require_once($sourcedir . '/Subs-MessageIndex.php');
93 98
 	$context['categories'] = getBoardList($options);
@@ -138,12 +143,14 @@  discard block
 block discarded – undo
138 143
 	global $txt, $topic, $scripturl, $sourcedir, $context;
139 144
 	global $board, $language, $user_info, $smcFunc;
140 145
 
141
-	if (empty($topic))
142
-		fatal_lang_error('no_access', false);
146
+	if (empty($topic)) {
147
+			fatal_lang_error('no_access', false);
148
+	}
143 149
 
144 150
 	// You can't choose to have a redirection topic and use an empty reason.
145
-	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == ''))
146
-		fatal_lang_error('movetopic_no_reason', false);
151
+	if (isset($_POST['postRedirect']) && (!isset($_POST['reason']) || trim($_POST['reason']) == '')) {
152
+			fatal_lang_error('movetopic_no_reason', false);
153
+	}
147 154
 
148 155
 	moveTopicConcurrence();
149 156
 
@@ -163,16 +170,18 @@  discard block
 block discarded – undo
163 170
 	$smcFunc['db_free_result']($request);
164 171
 
165 172
 	// Can they see it?
166
-	if (!$context['is_approved'])
167
-		isAllowedTo('approve_posts');
173
+	if (!$context['is_approved']) {
174
+			isAllowedTo('approve_posts');
175
+	}
168 176
 
169 177
 	// Can they move topics on this board?
170 178
 	if (!allowedTo('move_any'))
171 179
 	{
172
-		if ($id_member_started == $user_info['id'])
173
-			isAllowedTo('move_own');
174
-		else
175
-			isAllowedTo('move_any');
180
+		if ($id_member_started == $user_info['id']) {
181
+					isAllowedTo('move_own');
182
+		} else {
183
+					isAllowedTo('move_any');
184
+		}
176 185
 	}
177 186
 
178 187
 	checkSession();
@@ -197,8 +206,9 @@  discard block
 block discarded – undo
197 206
 			'blank_redirect' => '',
198 207
 		)
199 208
 	);
200
-	if ($smcFunc['db_num_rows']($request) == 0)
201
-		fatal_lang_error('no_board');
209
+	if ($smcFunc['db_num_rows']($request) == 0) {
210
+			fatal_lang_error('no_board');
211
+	}
202 212
 	list ($pcounter, $board_name, $subject) = $smcFunc['db_fetch_row']($request);
203 213
 	$smcFunc['db_free_result']($request);
204 214
 
@@ -210,8 +220,9 @@  discard block
 block discarded – undo
210 220
 	{
211 221
 		$_POST['custom_subject'] = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
212 222
 		// Keep checking the length.
213
-		if ($smcFunc['strlen']($_POST['custom_subject']) > 100)
214
-			$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
223
+		if ($smcFunc['strlen']($_POST['custom_subject']) > 100) {
224
+					$_POST['custom_subject'] = $smcFunc['substr']($_POST['custom_subject'], 0, 100);
225
+		}
215 226
 
216 227
 		// If it's still valid move onwards and upwards.
217 228
 		if ($_POST['custom_subject'] != '')
@@ -221,9 +232,9 @@  discard block
 block discarded – undo
221 232
 				// Get a response prefix, but in the forum's default language.
222 233
 				if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
223 234
 				{
224
-					if ($language === $user_info['language'])
225
-						$context['response_prefix'] = $txt['response_prefix'];
226
-					else
235
+					if ($language === $user_info['language']) {
236
+											$context['response_prefix'] = $txt['response_prefix'];
237
+					} else
227 238
 					{
228 239
 						loadLanguage('index', $language, false);
229 240
 						$context['response_prefix'] = $txt['response_prefix'];
@@ -263,8 +274,9 @@  discard block
 block discarded – undo
263 274
 	if (isset($_POST['postRedirect']))
264 275
 	{
265 276
 		// Should be in the boardwide language.
266
-		if ($user_info['language'] != $language)
267
-			loadLanguage('index', $language);
277
+		if ($user_info['language'] != $language) {
278
+					loadLanguage('index', $language);
279
+		}
268 280
 
269 281
 		$_POST['reason'] = $smcFunc['htmlspecialchars']($_POST['reason'], ENT_QUOTES);
270 282
 		preparsecode($_POST['reason']);
@@ -328,8 +340,9 @@  discard block
 block discarded – undo
328 340
 		$posters = array();
329 341
 		while ($row = $smcFunc['db_fetch_assoc']($request))
330 342
 		{
331
-			if (!isset($posters[$row['id_member']]))
332
-				$posters[$row['id_member']] = 0;
343
+			if (!isset($posters[$row['id_member']])) {
344
+							$posters[$row['id_member']] = 0;
345
+			}
333 346
 
334 347
 			$posters[$row['id_member']]++;
335 348
 		}
@@ -338,11 +351,13 @@  discard block
 block discarded – undo
338 351
 		foreach ($posters as $id_member => $posts)
339 352
 		{
340 353
 			// The board we're moving from counted posts, but not to.
341
-			if (empty($pcounter_from))
342
-				updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
354
+			if (empty($pcounter_from)) {
355
+							updateMemberData($id_member, array('posts' => 'posts - ' . $posts));
356
+			}
343 357
 			// The reverse: from didn't, to did.
344
-			else
345
-				updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
358
+			else {
359
+							updateMemberData($id_member, array('posts' => 'posts + ' . $posts));
360
+			}
346 361
 		}
347 362
 	}
348 363
 
@@ -350,17 +365,19 @@  discard block
 block discarded – undo
350 365
 	moveTopics($topic, $_POST['toboard']);
351 366
 
352 367
 	// Log that they moved this topic.
353
-	if (!allowedTo('move_own') || $id_member_started != $user_info['id'])
354
-		logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
368
+	if (!allowedTo('move_own') || $id_member_started != $user_info['id']) {
369
+			logAction('move', array('topic' => $topic, 'board_from' => $board, 'board_to' => $_POST['toboard']));
370
+	}
355 371
 	// Notify people that this topic has been moved?
356 372
 	sendNotifications($topic, 'move');
357 373
 
358 374
 	// Why not go back to the original board in case they want to keep moving?
359
-	if (!isset($_REQUEST['goback']))
360
-		redirectexit('board=' . $board . '.0');
361
-	else
362
-		redirectexit('topic=' . $topic . '.0');
363
-}
375
+	if (!isset($_REQUEST['goback'])) {
376
+			redirectexit('board=' . $board . '.0');
377
+	} else {
378
+			redirectexit('topic=' . $topic . '.0');
379
+	}
380
+	}
364 381
 
365 382
 /**
366 383
  * Moves one or more topics to a specific board. (doesn't check permissions.)
@@ -376,18 +393,21 @@  discard block
 block discarded – undo
376 393
 	global $sourcedir, $user_info, $modSettings, $smcFunc;
377 394
 
378 395
 	// Empty array?
379
-	if (empty($topics))
380
-		return;
396
+	if (empty($topics)) {
397
+			return;
398
+	}
381 399
 
382 400
 	// Only a single topic.
383
-	if (is_numeric($topics))
384
-		$topics = array($topics);
401
+	if (is_numeric($topics)) {
402
+			$topics = array($topics);
403
+	}
385 404
 
386 405
 	$fromBoards = array();
387 406
 
388 407
 	// Destination board empty or equal to 0?
389
-	if (empty($toBoard))
390
-		return;
408
+	if (empty($toBoard)) {
409
+			return;
410
+	}
391 411
 
392 412
 	// Are we moving to the recycle board?
393 413
 	$isRecycleDest = !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $toBoard;
@@ -395,8 +415,9 @@  discard block
 block discarded – undo
395 415
 	// Callback for search APIs to do their thing
396 416
 	require_once($sourcedir . '/Search.php');
397 417
 	$searchAPI = findSearchAPI();
398
-	if ($searchAPI->supportsMethod('topicsMoved'))
399
-		$searchAPI->topicsMoved($topics, $toBoard);
418
+	if ($searchAPI->supportsMethod('topicsMoved')) {
419
+			$searchAPI->topicsMoved($topics, $toBoard);
420
+	}
400 421
 
401 422
 	// Determine the source boards...
402 423
 	$request = $smcFunc['db_query']('', '
@@ -410,8 +431,9 @@  discard block
 block discarded – undo
410 431
 		)
411 432
 	);
412 433
 	// Num of rows = 0 -> no topics found. Num of rows > 1 -> topics are on multiple boards.
413
-	if ($smcFunc['db_num_rows']($request) == 0)
414
-		return;
434
+	if ($smcFunc['db_num_rows']($request) == 0) {
435
+			return;
436
+	}
415 437
 	while ($row = $smcFunc['db_fetch_assoc']($request))
416 438
 	{
417 439
 		if (!isset($fromBoards[$row['id_board']]['num_posts']))
@@ -429,10 +451,11 @@  discard block
 block discarded – undo
429 451
 		$fromBoards[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts'];
430 452
 
431 453
 		// Add the topics to the right type.
432
-		if ($row['approved'])
433
-			$fromBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
434
-		else
435
-			$fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
454
+		if ($row['approved']) {
455
+					$fromBoards[$row['id_board']]['num_topics'] += $row['num_topics'];
456
+		} else {
457
+					$fromBoards[$row['id_board']]['unapproved_topics'] += $row['num_topics'];
458
+		}
436 459
 	}
437 460
 	$smcFunc['db_free_result']($request);
438 461
 
@@ -558,13 +581,14 @@  discard block
 block discarded – undo
558 581
 			)
559 582
 		);
560 583
 		$approval_msgs = array();
561
-		while ($row = $smcFunc['db_fetch_assoc']($request))
562
-			$approval_msgs[] = $row['id_msg'];
584
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
585
+					$approval_msgs[] = $row['id_msg'];
586
+		}
563 587
 		$smcFunc['db_free_result']($request);
564 588
 
565 589
 		// Empty the approval queue for these, as we're going to approve them next.
566
-		if (!empty($approval_msgs))
567
-			$smcFunc['db_query']('', '
590
+		if (!empty($approval_msgs)) {
591
+					$smcFunc['db_query']('', '
568 592
 				DELETE FROM {db_prefix}approval_queue
569 593
 				WHERE id_msg IN ({array_int:message_list})
570 594
 					AND id_attach = {int:id_attach}',
@@ -573,6 +597,7 @@  discard block
 block discarded – undo
573 597
 					'id_attach' => 0,
574 598
 				)
575 599
 			);
600
+		}
576 601
 
577 602
 		// Get all the current max and mins.
578 603
 		$request = $smcFunc['db_query']('', '
@@ -606,8 +631,8 @@  discard block
 block discarded – undo
606 631
 		while ($row = $smcFunc['db_fetch_assoc']($request))
607 632
 		{
608 633
 			// If not, update.
609
-			if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max'])
610
-				$smcFunc['db_query']('', '
634
+			if ($row['first_msg'] != $topicMaxMin[$row['id_topic']]['min'] || $row['last_msg'] != $topicMaxMin[$row['id_topic']]['max']) {
635
+							$smcFunc['db_query']('', '
611 636
 					UPDATE {db_prefix}topics
612 637
 					SET id_first_msg = {int:first_msg}, id_last_msg = {int:last_msg}
613 638
 					WHERE id_topic = {int:selected_topic}',
@@ -617,6 +642,7 @@  discard block
 block discarded – undo
617 642
 						'selected_topic' => $row['id_topic'],
618 643
 					)
619 644
 				);
645
+			}
620 646
 		}
621 647
 		$smcFunc['db_free_result']($request);
622 648
 	}
@@ -675,9 +701,10 @@  discard block
 block discarded – undo
675 701
 	}
676 702
 
677 703
 	// Update the cache?
678
-	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3)
679
-		foreach ($topics as $topic_id)
704
+	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 3) {
705
+			foreach ($topics as $topic_id)
680 706
 			cache_put_data('topic_board-' . $topic_id, null, 120);
707
+	}
681 708
 
682 709
 	require_once($sourcedir . '/Subs-Post.php');
683 710
 
@@ -701,15 +728,17 @@  discard block
 block discarded – undo
701 728
 {
702 729
 	global $board, $topic, $smcFunc, $scripturl;
703 730
 
704
-	if (isset($_GET['current_board']))
705
-		$move_from = (int) $_GET['current_board'];
731
+	if (isset($_GET['current_board'])) {
732
+			$move_from = (int) $_GET['current_board'];
733
+	}
706 734
 
707
-	if (empty($move_from) || empty($board) || empty($topic))
708
-		return true;
735
+	if (empty($move_from) || empty($board) || empty($topic)) {
736
+			return true;
737
+	}
709 738
 
710
-	if ($move_from == $board)
711
-		return true;
712
-	else
739
+	if ($move_from == $board) {
740
+			return true;
741
+	} else
713 742
 	{
714 743
 		$request = $smcFunc['db_query']('', '
715 744
 			SELECT m.subject, b.name
Please login to merge, or discard this patch.
Sources/Display.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 		call_integration_hook('integrate_poll_buttons');
825 825
 	}
826 826
 	
827
-	if(!empty($_REQUEST['page_id']))
827
+	if (!empty($_REQUEST['page_id']))
828 828
 		$start_char = substr($_REQUEST['page_id'], 0, 1);
829 829
 	else
830 830
 		$start_char = null;
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
 			SELECT id_msg, id_member, approved
887 887
 			FROM {db_prefix}messages
888 888
 			WHERE id_topic = {int:current_topic} 
889
-			AND id_msg '. $page_operator . ' {int:page_id}'. (!$modSettings['postmod_active'] || $approve_posts ? '' : '
889
+			AND id_msg '. $page_operator . ' {int:page_id}' . (!$modSettings['postmod_active'] || $approve_posts ? '' : '
890 890
 			AND (approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR id_member = {int:current_member}') . ')') . '
891 891
 			ORDER BY id_msg ' . ($ascending ? '' : 'DESC') . ($context['messages_per_page'] == -1 ? '' : '
892 892
 			LIMIT {int:limit}'),
Please login to merge, or discard this patch.
Braces   +349 added lines, -263 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
  * The central part of the board - topic display.
@@ -34,8 +35,9 @@  discard block
 block discarded – undo
34 35
 	global $messages_request, $language, $smcFunc;
35 36
 
36 37
 	// What are you gonna display if these are empty?!
37
-	if (empty($topic))
38
-		fatal_lang_error('no_board', false);
38
+	if (empty($topic)) {
39
+			fatal_lang_error('no_board', false);
40
+	}
39 41
 
40 42
 	// Load the proper template.
41 43
 	loadTemplate('Display');
@@ -52,15 +54,17 @@  discard block
 block discarded – undo
52 54
 	$context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
53 55
 
54 56
 	// Let's do some work on what to search index.
55
-	if (count($_GET) > 2)
56
-		foreach ($_GET as $k => $v)
57
+	if (count($_GET) > 2) {
58
+			foreach ($_GET as $k => $v)
57 59
 		{
58 60
 			if (!in_array($k, array('topic', 'board', 'start', session_name())))
59 61
 				$context['robot_no_index'] = true;
62
+	}
60 63
 		}
61 64
 
62
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
63
-		$context['robot_no_index'] = true;
65
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
66
+			$context['robot_no_index'] = true;
67
+	}
64 68
 
65 69
 	// Find the previous or next topic.  Make a fuss if there are no more.
66 70
 	if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next'))
@@ -172,8 +176,9 @@  discard block
 block discarded – undo
172 176
 			$topic_parameters
173 177
 	);
174 178
 
175
-	if ($smcFunc['db_num_rows']($request) == 0)
176
-		fatal_lang_error('not_a_topic', false, 404);
179
+	if ($smcFunc['db_num_rows']($request) == 0) {
180
+			fatal_lang_error('not_a_topic', false, 404);
181
+	}
177 182
 	$context['topicinfo'] = $smcFunc['db_fetch_assoc']($request);
178 183
 	$smcFunc['db_free_result']($request);
179 184
 
@@ -210,8 +215,9 @@  discard block
 block discarded – undo
210 215
 	$context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0;
211 216
 
212 217
 	// Add up unapproved replies to get real number of replies...
213
-	if ($modSettings['postmod_active'] && $approve_posts)
214
-		$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
218
+	if ($modSettings['postmod_active'] && $approve_posts) {
219
+			$context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1);
220
+	}
215 221
 
216 222
 	// If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing.
217 223
 	if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts)
@@ -231,11 +237,11 @@  discard block
 block discarded – undo
231 237
 		$smcFunc['db_free_result']($request);
232 238
 
233 239
 		$context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0);
240
+	} elseif ($user_info['is_guest']) {
241
+			$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
242
+	} else {
243
+			$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
234 244
 	}
235
-	elseif ($user_info['is_guest'])
236
-		$context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0);
237
-	else
238
-		$context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0);
239 245
 
240 246
 	// The start isn't a number; it's information about what to do, where to go.
241 247
 	if (!is_numeric($_REQUEST['start']))
@@ -248,8 +254,7 @@  discard block
 block discarded – undo
248 254
 			{
249 255
 				$context['start_from'] = $context['total_visible_posts'] - 1;
250 256
 				$_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0;
251
-			}
252
-			else
257
+			} else
253 258
 			{
254 259
 				// Find the earliest unread message in the topic. (the use of topics here is just for both tables.)
255 260
 				$request = $smcFunc['db_query']('', '
@@ -277,9 +282,9 @@  discard block
 block discarded – undo
277 282
 		if (substr($_REQUEST['start'], 0, 4) == 'from')
278 283
 		{
279 284
 			$timestamp = (int) substr($_REQUEST['start'], 4);
280
-			if ($timestamp === 0)
281
-				$_REQUEST['start'] = 0;
282
-			else
285
+			if ($timestamp === 0) {
286
+							$_REQUEST['start'] = 0;
287
+			} else
283 288
 			{
284 289
 				// Find the number of messages posted before said time...
285 290
 				$request = $smcFunc['db_query']('', '
@@ -307,11 +312,11 @@  discard block
 block discarded – undo
307 312
 		elseif (substr($_REQUEST['start'], 0, 3) == 'msg')
308 313
 		{
309 314
 			$virtual_msg = (int) substr($_REQUEST['start'], 3);
310
-			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg'])
311
-				$context['start_from'] = $context['total_visible_posts'] - 1;
312
-			elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg'])
313
-				$context['start_from'] = 0;
314
-			else
315
+			if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) {
316
+							$context['start_from'] = $context['total_visible_posts'] - 1;
317
+			} elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) {
318
+							$context['start_from'] = 0;
319
+			} else
315 320
 			{
316 321
 				// Find the start value for that message......
317 322
 				$request = $smcFunc['db_query']('', '
@@ -394,21 +399,25 @@  discard block
 block discarded – undo
394 399
 		);
395 400
 		while ($row = $smcFunc['db_fetch_assoc']($request))
396 401
 		{
397
-			if (empty($row['id_member']))
398
-				continue;
402
+			if (empty($row['id_member'])) {
403
+							continue;
404
+			}
399 405
 
400
-			if (!empty($row['online_color']))
401
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
402
-			else
403
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
406
+			if (!empty($row['online_color'])) {
407
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
408
+			} else {
409
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
410
+			}
404 411
 
405 412
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
406
-			if ($is_buddy)
407
-				$link = '<strong>' . $link . '</strong>';
413
+			if ($is_buddy) {
414
+							$link = '<strong>' . $link . '</strong>';
415
+			}
408 416
 
409 417
 			// Add them both to the list and to the more detailed list.
410
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
411
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
418
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
419
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
420
+			}
412 421
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
413 422
 				'id' => $row['id_member'],
414 423
 				'username' => $row['member_name'],
@@ -420,8 +429,9 @@  discard block
 block discarded – undo
420 429
 				'hidden' => empty($row['show_online']),
421 430
 			);
422 431
 
423
-			if (empty($row['show_online']))
424
-				$context['view_num_hidden']++;
432
+			if (empty($row['show_online'])) {
433
+							$context['view_num_hidden']++;
434
+			}
425 435
 		}
426 436
 
427 437
 		// The number of guests is equal to the rows minus the ones we actually used ;).
@@ -435,11 +445,13 @@  discard block
 block discarded – undo
435 445
 
436 446
 	// If all is set, but not allowed... just unset it.
437 447
 	$can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages'];
438
-	if (isset($_REQUEST['all']) && !$can_show_all)
439
-		unset($_REQUEST['all']);
448
+	if (isset($_REQUEST['all']) && !$can_show_all) {
449
+			unset($_REQUEST['all']);
450
+	}
440 451
 	// Otherwise, it must be allowed... so pretend start was -1.
441
-	elseif (isset($_REQUEST['all']))
442
-		$_REQUEST['start'] = -1;
452
+	elseif (isset($_REQUEST['all'])) {
453
+			$_REQUEST['start'] = -1;
454
+	}
443 455
 
444 456
 	// Construct allowing for the .START method...
445 457
 	$context['start'] = $_REQUEST['start'];
@@ -475,14 +487,16 @@  discard block
 block discarded – undo
475 487
 	if (!empty($board_info['moderators']))
476 488
 	{
477 489
 		// Add a link for each moderator...
478
-		foreach ($board_info['moderators'] as $mod)
479
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
490
+		foreach ($board_info['moderators'] as $mod) {
491
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
492
+		}
480 493
 	}
481 494
 	if (!empty($board_info['moderator_groups']))
482 495
 	{
483 496
 		// Add a link for each moderator group as well...
484
-		foreach ($board_info['moderator_groups'] as $mod_group)
485
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
497
+		foreach ($board_info['moderator_groups'] as $mod_group) {
498
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
499
+		}
486 500
 	}
487 501
 
488 502
 	if (!empty($context['link_moderators']))
@@ -513,9 +527,9 @@  discard block
 block discarded – undo
513 527
 	// For quick reply we need a response prefix in the default forum language.
514 528
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600)))
515 529
 	{
516
-		if ($language === $user_info['language'])
517
-			$context['response_prefix'] = $txt['response_prefix'];
518
-		else
530
+		if ($language === $user_info['language']) {
531
+					$context['response_prefix'] = $txt['response_prefix'];
532
+		} else
519 533
 		{
520 534
 			loadLanguage('index', $language, false);
521 535
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -547,8 +561,9 @@  discard block
 block discarded – undo
547 561
 			list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
548 562
 
549 563
 			// Sanity check
550
-			if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
551
-				continue;
564
+			if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
565
+							continue;
566
+			}
552 567
 
553 568
 			$linked_calendar_event = array(
554 569
 				'id' => $row['id_event'],
@@ -597,8 +612,9 @@  discard block
 block discarded – undo
597 612
 		}
598 613
 		$smcFunc['db_free_result']($request);
599 614
 
600
-		if (!empty($context['linked_calendar_events']))
601
-			$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
615
+		if (!empty($context['linked_calendar_events'])) {
616
+					$context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true;
617
+		}
602 618
 	}
603 619
 
604 620
 	// Create the poll info if it exists.
@@ -661,8 +677,9 @@  discard block
 block discarded – undo
661 677
 		$smcFunc['db_free_result']($request);
662 678
 		
663 679
 		// Got we multi choice?
664
-		if ($pollinfo['max_votes'] > 1)
665
-			$realtotal = $pollinfo['total'];
680
+		if ($pollinfo['max_votes'] > 1) {
681
+					$realtotal = $pollinfo['total'];
682
+		}
666 683
 
667 684
 		// If this is a guest we need to do our best to work out if they have voted, and what they voted for.
668 685
 		if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote'))
@@ -675,20 +692,21 @@  discard block
 block discarded – undo
675 692
 				foreach ($guestinfo as $i => $guestvoted)
676 693
 				{
677 694
 					$guestvoted = explode(',', $guestvoted);
678
-					if ($guestvoted[0] == $context['topicinfo']['id_poll'])
679
-						break;
695
+					if ($guestvoted[0] == $context['topicinfo']['id_poll']) {
696
+											break;
697
+					}
680 698
 				}
681 699
 				// Has the poll been reset since guest voted?
682 700
 				if ($pollinfo['reset_poll'] > $guestvoted[1])
683 701
 				{
684 702
 					// Remove the poll info from the cookie to allow guest to vote again
685 703
 					unset($guestinfo[$i]);
686
-					if (!empty($guestinfo))
687
-						$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
688
-					else
689
-						unset($_COOKIE['guest_poll_vote']);
690
-				}
691
-				else
704
+					if (!empty($guestinfo)) {
705
+											$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
706
+					} else {
707
+											unset($_COOKIE['guest_poll_vote']);
708
+					}
709
+				} else
692 710
 				{
693 711
 					// What did they vote for?
694 712
 					unset($guestvoted[0], $guestvoted[1]);
@@ -802,35 +820,43 @@  discard block
 block discarded – undo
802 820
 		// Build the poll moderation button array.
803 821
 		$context['poll_buttons'] = array();
804 822
 
805
-		if ($context['allow_return_vote'])
806
-			$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
823
+		if ($context['allow_return_vote']) {
824
+					$context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']);
825
+		}
807 826
 
808
-		if ($context['show_view_results_button'])
809
-			$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
827
+		if ($context['show_view_results_button']) {
828
+					$context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults');
829
+		}
810 830
 
811
-		if ($context['allow_change_vote'])
812
-			$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
831
+		if ($context['allow_change_vote']) {
832
+					$context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']);
833
+		}
813 834
 
814
-		if ($context['allow_lock_poll'])
815
-			$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
835
+		if ($context['allow_lock_poll']) {
836
+					$context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
837
+		}
816 838
 
817
-		if ($context['allow_edit_poll'])
818
-			$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
839
+		if ($context['allow_edit_poll']) {
840
+					$context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']);
841
+		}
819 842
 
820
-		if ($context['can_remove_poll'])
821
-			$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
843
+		if ($context['can_remove_poll']) {
844
+					$context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
845
+		}
822 846
 
823 847
 		// Allow mods to add additional buttons here
824 848
 		call_integration_hook('integrate_poll_buttons');
825 849
 	}
826 850
 	
827
-	if(!empty($_REQUEST['page_id']))
828
-		$start_char = substr($_REQUEST['page_id'], 0, 1);
829
-	else
830
-		$start_char = null;
851
+	if(!empty($_REQUEST['page_id'])) {
852
+			$start_char = substr($_REQUEST['page_id'], 0, 1);
853
+	} else {
854
+			$start_char = null;
855
+	}
831 856
 
832
-	if ($start_char === 'M' || $start_char === 'L')
833
-		$page_id = substr($_REQUEST['page_id'], 1);
857
+	if ($start_char === 'M' || $start_char === 'L') {
858
+			$page_id = substr($_REQUEST['page_id'], 1);
859
+	}
834 860
 
835 861
 	$limit = $context['messages_per_page'];
836 862
  
@@ -866,8 +892,7 @@  discard block
 block discarded – undo
866 892
 				'max' => $limit,
867 893
 			)
868 894
 		);
869
-	}
870
-	else //next or before page
895
+	} else //next or before page
871 896
 	{
872 897
 		$firstIndex = 0;
873 898
 		
@@ -875,8 +900,7 @@  discard block
 block discarded – undo
875 900
 		{
876 901
 			$ascending = true;
877 902
 			$page_operator = '>';
878
-		}
879
-		else
903
+		} else
880 904
 		{
881 905
 			$ascending = false;
882 906
 			$page_operator = '<';
@@ -906,14 +930,16 @@  discard block
 block discarded – undo
906 930
 	$all_posters = array();
907 931
 	while ($row = $smcFunc['db_fetch_assoc']($request))
908 932
 	{
909
-		if (!empty($row['id_member']))
910
-			$all_posters[$row['id_msg']] = $row['id_member'];
933
+		if (!empty($row['id_member'])) {
934
+					$all_posters[$row['id_msg']] = $row['id_member'];
935
+		}
911 936
 		$messages[] = $row['id_msg'];
912 937
 	}
913 938
 	
914 939
 	// Before Page bring in the right order
915
-	if (!empty($start_char) && $start_char === 'L')
916
-		krsort($messages);
940
+	if (!empty($start_char) && $start_char === 'L') {
941
+			krsort($messages);
942
+	}
917 943
 	
918 944
 	// Construct the page index, allowing for the .START method...
919 945
 	$page_options = array(
@@ -935,8 +961,9 @@  discard block
 block discarded – undo
935 961
 			$_REQUEST['start'] = 0;
936 962
 		}
937 963
 		// They aren't using it, but the *option* is there, at least.
938
-		else
939
-			$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
964
+		else {
965
+					$context['page_index'] .= '&nbsp;<a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> ';
966
+		}
940 967
 	}
941 968
 	
942 969
 	$smcFunc['db_free_result']($request);
@@ -948,8 +975,9 @@  discard block
 block discarded – undo
948 975
 	if (!$user_info['is_guest'] && !empty($messages))
949 976
 	{
950 977
 		$mark_at_msg = max($messages);
951
-		if ($mark_at_msg >= $context['topicinfo']['id_last_msg'])
952
-			$mark_at_msg = $modSettings['maxMsgID'];
978
+		if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) {
979
+					$mark_at_msg = $modSettings['maxMsgID'];
980
+		}
953 981
 		if ($mark_at_msg >= $context['topicinfo']['new_from'])
954 982
 		{
955 983
 			$smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace',
@@ -981,8 +1009,9 @@  discard block
 block discarded – undo
981 1009
 		while ($row = $smcFunc['db_fetch_assoc']($request))
982 1010
 		{
983 1011
 			// Find if this topic is marked for notification...
984
-			if (!empty($row['id_topic']))
985
-				$context['is_marked_notify'] = true;
1012
+			if (!empty($row['id_topic'])) {
1013
+							$context['is_marked_notify'] = true;
1014
+			}
986 1015
 
987 1016
 			// Only do this once, but mark the notifications as "not sent yet" for next time.
988 1017
 			if (!empty($row['sent']) && $do_once)
@@ -1004,8 +1033,9 @@  discard block
 block discarded – undo
1004 1033
 		}
1005 1034
 
1006 1035
 		// Have we recently cached the number of new topics in this board, and it's still a lot?
1007
-		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5)
1008
-			$_SESSION['topicseen_cache'][$board]--;
1036
+		if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) {
1037
+					$_SESSION['topicseen_cache'][$board]--;
1038
+		}
1009 1039
 		// Mark board as seen if this is the only new topic.
1010 1040
 		elseif (isset($_REQUEST['topicseen']))
1011 1041
 		{
@@ -1029,14 +1059,16 @@  discard block
 block discarded – undo
1029 1059
 			$smcFunc['db_free_result']($request);
1030 1060
 
1031 1061
 			// If there're no real new topics in this board, mark the board as seen.
1032
-			if (empty($numNewTopics))
1033
-				$_REQUEST['boardseen'] = true;
1034
-			else
1035
-				$_SESSION['topicseen_cache'][$board] = $numNewTopics;
1062
+			if (empty($numNewTopics)) {
1063
+							$_REQUEST['boardseen'] = true;
1064
+			} else {
1065
+							$_SESSION['topicseen_cache'][$board] = $numNewTopics;
1066
+			}
1036 1067
 		}
1037 1068
 		// Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often.
1038
-		elseif (isset($_SESSION['topicseen_cache'][$board]))
1039
-			$_SESSION['topicseen_cache'][$board]--;
1069
+		elseif (isset($_SESSION['topicseen_cache'][$board])) {
1070
+					$_SESSION['topicseen_cache'][$board]--;
1071
+		}
1040 1072
 
1041 1073
 		// Mark board as seen if we came using last post link from BoardIndex. (or other places...)
1042 1074
 		if (isset($_REQUEST['boardseen']))
@@ -1093,23 +1125,26 @@  discard block
 block discarded – undo
1093 1125
 			$temp = array();
1094 1126
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1095 1127
 			{
1096
-				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id']))
1097
-					continue;
1128
+				if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) {
1129
+									continue;
1130
+				}
1098 1131
 
1099 1132
 				$temp[$row['id_attach']] = $row;
1100 1133
 				$temp[$row['id_attach']]['topic'] = $topic;
1101 1134
 				$temp[$row['id_attach']]['board'] = $board;
1102 1135
 
1103
-				if (!isset($context['loaded_attachments'][$row['id_msg']]))
1104
-					$context['loaded_attachments'][$row['id_msg']] = array();
1136
+				if (!isset($context['loaded_attachments'][$row['id_msg']])) {
1137
+									$context['loaded_attachments'][$row['id_msg']] = array();
1138
+				}
1105 1139
 			}
1106 1140
 			$smcFunc['db_free_result']($request);
1107 1141
 
1108 1142
 			// This is better than sorting it with the query...
1109 1143
 			ksort($temp);
1110 1144
 
1111
-			foreach ($temp as $row)
1112
-				$context['loaded_attachments'][$row['id_msg']][] = $row;
1145
+			foreach ($temp as $row) {
1146
+							$context['loaded_attachments'][$row['id_msg']][] = $row;
1147
+			}
1113 1148
 		}
1114 1149
 
1115 1150
 		$msg_parameters = array(
@@ -1136,21 +1171,23 @@  discard block
 block discarded – undo
1136 1171
 		);
1137 1172
 
1138 1173
 		// And the likes
1139
-		if (!empty($modSettings['enable_likes']))
1140
-			$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1174
+		if (!empty($modSettings['enable_likes'])) {
1175
+					$context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic);
1176
+		}
1141 1177
 
1142 1178
 		// Go to the last message if the given time is beyond the time of the last message.
1143
-		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies'])
1144
-			$context['start_from'] = $context['topicinfo']['num_replies'];
1179
+		if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) {
1180
+					$context['start_from'] = $context['topicinfo']['num_replies'];
1181
+		}
1145 1182
 
1146 1183
 		// Since the anchor information is needed on the top of the page we load these variables beforehand.
1147 1184
 		$context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0];
1148
-		if (empty($options['view_newest_first']))
1149
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1150
-		else
1151
-			$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1152
-	}
1153
-	else
1185
+		if (empty($options['view_newest_first'])) {
1186
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from'];
1187
+		} else {
1188
+					$context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from'];
1189
+		}
1190
+	} else
1154 1191
 	{
1155 1192
 		$messages_request = false;
1156 1193
 		$context['first_message'] = 0;
@@ -1186,8 +1223,9 @@  discard block
 block discarded – undo
1186 1223
 		'can_see_likes' => 'likes_view',
1187 1224
 		'can_like' => 'likes_like',
1188 1225
 	);
1189
-	foreach ($common_permissions as $contextual => $perm)
1190
-		$context[$contextual] = allowedTo($perm);
1226
+	foreach ($common_permissions as $contextual => $perm) {
1227
+			$context[$contextual] = allowedTo($perm);
1228
+	}
1191 1229
 
1192 1230
 	// Permissions with _any/_own versions.  $context[YYY] => ZZZ_any/_own.
1193 1231
 	$anyown_permissions = array(
@@ -1200,8 +1238,9 @@  discard block
 block discarded – undo
1200 1238
 		'can_reply_unapproved' => 'post_unapproved_replies',
1201 1239
 		'can_view_warning' => 'profile_warning',
1202 1240
 	);
1203
-	foreach ($anyown_permissions as $contextual => $perm)
1204
-		$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1241
+	foreach ($anyown_permissions as $contextual => $perm) {
1242
+			$context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own'));
1243
+	}
1205 1244
 
1206 1245
 	if (!$user_info['is_admin'] && !$modSettings['topic_move_any'])
1207 1246
 	{
@@ -1247,8 +1286,9 @@  discard block
 block discarded – undo
1247 1286
 	// Check if the draft functions are enabled and that they have permission to use them (for quick reply.)
1248 1287
 	$context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply'];
1249 1288
 	$context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']);
1250
-	if (!empty($context['drafts_save']))
1251
-		loadLanguage('Drafts');
1289
+	if (!empty($context['drafts_save'])) {
1290
+			loadLanguage('Drafts');
1291
+	}
1252 1292
 
1253 1293
 	// When was the last time this topic was replied to?  Should we warn them about it?
1254 1294
 	if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky']))
@@ -1309,26 +1349,31 @@  discard block
 block discarded – undo
1309 1349
 	// Message icons - customized icons are off?
1310 1350
 	$context['icons'] = getMessageIcons($board);
1311 1351
 
1312
-	if (!empty($context['icons']))
1313
-		$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1352
+	if (!empty($context['icons'])) {
1353
+			$context['icons'][count($context['icons']) - 1]['is_last'] = true;
1354
+	}
1314 1355
 
1315 1356
 	// Build the normal button array.
1316 1357
 	$context['normal_buttons'] = array();
1317 1358
 
1318
-	if ($context['can_reply'])
1319
-		$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1359
+	if ($context['can_reply']) {
1360
+			$context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true);
1361
+	}
1320 1362
 
1321
-	if ($context['can_add_poll'])
1322
-		$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1363
+	if ($context['can_add_poll']) {
1364
+			$context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']);
1365
+	}
1323 1366
 
1324
-	if ($context['can_mark_unread'])
1325
-		$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1367
+	if ($context['can_mark_unread']) {
1368
+			$context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1369
+	}
1326 1370
 
1327
-	if ($context['can_print'])
1328
-		$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1371
+	if ($context['can_print']) {
1372
+			$context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0');
1373
+	}
1329 1374
 
1330
-	if ($context['can_set_notify'])
1331
-		$context['normal_buttons']['notify'] = array(
1375
+	if ($context['can_set_notify']) {
1376
+			$context['normal_buttons']['notify'] = array(
1332 1377
 			'text' => 'notify_topic_' . $context['topic_notification_mode'],
1333 1378
 			'sub_buttons' => array(
1334 1379
 				array(
@@ -1350,38 +1395,47 @@  discard block
 block discarded – undo
1350 1395
 				),
1351 1396
 			),
1352 1397
 		);
1398
+	}
1353 1399
 
1354 1400
 	// Build the mod button array
1355 1401
 	$context['mod_buttons'] = array();
1356 1402
 
1357
-	if ($context['can_move'])
1358
-		$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1403
+	if ($context['can_move']) {
1404
+			$context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0');
1405
+	}
1359 1406
 
1360
-	if ($context['can_delete'])
1361
-		$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1407
+	if ($context['can_delete']) {
1408
+			$context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
1409
+	}
1362 1410
 
1363
-	if ($context['can_lock'])
1364
-		$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1411
+	if ($context['can_lock']) {
1412
+			$context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1413
+	}
1365 1414
 
1366
-	if ($context['can_sticky'])
1367
-		$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1415
+	if ($context['can_sticky']) {
1416
+			$context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1417
+	}
1368 1418
 
1369
-	if ($context['can_merge'])
1370
-		$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1419
+	if ($context['can_merge']) {
1420
+			$context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']);
1421
+	}
1371 1422
 
1372
-	if ($context['calendar_post'])
1373
-		$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1423
+	if ($context['calendar_post']) {
1424
+			$context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0');
1425
+	}
1374 1426
 
1375 1427
 	// Restore topic. eh?  No monkey business.
1376
-	if ($context['can_restore_topic'])
1377
-		$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1428
+	if ($context['can_restore_topic']) {
1429
+			$context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
1430
+	}
1378 1431
 
1379 1432
 	// Show a message in case a recently posted message became unapproved.
1380 1433
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
1381 1434
 
1382 1435
 	// Don't want to show this forever...
1383
-	if ($context['becomesUnapproved'])
1384
-		unset($_SESSION['becomesUnapproved']);
1436
+	if ($context['becomesUnapproved']) {
1437
+			unset($_SESSION['becomesUnapproved']);
1438
+	}
1385 1439
 
1386 1440
 	// Allow adding new mod buttons easily.
1387 1441
 	// Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used
@@ -1390,12 +1444,14 @@  discard block
 block discarded – undo
1390 1444
 	call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons']));
1391 1445
 
1392 1446
 	// Load the drafts js file
1393
-	if ($context['drafts_autosave'])
1394
-		loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1447
+	if ($context['drafts_autosave']) {
1448
+			loadJavaScriptFile('drafts.js', array('defer' => false), 'smf_drafts');
1449
+	}
1395 1450
 
1396 1451
 	// Spellcheck
1397
-	if ($context['show_spellchecking'])
1398
-		loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1452
+	if ($context['show_spellchecking']) {
1453
+			loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
1454
+	}
1399 1455
 
1400 1456
 	// topic.js
1401 1457
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -1429,16 +1485,19 @@  discard block
 block discarded – undo
1429 1485
 	static $counter = null;
1430 1486
 
1431 1487
 	// If the query returned false, bail.
1432
-	if ($messages_request == false)
1433
-		return false;
1488
+	if ($messages_request == false) {
1489
+			return false;
1490
+	}
1434 1491
 
1435 1492
 	// Remember which message this is.  (ie. reply #83)
1436
-	if ($counter === null || $reset)
1437
-		$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1493
+	if ($counter === null || $reset) {
1494
+			$counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start'];
1495
+	}
1438 1496
 
1439 1497
 	// Start from the beginning...
1440
-	if ($reset)
1441
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1498
+	if ($reset) {
1499
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1500
+	}
1442 1501
 
1443 1502
 	// Attempt to get the next message.
1444 1503
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
@@ -1452,19 +1511,21 @@  discard block
 block discarded – undo
1452 1511
 	if (empty($context['icon_sources']))
1453 1512
 	{
1454 1513
 		$context['icon_sources'] = array();
1455
-		foreach ($context['stable_icons'] as $icon)
1456
-			$context['icon_sources'][$icon] = 'images_url';
1514
+		foreach ($context['stable_icons'] as $icon) {
1515
+					$context['icon_sources'][$icon] = 'images_url';
1516
+		}
1457 1517
 	}
1458 1518
 
1459 1519
 	// Message Icon Management... check the images exist.
1460 1520
 	if (empty($modSettings['messageIconChecks_disable']))
1461 1521
 	{
1462 1522
 		// If the current icon isn't known, then we need to do something...
1463
-		if (!isset($context['icon_sources'][$message['icon']]))
1464
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1523
+		if (!isset($context['icon_sources'][$message['icon']])) {
1524
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1525
+		}
1526
+	} elseif (!isset($context['icon_sources'][$message['icon']])) {
1527
+			$context['icon_sources'][$message['icon']] = 'images_url';
1465 1528
 	}
1466
-	elseif (!isset($context['icon_sources'][$message['icon']]))
1467
-		$context['icon_sources'][$message['icon']] = 'images_url';
1468 1529
 
1469 1530
 	// If you're a lazy bum, you probably didn't give a subject...
1470 1531
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1489,8 +1550,7 @@  discard block
 block discarded – undo
1489 1550
 		$memberContext[$message['id_member']]['email'] = $message['poster_email'];
1490 1551
 		$memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum');
1491 1552
 		$memberContext[$message['id_member']]['is_guest'] = true;
1492
-	}
1493
-	else
1553
+	} else
1494 1554
 	{
1495 1555
 		// Define this here to make things a bit more readable
1496 1556
 		$can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own'));
@@ -1513,8 +1573,9 @@  discard block
 block discarded – undo
1513 1573
 	$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
1514 1574
 
1515 1575
 	// If it's in the recycle bin we need to override whatever icon we did have.
1516
-	if (!empty($board_info['recycle']))
1517
-		$message['icon'] = 'recycled';
1576
+	if (!empty($board_info['recycle'])) {
1577
+			$message['icon'] = 'recycled';
1578
+	}
1518 1579
 
1519 1580
 	require_once($sourcedir . '/Subs-Attachments.php');
1520 1581
 
@@ -1558,32 +1619,36 @@  discard block
 block discarded – undo
1558 1619
 	}
1559 1620
 
1560 1621
 	// Are likes enable?
1561
-	if (!empty($modSettings['enable_likes']))
1562
-		$output['likes'] = array(
1622
+	if (!empty($modSettings['enable_likes'])) {
1623
+			$output['likes'] = array(
1563 1624
 			'count' => $message['likes'],
1564 1625
 			'you' => in_array($message['id_msg'], $context['my_likes']),
1565 1626
 			'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']),
1566 1627
 		);
1628
+	}
1567 1629
 
1568 1630
 	// Is this user the message author?
1569 1631
 	$output['is_message_author'] = $message['id_member'] == $user_info['id'];
1570
-	if (!empty($output['modified']['name']))
1571
-		$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1632
+	if (!empty($output['modified']['name'])) {
1633
+			$output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']);
1634
+	}
1572 1635
 
1573 1636
 	// Did they give a reason for editing?
1574
-	if (!empty($output['modified']['name']) && !empty($output['modified']['reason']))
1575
-		$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1637
+	if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) {
1638
+			$output['modified']['last_edit_text'] .= '&nbsp;' . sprintf($txt['last_edit_reason'], $output['modified']['reason']);
1639
+	}
1576 1640
 
1577 1641
 	// Any custom profile fields?
1578
-	if (!empty($memberContext[$message['id_member']]['custom_fields']))
1579
-		foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1642
+	if (!empty($memberContext[$message['id_member']]['custom_fields'])) {
1643
+			foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom)
1580 1644
 			$output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
1645
+	}
1581 1646
 
1582
-	if (empty($options['view_newest_first']))
1583
-		$counter++;
1584
-
1585
-	else
1586
-		$counter--;
1647
+	if (empty($options['view_newest_first'])) {
1648
+			$counter++;
1649
+	} else {
1650
+			$counter--;
1651
+	}
1587 1652
 
1588 1653
 	call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter));
1589 1654
 
@@ -1609,21 +1674,23 @@  discard block
 block discarded – undo
1609 1674
 	$context['no_last_modified'] = true;
1610 1675
 
1611 1676
 	// Prevent a preview image from being displayed twice.
1612
-	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview'))
1613
-		return;
1677
+	if (isset($_GET['action']) && $_GET['action'] == 'dlattach' && isset($_GET['type']) && ($_GET['type'] == 'avatar' || $_GET['type'] == 'preview')) {
1678
+			return;
1679
+	}
1614 1680
 
1615 1681
 	// Make sure some attachment was requested!
1616
-	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id']))
1617
-		fatal_lang_error('no_access', false);
1682
+	if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) {
1683
+			fatal_lang_error('no_access', false);
1684
+	}
1618 1685
 
1619 1686
 	$_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id'];
1620 1687
 
1621 1688
 	// Do we have a hook wanting to use our attachment system? We use $attachRequest to prevent accidental usage of $request.
1622 1689
 	$attachRequest = null;
1623 1690
 	call_integration_hook('integrate_download_request', array(&$attachRequest));
1624
-	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest))
1625
-		$request = $attachRequest;
1626
-	else
1691
+	if (!is_null($attachRequest) && $smcFunc['db_is_resource']($attachRequest)) {
1692
+			$request = $attachRequest;
1693
+	} else
1627 1694
 	{
1628 1695
 		// This checks only the current board for $board/$topic's permissions.
1629 1696
 		isAllowedTo('view_attachments');
@@ -1644,19 +1711,21 @@  discard block
 block discarded – undo
1644 1711
 		);
1645 1712
 	}
1646 1713
 
1647
-	if ($smcFunc['db_num_rows']($request) == 0)
1648
-		fatal_lang_error('no_access', false);
1714
+	if ($smcFunc['db_num_rows']($request) == 0) {
1715
+			fatal_lang_error('no_access', false);
1716
+	}
1649 1717
 
1650 1718
 	list ($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request);
1651 1719
 	$smcFunc['db_free_result']($request);
1652 1720
 
1653 1721
 	// If it isn't yet approved, do they have permission to view it?
1654
-	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3))
1655
-		isAllowedTo('approve_posts');
1722
+	if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) {
1723
+			isAllowedTo('approve_posts');
1724
+	}
1656 1725
 
1657 1726
 	// Update the download counter (unless it's a thumbnail).
1658
-	if ($attachment_type != 3)
1659
-		$smcFunc['db_query']('attach_download_increase', '
1727
+	if ($attachment_type != 3) {
1728
+			$smcFunc['db_query']('attach_download_increase', '
1660 1729
 			UPDATE LOW_PRIORITY {db_prefix}attachments
1661 1730
 			SET downloads = downloads + 1
1662 1731
 			WHERE id_attach = {int:id_attach}',
@@ -1664,15 +1733,15 @@  discard block
 block discarded – undo
1664 1733
 				'id_attach' => $id_attach,
1665 1734
 			)
1666 1735
 		);
1736
+	}
1667 1737
 
1668 1738
 	$filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash);
1669 1739
 
1670 1740
 	// This is done to clear any output that was made before now.
1671 1741
 	ob_end_clean();
1672
-	if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java')))
1673
-		@ob_start('ob_gzhandler');
1674
-
1675
-	else
1742
+	if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) {
1743
+			@ob_start('ob_gzhandler');
1744
+	} else
1676 1745
 	{
1677 1746
 		ob_start();
1678 1747
 		header('Content-Encoding: none');
@@ -1715,8 +1784,9 @@  discard block
 block discarded – undo
1715 1784
 	// Send the attachment headers.
1716 1785
 	header('Pragma: ');
1717 1786
 
1718
-	if (!isBrowser('gecko'))
1719
-		header('Content-Transfer-Encoding: binary');
1787
+	if (!isBrowser('gecko')) {
1788
+			header('Content-Transfer-Encoding: binary');
1789
+	}
1720 1790
 
1721 1791
 	header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
1722 1792
 	header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT');
@@ -1725,18 +1795,19 @@  discard block
 block discarded – undo
1725 1795
 	header('ETag: ' . $eTag);
1726 1796
 
1727 1797
 	// Make sure the mime type warrants an inline display.
1728
-	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0)
1729
-		unset($_REQUEST['image']);
1798
+	if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) {
1799
+			unset($_REQUEST['image']);
1800
+	}
1730 1801
 
1731 1802
 	// Does this have a mime type?
1732
-	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff'))))
1733
-		header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1734
-
1735
-	else
1803
+	elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) {
1804
+			header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
1805
+	} else
1736 1806
 	{
1737 1807
 		header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
1738
-		if (isset($_REQUEST['image']))
1739
-			unset($_REQUEST['image']);
1808
+		if (isset($_REQUEST['image'])) {
1809
+					unset($_REQUEST['image']);
1810
+		}
1740 1811
 	}
1741 1812
 
1742 1813
 	// Convert the file to UTF-8, cuz most browsers dig that.
@@ -1744,23 +1815,22 @@  discard block
 block discarded – undo
1744 1815
 	$disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
1745 1816
 
1746 1817
 	// Different browsers like different standards...
1747
-	if (isBrowser('firefox'))
1748
-		header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1749
-
1750
-	elseif (isBrowser('opera'))
1751
-		header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1752
-
1753
-	elseif (isBrowser('ie'))
1754
-		header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1755
-
1756
-	else
1757
-		header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1818
+	if (isBrowser('firefox')) {
1819
+			header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)));
1820
+	} elseif (isBrowser('opera')) {
1821
+			header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name) . '"');
1822
+	} elseif (isBrowser('ie')) {
1823
+			header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\d{3,8});~', 'fixchar__callback', $utf8name)) . '"');
1824
+	} else {
1825
+			header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
1826
+	}
1758 1827
 
1759 1828
 	// If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
1760
-	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff')))
1761
-		header('Cache-Control: no-cache');
1762
-	else
1763
-		header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1829
+	if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) {
1830
+			header('Cache-Control: no-cache');
1831
+	} else {
1832
+			header('Cache-Control: max-age=' . (525600 * 60) . ', private');
1833
+	}
1764 1834
 
1765 1835
 	header('Content-Length: ' . filesize($filename));
1766 1836
 
@@ -1770,20 +1840,23 @@  discard block
 block discarded – undo
1770 1840
 	// Recode line endings for text files, if enabled.
1771 1841
 	if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml')))
1772 1842
 	{
1773
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false)
1774
-			$callback = function($buffer)
1843
+		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) {
1844
+					$callback = function($buffer)
1775 1845
 			{
1776 1846
 				return preg_replace('~[\r]?\n~', "\r\n", $buffer);
1847
+		}
1777 1848
 			};
1778
-		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false)
1779
-			$callback = function($buffer)
1849
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
1850
+					$callback = function($buffer)
1780 1851
 			{
1781 1852
 				return preg_replace('~[\r]?\n~', "\r", $buffer);
1853
+		}
1782 1854
 			};
1783
-		else
1784
-			$callback = function($buffer)
1855
+		else {
1856
+					$callback = function($buffer)
1785 1857
 			{
1786 1858
 				return preg_replace('~[\r]?\n~', "\n", $buffer);
1859
+		}
1787 1860
 			};
1788 1861
 	}
1789 1862
 
@@ -1791,23 +1864,26 @@  discard block
 block discarded – undo
1791 1864
 	if (filesize($filename) > 4194304)
1792 1865
 	{
1793 1866
 		// Forcibly end any output buffering going on.
1794
-		while (@ob_get_level() > 0)
1795
-			@ob_end_clean();
1867
+		while (@ob_get_level() > 0) {
1868
+					@ob_end_clean();
1869
+		}
1796 1870
 
1797 1871
 		$fp = fopen($filename, 'rb');
1798 1872
 		while (!feof($fp))
1799 1873
 		{
1800
-			if (isset($callback))
1801
-				echo $callback(fread($fp, 8192));
1802
-			else
1803
-				echo fread($fp, 8192);
1874
+			if (isset($callback)) {
1875
+							echo $callback(fread($fp, 8192));
1876
+			} else {
1877
+							echo fread($fp, 8192);
1878
+			}
1804 1879
 			flush();
1805 1880
 		}
1806 1881
 		fclose($fp);
1807 1882
 	}
1808 1883
 	// On some of the less-bright hosts, readfile() is disabled.  It's just a faster, more byte safe, version of what's in the if.
1809
-	elseif (isset($callback) || @readfile($filename) === null)
1810
-		echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1884
+	elseif (isset($callback) || @readfile($filename) === null) {
1885
+			echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
1886
+	}
1811 1887
 
1812 1888
 	obExit(false);
1813 1889
 }
@@ -1820,8 +1896,9 @@  discard block
 block discarded – undo
1820 1896
  */
1821 1897
 function approved_attach_sort($a, $b)
1822 1898
 {
1823
-	if ($a['is_approved'] == $b['is_approved'])
1824
-		return 0;
1899
+	if ($a['is_approved'] == $b['is_approved']) {
1900
+			return 0;
1901
+	}
1825 1902
 
1826 1903
 	return $a['is_approved'] > $b['is_approved'] ? -1 : 1;
1827 1904
 }
@@ -1838,16 +1915,19 @@  discard block
 block discarded – undo
1838 1915
 
1839 1916
 	require_once($sourcedir . '/RemoveTopic.php');
1840 1917
 
1841
-	if (empty($_REQUEST['msgs']))
1842
-		redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1918
+	if (empty($_REQUEST['msgs'])) {
1919
+			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
1920
+	}
1843 1921
 
1844 1922
 	$messages = array();
1845
-	foreach ($_REQUEST['msgs'] as $dummy)
1846
-		$messages[] = (int) $dummy;
1923
+	foreach ($_REQUEST['msgs'] as $dummy) {
1924
+			$messages[] = (int) $dummy;
1925
+	}
1847 1926
 
1848 1927
 	// We are restoring messages. We handle this in another place.
1849
-	if (isset($_REQUEST['restore_selected']))
1850
-		redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1928
+	if (isset($_REQUEST['restore_selected'])) {
1929
+			redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
1930
+	}
1851 1931
 	if (isset($_REQUEST['split_selection']))
1852 1932
 	{
1853 1933
 		$request = $smcFunc['db_query']('', '
@@ -1866,8 +1946,9 @@  discard block
 block discarded – undo
1866 1946
 	}
1867 1947
 
1868 1948
 	// Allowed to delete any message?
1869
-	if (allowedTo('delete_any'))
1870
-		$allowed_all = true;
1949
+	if (allowedTo('delete_any')) {
1950
+			$allowed_all = true;
1951
+	}
1871 1952
 	// Allowed to delete replies to their messages?
1872 1953
 	elseif (allowedTo('delete_replies'))
1873 1954
 	{
@@ -1884,13 +1965,14 @@  discard block
 block discarded – undo
1884 1965
 		$smcFunc['db_free_result']($request);
1885 1966
 
1886 1967
 		$allowed_all = $starter == $user_info['id'];
1968
+	} else {
1969
+			$allowed_all = false;
1887 1970
 	}
1888
-	else
1889
-		$allowed_all = false;
1890 1971
 
1891 1972
 	// Make sure they're allowed to delete their own messages, if not any.
1892
-	if (!$allowed_all)
1893
-		isAllowedTo('delete_own');
1973
+	if (!$allowed_all) {
1974
+			isAllowedTo('delete_own');
1975
+	}
1894 1976
 
1895 1977
 	// Allowed to remove which messages?
1896 1978
 	$request = $smcFunc['db_query']('', '
@@ -1910,8 +1992,9 @@  discard block
 block discarded – undo
1910 1992
 	$messages = array();
1911 1993
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1912 1994
 	{
1913
-		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time())
1914
-			continue;
1995
+		if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) {
1996
+					continue;
1997
+		}
1915 1998
 
1916 1999
 		$messages[$row['id_msg']] = array($row['subject'], $row['id_member']);
1917 2000
 	}
@@ -1934,17 +2017,20 @@  discard block
 block discarded – undo
1934 2017
 	foreach ($messages as $message => $info)
1935 2018
 	{
1936 2019
 		// Just skip the first message - if it's not the last.
1937
-		if ($message == $first_message && $message != $last_message)
1938
-			continue;
2020
+		if ($message == $first_message && $message != $last_message) {
2021
+					continue;
2022
+		}
1939 2023
 		// If the first message is going then don't bother going back to the topic as we're effectively deleting it.
1940
-		elseif ($message == $first_message)
1941
-			$topicGone = true;
2024
+		elseif ($message == $first_message) {
2025
+					$topicGone = true;
2026
+		}
1942 2027
 
1943 2028
 		removeMessage($message);
1944 2029
 
1945 2030
 		// Log this moderation action ;).
1946
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
1947
-			logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
2031
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
2032
+					logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board));
2033
+		}
1948 2034
 	}
1949 2035
 
1950 2036
 	redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']);
Please login to merge, or discard this patch.
Sources/ManageCalendar.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 					'value' => $txt['date'],
137 137
 				),
138 138
 				'data' => array(
139
-					'function' => function ($rowData) use ($txt)
139
+					'function' => function($rowData) use ($txt)
140 140
 					{
141 141
 						// Recurring every year or just a single year?
142 142
 						$year = $rowData['year'] == '1004' ? sprintf('(%1$s)', $txt['every_year']) : $rowData['year'];
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		checkSession();
219 219
 
220 220
 		// Not too long good sir?
221
-		$_REQUEST['title'] =  $smcFunc['substr']($_REQUEST['title'], 0, 60);
221
+		$_REQUEST['title'] = $smcFunc['substr']($_REQUEST['title'], 0, 60);
222 222
 		$_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0;
223 223
 
224 224
 		if (isset($_REQUEST['delete']))
Please login to merge, or discard this patch.
Braces   +37 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main controlling function doesn't have much to do... yet.
@@ -43,8 +44,7 @@  discard block
 block discarded – undo
43 44
 			'settings' => 'ModifyCalendarSettings'
44 45
 		);
45 46
 		$default = 'holidays';
46
-	}
47
-	else
47
+	} else
48 48
 	{
49 49
 		$subActions = array(
50 50
 			'settings' => 'ModifyCalendarSettings'
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 		'help' => 'calendar',
61 61
 		'description' => $txt['calendar_settings_desc'],
62 62
 	);
63
-	if (!empty($modSettings['cal_enabled']))
64
-		$context[$context['admin_menu_name']]['tab_data']['tabs'] = array(
63
+	if (!empty($modSettings['cal_enabled'])) {
64
+			$context[$context['admin_menu_name']]['tab_data']['tabs'] = array(
65 65
 			'holidays' => array(
66 66
 				'description' => $txt['manage_holidays_desc'],
67 67
 			),
@@ -69,6 +69,7 @@  discard block
 block discarded – undo
69 69
 				'description' => $txt['calendar_settings_desc'],
70 70
 			),
71 71
 		);
72
+	}
72 73
 
73 74
 	call_integration_hook('integrate_manage_calendar', array(&$subActions));
74 75
 
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
 		checkSession();
89 90
 		validateToken('admin-mc');
90 91
 
91
-		foreach ($_REQUEST['holiday'] as $id => $value)
92
-			$_REQUEST['holiday'][$id] = (int) $id;
92
+		foreach ($_REQUEST['holiday'] as $id => $value) {
93
+					$_REQUEST['holiday'][$id] = (int) $id;
94
+		}
93 95
 
94 96
 		// Now the IDs are "safe" do the delete...
95 97
 		require_once($sourcedir . '/Subs-Calendar.php');
@@ -209,8 +211,9 @@  discard block
 block discarded – undo
209 211
 	$context['sub_template'] = 'edit_holiday';
210 212
 
211 213
 	// Cast this for safety...
212
-	if (isset($_REQUEST['holiday']))
213
-		$_REQUEST['holiday'] = (int) $_REQUEST['holiday'];
214
+	if (isset($_REQUEST['holiday'])) {
215
+			$_REQUEST['holiday'] = (int) $_REQUEST['holiday'];
216
+	}
214 217
 
215 218
 	// Submitting?
216 219
 	if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != ''))
@@ -221,19 +224,19 @@  discard block
 block discarded – undo
221 224
 		$_REQUEST['title'] =  $smcFunc['substr']($_REQUEST['title'], 0, 60);
222 225
 		$_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0;
223 226
 
224
-		if (isset($_REQUEST['delete']))
225
-			$smcFunc['db_query']('', '
227
+		if (isset($_REQUEST['delete'])) {
228
+					$smcFunc['db_query']('', '
226 229
 				DELETE FROM {db_prefix}calendar_holidays
227 230
 				WHERE id_holiday = {int:selected_holiday}',
228 231
 				array(
229 232
 					'selected_holiday' => $_REQUEST['holiday'],
230 233
 				)
231 234
 			);
232
-		else
235
+		} else
233 236
 		{
234 237
 			$date = strftime($_REQUEST['year'] <= 1004 ? '1004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year']));
235
-			if (isset($_REQUEST['edit']))
236
-				$smcFunc['db_query']('', '
238
+			if (isset($_REQUEST['edit'])) {
239
+							$smcFunc['db_query']('', '
237 240
 					UPDATE {db_prefix}calendar_holidays
238 241
 					SET event_date = {date:holiday_date}, title = {string:holiday_title}
239 242
 					WHERE id_holiday = {int:selected_holiday}',
@@ -243,8 +246,8 @@  discard block
 block discarded – undo
243 246
 						'holiday_title' => $_REQUEST['title'],
244 247
 					)
245 248
 				);
246
-			else
247
-				$smcFunc['db_insert']('',
249
+			} else {
250
+							$smcFunc['db_insert']('',
248 251
 					'{db_prefix}calendar_holidays',
249 252
 					array(
250 253
 						'event_date' => 'date', 'title' => 'string-60',
@@ -254,6 +257,7 @@  discard block
 block discarded – undo
254 257
 					),
255 258
 					array('id_holiday')
256 259
 				);
260
+			}
257 261
 		}
258 262
 
259 263
 		updateSettings(array(
@@ -265,14 +269,15 @@  discard block
 block discarded – undo
265 269
 	}
266 270
 
267 271
 	// Default states...
268
-	if ($context['is_new'])
269
-		$context['holiday'] = array(
272
+	if ($context['is_new']) {
273
+			$context['holiday'] = array(
270 274
 			'id' => 0,
271 275
 			'day' => date('d'),
272 276
 			'month' => date('m'),
273 277
 			'year' => '0000',
274 278
 			'title' => ''
275 279
 		);
280
+	}
276 281
 	// If it's not new load the data.
277 282
 	else
278 283
 	{
@@ -285,14 +290,15 @@  discard block
 block discarded – undo
285 290
 				'selected_holiday' => $_REQUEST['holiday'],
286 291
 			)
287 292
 		);
288
-		while ($row = $smcFunc['db_fetch_assoc']($request))
289
-			$context['holiday'] = array(
293
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
294
+					$context['holiday'] = array(
290 295
 				'id' => $row['id_holiday'],
291 296
 				'day' => $row['day'],
292 297
 				'month' => $row['month'],
293 298
 				'year' => $row['year'] <= 4 ? 0 : $row['year'],
294 299
 				'title' => $row['title']
295 300
 			);
301
+		}
296 302
 		$smcFunc['db_free_result']($request);
297 303
 	}
298 304
 
@@ -319,16 +325,17 @@  discard block
 block discarded – undo
319 325
 		array(
320 326
 		)
321 327
 	);
322
-	while ($row = $smcFunc['db_fetch_assoc']($request))
323
-		$boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
328
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
329
+			$boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
330
+	}
324 331
 	$smcFunc['db_free_result']($request);
325 332
 
326 333
 	require_once($sourcedir . '/Subs-Boards.php');
327 334
 	sortBoards($boards);
328 335
 
329 336
 	// Look, all the calendar settings - of which there are many!
330
-	if (!empty($modSettings['cal_enabled']))
331
-		$config_vars = array(
337
+	if (!empty($modSettings['cal_enabled'])) {
338
+			$config_vars = array(
332 339
 				array('check', 'cal_enabled'),
333 340
 			'',
334 341
 				// All the permissions:
@@ -371,14 +378,16 @@  discard block
 block discarded – undo
371 378
 				array('check', 'cal_short_days'),
372 379
 				array('check', 'cal_short_months'),
373 380
 		);
374
-	else
375
-		$config_vars = array(
381
+	} else {
382
+			$config_vars = array(
376 383
 			array('check', 'cal_enabled'),
377 384
 		);
385
+	}
378 386
 
379 387
 	call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars));
380
-	if ($return_config)
381
-		return $config_vars;
388
+	if ($return_config) {
389
+			return $config_vars;
390
+	}
382 391
 
383 392
 	// Get the settings template fired up.
384 393
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.
Sources/Subs-Calendar.php 1 patch
Braces   +215 added lines, -157 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Get all birthdays within the given time range.
@@ -60,8 +61,7 @@  discard block
 block discarded – undo
60 61
 				'max_year' => $year_high,
61 62
 			)
62 63
 		);
63
-	}
64
-	else
64
+	} else
65 65
 	{
66 66
 		$result = $smcFunc['db_query']('birthday_array', '
67 67
 			SELECT id_member, real_name, YEAR(birthdate) AS birth_year, birthdate
@@ -91,10 +91,11 @@  discard block
 block discarded – undo
91 91
 	$bday = array();
92 92
 	while ($row = $smcFunc['db_fetch_assoc']($result))
93 93
 	{
94
-		if ($year_low != $year_high)
95
-			$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
96
-		else
97
-			$age_year = $year_low;
94
+		if ($year_low != $year_high) {
95
+					$age_year = substr($row['birthdate'], 5) < substr($high_date, 5) ? $year_high : $year_low;
96
+		} else {
97
+					$age_year = $year_low;
98
+		}
98 99
 
99 100
 		$bday[$age_year . substr($row['birthdate'], 4)][] = array(
100 101
 			'id' => $row['id_member'],
@@ -108,8 +109,9 @@  discard block
 block discarded – undo
108 109
 	ksort($bday);
109 110
 
110 111
 	// Set is_last, so the themes know when to stop placing separators.
111
-	foreach ($bday as $mday => $array)
112
-		$bday[$mday][count($array) - 1]['is_last'] = true;
112
+	foreach ($bday as $mday => $array) {
113
+			$bday[$mday][count($array) - 1]['is_last'] = true;
114
+	}
113 115
 
114 116
 	return $bday;
115 117
 }
@@ -157,8 +159,9 @@  discard block
 block discarded – undo
157 159
 	while ($row = $smcFunc['db_fetch_assoc']($result))
158 160
 	{
159 161
 		// If the attached topic is not approved then for the moment pretend it doesn't exist
160
-		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved'])
161
-			continue;
162
+		if (!empty($row['id_first_msg']) && $modSettings['postmod_active'] && !$row['approved']) {
163
+					continue;
164
+		}
162 165
 
163 166
 		// Force a censor of the title - as often these are used by others.
164 167
 		censorText($row['title'], $use_permissions ? false : true);
@@ -167,8 +170,9 @@  discard block
 block discarded – undo
167 170
 		list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
168 171
 
169 172
 		// Sanity check
170
-		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
171
-			continue;
173
+		if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
174
+					continue;
175
+		}
172 176
 
173 177
 		// Get set up for the loop
174 178
 		$start_object = date_create($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''), timezone_open($tz));
@@ -232,8 +236,8 @@  discard block
 block discarded – undo
232 236
 			);
233 237
 
234 238
 			// If we're using permissions (calendar pages?) then just ouput normal contextual style information.
235
-			if ($use_permissions)
236
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
239
+			if ($use_permissions) {
240
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
237 241
 					'href' => $row['id_board'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
238 242
 					'link' => $row['id_board'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
239 243
 					'can_edit' => allowedTo('calendar_edit_any') || ($row['id_member'] == $user_info['id'] && allowedTo('calendar_edit_own')),
@@ -241,9 +245,10 @@  discard block
 block discarded – undo
241 245
 					'can_export' => !empty($modSettings['cal_export']) ? true : false,
242 246
 					'export_href' => $scripturl . '?action=calendar;sa=ical;eventid=' . $row['id_event'] . ';' . $context['session_var'] . '=' . $context['session_id'],
243 247
 				));
248
+			}
244 249
 			// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
245
-			else
246
-				$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
250
+			else {
251
+							$events[date_format($cal_date, 'Y-m-d')][] = array_merge($eventProperties, array(
247 252
 					'href' => $row['id_topic'] == 0 ? '' : $scripturl . '?topic=' . $row['id_topic'] . '.0',
248 253
 					'link' => $row['id_topic'] == 0 ? $row['title'] : '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['title'] . '</a>',
249 254
 					'can_edit' => false,
@@ -253,6 +258,7 @@  discard block
 block discarded – undo
253 258
 					'poster' => $row['id_member'],
254 259
 					'allowed_groups' => explode(',', $row['member_groups']),
255 260
 				));
261
+			}
256 262
 
257 263
 			date_add($cal_date, date_interval_create_from_date_string('1 day'));
258 264
 		}
@@ -262,8 +268,9 @@  discard block
 block discarded – undo
262 268
 	// If we're doing normal contextual data, go through and make things clear to the templates ;).
263 269
 	if ($use_permissions)
264 270
 	{
265
-		foreach ($events as $mday => $array)
266
-			$events[$mday][count($array) - 1]['is_last'] = true;
271
+		foreach ($events as $mday => $array) {
272
+					$events[$mday][count($array) - 1]['is_last'] = true;
273
+		}
267 274
 	}
268 275
 
269 276
 	ksort($events);
@@ -283,11 +290,12 @@  discard block
 block discarded – undo
283 290
 	global $smcFunc;
284 291
 
285 292
 	// Get the lowest and highest dates for "all years".
286
-	if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
287
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
293
+	if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
294
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_dec}
288 295
 			OR event_date BETWEEN {date:all_year_jan} AND {date:all_year_high}';
289
-	else
290
-		$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
296
+	} else {
297
+			$allyear_part = 'event_date BETWEEN {date:all_year_low} AND {date:all_year_high}';
298
+	}
291 299
 
292 300
 	// Find some holidays... ;).
293 301
 	$result = $smcFunc['db_query']('', '
@@ -307,10 +315,11 @@  discard block
 block discarded – undo
307 315
 	$holidays = array();
308 316
 	while ($row = $smcFunc['db_fetch_assoc']($result))
309 317
 	{
310
-		if (substr($low_date, 0, 4) != substr($high_date, 0, 4))
311
-			$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
312
-		else
313
-			$event_year = substr($low_date, 0, 4);
318
+		if (substr($low_date, 0, 4) != substr($high_date, 0, 4)) {
319
+					$event_year = substr($row['event_date'], 5) < substr($high_date, 5) ? substr($high_date, 0, 4) : substr($low_date, 0, 4);
320
+		} else {
321
+					$event_year = substr($low_date, 0, 4);
322
+		}
314 323
 
315 324
 		$holidays[$event_year . substr($row['event_date'], 4)][] = $row['title'];
316 325
 	}
@@ -336,10 +345,12 @@  discard block
 block discarded – undo
336 345
 	isAllowedTo('calendar_post');
337 346
 
338 347
 	// No board?  No topic?!?
339
-	if (empty($board))
340
-		fatal_lang_error('missing_board_id', false);
341
-	if (empty($topic))
342
-		fatal_lang_error('missing_topic_id', false);
348
+	if (empty($board)) {
349
+			fatal_lang_error('missing_board_id', false);
350
+	}
351
+	if (empty($topic)) {
352
+			fatal_lang_error('missing_topic_id', false);
353
+	}
343 354
 
344 355
 	// Administrator, Moderator, or owner.  Period.
345 356
 	if (!allowedTo('admin_forum') && !allowedTo('moderate_board'))
@@ -357,12 +368,14 @@  discard block
 block discarded – undo
357 368
 		if ($row = $smcFunc['db_fetch_assoc']($result))
358 369
 		{
359 370
 			// Not the owner of the topic.
360
-			if ($row['id_member_started'] != $user_info['id'])
361
-				fatal_lang_error('not_your_topic', 'user');
371
+			if ($row['id_member_started'] != $user_info['id']) {
372
+							fatal_lang_error('not_your_topic', 'user');
373
+			}
362 374
 		}
363 375
 		// Topic/Board doesn't exist.....
364
-		else
365
-			fatal_lang_error('calendar_no_topic', 'general');
376
+		else {
377
+					fatal_lang_error('calendar_no_topic', 'general');
378
+		}
366 379
 		$smcFunc['db_free_result']($result);
367 380
 	}
368 381
 }
@@ -450,14 +463,16 @@  discard block
 block discarded – undo
450 463
 	if (!empty($calendarOptions['start_day']))
451 464
 	{
452 465
 		$nShift -= $calendarOptions['start_day'];
453
-		if ($nShift < 0)
454
-			$nShift = 7 + $nShift;
466
+		if ($nShift < 0) {
467
+					$nShift = 7 + $nShift;
468
+		}
455 469
 	}
456 470
 
457 471
 	// Number of rows required to fit the month.
458 472
 	$nRows = floor(($month_info['last_day']['day_of_month'] + $nShift) / 7);
459
-	if (($month_info['last_day']['day_of_month'] + $nShift) % 7)
460
-		$nRows++;
473
+	if (($month_info['last_day']['day_of_month'] + $nShift) % 7) {
474
+			$nRows++;
475
+	}
461 476
 
462 477
 	// Fetch the arrays for birthdays, posted events, and holidays.
463 478
 	$bday = $calendarOptions['show_birthdays'] ? getBirthdayRange($month_info['first_day']['date'], $month_info['last_day']['date']) : array();
@@ -470,8 +485,9 @@  discard block
 block discarded – undo
470 485
 	{
471 486
 		$calendarGrid['week_days'][] = $count;
472 487
 		$count++;
473
-		if ($count == 7)
474
-			$count = 0;
488
+		if ($count == 7) {
489
+					$count = 0;
490
+		}
475 491
 	}
476 492
 
477 493
 	// Iterate through each week.
@@ -488,8 +504,9 @@  discard block
 block discarded – undo
488 504
 		{
489 505
 			$nDay = ($nRow * 7) + $nCol - $nShift + 1;
490 506
 
491
-			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month'])
492
-				$nDay = 0;
507
+			if ($nDay < 1 || $nDay > $month_info['last_day']['day_of_month']) {
508
+							$nDay = 0;
509
+			}
493 510
 
494 511
 			$date = sprintf('%04d-%02d-%02d', $year, $month, $nDay);
495 512
 
@@ -507,8 +524,9 @@  discard block
 block discarded – undo
507 524
 	}
508 525
 
509 526
 	// What is the last day of the month?
510
-	if ($is_previous === true)
511
-		$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
527
+	if ($is_previous === true) {
528
+			$calendarGrid['last_of_month'] = $month_info['last_day']['day_of_month'];
529
+	}
512 530
 
513 531
 	// We'll use the shift in the template.
514 532
 	$calendarGrid['shift'] = $nShift;
@@ -542,8 +560,9 @@  discard block
 block discarded – undo
542 560
 	{
543 561
 		// Here we offset accordingly to get things to the real start of a week.
544 562
 		$date_diff = $day_of_week - $calendarOptions['start_day'];
545
-		if ($date_diff < 0)
546
-			$date_diff += 7;
563
+		if ($date_diff < 0) {
564
+					$date_diff += 7;
565
+		}
547 566
 		$new_timestamp = mktime(0, 0, 0, $month, $day, $year) - $date_diff * 86400;
548 567
 		$day = (int) strftime('%d', $new_timestamp);
549 568
 		$month = (int) strftime('%m', $new_timestamp);
@@ -673,18 +692,20 @@  discard block
 block discarded – undo
673 692
 	{
674 693
 		foreach ($date_events as $event_key => $event_val)
675 694
 		{
676
-			if (in_array($event_val['id'], $temp))
677
-				unset($calendarGrid['events'][$date][$event_key]);
678
-			else
679
-				$temp[] = $event_val['id'];
695
+			if (in_array($event_val['id'], $temp)) {
696
+							unset($calendarGrid['events'][$date][$event_key]);
697
+			} else {
698
+							$temp[] = $event_val['id'];
699
+			}
680 700
 		}
681 701
 	}
682 702
 
683 703
 	// Give birthdays and holidays a friendly format, without the year
684
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
685
-		$date_format = '%b %d';
686
-	else
687
-		$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
704
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
705
+			$date_format = '%b %d';
706
+	} else {
707
+			$date_format = str_replace(array('%Y', '%y', '%G', '%g', '%C', '%c', '%D'), array('', '', '', '', '', '%b %d', '%m/%d'), $matches[0]);
708
+	}
688 709
 
689 710
 	foreach (array('birthdays', 'holidays') as $type)
690 711
 	{
@@ -779,8 +800,9 @@  discard block
 block discarded – undo
779 800
 	// Holidays between now and now + days.
780 801
 	for ($i = $now; $i < $now + $days_for_index; $i += 86400)
781 802
 	{
782
-		if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)]))
783
-			$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
803
+		if (isset($cached_data['holidays'][strftime('%Y-%m-%d', $i)])) {
804
+					$return_data['calendar_holidays'] = array_merge($return_data['calendar_holidays'], $cached_data['holidays'][strftime('%Y-%m-%d', $i)]);
805
+		}
784 806
 	}
785 807
 
786 808
 	// Happy Birthday, guys and gals!
@@ -789,8 +811,9 @@  discard block
 block discarded – undo
789 811
 		$loop_date = strftime('%Y-%m-%d', $i);
790 812
 		if (isset($cached_data['birthdays'][$loop_date]))
791 813
 		{
792
-			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy)
793
-				$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
814
+			foreach ($cached_data['birthdays'][$loop_date] as $index => $dummy) {
815
+							$cached_data['birthdays'][strftime('%Y-%m-%d', $i)][$index]['is_today'] = $loop_date === $today['date'];
816
+			}
794 817
 			$return_data['calendar_birthdays'] = array_merge($return_data['calendar_birthdays'], $cached_data['birthdays'][$loop_date]);
795 818
 		}
796 819
 	}
@@ -802,8 +825,9 @@  discard block
 block discarded – undo
802 825
 		$loop_date = strftime('%Y-%m-%d', $i);
803 826
 
804 827
 		// No events today? Check the next day.
805
-		if (empty($cached_data['events'][$loop_date]))
806
-			continue;
828
+		if (empty($cached_data['events'][$loop_date])) {
829
+					continue;
830
+		}
807 831
 
808 832
 		// Loop through all events to add a few last-minute values.
809 833
 		foreach ($cached_data['events'][$loop_date] as $ev => $event)
@@ -816,9 +840,9 @@  discard block
 block discarded – undo
816 840
 			{
817 841
 				unset($cached_data['events'][$loop_date][$ev]);
818 842
 				continue;
843
+			} else {
844
+							$duplicates[$this_event['topic'] . $this_event['title']] = true;
819 845
 			}
820
-			else
821
-				$duplicates[$this_event['topic'] . $this_event['title']] = true;
822 846
 
823 847
 			// Might be set to true afterwards, depending on the permissions.
824 848
 			$this_event['can_edit'] = false;
@@ -826,15 +850,18 @@  discard block
 block discarded – undo
826 850
 			$this_event['date'] = $loop_date;
827 851
 		}
828 852
 
829
-		if (!empty($cached_data['events'][$loop_date]))
830
-			$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
853
+		if (!empty($cached_data['events'][$loop_date])) {
854
+					$return_data['calendar_events'] = array_merge($return_data['calendar_events'], $cached_data['events'][$loop_date]);
855
+		}
831 856
 	}
832 857
 
833 858
 	// Mark the last item so that a list separator can be used in the template.
834
-	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++)
835
-		$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
836
-	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++)
837
-		$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
859
+	for ($i = 0, $n = count($return_data['calendar_birthdays']); $i < $n; $i++) {
860
+			$return_data['calendar_birthdays'][$i]['is_last'] = !isset($return_data['calendar_birthdays'][$i + 1]);
861
+	}
862
+	for ($i = 0, $n = count($return_data['calendar_events']); $i < $n; $i++) {
863
+			$return_data['calendar_events'][$i]['is_last'] = !isset($return_data['calendar_events'][$i + 1]);
864
+	}
838 865
 
839 866
 	return array(
840 867
 		'data' => $return_data,
@@ -882,37 +909,46 @@  discard block
 block discarded – undo
882 909
 		if (isset($_POST['start_date']))
883 910
 		{
884 911
 			$d = date_parse($_POST['start_date']);
885
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
886
-				fatal_lang_error('invalid_date', false);
887
-			if (empty($d['year']))
888
-				fatal_lang_error('event_year_missing', false);
889
-			if (empty($d['month']))
890
-				fatal_lang_error('event_month_missing', false);
891
-		}
892
-		elseif (isset($_POST['start_datetime']))
912
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
913
+							fatal_lang_error('invalid_date', false);
914
+			}
915
+			if (empty($d['year'])) {
916
+							fatal_lang_error('event_year_missing', false);
917
+			}
918
+			if (empty($d['month'])) {
919
+							fatal_lang_error('event_month_missing', false);
920
+			}
921
+		} elseif (isset($_POST['start_datetime']))
893 922
 		{
894 923
 			$d = date_parse($_POST['start_datetime']);
895
-			if (!empty($d['error_count']) || !empty($d['warning_count']))
896
-				fatal_lang_error('invalid_date', false);
897
-			if (empty($d['year']))
898
-				fatal_lang_error('event_year_missing', false);
899
-			if (empty($d['month']))
900
-				fatal_lang_error('event_month_missing', false);
924
+			if (!empty($d['error_count']) || !empty($d['warning_count'])) {
925
+							fatal_lang_error('invalid_date', false);
926
+			}
927
+			if (empty($d['year'])) {
928
+							fatal_lang_error('event_year_missing', false);
929
+			}
930
+			if (empty($d['month'])) {
931
+							fatal_lang_error('event_month_missing', false);
932
+			}
901 933
 		}
902 934
 		// The 2.0 way
903 935
 		else
904 936
 		{
905 937
 			// No month?  No year?
906
-			if (!isset($_POST['month']))
907
-				fatal_lang_error('event_month_missing', false);
908
-			if (!isset($_POST['year']))
909
-				fatal_lang_error('event_year_missing', false);
938
+			if (!isset($_POST['month'])) {
939
+							fatal_lang_error('event_month_missing', false);
940
+			}
941
+			if (!isset($_POST['year'])) {
942
+							fatal_lang_error('event_year_missing', false);
943
+			}
910 944
 
911 945
 			// Check the month and year...
912
-			if ($_POST['month'] < 1 || $_POST['month'] > 12)
913
-				fatal_lang_error('invalid_month', false);
914
-			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear'])
915
-				fatal_lang_error('invalid_year', false);
946
+			if ($_POST['month'] < 1 || $_POST['month'] > 12) {
947
+							fatal_lang_error('invalid_month', false);
948
+			}
949
+			if ($_POST['year'] < $modSettings['cal_minyear'] || $_POST['year'] > $modSettings['cal_maxyear']) {
950
+							fatal_lang_error('invalid_year', false);
951
+			}
916 952
 		}
917 953
 	}
918 954
 
@@ -922,8 +958,9 @@  discard block
 block discarded – undo
922 958
 	// If they want to us to calculate an end date, make sure it will fit in an acceptable range.
923 959
 	if (isset($_POST['span']))
924 960
 	{
925
-		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan']))
926
-			fatal_lang_error('invalid_days_numb', false);
961
+		if (($_POST['span'] < 1) || (!empty($modSettings['cal_maxspan']) && $_POST['span'] > $modSettings['cal_maxspan'])) {
962
+					fatal_lang_error('invalid_days_numb', false);
963
+		}
927 964
 	}
928 965
 
929 966
 	// There is no need to validate the following values if we are just deleting the event.
@@ -933,24 +970,29 @@  discard block
 block discarded – undo
933 970
 		if (empty($_POST['start_date']) && empty($_POST['start_datetime']))
934 971
 		{
935 972
 			// No day?
936
-			if (!isset($_POST['day']))
937
-				fatal_lang_error('event_day_missing', false);
973
+			if (!isset($_POST['day'])) {
974
+							fatal_lang_error('event_day_missing', false);
975
+			}
938 976
 
939 977
 			// Bad day?
940
-			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year']))
941
-				fatal_lang_error('invalid_date', false);
978
+			if (!checkdate($_POST['month'], $_POST['day'], $_POST['year'])) {
979
+							fatal_lang_error('invalid_date', false);
980
+			}
942 981
 		}
943 982
 
944
-		if (!isset($_POST['evtitle']) && !isset($_POST['subject']))
945
-			fatal_lang_error('event_title_missing', false);
946
-		elseif (!isset($_POST['evtitle']))
947
-			$_POST['evtitle'] = $_POST['subject'];
983
+		if (!isset($_POST['evtitle']) && !isset($_POST['subject'])) {
984
+					fatal_lang_error('event_title_missing', false);
985
+		} elseif (!isset($_POST['evtitle'])) {
986
+					$_POST['evtitle'] = $_POST['subject'];
987
+		}
948 988
 
949 989
 		// No title?
950
-		if ($smcFunc['htmltrim']($_POST['evtitle']) === '')
951
-			fatal_lang_error('no_event_title', false);
952
-		if ($smcFunc['strlen']($_POST['evtitle']) > 100)
953
-			$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
990
+		if ($smcFunc['htmltrim']($_POST['evtitle']) === '') {
991
+					fatal_lang_error('no_event_title', false);
992
+		}
993
+		if ($smcFunc['strlen']($_POST['evtitle']) > 100) {
994
+					$_POST['evtitle'] = $smcFunc['substr']($_POST['evtitle'], 0, 100);
995
+		}
954 996
 		$_POST['evtitle'] = str_replace(';', '', $_POST['evtitle']);
955 997
 	}
956 998
 }
@@ -977,8 +1019,9 @@  discard block
 block discarded – undo
977 1019
 	);
978 1020
 
979 1021
 	// No results, return false.
980
-	if ($smcFunc['db_num_rows'] === 0)
981
-		return false;
1022
+	if ($smcFunc['db_num_rows'] === 0) {
1023
+			return false;
1024
+	}
982 1025
 
983 1026
 	// Grab the results and return.
984 1027
 	list ($poster) = $smcFunc['db_fetch_row']($request);
@@ -1112,8 +1155,9 @@  discard block
 block discarded – undo
1112 1155
 	call_integration_hook('integrate_modify_event', array($event_id, &$eventOptions, &$event_columns, &$event_parameters));
1113 1156
 
1114 1157
 	$column_clauses = array();
1115
-	foreach ($event_columns as $col => $crit)
1116
-		$column_clauses[] = $col . ' = ' . $crit;
1158
+	foreach ($event_columns as $col => $crit) {
1159
+			$column_clauses[] = $col . ' = ' . $crit;
1160
+	}
1117 1161
 
1118 1162
 	$smcFunc['db_query']('', '
1119 1163
 		UPDATE {db_prefix}calendar
@@ -1198,8 +1242,9 @@  discard block
 block discarded – undo
1198 1242
 	);
1199 1243
 
1200 1244
 	// If nothing returned, we are in poo, poo.
1201
-	if ($smcFunc['db_num_rows']($request) === 0)
1202
-		return false;
1245
+	if ($smcFunc['db_num_rows']($request) === 0) {
1246
+			return false;
1247
+	}
1203 1248
 
1204 1249
 	$row = $smcFunc['db_fetch_assoc']($request);
1205 1250
 	$smcFunc['db_free_result']($request);
@@ -1207,8 +1252,9 @@  discard block
 block discarded – undo
1207 1252
 	list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row);
1208 1253
 
1209 1254
 	// Sanity check
1210
-	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count']))
1211
-		return false;
1255
+	if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) {
1256
+			return false;
1257
+	}
1212 1258
 
1213 1259
 	$return_value = array(
1214 1260
 		'boards' => array(),
@@ -1345,24 +1391,27 @@  discard block
 block discarded – undo
1345 1391
 
1346 1392
 	// Set $span, in case we need it
1347 1393
 	$span = isset($eventOptions['span']) ? $eventOptions['span'] : (isset($_POST['span']) ? $_POST['span'] : 0);
1348
-	if ($span > 0)
1349
-		$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1394
+	if ($span > 0) {
1395
+			$span = !empty($modSettings['cal_maxspan']) ? min($modSettings['cal_maxspan'], $span - 1) : $span - 1;
1396
+	}
1350 1397
 
1351 1398
 	// Define the timezone for this event, falling back to the default if not provided
1352
-	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1353
-		$tz = $eventOptions['tz'];
1354
-	elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1355
-		$tz = $_POST['tz'];
1356
-	else
1357
-		$tz = getUserTimezone();
1399
+	if (!empty($eventOptions['tz']) && in_array($eventOptions['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1400
+			$tz = $eventOptions['tz'];
1401
+	} elseif (!empty($_POST['tz']) && in_array($_POST['tz'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1402
+			$tz = $_POST['tz'];
1403
+	} else {
1404
+			$tz = getUserTimezone();
1405
+	}
1358 1406
 
1359 1407
 	// Is this supposed to be an all day event, or should it have specific start and end times?
1360
-	if (isset($eventOptions['allday']))
1361
-		$allday = $eventOptions['allday'];
1362
-	elseif (empty($_POST['allday']))
1363
-		$allday = false;
1364
-	else
1365
-		$allday = true;
1408
+	if (isset($eventOptions['allday'])) {
1409
+			$allday = $eventOptions['allday'];
1410
+	} elseif (empty($_POST['allday'])) {
1411
+			$allday = false;
1412
+	} else {
1413
+			$allday = true;
1414
+	}
1366 1415
 
1367 1416
 	// Input might come as individual parameters...
1368 1417
 	$start_year = isset($eventOptions['year']) ? $eventOptions['year'] : (isset($_POST['year']) ? $_POST['year'] : null);
@@ -1389,10 +1438,12 @@  discard block
 block discarded – undo
1389 1438
 	$end_time_string = isset($eventOptions['end_time']) ? $eventOptions['end_time'] : (isset($_POST['end_time']) ? $_POST['end_time'] : null);
1390 1439
 
1391 1440
 	// If the date and time were given in separate strings, combine them
1392
-	if (empty($start_string) && isset($start_date_string))
1393
-		$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1394
-	if (empty($end_string) && isset($end_date_string))
1395
-		$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1441
+	if (empty($start_string) && isset($start_date_string)) {
1442
+			$start_string = $start_date_string . (isset($start_time_string) ? ' ' . $start_time_string : '');
1443
+	}
1444
+	if (empty($end_string) && isset($end_date_string)) {
1445
+			$end_string = $end_date_string . (isset($end_time_string) ? ' ' . $end_time_string : '');
1446
+	}
1396 1447
 
1397 1448
 	// If some form of string input was given, override individually defined options with it
1398 1449
 	if (isset($start_string))
@@ -1483,10 +1534,11 @@  discard block
 block discarded – undo
1483 1534
 	if ($start_object >= $end_object)
1484 1535
 	{
1485 1536
 		$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1486
-		if ($span > 0)
1487
-			date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1488
-		else
1489
-			date_add($end_object, date_interval_create_from_date_string('1 hour'));
1537
+		if ($span > 0) {
1538
+					date_add($end_object, date_interval_create_from_date_string($span . ' days'));
1539
+		} else {
1540
+					date_add($end_object, date_interval_create_from_date_string('1 hour'));
1541
+		}
1490 1542
 	}
1491 1543
 
1492 1544
 	// Is $end_object too late?
@@ -1499,9 +1551,9 @@  discard block
 block discarded – undo
1499 1551
 			{
1500 1552
 				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, $start_hour, $start_minute, $start_second) . ' ' . $tz);
1501 1553
 				date_add($end_object, date_interval_create_from_date_string($modSettings['cal_maxspan'] . ' days'));
1554
+			} else {
1555
+							$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1502 1556
 			}
1503
-			else
1504
-				$end_object = date_create(sprintf('%04d-%02d-%02d %02d:%02d:%02d', $start_year, $start_month, $start_day, '11', '59', '59') . ' ' . $tz);
1505 1557
 		}
1506 1558
 	}
1507 1559
 
@@ -1514,8 +1566,7 @@  discard block
 block discarded – undo
1514 1566
 		$start_time = null;
1515 1567
 		$end_time = null;
1516 1568
 		$tz = null;
1517
-	}
1518
-	else
1569
+	} else
1519 1570
 	{
1520 1571
 		$start_time = date_format($start_object, 'H:i:s');
1521 1572
 		$end_time = date_format($end_object, 'H:i:s');
@@ -1536,16 +1587,18 @@  discard block
 block discarded – undo
1536 1587
 	require_once($sourcedir . '/Subs.php');
1537 1588
 
1538 1589
 	// First, try to create a better date format, ignoring the "time" elements.
1539
-	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1540
-		$date_format = '%F';
1541
-	else
1542
-		$date_format = $matches[0];
1590
+	if (preg_match('~%[AaBbCcDdeGghjmuYy](?:[^%]*%[AaBbCcDdeGghjmuYy])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1591
+			$date_format = '%F';
1592
+	} else {
1593
+			$date_format = $matches[0];
1594
+	}
1543 1595
 
1544 1596
 	// We want a fairly compact version of the time, but as close as possible to the user's settings.
1545
-	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0]))
1546
-		$time_format = '%k:%M';
1547
-	else
1548
-		$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1597
+	if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) {
1598
+			$time_format = '%k:%M';
1599
+	} else {
1600
+			$time_format = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]);
1601
+	}
1549 1602
 
1550 1603
 	// Should this be an all day event?
1551 1604
 	$allday = (empty($row['start_time']) || empty($row['end_time']) || empty($row['timezone']) || !in_array($row['timezone'], timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) ? true : false;
@@ -1554,8 +1607,9 @@  discard block
 block discarded – undo
1554 1607
 	$span = 1 + date_interval_format(date_diff(date_create($row['start_date']), date_create($row['end_date'])), '%d');
1555 1608
 
1556 1609
 	// We need to have a defined timezone in the steps below
1557
-	if (empty($row['timezone']))
1558
-		$row['timezone'] = getUserTimezone();
1610
+	if (empty($row['timezone'])) {
1611
+			$row['timezone'] = getUserTimezone();
1612
+	}
1559 1613
 
1560 1614
 	// Get most of the standard date information for the start and end datetimes
1561 1615
 	$start = date_parse($row['start_date'] . (!$allday ? ' ' . $row['start_time'] : ''));
@@ -1607,8 +1661,9 @@  discard block
 block discarded – undo
1607 1661
 	global $smcFunc, $context, $user_info, $modSettings, $user_settings;
1608 1662
 	static $member_cache = array();
1609 1663
 
1610
-	if (is_null($id_member) && $user_info['is_guest'] == false)
1611
-		$id_member = $context['user']['id'];
1664
+	if (is_null($id_member) && $user_info['is_guest'] == false) {
1665
+			$id_member = $context['user']['id'];
1666
+	}
1612 1667
 
1613 1668
 	//check if the cache got the data
1614 1669
 	if (isset($id_member) && isset($member_cache[$id_member]))
@@ -1637,11 +1692,13 @@  discard block
 block discarded – undo
1637 1692
 		$smcFunc['db_free_result']($request);
1638 1693
 	}
1639 1694
 
1640
-	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
1641
-		$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1695
+	if (empty($timezone) || !in_array($timezone, timezone_identifiers_list(DateTimeZone::ALL_WITH_BC))) {
1696
+			$timezone = isset($modSettings['default_timezone']) ? $modSettings['default_timezone'] : date_default_timezone_get();
1697
+	}
1642 1698
 
1643
-	if (isset($id_member))
1644
-		$member_cache[$id_member] = $timezone;
1699
+	if (isset($id_member)) {
1700
+			$member_cache[$id_member] = $timezone;
1701
+	}
1645 1702
 
1646 1703
 	return $timezone;
1647 1704
 }
@@ -1670,8 +1727,9 @@  discard block
 block discarded – undo
1670 1727
 		)
1671 1728
 	);
1672 1729
 	$holidays = array();
1673
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1674
-		$holidays[] = $row;
1730
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1731
+			$holidays[] = $row;
1732
+	}
1675 1733
 	$smcFunc['db_free_result']($request);
1676 1734
 
1677 1735
 	return $holidays;
Please login to merge, or discard this patch.