Completed
Push — release-2.1 ( 2c98df...eb2022 )
by Colin
10:42
created
Sources/Profile-View.php 1 patch
Braces   +303 added lines, -222 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@  discard block
 block discarded – undo
11 11
  * @version 2.1 Beta 4
12 12
  */
13 13
 
14
-if (!defined('SMF'))
14
+if (!defined('SMF')) {
15 15
 	die('No direct access...');
16
+}
16 17
 
17 18
 /**
18 19
  * View a summary.
@@ -23,8 +24,9 @@  discard block
 block discarded – undo
23 24
 	global $context, $memberContext, $txt, $modSettings, $user_profile, $sourcedir, $scripturl, $smcFunc;
24 25
 
25 26
 	// Attempt to load the member's profile data.
26
-	if (!loadMemberContext($memID) || !isset($memberContext[$memID]))
27
-		fatal_lang_error('not_a_user', false, 404);
27
+	if (!loadMemberContext($memID) || !isset($memberContext[$memID])) {
28
+			fatal_lang_error('not_a_user', false, 404);
29
+	}
28 30
 
29 31
 	// Set up the stuff and load the user.
30 32
 	$context += array(
@@ -49,19 +51,21 @@  discard block
 block discarded – undo
49 51
 
50 52
 	// See if they have broken any warning levels...
51 53
 	list ($modSettings['warning_enable'], $modSettings['user_limit']) = explode(',', $modSettings['warning_settings']);
52
-	if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning'])
53
-		$context['warning_status'] = $txt['profile_warning_is_muted'];
54
-	elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning'])
55
-		$context['warning_status'] = $txt['profile_warning_is_moderation'];
56
-	elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning'])
57
-		$context['warning_status'] = $txt['profile_warning_is_watch'];
54
+	if (!empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $context['member']['warning']) {
55
+			$context['warning_status'] = $txt['profile_warning_is_muted'];
56
+	} elseif (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $context['member']['warning']) {
57
+			$context['warning_status'] = $txt['profile_warning_is_moderation'];
58
+	} elseif (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $context['member']['warning']) {
59
+			$context['warning_status'] = $txt['profile_warning_is_watch'];
60
+	}
58 61
 
59 62
 	// They haven't even been registered for a full day!?
60 63
 	$days_registered = (int) ((time() - $user_profile[$memID]['date_registered']) / (3600 * 24));
61
-	if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1)
62
-		$context['member']['posts_per_day'] = $txt['not_applicable'];
63
-	else
64
-		$context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3);
64
+	if (empty($user_profile[$memID]['date_registered']) || $days_registered < 1) {
65
+			$context['member']['posts_per_day'] = $txt['not_applicable'];
66
+	} else {
67
+			$context['member']['posts_per_day'] = comma_format($context['member']['real_posts'] / $days_registered, 3);
68
+	}
65 69
 
66 70
 	// Set the age...
67 71
 	if (empty($context['member']['birth_date']) || substr($context['member']['birth_date'], 0, 4) < 1002)
@@ -70,8 +74,7 @@  discard block
 block discarded – undo
70 74
 			'age' => $txt['not_applicable'],
71 75
 			'today_is_birthday' => false
72 76
 		);
73
-	}
74
-	else
77
+	} else
75 78
 	{
76 79
 		list ($birth_year, $birth_month, $birth_day) = sscanf($context['member']['birth_date'], '%d-%d-%d');
77 80
 		$datearray = getdate(forum_time());
@@ -84,15 +87,16 @@  discard block
 block discarded – undo
84 87
 	if (allowedTo('moderate_forum'))
85 88
 	{
86 89
 		// Make sure it's a valid ip address; otherwise, don't bother...
87
-		if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup']))
88
-			$context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']);
89
-		else
90
-			$context['member']['hostname'] = '';
90
+		if (preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $memberContext[$memID]['ip']) == 1 && empty($modSettings['disableHostnameLookup'])) {
91
+					$context['member']['hostname'] = host_from_ip($memberContext[$memID]['ip']);
92
+		} else {
93
+					$context['member']['hostname'] = '';
94
+		}
91 95
 
92 96
 		$context['can_see_ip'] = true;
97
+	} else {
98
+			$context['can_see_ip'] = false;
93 99
 	}
94
-	else
95
-		$context['can_see_ip'] = false;
96 100
 
97 101
 	// Are they hidden?
98 102
 	$context['member']['is_hidden'] = empty($user_profile[$memID]['show_online']);
@@ -103,8 +107,9 @@  discard block
 block discarded – undo
103 107
 		include_once($sourcedir . '/Who.php');
104 108
 		$action = determineActions($user_profile[$memID]['url']);
105 109
 
106
-		if ($action !== false)
107
-			$context['member']['action'] = $action;
110
+		if ($action !== false) {
111
+					$context['member']['action'] = $action;
112
+		}
108 113
 	}
109 114
 
110 115
 	// If the user is awaiting activation, and the viewer has permission - setup some activation context messages.
@@ -167,13 +172,15 @@  discard block
 block discarded – undo
167 172
 		{
168 173
 			// Work out what restrictions we actually have.
169 174
 			$ban_restrictions = array();
170
-			foreach (array('access', 'login', 'post') as $type)
171
-				if ($row['cannot_' . $type])
175
+			foreach (array('access', 'login', 'post') as $type) {
176
+							if ($row['cannot_' . $type])
172 177
 					$ban_restrictions[] = $txt['ban_type_' . $type];
178
+			}
173 179
 
174 180
 			// No actual ban in place?
175
-			if (empty($ban_restrictions))
176
-				continue;
181
+			if (empty($ban_restrictions)) {
182
+							continue;
183
+			}
177 184
 
178 185
 			// Prepare the link for context.
179 186
 			$ban_explanation = sprintf($txt['user_cannot_due_to'], implode(', ', $ban_restrictions), '<a href="' . $scripturl . '?action=admin;area=ban;sa=edit;bg=' . $row['id_ban_group'] . '">' . $row['name'] . '</a>');
@@ -195,9 +202,10 @@  discard block
 block discarded – undo
195 202
 	$context['print_custom_fields'] = array();
196 203
 
197 204
 	// Any custom profile fields?
198
-	if (!empty($context['custom_fields']))
199
-		foreach ($context['custom_fields'] as $custom)
205
+	if (!empty($context['custom_fields'])) {
206
+			foreach ($context['custom_fields'] as $custom)
200 207
 			$context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
208
+	}
201 209
 
202 210
 }
203 211
 
@@ -245,16 +253,18 @@  discard block
 block discarded – undo
245 253
 		$row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array();
246 254
 		$alerts[$id_alert] = $row;
247 255
 
248
-		if (!empty($row['sender_id']))
249
-			$senders[] = $row['sender_id'];
256
+		if (!empty($row['sender_id'])) {
257
+					$senders[] = $row['sender_id'];
258
+		}
250 259
 	}
251 260
 	$smcFunc['db_free_result']($request);
252 261
 
253 262
 	if($withSender)
254 263
 	{
255 264
 		$senders = loadMemberData($senders);
256
-		foreach ($senders as $member)
257
-			loadMemberContext($member);
265
+		foreach ($senders as $member) {
266
+					loadMemberContext($member);
267
+		}
258 268
 	}
259 269
 
260 270
 	// Now go through and actually make with the text.
@@ -269,12 +279,15 @@  discard block
 block discarded – undo
269 279
 	$msgs = array();
270 280
 	foreach ($alerts as $id_alert => $alert)
271 281
 	{
272
-		if (isset($alert['extra']['board']))
273
-			$boards[$alert['extra']['board']] = $txt['board_na'];
274
-		if (isset($alert['extra']['topic']))
275
-			$topics[$alert['extra']['topic']] = $txt['topic_na'];
276
-		if ($alert['content_type'] == 'msg')
277
-			$msgs[$alert['content_id']] = $txt['topic_na'];
282
+		if (isset($alert['extra']['board'])) {
283
+					$boards[$alert['extra']['board']] = $txt['board_na'];
284
+		}
285
+		if (isset($alert['extra']['topic'])) {
286
+					$topics[$alert['extra']['topic']] = $txt['topic_na'];
287
+		}
288
+		if ($alert['content_type'] == 'msg') {
289
+					$msgs[$alert['content_id']] = $txt['topic_na'];
290
+		}
278 291
 	}
279 292
 
280 293
 	// Having figured out what boards etc. there are, let's now get the names of them if we can see them. If not, there's already a fallback set up.
@@ -289,8 +302,9 @@  discard block
 block discarded – undo
289 302
 				'boards' => array_keys($boards),
290 303
 			)
291 304
 		);
292
-		while ($row = $smcFunc['db_fetch_assoc']($request))
293
-			$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
305
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
306
+					$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
307
+		}
294 308
 	}
295 309
 	if (!empty($topics))
296 310
 	{
@@ -305,8 +319,9 @@  discard block
 block discarded – undo
305 319
 				'topics' => array_keys($topics),
306 320
 			)
307 321
 		);
308
-		while ($row = $smcFunc['db_fetch_assoc']($request))
309
-			$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
322
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
323
+					$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
324
+		}
310 325
 	}
311 326
 	if (!empty($msgs))
312 327
 	{
@@ -321,44 +336,51 @@  discard block
 block discarded – undo
321 336
 				'msgs' => array_keys($msgs),
322 337
 			)
323 338
 		);
324
-		while ($row = $smcFunc['db_fetch_assoc']($request))
325
-			$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
339
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
340
+					$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
341
+		}
326 342
 	}
327 343
 
328 344
 	// Now to go back through the alerts, reattach this extra information and then try to build the string out of it (if a hook didn't already)
329 345
 	foreach ($alerts as $id_alert => $alert)
330 346
 	{
331
-		if (!empty($alert['text']))
332
-			continue;
333
-		if (isset($alert['extra']['board']))
334
-			if ($boards[$alert['extra']['board']] == $txt['board_na'])
347
+		if (!empty($alert['text'])) {
348
+					continue;
349
+		}
350
+		if (isset($alert['extra']['board'])) {
351
+					if ($boards[$alert['extra']['board']] == $txt['board_na'])
335 352
 			{
336 353
 				unset($alerts[$id_alert]);
354
+		}
337 355
 				continue;
356
+			} else {
357
+							$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
338 358
 			}
339
-			else
340
-				$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
341
-		if (isset($alert['extra']['topic']))
342
-			if ($alert['extra']['topic'] == $txt['topic_na'])
359
+		if (isset($alert['extra']['topic'])) {
360
+					if ($alert['extra']['topic'] == $txt['topic_na'])
343 361
 			{
344 362
 				unset($alerts[$id_alert]);
363
+		}
345 364
 				continue;
365
+			} else {
366
+							$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
346 367
 			}
347
-			else
348
-				$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
349
-		if ($alert['content_type'] == 'msg')
350
-			if ($msgs[$alert['content_id']] == $txt['topic_na'])
368
+		if ($alert['content_type'] == 'msg') {
369
+					if ($msgs[$alert['content_id']] == $txt['topic_na'])
351 370
 			{
352 371
 				unset($alerts[$id_alert]);
372
+		}
353 373
 				continue;
354
-			}				
355
-			else
356
-				$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
357
-		if ($alert['content_type'] == 'profile')
358
-			$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
374
+			} else {
375
+							$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
376
+			}
377
+		if ($alert['content_type'] == 'profile') {
378
+					$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
379
+		}
359 380
 
360
-		if (!empty($memberContext[$alert['sender_id']]))
361
-			$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
381
+		if (!empty($memberContext[$alert['sender_id']])) {
382
+					$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
383
+		}
362 384
 
363 385
 		$string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action'];
364 386
 		if (isset($txt[$string]))
@@ -446,11 +468,11 @@  discard block
 block discarded – undo
446 468
 		checkSession('request');
447 469
 
448 470
 		// Call it!
449
-		if ($action == 'remove')
450
-			alert_delete($toMark, $memID);
451
-
452
-		else
453
-			alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
471
+		if ($action == 'remove') {
472
+					alert_delete($toMark, $memID);
473
+		} else {
474
+					alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
475
+		}
454 476
 
455 477
 		// Set a nice update message.
456 478
 		$_SESSION['update_message'] = true;
@@ -500,23 +522,27 @@  discard block
 block discarded – undo
500 522
 	);
501 523
 
502 524
 	// Set the page title
503
-	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title))
504
-		$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
505
-	else
506
-		$context['page_title'] = $txt['showPosts'];
525
+	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) {
526
+			$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
527
+	} else {
528
+			$context['page_title'] = $txt['showPosts'];
529
+	}
507 530
 
508 531
 	$context['page_title'] .= ' - ' . $user_profile[$memID]['real_name'];
509 532
 
510 533
 	// Is the load average too high to allow searching just now?
511
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts'])
512
-		fatal_lang_error('loadavg_show_posts_disabled', false);
534
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) {
535
+			fatal_lang_error('loadavg_show_posts_disabled', false);
536
+	}
513 537
 
514 538
 	// If we're specifically dealing with attachments use that function!
515
-	if (isset($_GET['sa']) && $_GET['sa'] == 'attach')
516
-		return showAttachments($memID);
539
+	if (isset($_GET['sa']) && $_GET['sa'] == 'attach') {
540
+			return showAttachments($memID);
541
+	}
517 542
 	// Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function.
518
-	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics')
519
-		return showUnwatched($memID);
543
+	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') {
544
+			return showUnwatched($memID);
545
+	}
520 546
 
521 547
 	// Are we just viewing topics?
522 548
 	$context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false;
@@ -539,27 +565,30 @@  discard block
 block discarded – undo
539 565
 		$smcFunc['db_free_result']($request);
540 566
 
541 567
 		// Trying to remove a message that doesn't exist.
542
-		if (empty($info))
543
-			redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
568
+		if (empty($info)) {
569
+					redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
570
+		}
544 571
 
545 572
 		// We can be lazy, since removeMessage() will check the permissions for us.
546 573
 		require_once($sourcedir . '/RemoveTopic.php');
547 574
 		removeMessage((int) $_GET['delete']);
548 575
 
549 576
 		// Add it to the mod log.
550
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
551
-			logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
577
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
578
+					logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
579
+		}
552 580
 
553 581
 		// Back to... where we are now ;).
554 582
 		redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
555 583
 	}
556 584
 
557 585
 	// Default to 10.
558
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
559
-		$_REQUEST['viewscount'] = '10';
586
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
587
+			$_REQUEST['viewscount'] = '10';
588
+	}
560 589
 
561
-	if ($context['is_topics'])
562
-		$request = $smcFunc['db_query']('', '
590
+	if ($context['is_topics']) {
591
+			$request = $smcFunc['db_query']('', '
563 592
 			SELECT COUNT(*)
564 593
 			FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : '
565 594
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . '
@@ -572,8 +601,8 @@  discard block
 block discarded – undo
572 601
 				'board' => $board,
573 602
 			)
574 603
 		);
575
-	else
576
-		$request = $smcFunc['db_query']('', '
604
+	} else {
605
+			$request = $smcFunc['db_query']('', '
577 606
 			SELECT COUNT(*)
578 607
 			FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : '
579 608
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . '
@@ -586,6 +615,7 @@  discard block
 block discarded – undo
586 615
 				'board' => $board,
587 616
 			)
588 617
 		);
618
+	}
589 619
 	list ($msgCount) = $smcFunc['db_fetch_row']($request);
590 620
 	$smcFunc['db_free_result']($request);
591 621
 
@@ -606,10 +636,11 @@  discard block
 block discarded – undo
606 636
 
607 637
 	$range_limit = '';
608 638
 
609
-	if ($context['is_topics'])
610
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
611
-	else
612
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
639
+	if ($context['is_topics']) {
640
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
641
+	} else {
642
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
643
+	}
613 644
 
614 645
 	$maxIndex = $maxPerPage;
615 646
 
@@ -635,9 +666,9 @@  discard block
 block discarded – undo
635 666
 		{
636 667
 			$margin *= 5;
637 668
 			$range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin);
669
+		} else {
670
+					$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
638 671
 		}
639
-		else
640
-			$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
641 672
 	}
642 673
 
643 674
 	// Find this user's posts.  The left join on categories somehow makes this faster, weird as it looks.
@@ -669,8 +700,7 @@  discard block
 block discarded – undo
669 700
 					'max' => $maxIndex,
670 701
 				)
671 702
 			);
672
-		}
673
-		else
703
+		} else
674 704
 		{
675 705
 			$request = $smcFunc['db_query']('', '
676 706
 				SELECT
@@ -699,8 +729,9 @@  discard block
 block discarded – undo
699 729
 		}
700 730
 
701 731
 		// Make sure we quit this loop.
702
-		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '')
703
-			break;
732
+		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') {
733
+					break;
734
+		}
704 735
 		$looped = true;
705 736
 		$range_limit = '';
706 737
 	}
@@ -744,19 +775,21 @@  discard block
 block discarded – undo
744 775
 			'css_class' => $row['approved'] ? 'windowbg' : 'approvebg',
745 776
 		);
746 777
 
747
-		if ($user_info['id'] == $row['id_member_started'])
748
-			$board_ids['own'][$row['id_board']][] = $counter;
778
+		if ($user_info['id'] == $row['id_member_started']) {
779
+					$board_ids['own'][$row['id_board']][] = $counter;
780
+		}
749 781
 		$board_ids['any'][$row['id_board']][] = $counter;
750 782
 	}
751 783
 	$smcFunc['db_free_result']($request);
752 784
 
753 785
 	// All posts were retrieved in reverse order, get them right again.
754
-	if ($reverse)
755
-		$context['posts'] = array_reverse($context['posts'], true);
786
+	if ($reverse) {
787
+			$context['posts'] = array_reverse($context['posts'], true);
788
+	}
756 789
 
757 790
 	// These are all the permissions that are different from board to board..
758
-	if ($context['is_topics'])
759
-		$permissions = array(
791
+	if ($context['is_topics']) {
792
+			$permissions = array(
760 793
 			'own' => array(
761 794
 				'post_reply_own' => 'can_reply',
762 795
 			),
@@ -764,8 +797,8 @@  discard block
 block discarded – undo
764 797
 				'post_reply_any' => 'can_reply',
765 798
 			)
766 799
 		);
767
-	else
768
-		$permissions = array(
800
+	} else {
801
+			$permissions = array(
769 802
 			'own' => array(
770 803
 				'post_reply_own' => 'can_reply',
771 804
 				'delete_own' => 'can_delete',
@@ -775,6 +808,7 @@  discard block
 block discarded – undo
775 808
 				'delete_any' => 'can_delete',
776 809
 			)
777 810
 		);
811
+	}
778 812
 
779 813
 	// For every permission in the own/any lists...
780 814
 	foreach ($permissions as $type => $list)
@@ -785,19 +819,22 @@  discard block
 block discarded – undo
785 819
 			$boards = boardsAllowedTo($permission);
786 820
 
787 821
 			// Hmm, they can do it on all boards, can they?
788
-			if (!empty($boards) && $boards[0] == 0)
789
-				$boards = array_keys($board_ids[$type]);
822
+			if (!empty($boards) && $boards[0] == 0) {
823
+							$boards = array_keys($board_ids[$type]);
824
+			}
790 825
 
791 826
 			// Now go through each board they can do the permission on.
792 827
 			foreach ($boards as $board_id)
793 828
 			{
794 829
 				// There aren't any posts displayed from this board.
795
-				if (!isset($board_ids[$type][$board_id]))
796
-					continue;
830
+				if (!isset($board_ids[$type][$board_id])) {
831
+									continue;
832
+				}
797 833
 
798 834
 				// Set the permission to true ;).
799
-				foreach ($board_ids[$type][$board_id] as $counter)
800
-					$context['posts'][$counter][$allowed] = true;
835
+				foreach ($board_ids[$type][$board_id] as $counter) {
836
+									$context['posts'][$counter][$allowed] = true;
837
+				}
801 838
 			}
802 839
 		}
803 840
 	}
@@ -828,8 +865,9 @@  discard block
 block discarded – undo
828 865
 	$boardsAllowed = boardsAllowedTo('view_attachments');
829 866
 
830 867
 	// Make sure we can't actually see anything...
831
-	if (empty($boardsAllowed))
832
-		$boardsAllowed = array(-1);
868
+	if (empty($boardsAllowed)) {
869
+			$boardsAllowed = array(-1);
870
+	}
833 871
 
834 872
 	require_once($sourcedir . '/Subs-List.php');
835 873
 
@@ -980,8 +1018,8 @@  discard block
 block discarded – undo
980 1018
 		)
981 1019
 	);
982 1020
 	$attachments = array();
983
-	while ($row = $smcFunc['db_fetch_assoc']($request))
984
-		$attachments[] = array(
1021
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1022
+			$attachments[] = array(
985 1023
 			'id' => $row['id_attach'],
986 1024
 			'filename' => $row['filename'],
987 1025
 			'downloads' => $row['downloads'],
@@ -993,6 +1031,7 @@  discard block
 block discarded – undo
993 1031
 			'board_name' => $row['name'],
994 1032
 			'approved' => $row['approved'],
995 1033
 		);
1034
+	}
996 1035
 
997 1036
 	$smcFunc['db_free_result']($request);
998 1037
 
@@ -1047,8 +1086,9 @@  discard block
 block discarded – undo
1047 1086
 	global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir;
1048 1087
 
1049 1088
 	// Only the owner can see the list (if the function is enabled of course)
1050
-	if ($user_info['id'] != $memID)
1051
-		return;
1089
+	if ($user_info['id'] != $memID) {
1090
+			return;
1091
+	}
1052 1092
 
1053 1093
 	require_once($sourcedir . '/Subs-List.php');
1054 1094
 
@@ -1194,8 +1234,9 @@  discard block
 block discarded – undo
1194 1234
 	);
1195 1235
 
1196 1236
 	$topics = array();
1197
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1198
-		$topics[] = $row['id_topic'];
1237
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1238
+			$topics[] = $row['id_topic'];
1239
+	}
1199 1240
 
1200 1241
 	$smcFunc['db_free_result']($request);
1201 1242
 
@@ -1215,8 +1256,9 @@  discard block
 block discarded – undo
1215 1256
 				'topics' => $topics,
1216 1257
 			)
1217 1258
 		);
1218
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1219
-			$topicsInfo[] = $row;
1259
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1260
+					$topicsInfo[] = $row;
1261
+		}
1220 1262
 		$smcFunc['db_free_result']($request);
1221 1263
 	}
1222 1264
 
@@ -1264,8 +1306,9 @@  discard block
 block discarded – undo
1264 1306
 	$context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name'];
1265 1307
 
1266 1308
 	// Is the load average too high to allow searching just now?
1267
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats'])
1268
-		fatal_lang_error('loadavg_userstats_disabled', false);
1309
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) {
1310
+			fatal_lang_error('loadavg_userstats_disabled', false);
1311
+	}
1269 1312
 
1270 1313
 	// General user statistics.
1271 1314
 	$timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400);
@@ -1408,11 +1451,13 @@  discard block
 block discarded – undo
1408 1451
 	}
1409 1452
 	$smcFunc['db_free_result']($result);
1410 1453
 
1411
-	if ($maxPosts > 0)
1412
-		for ($hour = 0; $hour < 24; $hour++)
1454
+	if ($maxPosts > 0) {
1455
+			for ($hour = 0;
1456
+	}
1457
+	$hour < 24; $hour++)
1413 1458
 		{
1414
-			if (!isset($context['posts_by_time'][$hour]))
1415
-				$context['posts_by_time'][$hour] = array(
1459
+			if (!isset($context['posts_by_time'][$hour])) {
1460
+							$context['posts_by_time'][$hour] = array(
1416 1461
 					'hour' => $hour,
1417 1462
 					'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)),
1418 1463
 					'posts' => 0,
@@ -1420,7 +1465,7 @@  discard block
 block discarded – undo
1420 1465
 					'relative_percent' => 0,
1421 1466
 					'is_last' => $hour == 23,
1422 1467
 				);
1423
-			else
1468
+			} else
1424 1469
 			{
1425 1470
 				$context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts);
1426 1471
 				$context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts);
@@ -1453,8 +1498,9 @@  discard block
 block discarded – undo
1453 1498
 
1454 1499
 	foreach ($subActions as $sa => $action)
1455 1500
 	{
1456
-		if (!allowedTo($action[2]))
1457
-			unset($subActions[$sa]);
1501
+		if (!allowedTo($action[2])) {
1502
+					unset($subActions[$sa]);
1503
+		}
1458 1504
 	}
1459 1505
 
1460 1506
 	// Create the tabs for the template.
@@ -1472,15 +1518,18 @@  discard block
 block discarded – undo
1472 1518
 	);
1473 1519
 
1474 1520
 	// Moderation must be on to track edits.
1475
-	if (empty($modSettings['userlog_enabled']))
1476
-		unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1521
+	if (empty($modSettings['userlog_enabled'])) {
1522
+			unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1523
+	}
1477 1524
 
1478 1525
 	// Group requests must be active to show it...
1479
-	if (empty($modSettings['show_group_membership']))
1480
-		unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1526
+	if (empty($modSettings['show_group_membership'])) {
1527
+			unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1528
+	}
1481 1529
 
1482
-	if (empty($subActions))
1483
-		fatal_lang_error('no_access', false);
1530
+	if (empty($subActions)) {
1531
+			fatal_lang_error('no_access', false);
1532
+	}
1484 1533
 
1485 1534
 	$keys = array_keys($subActions);
1486 1535
 	$default = array_shift($keys);
@@ -1493,9 +1542,10 @@  discard block
 block discarded – undo
1493 1542
 	$context['sub_template'] = $subActions[$context['tracking_area']][0];
1494 1543
 	$call = call_helper($subActions[$context['tracking_area']][0], true);
1495 1544
 
1496
-	if (!empty($call))
1497
-		call_user_func($call, $memID);
1498
-}
1545
+	if (!empty($call)) {
1546
+			call_user_func($call, $memID);
1547
+	}
1548
+	}
1499 1549
 
1500 1550
 /**
1501 1551
  * Handles tracking a user's activity
@@ -1511,8 +1561,9 @@  discard block
 block discarded – undo
1511 1561
 	isAllowedTo('moderate_forum');
1512 1562
 
1513 1563
 	$context['last_ip'] = $user_profile[$memID]['member_ip'];
1514
-	if ($context['last_ip'] != $user_profile[$memID]['member_ip2'])
1515
-		$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1564
+	if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) {
1565
+			$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1566
+	}
1516 1567
 	$context['member']['name'] = $user_profile[$memID]['real_name'];
1517 1568
 
1518 1569
 	// Set the options for the list component.
@@ -1678,8 +1729,9 @@  discard block
 block discarded – undo
1678 1729
 			)
1679 1730
 		);
1680 1731
 		$message_members = array();
1681
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1682
-			$message_members[] = $row['id_member'];
1732
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1733
+					$message_members[] = $row['id_member'];
1734
+		}
1683 1735
 		$smcFunc['db_free_result']($request);
1684 1736
 
1685 1737
 		// Fetch their names, cause of the GROUP BY doesn't like giving us that normally.
@@ -1694,8 +1746,9 @@  discard block
 block discarded – undo
1694 1746
 					'ip_list' => $ips,
1695 1747
 				)
1696 1748
 			);
1697
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1698
-				$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1749
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1750
+							$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1751
+			}
1699 1752
 			$smcFunc['db_free_result']($request);
1700 1753
 		}
1701 1754
 
@@ -1709,8 +1762,9 @@  discard block
 block discarded – undo
1709 1762
 				'ip_list' => $ips,
1710 1763
 			)
1711 1764
 		);
1712
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1713
-			$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1765
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1766
+					$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1767
+		}
1714 1768
 		$smcFunc['db_free_result']($request);
1715 1769
 	}
1716 1770
 }
@@ -1770,8 +1824,8 @@  discard block
 block discarded – undo
1770 1824
 		))
1771 1825
 	);
1772 1826
 	$error_messages = array();
1773
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1774
-		$error_messages[] = array(
1827
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1828
+			$error_messages[] = array(
1775 1829
 			'ip' => inet_dtop($row['ip']),
1776 1830
 			'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'],
1777 1831
 			'message' => strtr($row['message'], array('&lt;span class=&quot;remove&quot;&gt;' => '', '&lt;/span&gt;' => '')),
@@ -1779,6 +1833,7 @@  discard block
 block discarded – undo
1779 1833
 			'time' => timeformat($row['log_time']),
1780 1834
 			'timestamp' => forum_time(true, $row['log_time']),
1781 1835
 		);
1836
+	}
1782 1837
 	$smcFunc['db_free_result']($request);
1783 1838
 
1784 1839
 	return $error_messages;
@@ -1841,8 +1896,8 @@  discard block
 block discarded – undo
1841 1896
 		))
1842 1897
 	);
1843 1898
 	$messages = array();
1844
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1845
-		$messages[] = array(
1899
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1900
+			$messages[] = array(
1846 1901
 			'ip' => inet_dtop($row['poster_ip']),
1847 1902
 			'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>',
1848 1903
 			'board' => array(
@@ -1855,6 +1910,7 @@  discard block
 block discarded – undo
1855 1910
 			'time' => timeformat($row['poster_time']),
1856 1911
 			'timestamp' => forum_time(true, $row['poster_time'])
1857 1912
 		);
1913
+	}
1858 1914
 	$smcFunc['db_free_result']($request);
1859 1915
 
1860 1916
 	return $messages;
@@ -1881,19 +1937,20 @@  discard block
 block discarded – undo
1881 1937
 		$context['sub_template'] = 'trackIP';
1882 1938
 		$context['page_title'] = $txt['profile'];
1883 1939
 		$context['base_url'] = $scripturl . '?action=trackip';
1884
-	}
1885
-	else
1940
+	} else
1886 1941
 	{
1887 1942
 		$context['ip'] = $user_profile[$memID]['member_ip'];
1888 1943
 		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
1889 1944
 	}
1890 1945
 
1891 1946
 	// Searching?
1892
-	if (isset($_REQUEST['searchip']))
1893
-		$context['ip'] = trim($_REQUEST['searchip']);
1947
+	if (isset($_REQUEST['searchip'])) {
1948
+			$context['ip'] = trim($_REQUEST['searchip']);
1949
+	}
1894 1950
 
1895
-	if (isValidIP($context['ip']) === false)
1896
-		fatal_lang_error('invalid_tracking_ip', false);
1951
+	if (isValidIP($context['ip']) === false) {
1952
+			fatal_lang_error('invalid_tracking_ip', false);
1953
+	}
1897 1954
 
1898 1955
 	//mysql didn't support like search with varbinary
1899 1956
 	//$ip_var = str_replace('*', '%', $context['ip']);
@@ -1901,8 +1958,9 @@  discard block
 block discarded – undo
1901 1958
 	$ip_var = $context['ip'];
1902 1959
 	$ip_string = '= {inet:ip_address}';
1903 1960
 
1904
-	if (empty($context['tracking_area']))
1905
-		$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1961
+	if (empty($context['tracking_area'])) {
1962
+			$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1963
+	}
1906 1964
 
1907 1965
 	$request = $smcFunc['db_query']('', '
1908 1966
 		SELECT id_member, real_name AS display_name, member_ip
@@ -1913,8 +1971,9 @@  discard block
 block discarded – undo
1913 1971
 		)
1914 1972
 	);
1915 1973
 	$context['ips'] = array();
1916
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1917
-		$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
1974
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1975
+			$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
1976
+	}
1918 1977
 	$smcFunc['db_free_result']($request);
1919 1978
 
1920 1979
 	ksort($context['ips']);
@@ -2143,8 +2202,9 @@  discard block
 block discarded – undo
2143 2202
 		foreach ($context['whois_servers'] as $whois)
2144 2203
 		{
2145 2204
 			// Strip off the "decimal point" and anything following...
2146
-			if (in_array((int) $context['ip'], $whois['range']))
2147
-				$context['auto_whois_server'] = $whois;
2205
+			if (in_array((int) $context['ip'], $whois['range'])) {
2206
+							$context['auto_whois_server'] = $whois;
2207
+			}
2148 2208
 		}
2149 2209
 	}
2150 2210
 }
@@ -2161,10 +2221,11 @@  discard block
 block discarded – undo
2161 2221
 	// Gonna want this for the list.
2162 2222
 	require_once($sourcedir . '/Subs-List.php');
2163 2223
 
2164
-	if ($memID == 0)
2165
-		$context['base_url'] = $scripturl . '?action=trackip';
2166
-	else
2167
-		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2224
+	if ($memID == 0) {
2225
+			$context['base_url'] = $scripturl . '?action=trackip';
2226
+	} else {
2227
+			$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2228
+	}
2168 2229
 
2169 2230
 	// Start with the user messages.
2170 2231
 	$listOptions = array(
@@ -2274,12 +2335,13 @@  discard block
 block discarded – undo
2274 2335
 		)
2275 2336
 	);
2276 2337
 	$logins = array();
2277
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2278
-		$logins[] = array(
2338
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2339
+			$logins[] = array(
2279 2340
 			'time' => timeformat($row['time']),
2280 2341
 			'ip' => inet_dtop($row['ip']),
2281 2342
 			'ip2' => inet_dtop($row['ip2']),
2282 2343
 		);
2344
+	}
2283 2345
 	$smcFunc['db_free_result']($request);
2284 2346
 
2285 2347
 	return $logins;
@@ -2304,11 +2366,12 @@  discard block
 block discarded – undo
2304 2366
 		)
2305 2367
 	);
2306 2368
 	$context['custom_field_titles'] = array();
2307
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2308
-		$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2369
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2370
+			$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2309 2371
 			'title' => $row['field_name'],
2310 2372
 			'parse_bbc' => $row['bbc'],
2311 2373
 		);
2374
+	}
2312 2375
 	$smcFunc['db_free_result']($request);
2313 2376
 
2314 2377
 	// Set the options for the error lists.
@@ -2447,19 +2510,22 @@  discard block
 block discarded – undo
2447 2510
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2448 2511
 	{
2449 2512
 		$extra = $smcFunc['json_decode']($row['extra'], true);
2450
-		if (!empty($extra['applicator']))
2451
-			$members[] = $extra['applicator'];
2513
+		if (!empty($extra['applicator'])) {
2514
+					$members[] = $extra['applicator'];
2515
+		}
2452 2516
 
2453 2517
 		// Work out what the name of the action is.
2454
-		if (isset($txt['trackEdit_action_' . $row['action']]))
2455
-			$action_text = $txt['trackEdit_action_' . $row['action']];
2456
-		elseif (isset($txt[$row['action']]))
2457
-			$action_text = $txt[$row['action']];
2518
+		if (isset($txt['trackEdit_action_' . $row['action']])) {
2519
+					$action_text = $txt['trackEdit_action_' . $row['action']];
2520
+		} elseif (isset($txt[$row['action']])) {
2521
+					$action_text = $txt[$row['action']];
2522
+		}
2458 2523
 		// Custom field?
2459
-		elseif (isset($context['custom_field_titles'][$row['action']]))
2460
-			$action_text = $context['custom_field_titles'][$row['action']]['title'];
2461
-		else
2462
-			$action_text = $row['action'];
2524
+		elseif (isset($context['custom_field_titles'][$row['action']])) {
2525
+					$action_text = $context['custom_field_titles'][$row['action']]['title'];
2526
+		} else {
2527
+					$action_text = $row['action'];
2528
+		}
2463 2529
 
2464 2530
 		// Parse BBC?
2465 2531
 		$parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false;
@@ -2491,13 +2557,15 @@  discard block
 block discarded – undo
2491 2557
 			)
2492 2558
 		);
2493 2559
 		$members = array();
2494
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2495
-			$members[$row['id_member']] = $row['real_name'];
2560
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2561
+					$members[$row['id_member']] = $row['real_name'];
2562
+		}
2496 2563
 		$smcFunc['db_free_result']($request);
2497 2564
 
2498
-		foreach ($edits as $key => $value)
2499
-			if (isset($members[$value['id_member']]))
2565
+		foreach ($edits as $key => $value) {
2566
+					if (isset($members[$value['id_member']]))
2500 2567
 				$edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>';
2568
+		}
2501 2569
 	}
2502 2570
 
2503 2571
 	return $edits;
@@ -2698,10 +2766,11 @@  discard block
 block discarded – undo
2698 2766
 	$context['board'] = $board;
2699 2767
 
2700 2768
 	// Determine which groups this user is in.
2701
-	if (empty($user_profile[$memID]['additional_groups']))
2702
-		$curGroups = array();
2703
-	else
2704
-		$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2769
+	if (empty($user_profile[$memID]['additional_groups'])) {
2770
+			$curGroups = array();
2771
+	} else {
2772
+			$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2773
+	}
2705 2774
 	$curGroups[] = $user_profile[$memID]['id_group'];
2706 2775
 	$curGroups[] = $user_profile[$memID]['id_post_group'];
2707 2776
 
@@ -2721,28 +2790,30 @@  discard block
 block discarded – undo
2721 2790
 	$context['no_access_boards'] = array();
2722 2791
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2723 2792
 	{
2724
-		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod'])
2725
-			$context['no_access_boards'][] = array(
2793
+		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) {
2794
+					$context['no_access_boards'][] = array(
2726 2795
 				'id' => $row['id_board'],
2727 2796
 				'name' => $row['name'],
2728 2797
 				'is_last' => false,
2729 2798
 			);
2730
-		elseif ($row['id_profile'] != 1 || $row['is_mod'])
2731
-			$context['boards'][$row['id_board']] = array(
2799
+		} elseif ($row['id_profile'] != 1 || $row['is_mod']) {
2800
+					$context['boards'][$row['id_board']] = array(
2732 2801
 				'id' => $row['id_board'],
2733 2802
 				'name' => $row['name'],
2734 2803
 				'selected' => $board == $row['id_board'],
2735 2804
 				'profile' => $row['id_profile'],
2736 2805
 				'profile_name' => $context['profiles'][$row['id_profile']]['name'],
2737 2806
 			);
2807
+		}
2738 2808
 	}
2739 2809
 	$smcFunc['db_free_result']($request);
2740 2810
 
2741 2811
 	require_once($sourcedir . '/Subs-Boards.php');
2742 2812
 	sortBoards($context['boards']);
2743 2813
 
2744
-	if (!empty($context['no_access_boards']))
2745
-		$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2814
+	if (!empty($context['no_access_boards'])) {
2815
+			$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2816
+	}
2746 2817
 
2747 2818
 	$context['member']['permissions'] = array(
2748 2819
 		'general' => array(),
@@ -2751,8 +2822,9 @@  discard block
 block discarded – undo
2751 2822
 
2752 2823
 	// If you're an admin we know you can do everything, we might as well leave.
2753 2824
 	$context['member']['has_all_permissions'] = in_array(1, $curGroups);
2754
-	if ($context['member']['has_all_permissions'])
2755
-		return;
2825
+	if ($context['member']['has_all_permissions']) {
2826
+			return;
2827
+	}
2756 2828
 
2757 2829
 	$denied = array();
2758 2830
 
@@ -2771,21 +2843,24 @@  discard block
 block discarded – undo
2771 2843
 	while ($row = $smcFunc['db_fetch_assoc']($result))
2772 2844
 	{
2773 2845
 		// We don't know about this permission, it doesn't exist :P.
2774
-		if (!isset($txt['permissionname_' . $row['permission']]))
2775
-			continue;
2846
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2847
+					continue;
2848
+		}
2776 2849
 
2777
-		if (empty($row['add_deny']))
2778
-			$denied[] = $row['permission'];
2850
+		if (empty($row['add_deny'])) {
2851
+					$denied[] = $row['permission'];
2852
+		}
2779 2853
 
2780 2854
 		// Permissions that end with _own or _any consist of two parts.
2781
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2782
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2783
-		else
2784
-			$name = $txt['permissionname_' . $row['permission']];
2855
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2856
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2857
+		} else {
2858
+					$name = $txt['permissionname_' . $row['permission']];
2859
+		}
2785 2860
 
2786 2861
 		// Add this permission if it doesn't exist yet.
2787
-		if (!isset($context['member']['permissions']['general'][$row['permission']]))
2788
-			$context['member']['permissions']['general'][$row['permission']] = array(
2862
+		if (!isset($context['member']['permissions']['general'][$row['permission']])) {
2863
+					$context['member']['permissions']['general'][$row['permission']] = array(
2789 2864
 				'id' => $row['permission'],
2790 2865
 				'groups' => array(
2791 2866
 					'allowed' => array(),
@@ -2795,6 +2870,7 @@  discard block
 block discarded – undo
2795 2870
 				'is_denied' => false,
2796 2871
 				'is_global' => true,
2797 2872
 			);
2873
+		}
2798 2874
 
2799 2875
 		// Add the membergroup to either the denied or the allowed groups.
2800 2876
 		$context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
@@ -2828,18 +2904,20 @@  discard block
 block discarded – undo
2828 2904
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2829 2905
 	{
2830 2906
 		// We don't know about this permission, it doesn't exist :P.
2831
-		if (!isset($txt['permissionname_' . $row['permission']]))
2832
-			continue;
2907
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2908
+					continue;
2909
+		}
2833 2910
 
2834 2911
 		// The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'.
2835
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2836
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2837
-		else
2838
-			$name = $txt['permissionname_' . $row['permission']];
2912
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2913
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2914
+		} else {
2915
+					$name = $txt['permissionname_' . $row['permission']];
2916
+		}
2839 2917
 
2840 2918
 		// Create the structure for this permission.
2841
-		if (!isset($context['member']['permissions']['board'][$row['permission']]))
2842
-			$context['member']['permissions']['board'][$row['permission']] = array(
2919
+		if (!isset($context['member']['permissions']['board'][$row['permission']])) {
2920
+					$context['member']['permissions']['board'][$row['permission']] = array(
2843 2921
 				'id' => $row['permission'],
2844 2922
 				'groups' => array(
2845 2923
 					'allowed' => array(),
@@ -2849,6 +2927,7 @@  discard block
 block discarded – undo
2849 2927
 				'is_denied' => false,
2850 2928
 				'is_global' => empty($board),
2851 2929
 			);
2930
+		}
2852 2931
 
2853 2932
 		$context['member']['permissions']['board'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][$row['id_group']] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
2854 2933
 
@@ -2867,8 +2946,9 @@  discard block
 block discarded – undo
2867 2946
 	global $modSettings, $context, $sourcedir, $txt, $scripturl;
2868 2947
 
2869 2948
 	// Firstly, can we actually even be here?
2870
-	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum'))
2871
-		fatal_lang_error('no_access', false);
2949
+	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) {
2950
+			fatal_lang_error('no_access', false);
2951
+	}
2872 2952
 
2873 2953
 	// Make sure things which are disabled stay disabled.
2874 2954
 	$modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110;
@@ -2955,9 +3035,10 @@  discard block
 block discarded – undo
2955 3035
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'],
2956 3036
 	);
2957 3037
 	$context['current_level'] = 0;
2958
-	foreach ($context['level_effects'] as $limit => $dummy)
2959
-		if ($context['member']['warning'] >= $limit)
3038
+	foreach ($context['level_effects'] as $limit => $dummy) {
3039
+			if ($context['member']['warning'] >= $limit)
2960 3040
 			$context['current_level'] = $limit;
2961
-}
3041
+	}
3042
+	}
2962 3043
 
2963 3044
 ?>
2964 3045
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/MessageIndex.php 2 patches
Braces   +266 added lines, -199 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
  * Show the list of topics in this board, along with any child boards.
@@ -56,8 +57,9 @@  discard block
 block discarded – undo
56 57
 
57 58
 	$context['name'] = $board_info['name'];
58 59
 	$context['description'] = $board_info['description'];
59
-	if (!empty($board_info['description']))
60
-		$context['meta_description'] = strip_tags($board_info['description']);
60
+	if (!empty($board_info['description'])) {
61
+			$context['meta_description'] = strip_tags($board_info['description']);
62
+	}
61 63
 
62 64
 	// How many topics do we have in total?
63 65
 	$board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics'];
@@ -73,12 +75,14 @@  discard block
 block discarded – undo
73 75
 		$session_name = session_name();
74 76
 		foreach ($_GET as $k => $v)
75 77
 		{
76
-			if (!in_array($k, array('board', 'start', $session_name)))
77
-				$context['robot_no_index'] = true;
78
+			if (!in_array($k, array('board', 'start', $session_name))) {
79
+							$context['robot_no_index'] = true;
80
+			}
78 81
 		}
79 82
 	}
80
-	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0))
81
-		$context['robot_no_index'] = true;
83
+	if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) {
84
+			$context['robot_no_index'] = true;
85
+	}
82 86
 
83 87
 	// If we can view unapproved messages and there are some build up a list.
84 88
 	if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts']))
@@ -89,14 +93,16 @@  discard block
 block discarded – undo
89 93
 	}
90 94
 
91 95
 	// We only know these.
92
-	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post')))
93
-		$_REQUEST['sort'] = 'last_post';
96
+	if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) {
97
+			$_REQUEST['sort'] = 'last_post';
98
+	}
94 99
 
95 100
 	// Make sure the starting place makes sense and construct the page index.
96
-	if (isset($_REQUEST['sort']))
97
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
98
-	else
99
-		$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
101
+	if (isset($_REQUEST['sort'])) {
102
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
103
+	} else {
104
+			$context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true);
105
+	}
100 106
 	$context['start'] = &$_REQUEST['start'];
101 107
 
102 108
 	// Set a canonical URL for this page.
@@ -132,14 +138,16 @@  discard block
 block discarded – undo
132 138
 	$context['link_moderators'] = array();
133 139
 	if (!empty($board_info['moderators']))
134 140
 	{
135
-		foreach ($board_info['moderators'] as $mod)
136
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
141
+		foreach ($board_info['moderators'] as $mod) {
142
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>';
143
+		}
137 144
 	}
138 145
 	if (!empty($board_info['moderator_groups']))
139 146
 	{
140 147
 		// By default just tack the moderator groups onto the end of the members
141
-		foreach ($board_info['moderator_groups'] as $mod_group)
142
-			$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
148
+		foreach ($board_info['moderator_groups'] as $mod_group) {
149
+					$context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>';
150
+		}
143 151
 	}
144 152
 
145 153
 	// Now we tack the info onto the end of the linktree
@@ -191,20 +199,24 @@  discard block
 block discarded – undo
191 199
 		);
192 200
 		while ($row = $smcFunc['db_fetch_assoc']($request))
193 201
 		{
194
-			if (empty($row['id_member']))
195
-				continue;
202
+			if (empty($row['id_member'])) {
203
+							continue;
204
+			}
196 205
 
197
-			if (!empty($row['online_color']))
198
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
199
-			else
200
-				$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
206
+			if (!empty($row['online_color'])) {
207
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';
208
+			} else {
209
+							$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
210
+			}
201 211
 
202 212
 			$is_buddy = in_array($row['id_member'], $user_info['buddies']);
203
-			if ($is_buddy)
204
-				$link = '<strong>' . $link . '</strong>';
213
+			if ($is_buddy) {
214
+							$link = '<strong>' . $link . '</strong>';
215
+			}
205 216
 
206
-			if (!empty($row['show_online']) || allowedTo('moderate_forum'))
207
-				$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
217
+			if (!empty($row['show_online']) || allowedTo('moderate_forum')) {
218
+							$context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link;
219
+			}
208 220
 			// @todo why are we filling this array of data that are just counted (twice) and discarded? ???
209 221
 			$context['view_members'][$row['log_time'] . $row['member_name']] = array(
210 222
 				'id' => $row['id_member'],
@@ -217,8 +229,9 @@  discard block
 block discarded – undo
217 229
 				'hidden' => empty($row['show_online']),
218 230
 			);
219 231
 
220
-			if (empty($row['show_online']))
221
-				$context['view_num_hidden']++;
232
+			if (empty($row['show_online'])) {
233
+							$context['view_num_hidden']++;
234
+			}
222 235
 		}
223 236
 		$context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']);
224 237
 		$smcFunc['db_free_result']($request);
@@ -260,8 +273,9 @@  discard block
 block discarded – undo
260 273
 	// Bring in any changes we want to make before the query.
261 274
 	call_integration_hook('integrate_pre_messageindex', array(&$sort_methods));
262 275
 
263
-	foreach ($sort_methods as $key => $val)
264
-		$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
276
+	foreach ($sort_methods as $key => $val) {
277
+			$context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>';
278
+	}
265 279
 
266 280
 	// Calculate the fastest way to get the topics.
267 281
 	$start = (int) $_REQUEST['start'];
@@ -271,14 +285,15 @@  discard block
 block discarded – undo
271 285
 		$fake_ascending = true;
272 286
 		$context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex'];
273 287
 		$start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex'];
288
+	} else {
289
+			$fake_ascending = false;
274 290
 	}
275
-	else
276
-		$fake_ascending = false;
277 291
 
278 292
 	// Setup the default topic icons...
279 293
 	$context['icon_sources'] = array();
280
-	foreach ($context['stable_icons'] as $icon)
281
-		$context['icon_sources'][$icon] = 'images_url';
294
+	foreach ($context['stable_icons'] as $icon) {
295
+			$context['icon_sources'][$icon] = 'images_url';
296
+	}
282 297
 
283 298
 	$topic_ids = array();
284 299
 	$context['topics'] = array();
@@ -316,8 +331,9 @@  discard block
 block discarded – undo
316 331
 			$message_pre_index_parameters
317 332
 		);
318 333
 		$topic_ids = array();
319
-		while ($row = $smcFunc['db_fetch_assoc']($request))
320
-			$topic_ids[] = $row['id_topic'];
334
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
335
+					$topic_ids[] = $row['id_topic'];
336
+		}
321 337
 	}
322 338
 
323 339
 	// Grab the appropriate topic information...
@@ -340,10 +356,11 @@  discard block
 block discarded – undo
340 356
 		$message_index_wheres = array();
341 357
 		call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids));
342 358
 		
343
-		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'])
344
-			$enableParticipation = true;
345
-		else
346
-			$enableParticipation = false;
359
+		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) {
360
+					$enableParticipation = true;
361
+		} else {
362
+					$enableParticipation = false;
363
+		}
347 364
 
348 365
 		$result = $smcFunc['db_query']('substring', '
349 366
 			SELECT
@@ -382,11 +399,13 @@  discard block
 block discarded – undo
382 399
 		// Begin 'printing' the message index for current board.
383 400
 		while ($row = $smcFunc['db_fetch_assoc']($result))
384 401
 		{
385
-			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0')
386
-				continue;
402
+			if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') {
403
+							continue;
404
+			}
387 405
 
388
-			if (!$pre_query)
389
-				$topic_ids[] = $row['id_topic'];
406
+			if (!$pre_query) {
407
+							$topic_ids[] = $row['id_topic'];
408
+			}
390 409
 
391 410
 			// Reference the main color class.
392 411
 			$colorClass = 'windowbg';
@@ -396,8 +415,9 @@  discard block
 block discarded – undo
396 415
 			{
397 416
 				// Limit them to $modSettings['preview_characters'] characters
398 417
 				$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => '&#10;')));
399
-				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
400
-					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
418
+				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) {
419
+									$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
420
+				}
401 421
 
402 422
 				// Censor the subject and message preview.
403 423
 				censorText($row['first_subject']);
@@ -408,27 +428,27 @@  discard block
 block discarded – undo
408 428
 				{
409 429
 					$row['last_subject'] = $row['first_subject'];
410 430
 					$row['last_body'] = $row['first_body'];
411
-				}
412
-				else
431
+				} else
413 432
 				{
414 433
 					$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => '&#10;')));
415
-					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
416
-						$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
434
+					if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) {
435
+											$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
436
+					}
417 437
 
418 438
 					censorText($row['last_subject']);
419 439
 					censorText($row['last_body']);
420 440
 				}
421
-			}
422
-			else
441
+			} else
423 442
 			{
424 443
 				$row['first_body'] = '';
425 444
 				$row['last_body'] = '';
426 445
 				censorText($row['first_subject']);
427 446
 
428
-				if ($row['id_first_msg'] == $row['id_last_msg'])
429
-					$row['last_subject'] = $row['first_subject'];
430
-				else
431
-					censorText($row['last_subject']);
447
+				if ($row['id_first_msg'] == $row['id_last_msg']) {
448
+									$row['last_subject'] = $row['first_subject'];
449
+				} else {
450
+									censorText($row['last_subject']);
451
+				}
432 452
 			}
433 453
 
434 454
 			// Decide how many pages the topic should have.
@@ -439,42 +459,50 @@  discard block
 block discarded – undo
439 459
 				$pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false);
440 460
 
441 461
 				// If we can use all, show all.
442
-				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages'])
443
-					$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
462
+				if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) {
463
+									$pages .= ' &nbsp;<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>';
464
+				}
465
+			} else {
466
+							$pages = '';
444 467
 			}
445
-			else
446
-				$pages = '';
447 468
 
448 469
 			// We need to check the topic icons exist...
449 470
 			if (!empty($modSettings['messageIconChecks_enable']))
450 471
 			{
451
-				if (!isset($context['icon_sources'][$row['first_icon']]))
452
-					$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
453
-				if (!isset($context['icon_sources'][$row['last_icon']]))
454
-					$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
455
-			}
456
-			else
472
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
473
+									$context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
474
+				}
475
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
476
+									$context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
477
+				}
478
+			} else
457 479
 			{
458
-				if (!isset($context['icon_sources'][$row['first_icon']]))
459
-					$context['icon_sources'][$row['first_icon']] = 'images_url';
460
-				if (!isset($context['icon_sources'][$row['last_icon']]))
461
-					$context['icon_sources'][$row['last_icon']] = 'images_url';
480
+				if (!isset($context['icon_sources'][$row['first_icon']])) {
481
+									$context['icon_sources'][$row['first_icon']] = 'images_url';
482
+				}
483
+				if (!isset($context['icon_sources'][$row['last_icon']])) {
484
+									$context['icon_sources'][$row['last_icon']] = 'images_url';
485
+				}
462 486
 			}
463 487
 
464
-			if (!empty($board_info['recycle']))
465
-				$row['first_icon'] = 'recycled';
488
+			if (!empty($board_info['recycle'])) {
489
+							$row['first_icon'] = 'recycled';
490
+			}
466 491
 
467 492
 			// Is this topic pending approval, or does it have any posts pending approval?
468
-			if ($context['can_approve_posts'] && $row['unapproved_posts'])
469
-				$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
493
+			if ($context['can_approve_posts'] && $row['unapproved_posts']) {
494
+							$colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost');
495
+			}
470 496
 
471 497
 			// Sticky topics should get a different color, too.
472
-			if ($row['is_sticky'])
473
-				$colorClass .= ' sticky';
498
+			if ($row['is_sticky']) {
499
+							$colorClass .= ' sticky';
500
+			}
474 501
 
475 502
 			// Locked topics get special treatment as well.
476
-			if ($row['locked'])
477
-				$colorClass .= ' locked';
503
+			if ($row['locked']) {
504
+							$colorClass .= ' locked';
505
+			}
478 506
 
479 507
 			// 'Print' the topic info.
480 508
 			$context['topics'][$row['id_topic']] = array_merge($row, array(
@@ -555,8 +583,9 @@  discard block
 block discarded – undo
555 583
 		$smcFunc['db_free_result']($result);
556 584
 
557 585
 		// Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...)
558
-		if ($fake_ascending)
559
-			$context['topics'] = array_reverse($context['topics'], true);
586
+		if ($fake_ascending) {
587
+					$context['topics'] = array_reverse($context['topics'], true);
588
+		}
560 589
 	}
561 590
 
562 591
 	$context['jump_to'] = array(
@@ -579,9 +608,9 @@  discard block
 block discarded – undo
579 608
 		// Can we restore topics?
580 609
 		$context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']);
581 610
 
582
-		if ($user_info['is_admin'] || $modSettings['topic_move_any'])
583
-			$context['can_move_any'] = true;
584
-		else
611
+		if ($user_info['is_admin'] || $modSettings['topic_move_any']) {
612
+					$context['can_move_any'] = true;
613
+		} else
585 614
 		{
586 615
 			// We'll use this in a minute
587 616
 			$boards_allowed = boardsAllowedTo('post_new');
@@ -608,11 +637,13 @@  discard block
 block discarded – undo
608 637
 		}
609 638
 
610 639
 		// Can we use quick moderation checkboxes?
611
-		if ($options['display_quick_mod'] == 1)
612
-			$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
640
+		if ($options['display_quick_mod'] == 1) {
641
+					$context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore'];
642
+		}
613 643
 		// Or the icons?
614
-		else
615
-			$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
644
+		else {
645
+					$context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'];
646
+		}
616 647
 	}
617 648
 
618 649
 	if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1)
@@ -646,13 +677,15 @@  discard block
 block discarded – undo
646 677
 			);
647 678
 
648 679
 			// We've seen all these boards now!
649
-			foreach ($board_info['parent_boards'] as $k => $dummy)
650
-				if (isset($_SESSION['topicseen_cache'][$k]))
680
+			foreach ($board_info['parent_boards'] as $k => $dummy) {
681
+							if (isset($_SESSION['topicseen_cache'][$k]))
651 682
 					unset($_SESSION['topicseen_cache'][$k]);
683
+			}
652 684
 		}
653 685
 
654
-		if (isset($_SESSION['topicseen_cache'][$board]))
655
-			unset($_SESSION['topicseen_cache'][$board]);
686
+		if (isset($_SESSION['topicseen_cache'][$board])) {
687
+					unset($_SESSION['topicseen_cache'][$board]);
688
+		}
656 689
 
657 690
 		$request = $smcFunc['db_query']('', '
658 691
 			SELECT id_topic, id_board, sent
@@ -673,8 +706,9 @@  discard block
 block discarded – undo
673 706
 				$context['is_marked_notify'] = true;
674 707
 				$board_sent = $row['sent'];
675 708
 			}
676
-			if (!empty($row['id_topic']))
677
-				$context['topics'][$row['id_topic']]['is_watched'] = true;
709
+			if (!empty($row['id_topic'])) {
710
+							$context['topics'][$row['id_topic']]['is_watched'] = true;
711
+			}
678 712
 		}
679 713
 		$smcFunc['db_free_result']($request);
680 714
 
@@ -698,8 +732,7 @@  discard block
 block discarded – undo
698 732
 		$pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array();
699 733
 		$pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0);
700 734
 		$context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1));
701
-	}
702
-	else
735
+	} else
703 736
 	{
704 737
 		$context['is_marked_notify'] = false;
705 738
 		$context['board_notification_mode'] = 1;
@@ -712,23 +745,27 @@  discard block
 block discarded – undo
712 745
 	$context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false;
713 746
 
714 747
 	// Don't want to show this forever...
715
-	if ($context['becomesUnapproved'])
716
-		unset($_SESSION['becomesUnapproved']);
748
+	if ($context['becomesUnapproved']) {
749
+			unset($_SESSION['becomesUnapproved']);
750
+	}
717 751
 
718 752
 	// Build the message index button array.
719 753
 	$context['normal_buttons'] = array();
720 754
 
721
-	if ($context['can_post_new'])
722
-		$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
755
+	if ($context['can_post_new']) {
756
+			$context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true);
757
+	}
723 758
 
724
-	if ($context['can_post_poll'])
725
-		$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
759
+	if ($context['can_post_poll']) {
760
+			$context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll');
761
+	}
726 762
 
727
-	if (!$context['user']['is_logged'])
728
-		$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
763
+	if (!$context['user']['is_logged']) {
764
+			$context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']);
765
+	}
729 766
 
730
-	if ($context['can_mark_notify'])
731
-		$context['normal_buttons']['notify'] = array(
767
+	if ($context['can_mark_notify']) {
768
+			$context['normal_buttons']['notify'] = array(
732 769
 			'lang' => true,
733 770
 			'text' => 'notify_board_' . $context['board_notification_mode'],
734 771
 			'sub_buttons' => array(
@@ -746,6 +783,7 @@  discard block
 block discarded – undo
746 783
 				),
747 784
 			),
748 785
 		);
786
+	}
749 787
 
750 788
 	// Javascript for inline editing.
751 789
 	loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic');
@@ -767,18 +805,21 @@  discard block
 block discarded – undo
767 805
 	checkSession('request');
768 806
 
769 807
 	// Lets go straight to the restore area.
770
-	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics']))
771
-		redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
808
+	if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) {
809
+			redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']);
810
+	}
772 811
 
773
-	if (isset($_SESSION['topicseen_cache']))
774
-		$_SESSION['topicseen_cache'] = array();
812
+	if (isset($_SESSION['topicseen_cache'])) {
813
+			$_SESSION['topicseen_cache'] = array();
814
+	}
775 815
 
776 816
 	// This is going to be needed to send off the notifications and for updateLastMessages().
777 817
 	require_once($sourcedir . '/Subs-Post.php');
778 818
 
779 819
 	// Remember the last board they moved things to.
780
-	if (isset($_REQUEST['move_to']))
781
-		$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
820
+	if (isset($_REQUEST['move_to'])) {
821
+			$_SESSION['move_to_topic'] = $_REQUEST['move_to'];
822
+	}
782 823
 
783 824
 	// Only a few possible actions.
784 825
 	$possibleActions = array();
@@ -798,8 +839,7 @@  discard block
 block discarded – undo
798 839
 		);
799 840
 
800 841
 		$redirect_url = 'board=' . $board . '.' . $_REQUEST['start'];
801
-	}
802
-	else
842
+	} else
803 843
 	{
804 844
 		/**
805 845
 		 * @todo Ugly. There's no getting around this, is there?
@@ -817,8 +857,7 @@  discard block
 block discarded – undo
817 857
 		if (!empty($board))
818 858
 		{
819 859
 			$boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board));
820
-		}
821
-		else
860
+		} else
822 861
 		{
823 862
 			$boards_can['post_new'] = boardsAllowedTo('post_new');
824 863
 		}
@@ -829,55 +868,67 @@  discard block
 block discarded – undo
829 868
 		}
830 869
 	}
831 870
 
832
-	if (!$user_info['is_guest'])
833
-		$possibleActions[] = 'markread';
834
-	if (!empty($boards_can['make_sticky']))
835
-		$possibleActions[] = 'sticky';
836
-	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own']))
837
-		$possibleActions[] = 'move';
838
-	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own']))
839
-		$possibleActions[] = 'remove';
840
-	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own']))
841
-		$possibleActions[] = 'lock';
842
-	if (!empty($boards_can['merge_any']))
843
-		$possibleActions[] = 'merge';
844
-	if (!empty($boards_can['approve_posts']))
845
-		$possibleActions[] = 'approve';
871
+	if (!$user_info['is_guest']) {
872
+			$possibleActions[] = 'markread';
873
+	}
874
+	if (!empty($boards_can['make_sticky'])) {
875
+			$possibleActions[] = 'sticky';
876
+	}
877
+	if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) {
878
+			$possibleActions[] = 'move';
879
+	}
880
+	if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) {
881
+			$possibleActions[] = 'remove';
882
+	}
883
+	if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) {
884
+			$possibleActions[] = 'lock';
885
+	}
886
+	if (!empty($boards_can['merge_any'])) {
887
+			$possibleActions[] = 'merge';
888
+	}
889
+	if (!empty($boards_can['approve_posts'])) {
890
+			$possibleActions[] = 'approve';
891
+	}
846 892
 
847 893
 	// Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction'].
848 894
 	// (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.)
849 895
 	if (!empty($_REQUEST['topics']))
850 896
 	{
851 897
 		// If the action isn't valid, just quit now.
852
-		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions))
853
-			redirectexit($redirect_url);
898
+		if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) {
899
+					redirectexit($redirect_url);
900
+		}
854 901
 
855 902
 		// Merge requires all topics as one parameter and can be done at once.
856 903
 		if ($_REQUEST['qaction'] == 'merge')
857 904
 		{
858 905
 			// Merge requires at least two topics.
859
-			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2)
860
-				redirectexit($redirect_url);
906
+			if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) {
907
+							redirectexit($redirect_url);
908
+			}
861 909
 
862 910
 			require_once($sourcedir . '/SplitTopics.php');
863 911
 			return MergeExecute($_REQUEST['topics']);
864 912
 		}
865 913
 
866 914
 		// Just convert to the other method, to make it easier.
867
-		foreach ($_REQUEST['topics'] as $topic)
868
-			$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
915
+		foreach ($_REQUEST['topics'] as $topic) {
916
+					$_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction'];
917
+		}
869 918
 	}
870 919
 
871 920
 	// Weird... how'd you get here?
872
-	if (empty($_REQUEST['actions']))
873
-		redirectexit($redirect_url);
921
+	if (empty($_REQUEST['actions'])) {
922
+			redirectexit($redirect_url);
923
+	}
874 924
 
875 925
 	// Validate each action.
876 926
 	$temp = array();
877 927
 	foreach ($_REQUEST['actions'] as $topic => $action)
878 928
 	{
879
-		if (in_array($action, $possibleActions))
880
-			$temp[(int) $topic] = $action;
929
+		if (in_array($action, $possibleActions)) {
930
+					$temp[(int) $topic] = $action;
931
+		}
881 932
 	}
882 933
 	$_REQUEST['actions'] = $temp;
883 934
 
@@ -898,27 +949,31 @@  discard block
 block discarded – undo
898 949
 		{
899 950
 			if (!empty($board))
900 951
 			{
901
-				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts')))
902
-					unset($_REQUEST['actions'][$row['id_topic']]);
903
-			}
904
-			else
952
+				if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) {
953
+									unset($_REQUEST['actions'][$row['id_topic']]);
954
+				}
955
+			} else
905 956
 			{
906 957
 				// Don't allow them to act on unapproved posts they can't see...
907
-				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))
908
-					unset($_REQUEST['actions'][$row['id_topic']]);
958
+				if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) {
959
+									unset($_REQUEST['actions'][$row['id_topic']]);
960
+				}
909 961
 				// Goodness, this is fun.  We need to validate the action.
910
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky']))
911
-					unset($_REQUEST['actions'][$row['id_topic']]);
912
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own']))))
913
-					unset($_REQUEST['actions'][$row['id_topic']]);
914
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own']))))
915
-					unset($_REQUEST['actions'][$row['id_topic']]);
962
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) {
963
+									unset($_REQUEST['actions'][$row['id_topic']]);
964
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) {
965
+									unset($_REQUEST['actions'][$row['id_topic']]);
966
+				} elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) {
967
+									unset($_REQUEST['actions'][$row['id_topic']]);
968
+				}
916 969
 				// @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked'])
917
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own']))))
918
-					unset($_REQUEST['actions'][$row['id_topic']]);
970
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) {
971
+									unset($_REQUEST['actions'][$row['id_topic']]);
972
+				}
919 973
 				// If the topic is approved then you need permission to approve the posts within.
920
-				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts']))))
921
-					unset($_REQUEST['actions'][$row['id_topic']]);
974
+				elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) {
975
+									unset($_REQUEST['actions'][$row['id_topic']]);
976
+				}
922 977
 			}
923 978
 		}
924 979
 		$smcFunc['db_free_result']($request);
@@ -936,11 +991,11 @@  discard block
 block discarded – undo
936 991
 	{
937 992
 		$topic = (int) $topic;
938 993
 
939
-		if ($action == 'markread')
940
-			$markCache[] = $topic;
941
-		elseif ($action == 'sticky')
942
-			$stickyCache[] = $topic;
943
-		elseif ($action == 'move')
994
+		if ($action == 'markread') {
995
+					$markCache[] = $topic;
996
+		} elseif ($action == 'sticky') {
997
+					$stickyCache[] = $topic;
998
+		} elseif ($action == 'move')
944 999
 		{
945 1000
 			require_once($sourcedir . '/MoveTopic.php');
946 1001
 			moveTopicConcurrence();
@@ -948,23 +1003,25 @@  discard block
 block discarded – undo
948 1003
 			// $moveCache[0] is the topic, $moveCache[1] is the board to move to.
949 1004
 			$moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']);
950 1005
 
951
-			if (empty($moveCache[1][$topic]))
952
-				continue;
1006
+			if (empty($moveCache[1][$topic])) {
1007
+							continue;
1008
+			}
953 1009
 
954 1010
 			$moveCache[0][] = $topic;
1011
+		} elseif ($action == 'remove') {
1012
+					$removeCache[] = $topic;
1013
+		} elseif ($action == 'lock') {
1014
+					$lockCache[] = $topic;
1015
+		} elseif ($action == 'approve') {
1016
+					$approveCache[] = $topic;
955 1017
 		}
956
-		elseif ($action == 'remove')
957
-			$removeCache[] = $topic;
958
-		elseif ($action == 'lock')
959
-			$lockCache[] = $topic;
960
-		elseif ($action == 'approve')
961
-			$approveCache[] = $topic;
962 1018
 	}
963 1019
 
964
-	if (empty($board))
965
-		$affectedBoards = array();
966
-	else
967
-		$affectedBoards = array($board => array(0, 0));
1020
+	if (empty($board)) {
1021
+			$affectedBoards = array();
1022
+	} else {
1023
+			$affectedBoards = array($board => array(0, 0));
1024
+	}
968 1025
 
969 1026
 	// Do all the stickies...
970 1027
 	if (!empty($stickyCache))
@@ -1024,14 +1081,16 @@  discard block
 block discarded – undo
1024 1081
 		{
1025 1082
 			$to = $moveCache[1][$row['id_topic']];
1026 1083
 
1027
-			if (empty($to))
1028
-				continue;
1084
+			if (empty($to)) {
1085
+							continue;
1086
+			}
1029 1087
 
1030 1088
 			// Does this topic's board count the posts or not?
1031 1089
 			$countPosts[$row['id_topic']] = empty($row['count_posts']);
1032 1090
 
1033
-			if (!isset($moveTos[$to]))
1034
-				$moveTos[$to] = array();
1091
+			if (!isset($moveTos[$to])) {
1092
+							$moveTos[$to] = array();
1093
+			}
1035 1094
 
1036 1095
 			$moveTos[$to][] = $row['id_topic'];
1037 1096
 
@@ -1045,8 +1104,9 @@  discard block
 block discarded – undo
1045 1104
 		require_once($sourcedir . '/MoveTopic.php');
1046 1105
 
1047 1106
 		// Do the actual moves...
1048
-		foreach ($moveTos as $to => $topics)
1049
-			moveTopics($topics, $to);
1107
+		foreach ($moveTos as $to => $topics) {
1108
+					moveTopics($topics, $to);
1109
+		}
1050 1110
 
1051 1111
 		// Does the post counts need to be updated?
1052 1112
 		if (!empty($moveTos))
@@ -1095,20 +1155,23 @@  discard block
 block discarded – undo
1095 1155
 
1096 1156
 				while ($row = $smcFunc['db_fetch_assoc']($request))
1097 1157
 				{
1098
-					if (!isset($members[$row['id_member']]))
1099
-						$members[$row['id_member']] = 0;
1158
+					if (!isset($members[$row['id_member']])) {
1159
+											$members[$row['id_member']] = 0;
1160
+					}
1100 1161
 
1101
-					if ($topicRecounts[$row['id_topic']] === '+')
1102
-						$members[$row['id_member']] += 1;
1103
-					else
1104
-						$members[$row['id_member']] -= 1;
1162
+					if ($topicRecounts[$row['id_topic']] === '+') {
1163
+											$members[$row['id_member']] += 1;
1164
+					} else {
1165
+											$members[$row['id_member']] -= 1;
1166
+					}
1105 1167
 				}
1106 1168
 
1107 1169
 				$smcFunc['db_free_result']($request);
1108 1170
 
1109 1171
 				// And now update them member's post counts
1110
-				foreach ($members as $id_member => $post_adj)
1111
-					updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1172
+				foreach ($members as $id_member => $post_adj) {
1173
+									updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj));
1174
+				}
1112 1175
 
1113 1176
 			}
1114 1177
 		}
@@ -1188,8 +1251,9 @@  discard block
 block discarded – undo
1188 1251
 			approveTopics($approveCache);
1189 1252
 
1190 1253
 			// Time for some logging!
1191
-			foreach ($approveCache as $topic)
1192
-				logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1254
+			foreach ($approveCache as $topic) {
1255
+							logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic]));
1256
+			}
1193 1257
 		}
1194 1258
 	}
1195 1259
 
@@ -1224,8 +1288,7 @@  discard block
 block discarded – undo
1224 1288
 				$lockStatus[$row['id_topic']] = empty($row['locked']);
1225 1289
 			}
1226 1290
 			$smcFunc['db_free_result']($result);
1227
-		}
1228
-		else
1291
+		} else
1229 1292
 		{
1230 1293
 			$result = $smcFunc['db_query']('', '
1231 1294
 				SELECT id_topic, locked, id_board
@@ -1275,13 +1338,15 @@  discard block
 block discarded – undo
1275 1338
 			)
1276 1339
 		);
1277 1340
 		$logged_topics = array();
1278
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1279
-			$logged_topics[$row['id_topic']] = $row['unwatched'];
1341
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1342
+					$logged_topics[$row['id_topic']] = $row['unwatched'];
1343
+		}
1280 1344
 		$smcFunc['db_free_result']($request);
1281 1345
 
1282 1346
 		$markArray = array();
1283
-		foreach ($markCache as $topic)
1284
-			$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1347
+		foreach ($markCache as $topic) {
1348
+					$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0));
1349
+		}
1285 1350
 
1286 1351
 		$smcFunc['db_insert']('replace',
1287 1352
 			'{db_prefix}log_topics',
@@ -1294,8 +1359,9 @@  discard block
 block discarded – undo
1294 1359
 	foreach ($moveCache as $topic)
1295 1360
 	{
1296 1361
 		// Didn't actually move anything!
1297
-		if (!isset($topic[0]))
1298
-			break;
1362
+		if (!isset($topic[0])) {
1363
+					break;
1364
+		}
1299 1365
 
1300 1366
 		logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2]));
1301 1367
 		sendNotifications($topic[0], 'move');
@@ -1317,8 +1383,9 @@  discard block
 block discarded – undo
1317 1383
 		'calendar_updated' => time(),
1318 1384
 	));
1319 1385
 
1320
-	if (!empty($affectedBoards))
1321
-		updateLastMessages(array_keys($affectedBoards));
1386
+	if (!empty($affectedBoards)) {
1387
+			updateLastMessages(array_keys($affectedBoards));
1388
+	}
1322 1389
 
1323 1390
 	redirectexit($redirect_url);
1324 1391
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -349,7 +349,7 @@
 block discarded – undo
349 349
 			SELECT
350 350
 				t.id_topic, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board,
351 351
 				' . ($user_info['is_guest'] ? '0' : 'COALESCE(lt.id_msg, COALESCE(lmr.id_msg, -1)) + 1') . ' AS new_from,
352
-				' . ( $enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in,
352
+				' . ($enableParticipation ? ' COALESCE(( SELECT 1 FROM {db_prefix}messages AS parti WHERE t.id_topic = parti.id_topic and parti.id_member = {int:current_member} LIMIT 1) , 0) as is_posted_in,
353 353
 				'	: '') . '
354 354
 				t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time AS last_poster_time, t.id_redirect_topic,
355 355
 				ml.id_msg_modified, ml.subject AS last_subject, ml.icon AS last_icon,
Please login to merge, or discard this patch.