Completed
Push — release-2.1 ( deac78...651c45 )
by Colin
39:45 queued 31:25
created
Sources/Profile-View.php 1 patch
Braces   +310 added lines, -227 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
 
@@ -222,8 +230,9 @@  discard block
 block discarded – undo
222 230
 	// are we someone else?
223 231
 	if (empty($user_info) || $user_info['id'] != $memID)
224 232
 	{
225
-		if (empty($user_profile[$memID]))
226
-			loadMemberData($memID, false, 'profile');
233
+		if (empty($user_profile[$memID])) {
234
+					loadMemberData($memID, false, 'profile');
235
+		}
227 236
 		$user_info = $user_profile[$memID];
228 237
 	}
229 238
 
@@ -254,16 +263,18 @@  discard block
 block discarded – undo
254 263
 		$row['extra'] = !empty($row['extra']) ? $smcFunc['json_decode']($row['extra'], true) : array();
255 264
 		$alerts[$id_alert] = $row;
256 265
 
257
-		if (!empty($row['sender_id']))
258
-			$senders[] = $row['sender_id'];
266
+		if (!empty($row['sender_id'])) {
267
+					$senders[] = $row['sender_id'];
268
+		}
259 269
 	}
260 270
 	$smcFunc['db_free_result']($request);
261 271
 
262 272
 	if($withSender)
263 273
 	{
264 274
 		$senders = loadMemberData($senders);
265
-		foreach ($senders as $member)
266
-			loadMemberContext($member);
275
+		foreach ($senders as $member) {
276
+					loadMemberContext($member);
277
+		}
267 278
 	}
268 279
 
269 280
 	// Now go through and actually make with the text.
@@ -278,12 +289,15 @@  discard block
 block discarded – undo
278 289
 	$msgs = array();
279 290
 	foreach ($alerts as $id_alert => $alert)
280 291
 	{
281
-		if (isset($alert['extra']['board']))
282
-			$boards[$alert['extra']['board']] = $txt['board_na'];
283
-		if (isset($alert['extra']['topic']))
284
-			$topics[$alert['extra']['topic']] = $txt['topic_na'];
285
-		if ($alert['content_type'] == 'msg')
286
-			$msgs[$alert['content_id']] = $txt['topic_na'];
292
+		if (isset($alert['extra']['board'])) {
293
+					$boards[$alert['extra']['board']] = $txt['board_na'];
294
+		}
295
+		if (isset($alert['extra']['topic'])) {
296
+					$topics[$alert['extra']['topic']] = $txt['topic_na'];
297
+		}
298
+		if ($alert['content_type'] == 'msg') {
299
+					$msgs[$alert['content_id']] = $txt['topic_na'];
300
+		}
287 301
 	}
288 302
 
289 303
 	// 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.
@@ -298,8 +312,9 @@  discard block
 block discarded – undo
298 312
 				'boards' => array_keys($boards),
299 313
 			)
300 314
 		);
301
-		while ($row = $smcFunc['db_fetch_assoc']($request))
302
-			$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
315
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
316
+					$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
317
+		}
303 318
 	}
304 319
 	if (!empty($topics))
305 320
 	{
@@ -314,8 +329,9 @@  discard block
 block discarded – undo
314 329
 				'topics' => array_keys($topics),
315 330
 			)
316 331
 		);
317
-		while ($row = $smcFunc['db_fetch_assoc']($request))
318
-			$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
332
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
333
+					$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
334
+		}
319 335
 	}
320 336
 	if (!empty($msgs))
321 337
 	{
@@ -330,44 +346,51 @@  discard block
 block discarded – undo
330 346
 				'msgs' => array_keys($msgs),
331 347
 			)
332 348
 		);
333
-		while ($row = $smcFunc['db_fetch_assoc']($request))
334
-			$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
349
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
350
+					$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
351
+		}
335 352
 	}
336 353
 
337 354
 	// 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)
338 355
 	foreach ($alerts as $id_alert => $alert)
339 356
 	{
340
-		if (!empty($alert['text']))
341
-			continue;
342
-		if (isset($alert['extra']['board']))
343
-			if ($boards[$alert['extra']['board']] == $txt['board_na'])
357
+		if (!empty($alert['text'])) {
358
+					continue;
359
+		}
360
+		if (isset($alert['extra']['board'])) {
361
+					if ($boards[$alert['extra']['board']] == $txt['board_na'])
344 362
 			{
345 363
 				unset($alerts[$id_alert]);
364
+		}
346 365
 				continue;
366
+			} else {
367
+							$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
347 368
 			}
348
-			else
349
-				$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
350
-		if (isset($alert['extra']['topic']))
351
-			if ($alert['extra']['topic'] == $txt['topic_na'])
369
+		if (isset($alert['extra']['topic'])) {
370
+					if ($alert['extra']['topic'] == $txt['topic_na'])
352 371
 			{
353 372
 				unset($alerts[$id_alert]);
373
+		}
354 374
 				continue;
375
+			} else {
376
+							$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
355 377
 			}
356
-			else
357
-				$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
358
-		if ($alert['content_type'] == 'msg')
359
-			if ($msgs[$alert['content_id']] == $txt['topic_na'])
378
+		if ($alert['content_type'] == 'msg') {
379
+					if ($msgs[$alert['content_id']] == $txt['topic_na'])
360 380
 			{
361 381
 				unset($alerts[$id_alert]);
382
+		}
362 383
 				continue;
384
+			} else {
385
+							$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
363 386
 			}
364
-			else
365
-				$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
366
-		if ($alert['content_type'] == 'profile')
367
-			$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
387
+		if ($alert['content_type'] == 'profile') {
388
+					$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
389
+		}
368 390
 
369
-		if (!empty($memberContext[$alert['sender_id']]))
370
-			$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
391
+		if (!empty($memberContext[$alert['sender_id']])) {
392
+					$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
393
+		}
371 394
 
372 395
 		$string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action'];
373 396
 		if (isset($txt[$string]))
@@ -417,8 +440,8 @@  discard block
 block discarded – undo
417 440
 	$context['pagination'] = constructPageIndex($scripturl . '?action=profile;area=showalerts;u=' . $memID, $start, $count, $maxIndex, false);
418 441
 
419 442
 	// Set some JavaScript for checking all alerts at once.
420
-	if ($context['showCheckboxes'])
421
-		addInlineJavaScript('
443
+	if ($context['showCheckboxes']) {
444
+			addInlineJavaScript('
422 445
 		$(function(){
423 446
 			$(\'#select_all\').on(\'change\', function() {
424 447
 				var checkboxes = $(\'ul.quickbuttons\').find(\':checkbox\');
@@ -430,6 +453,7 @@  discard block
 block discarded – undo
430 453
 				}
431 454
 			});
432 455
 		});', true);
456
+	}
433 457
 
434 458
 	// Set a nice message.
435 459
 	if (!empty($_SESSION['update_message']))
@@ -461,11 +485,11 @@  discard block
 block discarded – undo
461 485
 		checkSession('request');
462 486
 
463 487
 		// Call it!
464
-		if ($action == 'remove')
465
-			alert_delete($toMark, $memID);
466
-
467
-		else
468
-			alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
488
+		if ($action == 'remove') {
489
+					alert_delete($toMark, $memID);
490
+		} else {
491
+					alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
492
+		}
469 493
 
470 494
 		// Set a nice update message.
471 495
 		$_SESSION['update_message'] = true;
@@ -515,23 +539,27 @@  discard block
 block discarded – undo
515 539
 	);
516 540
 
517 541
 	// Set the page title
518
-	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title))
519
-		$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
520
-	else
521
-		$context['page_title'] = $txt['showPosts'];
542
+	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) {
543
+			$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
544
+	} else {
545
+			$context['page_title'] = $txt['showPosts'];
546
+	}
522 547
 
523 548
 	$context['page_title'] .= ' - ' . $user_profile[$memID]['real_name'];
524 549
 
525 550
 	// Is the load average too high to allow searching just now?
526
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts'])
527
-		fatal_lang_error('loadavg_show_posts_disabled', false);
551
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) {
552
+			fatal_lang_error('loadavg_show_posts_disabled', false);
553
+	}
528 554
 
529 555
 	// If we're specifically dealing with attachments use that function!
530
-	if (isset($_GET['sa']) && $_GET['sa'] == 'attach')
531
-		return showAttachments($memID);
556
+	if (isset($_GET['sa']) && $_GET['sa'] == 'attach') {
557
+			return showAttachments($memID);
558
+	}
532 559
 	// Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function.
533
-	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics')
534
-		return showUnwatched($memID);
560
+	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') {
561
+			return showUnwatched($memID);
562
+	}
535 563
 
536 564
 	// Are we just viewing topics?
537 565
 	$context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false;
@@ -554,27 +582,30 @@  discard block
 block discarded – undo
554 582
 		$smcFunc['db_free_result']($request);
555 583
 
556 584
 		// Trying to remove a message that doesn't exist.
557
-		if (empty($info))
558
-			redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
585
+		if (empty($info)) {
586
+					redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
587
+		}
559 588
 
560 589
 		// We can be lazy, since removeMessage() will check the permissions for us.
561 590
 		require_once($sourcedir . '/RemoveTopic.php');
562 591
 		removeMessage((int) $_GET['delete']);
563 592
 
564 593
 		// Add it to the mod log.
565
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
566
-			logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
594
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
595
+					logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
596
+		}
567 597
 
568 598
 		// Back to... where we are now ;).
569 599
 		redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
570 600
 	}
571 601
 
572 602
 	// Default to 10.
573
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
574
-		$_REQUEST['viewscount'] = '10';
603
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
604
+			$_REQUEST['viewscount'] = '10';
605
+	}
575 606
 
576
-	if ($context['is_topics'])
577
-		$request = $smcFunc['db_query']('', '
607
+	if ($context['is_topics']) {
608
+			$request = $smcFunc['db_query']('', '
578 609
 			SELECT COUNT(*)
579 610
 			FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : '
580 611
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . '
@@ -587,8 +618,8 @@  discard block
 block discarded – undo
587 618
 				'board' => $board,
588 619
 			)
589 620
 		);
590
-	else
591
-		$request = $smcFunc['db_query']('', '
621
+	} else {
622
+			$request = $smcFunc['db_query']('', '
592 623
 			SELECT COUNT(*)
593 624
 			FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : '
594 625
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . '
@@ -601,6 +632,7 @@  discard block
 block discarded – undo
601 632
 				'board' => $board,
602 633
 			)
603 634
 		);
635
+	}
604 636
 	list ($msgCount) = $smcFunc['db_fetch_row']($request);
605 637
 	$smcFunc['db_free_result']($request);
606 638
 
@@ -621,10 +653,11 @@  discard block
 block discarded – undo
621 653
 
622 654
 	$range_limit = '';
623 655
 
624
-	if ($context['is_topics'])
625
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
626
-	else
627
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
656
+	if ($context['is_topics']) {
657
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
658
+	} else {
659
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
660
+	}
628 661
 
629 662
 	$maxIndex = $maxPerPage;
630 663
 
@@ -650,9 +683,9 @@  discard block
 block discarded – undo
650 683
 		{
651 684
 			$margin *= 5;
652 685
 			$range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin);
686
+		} else {
687
+					$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
653 688
 		}
654
-		else
655
-			$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
656 689
 	}
657 690
 
658 691
 	// Find this user's posts.  The left join on categories somehow makes this faster, weird as it looks.
@@ -684,8 +717,7 @@  discard block
 block discarded – undo
684 717
 					'max' => $maxIndex,
685 718
 				)
686 719
 			);
687
-		}
688
-		else
720
+		} else
689 721
 		{
690 722
 			$request = $smcFunc['db_query']('', '
691 723
 				SELECT
@@ -714,8 +746,9 @@  discard block
 block discarded – undo
714 746
 		}
715 747
 
716 748
 		// Make sure we quit this loop.
717
-		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '')
718
-			break;
749
+		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped || $range_limit == '') {
750
+					break;
751
+		}
719 752
 		$looped = true;
720 753
 		$range_limit = '';
721 754
 	}
@@ -759,19 +792,21 @@  discard block
 block discarded – undo
759 792
 			'css_class' => $row['approved'] ? 'windowbg' : 'approvebg',
760 793
 		);
761 794
 
762
-		if ($user_info['id'] == $row['id_member_started'])
763
-			$board_ids['own'][$row['id_board']][] = $counter;
795
+		if ($user_info['id'] == $row['id_member_started']) {
796
+					$board_ids['own'][$row['id_board']][] = $counter;
797
+		}
764 798
 		$board_ids['any'][$row['id_board']][] = $counter;
765 799
 	}
766 800
 	$smcFunc['db_free_result']($request);
767 801
 
768 802
 	// All posts were retrieved in reverse order, get them right again.
769
-	if ($reverse)
770
-		$context['posts'] = array_reverse($context['posts'], true);
803
+	if ($reverse) {
804
+			$context['posts'] = array_reverse($context['posts'], true);
805
+	}
771 806
 
772 807
 	// These are all the permissions that are different from board to board..
773
-	if ($context['is_topics'])
774
-		$permissions = array(
808
+	if ($context['is_topics']) {
809
+			$permissions = array(
775 810
 			'own' => array(
776 811
 				'post_reply_own' => 'can_reply',
777 812
 			),
@@ -779,8 +814,8 @@  discard block
 block discarded – undo
779 814
 				'post_reply_any' => 'can_reply',
780 815
 			)
781 816
 		);
782
-	else
783
-		$permissions = array(
817
+	} else {
818
+			$permissions = array(
784 819
 			'own' => array(
785 820
 				'post_reply_own' => 'can_reply',
786 821
 				'delete_own' => 'can_delete',
@@ -790,6 +825,7 @@  discard block
 block discarded – undo
790 825
 				'delete_any' => 'can_delete',
791 826
 			)
792 827
 		);
828
+	}
793 829
 
794 830
 	// For every permission in the own/any lists...
795 831
 	foreach ($permissions as $type => $list)
@@ -800,19 +836,22 @@  discard block
 block discarded – undo
800 836
 			$boards = boardsAllowedTo($permission);
801 837
 
802 838
 			// Hmm, they can do it on all boards, can they?
803
-			if (!empty($boards) && $boards[0] == 0)
804
-				$boards = array_keys($board_ids[$type]);
839
+			if (!empty($boards) && $boards[0] == 0) {
840
+							$boards = array_keys($board_ids[$type]);
841
+			}
805 842
 
806 843
 			// Now go through each board they can do the permission on.
807 844
 			foreach ($boards as $board_id)
808 845
 			{
809 846
 				// There aren't any posts displayed from this board.
810
-				if (!isset($board_ids[$type][$board_id]))
811
-					continue;
847
+				if (!isset($board_ids[$type][$board_id])) {
848
+									continue;
849
+				}
812 850
 
813 851
 				// Set the permission to true ;).
814
-				foreach ($board_ids[$type][$board_id] as $counter)
815
-					$context['posts'][$counter][$allowed] = true;
852
+				foreach ($board_ids[$type][$board_id] as $counter) {
853
+									$context['posts'][$counter][$allowed] = true;
854
+				}
816 855
 			}
817 856
 		}
818 857
 	}
@@ -843,8 +882,9 @@  discard block
 block discarded – undo
843 882
 	$boardsAllowed = boardsAllowedTo('view_attachments');
844 883
 
845 884
 	// Make sure we can't actually see anything...
846
-	if (empty($boardsAllowed))
847
-		$boardsAllowed = array(-1);
885
+	if (empty($boardsAllowed)) {
886
+			$boardsAllowed = array(-1);
887
+	}
848 888
 
849 889
 	require_once($sourcedir . '/Subs-List.php');
850 890
 
@@ -995,8 +1035,8 @@  discard block
 block discarded – undo
995 1035
 		)
996 1036
 	);
997 1037
 	$attachments = array();
998
-	while ($row = $smcFunc['db_fetch_assoc']($request))
999
-		$attachments[] = array(
1038
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1039
+			$attachments[] = array(
1000 1040
 			'id' => $row['id_attach'],
1001 1041
 			'filename' => $row['filename'],
1002 1042
 			'downloads' => $row['downloads'],
@@ -1008,6 +1048,7 @@  discard block
 block discarded – undo
1008 1048
 			'board_name' => $row['name'],
1009 1049
 			'approved' => $row['approved'],
1010 1050
 		);
1051
+	}
1011 1052
 
1012 1053
 	$smcFunc['db_free_result']($request);
1013 1054
 
@@ -1062,8 +1103,9 @@  discard block
 block discarded – undo
1062 1103
 	global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir;
1063 1104
 
1064 1105
 	// Only the owner can see the list (if the function is enabled of course)
1065
-	if ($user_info['id'] != $memID)
1066
-		return;
1106
+	if ($user_info['id'] != $memID) {
1107
+			return;
1108
+	}
1067 1109
 
1068 1110
 	require_once($sourcedir . '/Subs-List.php');
1069 1111
 
@@ -1209,8 +1251,9 @@  discard block
 block discarded – undo
1209 1251
 	);
1210 1252
 
1211 1253
 	$topics = array();
1212
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1213
-		$topics[] = $row['id_topic'];
1254
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1255
+			$topics[] = $row['id_topic'];
1256
+	}
1214 1257
 
1215 1258
 	$smcFunc['db_free_result']($request);
1216 1259
 
@@ -1230,8 +1273,9 @@  discard block
 block discarded – undo
1230 1273
 				'topics' => $topics,
1231 1274
 			)
1232 1275
 		);
1233
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1234
-			$topicsInfo[] = $row;
1276
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1277
+					$topicsInfo[] = $row;
1278
+		}
1235 1279
 		$smcFunc['db_free_result']($request);
1236 1280
 	}
1237 1281
 
@@ -1279,8 +1323,9 @@  discard block
 block discarded – undo
1279 1323
 	$context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name'];
1280 1324
 
1281 1325
 	// Is the load average too high to allow searching just now?
1282
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats'])
1283
-		fatal_lang_error('loadavg_userstats_disabled', false);
1326
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) {
1327
+			fatal_lang_error('loadavg_userstats_disabled', false);
1328
+	}
1284 1329
 
1285 1330
 	// General user statistics.
1286 1331
 	$timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400);
@@ -1423,11 +1468,13 @@  discard block
 block discarded – undo
1423 1468
 	}
1424 1469
 	$smcFunc['db_free_result']($result);
1425 1470
 
1426
-	if ($maxPosts > 0)
1427
-		for ($hour = 0; $hour < 24; $hour++)
1471
+	if ($maxPosts > 0) {
1472
+			for ($hour = 0;
1473
+	}
1474
+	$hour < 24; $hour++)
1428 1475
 		{
1429
-			if (!isset($context['posts_by_time'][$hour]))
1430
-				$context['posts_by_time'][$hour] = array(
1476
+			if (!isset($context['posts_by_time'][$hour])) {
1477
+							$context['posts_by_time'][$hour] = array(
1431 1478
 					'hour' => $hour,
1432 1479
 					'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)),
1433 1480
 					'posts' => 0,
@@ -1435,7 +1482,7 @@  discard block
 block discarded – undo
1435 1482
 					'relative_percent' => 0,
1436 1483
 					'is_last' => $hour == 23,
1437 1484
 				);
1438
-			else
1485
+			} else
1439 1486
 			{
1440 1487
 				$context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts);
1441 1488
 				$context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts);
@@ -1468,8 +1515,9 @@  discard block
 block discarded – undo
1468 1515
 
1469 1516
 	foreach ($subActions as $sa => $action)
1470 1517
 	{
1471
-		if (!allowedTo($action[2]))
1472
-			unset($subActions[$sa]);
1518
+		if (!allowedTo($action[2])) {
1519
+					unset($subActions[$sa]);
1520
+		}
1473 1521
 	}
1474 1522
 
1475 1523
 	// Create the tabs for the template.
@@ -1487,15 +1535,18 @@  discard block
 block discarded – undo
1487 1535
 	);
1488 1536
 
1489 1537
 	// Moderation must be on to track edits.
1490
-	if (empty($modSettings['userlog_enabled']))
1491
-		unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1538
+	if (empty($modSettings['userlog_enabled'])) {
1539
+			unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1540
+	}
1492 1541
 
1493 1542
 	// Group requests must be active to show it...
1494
-	if (empty($modSettings['show_group_membership']))
1495
-		unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1543
+	if (empty($modSettings['show_group_membership'])) {
1544
+			unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1545
+	}
1496 1546
 
1497
-	if (empty($subActions))
1498
-		fatal_lang_error('no_access', false);
1547
+	if (empty($subActions)) {
1548
+			fatal_lang_error('no_access', false);
1549
+	}
1499 1550
 
1500 1551
 	$keys = array_keys($subActions);
1501 1552
 	$default = array_shift($keys);
@@ -1508,9 +1559,10 @@  discard block
 block discarded – undo
1508 1559
 	$context['sub_template'] = $subActions[$context['tracking_area']][0];
1509 1560
 	$call = call_helper($subActions[$context['tracking_area']][0], true);
1510 1561
 
1511
-	if (!empty($call))
1512
-		call_user_func($call, $memID);
1513
-}
1562
+	if (!empty($call)) {
1563
+			call_user_func($call, $memID);
1564
+	}
1565
+	}
1514 1566
 
1515 1567
 /**
1516 1568
  * Handles tracking a user's activity
@@ -1526,8 +1578,9 @@  discard block
 block discarded – undo
1526 1578
 	isAllowedTo('moderate_forum');
1527 1579
 
1528 1580
 	$context['last_ip'] = $user_profile[$memID]['member_ip'];
1529
-	if ($context['last_ip'] != $user_profile[$memID]['member_ip2'])
1530
-		$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1581
+	if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) {
1582
+			$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1583
+	}
1531 1584
 	$context['member']['name'] = $user_profile[$memID]['real_name'];
1532 1585
 
1533 1586
 	// Set the options for the list component.
@@ -1694,8 +1747,9 @@  discard block
 block discarded – undo
1694 1747
 			)
1695 1748
 		);
1696 1749
 		$message_members = array();
1697
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1698
-			$message_members[] = $row['id_member'];
1750
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1751
+					$message_members[] = $row['id_member'];
1752
+		}
1699 1753
 		$smcFunc['db_free_result']($request);
1700 1754
 
1701 1755
 		// Fetch their names, cause of the GROUP BY doesn't like giving us that normally.
@@ -1710,8 +1764,9 @@  discard block
 block discarded – undo
1710 1764
 					'ip_list' => $ips,
1711 1765
 				)
1712 1766
 			);
1713
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1714
-				$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1767
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1768
+							$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1769
+			}
1715 1770
 			$smcFunc['db_free_result']($request);
1716 1771
 		}
1717 1772
 
@@ -1725,8 +1780,9 @@  discard block
 block discarded – undo
1725 1780
 				'ip_list' => $ips,
1726 1781
 			)
1727 1782
 		);
1728
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1729
-			$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1783
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1784
+					$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1785
+		}
1730 1786
 		$smcFunc['db_free_result']($request);
1731 1787
 	}
1732 1788
 }
@@ -1786,8 +1842,8 @@  discard block
 block discarded – undo
1786 1842
 		))
1787 1843
 	);
1788 1844
 	$error_messages = array();
1789
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1790
-		$error_messages[] = array(
1845
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1846
+			$error_messages[] = array(
1791 1847
 			'ip' => inet_dtop($row['ip']),
1792 1848
 			'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'],
1793 1849
 			'message' => strtr($row['message'], array('&lt;span class=&quot;remove&quot;&gt;' => '', '&lt;/span&gt;' => '')),
@@ -1795,6 +1851,7 @@  discard block
 block discarded – undo
1795 1851
 			'time' => timeformat($row['log_time']),
1796 1852
 			'timestamp' => forum_time(true, $row['log_time']),
1797 1853
 		);
1854
+	}
1798 1855
 	$smcFunc['db_free_result']($request);
1799 1856
 
1800 1857
 	return $error_messages;
@@ -1857,8 +1914,8 @@  discard block
 block discarded – undo
1857 1914
 		))
1858 1915
 	);
1859 1916
 	$messages = array();
1860
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1861
-		$messages[] = array(
1917
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1918
+			$messages[] = array(
1862 1919
 			'ip' => inet_dtop($row['poster_ip']),
1863 1920
 			'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>',
1864 1921
 			'board' => array(
@@ -1871,6 +1928,7 @@  discard block
 block discarded – undo
1871 1928
 			'time' => timeformat($row['poster_time']),
1872 1929
 			'timestamp' => forum_time(true, $row['poster_time'])
1873 1930
 		);
1931
+	}
1874 1932
 	$smcFunc['db_free_result']($request);
1875 1933
 
1876 1934
 	return $messages;
@@ -1897,19 +1955,20 @@  discard block
 block discarded – undo
1897 1955
 		$context['sub_template'] = 'trackIP';
1898 1956
 		$context['page_title'] = $txt['profile'];
1899 1957
 		$context['base_url'] = $scripturl . '?action=trackip';
1900
-	}
1901
-	else
1958
+	} else
1902 1959
 	{
1903 1960
 		$context['ip'] = ip2range($user_profile[$memID]['member_ip']);
1904 1961
 		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
1905 1962
 	}
1906 1963
 
1907 1964
 	// Searching?
1908
-	if (isset($_REQUEST['searchip']))
1909
-		$context['ip'] = ip2range(trim($_REQUEST['searchip']));
1965
+	if (isset($_REQUEST['searchip'])) {
1966
+			$context['ip'] = ip2range(trim($_REQUEST['searchip']));
1967
+	}
1910 1968
 
1911
-	if (count($context['ip']) !== 2)
1912
-		fatal_lang_error('invalid_tracking_ip', false);
1969
+	if (count($context['ip']) !== 2) {
1970
+			fatal_lang_error('invalid_tracking_ip', false);
1971
+	}
1913 1972
 
1914 1973
 	$ip_string = array('{inet:ip_address_low}','{inet:ip_address_high}');
1915 1974
 	$fields = array(
@@ -1919,13 +1978,15 @@  discard block
 block discarded – undo
1919 1978
 
1920 1979
 	$ip_var = $context['ip'];
1921 1980
 
1922
-	if ($context['ip']['low'] !==  $context['ip']['high'])
1923
-		$context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high'];
1924
-	else
1925
-		$context['ip'] = $context['ip']['low'];
1981
+	if ($context['ip']['low'] !==  $context['ip']['high']) {
1982
+			$context['ip'] = $context['ip']['low'] . ' - ' . $context['ip']['high'];
1983
+	} else {
1984
+			$context['ip'] = $context['ip']['low'];
1985
+	}
1926 1986
 
1927
-	if (empty($context['tracking_area']))
1928
-		$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1987
+	if (empty($context['tracking_area'])) {
1988
+			$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1989
+	}
1929 1990
 
1930 1991
 	$request = $smcFunc['db_query']('', '
1931 1992
 		SELECT id_member, real_name AS display_name, member_ip
@@ -1934,8 +1995,9 @@  discard block
 block discarded – undo
1934 1995
 		$fields
1935 1996
 	);
1936 1997
 	$context['ips'] = array();
1937
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1938
-		$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
1998
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1999
+			$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
2000
+	}
1939 2001
 	$smcFunc['db_free_result']($request);
1940 2002
 
1941 2003
 	ksort($context['ips']);
@@ -2165,10 +2227,11 @@  discard block
 block discarded – undo
2165 2227
 	// Gonna want this for the list.
2166 2228
 	require_once($sourcedir . '/Subs-List.php');
2167 2229
 
2168
-	if ($memID == 0)
2169
-		$context['base_url'] = $scripturl . '?action=trackip';
2170
-	else
2171
-		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2230
+	if ($memID == 0) {
2231
+			$context['base_url'] = $scripturl . '?action=trackip';
2232
+	} else {
2233
+			$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2234
+	}
2172 2235
 
2173 2236
 	// Start with the user messages.
2174 2237
 	$listOptions = array(
@@ -2278,12 +2341,13 @@  discard block
 block discarded – undo
2278 2341
 		)
2279 2342
 	);
2280 2343
 	$logins = array();
2281
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2282
-		$logins[] = array(
2344
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2345
+			$logins[] = array(
2283 2346
 			'time' => timeformat($row['time']),
2284 2347
 			'ip' => inet_dtop($row['ip']),
2285 2348
 			'ip2' => inet_dtop($row['ip2']),
2286 2349
 		);
2350
+	}
2287 2351
 	$smcFunc['db_free_result']($request);
2288 2352
 
2289 2353
 	return $logins;
@@ -2308,11 +2372,12 @@  discard block
 block discarded – undo
2308 2372
 		)
2309 2373
 	);
2310 2374
 	$context['custom_field_titles'] = array();
2311
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2312
-		$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2375
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2376
+			$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2313 2377
 			'title' => $row['field_name'],
2314 2378
 			'parse_bbc' => $row['bbc'],
2315 2379
 		);
2380
+	}
2316 2381
 	$smcFunc['db_free_result']($request);
2317 2382
 
2318 2383
 	// Set the options for the error lists.
@@ -2451,19 +2516,22 @@  discard block
 block discarded – undo
2451 2516
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2452 2517
 	{
2453 2518
 		$extra = $smcFunc['json_decode']($row['extra'], true);
2454
-		if (!empty($extra['applicator']))
2455
-			$members[] = $extra['applicator'];
2519
+		if (!empty($extra['applicator'])) {
2520
+					$members[] = $extra['applicator'];
2521
+		}
2456 2522
 
2457 2523
 		// Work out what the name of the action is.
2458
-		if (isset($txt['trackEdit_action_' . $row['action']]))
2459
-			$action_text = $txt['trackEdit_action_' . $row['action']];
2460
-		elseif (isset($txt[$row['action']]))
2461
-			$action_text = $txt[$row['action']];
2524
+		if (isset($txt['trackEdit_action_' . $row['action']])) {
2525
+					$action_text = $txt['trackEdit_action_' . $row['action']];
2526
+		} elseif (isset($txt[$row['action']])) {
2527
+					$action_text = $txt[$row['action']];
2528
+		}
2462 2529
 		// Custom field?
2463
-		elseif (isset($context['custom_field_titles'][$row['action']]))
2464
-			$action_text = $context['custom_field_titles'][$row['action']]['title'];
2465
-		else
2466
-			$action_text = $row['action'];
2530
+		elseif (isset($context['custom_field_titles'][$row['action']])) {
2531
+					$action_text = $context['custom_field_titles'][$row['action']]['title'];
2532
+		} else {
2533
+					$action_text = $row['action'];
2534
+		}
2467 2535
 
2468 2536
 		// Parse BBC?
2469 2537
 		$parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false;
@@ -2495,13 +2563,15 @@  discard block
 block discarded – undo
2495 2563
 			)
2496 2564
 		);
2497 2565
 		$members = array();
2498
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2499
-			$members[$row['id_member']] = $row['real_name'];
2566
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2567
+					$members[$row['id_member']] = $row['real_name'];
2568
+		}
2500 2569
 		$smcFunc['db_free_result']($request);
2501 2570
 
2502
-		foreach ($edits as $key => $value)
2503
-			if (isset($members[$value['id_member']]))
2571
+		foreach ($edits as $key => $value) {
2572
+					if (isset($members[$value['id_member']]))
2504 2573
 				$edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>';
2574
+		}
2505 2575
 	}
2506 2576
 
2507 2577
 	return $edits;
@@ -2702,10 +2772,11 @@  discard block
 block discarded – undo
2702 2772
 	$context['board'] = $board;
2703 2773
 
2704 2774
 	// Determine which groups this user is in.
2705
-	if (empty($user_profile[$memID]['additional_groups']))
2706
-		$curGroups = array();
2707
-	else
2708
-		$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2775
+	if (empty($user_profile[$memID]['additional_groups'])) {
2776
+			$curGroups = array();
2777
+	} else {
2778
+			$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2779
+	}
2709 2780
 	$curGroups[] = $user_profile[$memID]['id_group'];
2710 2781
 	$curGroups[] = $user_profile[$memID]['id_post_group'];
2711 2782
 
@@ -2725,28 +2796,30 @@  discard block
 block discarded – undo
2725 2796
 	$context['no_access_boards'] = array();
2726 2797
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2727 2798
 	{
2728
-		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod'])
2729
-			$context['no_access_boards'][] = array(
2799
+		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) {
2800
+					$context['no_access_boards'][] = array(
2730 2801
 				'id' => $row['id_board'],
2731 2802
 				'name' => $row['name'],
2732 2803
 				'is_last' => false,
2733 2804
 			);
2734
-		elseif ($row['id_profile'] != 1 || $row['is_mod'])
2735
-			$context['boards'][$row['id_board']] = array(
2805
+		} elseif ($row['id_profile'] != 1 || $row['is_mod']) {
2806
+					$context['boards'][$row['id_board']] = array(
2736 2807
 				'id' => $row['id_board'],
2737 2808
 				'name' => $row['name'],
2738 2809
 				'selected' => $board == $row['id_board'],
2739 2810
 				'profile' => $row['id_profile'],
2740 2811
 				'profile_name' => $context['profiles'][$row['id_profile']]['name'],
2741 2812
 			);
2813
+		}
2742 2814
 	}
2743 2815
 	$smcFunc['db_free_result']($request);
2744 2816
 
2745 2817
 	require_once($sourcedir . '/Subs-Boards.php');
2746 2818
 	sortBoards($context['boards']);
2747 2819
 
2748
-	if (!empty($context['no_access_boards']))
2749
-		$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2820
+	if (!empty($context['no_access_boards'])) {
2821
+			$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2822
+	}
2750 2823
 
2751 2824
 	$context['member']['permissions'] = array(
2752 2825
 		'general' => array(),
@@ -2755,8 +2828,9 @@  discard block
 block discarded – undo
2755 2828
 
2756 2829
 	// If you're an admin we know you can do everything, we might as well leave.
2757 2830
 	$context['member']['has_all_permissions'] = in_array(1, $curGroups);
2758
-	if ($context['member']['has_all_permissions'])
2759
-		return;
2831
+	if ($context['member']['has_all_permissions']) {
2832
+			return;
2833
+	}
2760 2834
 
2761 2835
 	$denied = array();
2762 2836
 
@@ -2775,21 +2849,24 @@  discard block
 block discarded – undo
2775 2849
 	while ($row = $smcFunc['db_fetch_assoc']($result))
2776 2850
 	{
2777 2851
 		// We don't know about this permission, it doesn't exist :P.
2778
-		if (!isset($txt['permissionname_' . $row['permission']]))
2779
-			continue;
2852
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2853
+					continue;
2854
+		}
2780 2855
 
2781
-		if (empty($row['add_deny']))
2782
-			$denied[] = $row['permission'];
2856
+		if (empty($row['add_deny'])) {
2857
+					$denied[] = $row['permission'];
2858
+		}
2783 2859
 
2784 2860
 		// Permissions that end with _own or _any consist of two parts.
2785
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2786
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2787
-		else
2788
-			$name = $txt['permissionname_' . $row['permission']];
2861
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2862
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2863
+		} else {
2864
+					$name = $txt['permissionname_' . $row['permission']];
2865
+		}
2789 2866
 
2790 2867
 		// Add this permission if it doesn't exist yet.
2791
-		if (!isset($context['member']['permissions']['general'][$row['permission']]))
2792
-			$context['member']['permissions']['general'][$row['permission']] = array(
2868
+		if (!isset($context['member']['permissions']['general'][$row['permission']])) {
2869
+					$context['member']['permissions']['general'][$row['permission']] = array(
2793 2870
 				'id' => $row['permission'],
2794 2871
 				'groups' => array(
2795 2872
 					'allowed' => array(),
@@ -2799,6 +2876,7 @@  discard block
 block discarded – undo
2799 2876
 				'is_denied' => false,
2800 2877
 				'is_global' => true,
2801 2878
 			);
2879
+		}
2802 2880
 
2803 2881
 		// Add the membergroup to either the denied or the allowed groups.
2804 2882
 		$context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
@@ -2832,18 +2910,20 @@  discard block
 block discarded – undo
2832 2910
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2833 2911
 	{
2834 2912
 		// We don't know about this permission, it doesn't exist :P.
2835
-		if (!isset($txt['permissionname_' . $row['permission']]))
2836
-			continue;
2913
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2914
+					continue;
2915
+		}
2837 2916
 
2838 2917
 		// The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'.
2839
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2840
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2841
-		else
2842
-			$name = $txt['permissionname_' . $row['permission']];
2918
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2919
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2920
+		} else {
2921
+					$name = $txt['permissionname_' . $row['permission']];
2922
+		}
2843 2923
 
2844 2924
 		// Create the structure for this permission.
2845
-		if (!isset($context['member']['permissions']['board'][$row['permission']]))
2846
-			$context['member']['permissions']['board'][$row['permission']] = array(
2925
+		if (!isset($context['member']['permissions']['board'][$row['permission']])) {
2926
+					$context['member']['permissions']['board'][$row['permission']] = array(
2847 2927
 				'id' => $row['permission'],
2848 2928
 				'groups' => array(
2849 2929
 					'allowed' => array(),
@@ -2853,6 +2933,7 @@  discard block
 block discarded – undo
2853 2933
 				'is_denied' => false,
2854 2934
 				'is_global' => empty($board),
2855 2935
 			);
2936
+		}
2856 2937
 
2857 2938
 		$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'];
2858 2939
 
@@ -2871,8 +2952,9 @@  discard block
 block discarded – undo
2871 2952
 	global $modSettings, $context, $sourcedir, $txt, $scripturl;
2872 2953
 
2873 2954
 	// Firstly, can we actually even be here?
2874
-	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum'))
2875
-		fatal_lang_error('no_access', false);
2955
+	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) {
2956
+			fatal_lang_error('no_access', false);
2957
+	}
2876 2958
 
2877 2959
 	// Make sure things which are disabled stay disabled.
2878 2960
 	$modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110;
@@ -2959,9 +3041,10 @@  discard block
 block discarded – undo
2959 3041
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'],
2960 3042
 	);
2961 3043
 	$context['current_level'] = 0;
2962
-	foreach ($context['level_effects'] as $limit => $dummy)
2963
-		if ($context['member']['warning'] >= $limit)
3044
+	foreach ($context['level_effects'] as $limit => $dummy) {
3045
+			if ($context['member']['warning'] >= $limit)
2964 3046
 			$context['current_level'] = $limit;
2965
-}
3047
+	}
3048
+	}
2966 3049
 
2967 3050
 ?>
2968 3051
\ No newline at end of file
Please login to merge, or discard this patch.