Completed
Pull Request — release-2.1 (#4139)
by Michael
09:53
created
Sources/Profile-View.php 1 patch
Braces   +297 added lines, -216 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']['birthdate'], 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', 'register', 'login', 'post') as $type)
171
-				if ($row['cannot_' . $type])
175
+			foreach (array('access', 'register', '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>');
@@ -196,9 +203,10 @@  discard block
 block discarded – undo
196 203
 	$context['print_custom_fields'] = array();
197 204
 
198 205
 	// Any custom profile fields?
199
-	if (!empty($context['custom_fields']))
200
-		foreach ($context['custom_fields'] as $custom)
206
+	if (!empty($context['custom_fields'])) {
207
+			foreach ($context['custom_fields'] as $custom)
201 208
 			$context['print_custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom;
209
+	}
202 210
 
203 211
 }
204 212
 
@@ -242,14 +250,16 @@  discard block
 block discarded – undo
242 250
 		$row['extra'] = !empty($row['extra']) ? smf_json_decode($row['extra'], true) : array();
243 251
 		$alerts[$id_alert] = $row;
244 252
 
245
-		if (!empty($row['sender_id']))
246
-			$senders[] = $row['sender_id'];
253
+		if (!empty($row['sender_id'])) {
254
+					$senders[] = $row['sender_id'];
255
+		}
247 256
 	}
248 257
 	$smcFunc['db_free_result']($request);
249 258
 
250 259
 	$senders = loadMemberData($senders);
251
-	foreach ($senders as $member)
252
-		loadMemberContext($member);
260
+	foreach ($senders as $member) {
261
+			loadMemberContext($member);
262
+	}
253 263
 
254 264
 	// Now go through and actually make with the text.
255 265
 	loadLanguage('Alerts');
@@ -263,12 +273,15 @@  discard block
 block discarded – undo
263 273
 	$msgs = array();
264 274
 	foreach ($alerts as $id_alert => $alert)
265 275
 	{
266
-		if (isset($alert['extra']['board']))
267
-			$boards[$alert['extra']['board']] = $txt['board_na'];
268
-		if (isset($alert['extra']['topic']))
269
-			$topics[$alert['extra']['topic']] = $txt['topic_na'];
270
-		if ($alert['content_type'] == 'msg')
271
-			$msgs[$alert['content_id']] = $txt['topic_na'];
276
+		if (isset($alert['extra']['board'])) {
277
+					$boards[$alert['extra']['board']] = $txt['board_na'];
278
+		}
279
+		if (isset($alert['extra']['topic'])) {
280
+					$topics[$alert['extra']['topic']] = $txt['topic_na'];
281
+		}
282
+		if ($alert['content_type'] == 'msg') {
283
+					$msgs[$alert['content_id']] = $txt['topic_na'];
284
+		}
272 285
 	}
273 286
 
274 287
 	// 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.
@@ -283,8 +296,9 @@  discard block
 block discarded – undo
283 296
 				'boards' => array_keys($boards),
284 297
 			)
285 298
 		);
286
-		while ($row = $smcFunc['db_fetch_assoc']($request))
287
-			$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
299
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
300
+					$boards[$row['id_board']] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
301
+		}
288 302
 	}
289 303
 	if (!empty($topics))
290 304
 	{
@@ -299,8 +313,9 @@  discard block
 block discarded – undo
299 313
 				'topics' => array_keys($topics),
300 314
 			)
301 315
 		);
302
-		while ($row = $smcFunc['db_fetch_assoc']($request))
303
-			$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
316
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
317
+					$topics[$row['id_topic']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>';
318
+		}
304 319
 	}
305 320
 	if (!empty($msgs))
306 321
 	{
@@ -315,26 +330,33 @@  discard block
 block discarded – undo
315 330
 				'msgs' => array_keys($msgs),
316 331
 			)
317 332
 		);
318
-		while ($row = $smcFunc['db_fetch_assoc']($request))
319
-			$msgs[$row['id_msg']] = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>';
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>';
335
+		}
320 336
 	}
321 337
 
322 338
 	// 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)
323 339
 	foreach ($alerts as $id_alert => $alert)
324 340
 	{
325
-		if (!empty($alert['text']))
326
-			continue;
327
-		if (isset($alert['extra']['board']))
328
-			$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
329
-		if (isset($alert['extra']['topic']))
330
-			$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
331
-		if ($alert['content_type'] == 'msg')
332
-			$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
333
-		if ($alert['content_type'] == 'profile')
334
-			$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
335
-
336
-		if (!empty($memberContext[$alert['sender_id']]))
337
-			$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
341
+		if (!empty($alert['text'])) {
342
+					continue;
343
+		}
344
+		if (isset($alert['extra']['board'])) {
345
+					$alerts[$id_alert]['extra']['board_msg'] = $boards[$alert['extra']['board']];
346
+		}
347
+		if (isset($alert['extra']['topic'])) {
348
+					$alerts[$id_alert]['extra']['topic_msg'] = $topics[$alert['extra']['topic']];
349
+		}
350
+		if ($alert['content_type'] == 'msg') {
351
+					$alerts[$id_alert]['extra']['msg_msg'] = $msgs[$alert['content_id']];
352
+		}
353
+		if ($alert['content_type'] == 'profile') {
354
+					$alerts[$id_alert]['extra']['profile_msg'] = '<a href="' . $scripturl . '?action=profile;u=' . $alerts[$id_alert]['content_id'] . '">' . $alerts[$id_alert]['extra']['user_name'] . '</a>';
355
+		}
356
+
357
+		if (!empty($memberContext[$alert['sender_id']])) {
358
+					$alerts[$id_alert]['sender'] = &$memberContext[$alert['sender_id']];
359
+		}
338 360
 
339 361
 		$string = 'alert_' . $alert['content_type'] . '_' . $alert['content_action'];
340 362
 		if (isset($txt[$string]))
@@ -422,11 +444,11 @@  discard block
 block discarded – undo
422 444
 		checkSession('request');
423 445
 
424 446
 		// Call it!
425
-		if ($action == 'remove')
426
-			alert_delete($toMark, $memID);
427
-
428
-		else
429
-			alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
447
+		if ($action == 'remove') {
448
+					alert_delete($toMark, $memID);
449
+		} else {
450
+					alert_mark($memID, $toMark, $action == 'read' ? 1 : 0);
451
+		}
430 452
 
431 453
 		// Set a nice update message.
432 454
 		$_SESSION['update_message'] = true;
@@ -476,23 +498,27 @@  discard block
 block discarded – undo
476 498
 	);
477 499
 
478 500
 	// Set the page title
479
-	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title))
480
-		$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
481
-	else
482
-		$context['page_title'] = $txt['showPosts'];
501
+	if (isset($_GET['sa']) && array_key_exists($_GET['sa'], $title)) {
502
+			$context['page_title'] = $txt['show' . $title[$_GET['sa']]];
503
+	} else {
504
+			$context['page_title'] = $txt['showPosts'];
505
+	}
483 506
 
484 507
 	$context['page_title'] .= ' - ' . $user_profile[$memID]['real_name'];
485 508
 
486 509
 	// Is the load average too high to allow searching just now?
487
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts'])
488
-		fatal_lang_error('loadavg_show_posts_disabled', false);
510
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts']) {
511
+			fatal_lang_error('loadavg_show_posts_disabled', false);
512
+	}
489 513
 
490 514
 	// If we're specifically dealing with attachments use that function!
491
-	if (isset($_GET['sa']) && $_GET['sa'] == 'attach')
492
-		return showAttachments($memID);
515
+	if (isset($_GET['sa']) && $_GET['sa'] == 'attach') {
516
+			return showAttachments($memID);
517
+	}
493 518
 	// Instead, if we're dealing with unwatched topics (and the feature is enabled) use that other function.
494
-	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics')
495
-		return showUnwatched($memID);
519
+	elseif (isset($_GET['sa']) && $_GET['sa'] == 'unwatchedtopics') {
520
+			return showUnwatched($memID);
521
+	}
496 522
 
497 523
 	// Are we just viewing topics?
498 524
 	$context['is_topics'] = isset($_GET['sa']) && $_GET['sa'] == 'topics' ? true : false;
@@ -515,27 +541,30 @@  discard block
 block discarded – undo
515 541
 		$smcFunc['db_free_result']($request);
516 542
 
517 543
 		// Trying to remove a message that doesn't exist.
518
-		if (empty($info))
519
-			redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
544
+		if (empty($info)) {
545
+					redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
546
+		}
520 547
 
521 548
 		// We can be lazy, since removeMessage() will check the permissions for us.
522 549
 		require_once($sourcedir . '/RemoveTopic.php');
523 550
 		removeMessage((int) $_GET['delete']);
524 551
 
525 552
 		// Add it to the mod log.
526
-		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id']))
527
-			logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
553
+		if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) {
554
+					logAction('delete', array('topic' => $info[2], 'subject' => $info[0], 'member' => $info[1], 'board' => $info[3]));
555
+		}
528 556
 
529 557
 		// Back to... where we are now ;).
530 558
 		redirectexit('action=profile;u=' . $memID . ';area=showposts;start=' . $_GET['start']);
531 559
 	}
532 560
 
533 561
 	// Default to 10.
534
-	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
535
-		$_REQUEST['viewscount'] = '10';
562
+	if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
563
+			$_REQUEST['viewscount'] = '10';
564
+	}
536 565
 
537
-	if ($context['is_topics'])
538
-		$request = $smcFunc['db_query']('', '
566
+	if ($context['is_topics']) {
567
+			$request = $smcFunc['db_query']('', '
539 568
 			SELECT COUNT(*)
540 569
 			FROM {db_prefix}topics AS t' . ($user_info['query_see_board'] == '1=1' ? '' : '
541 570
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board AND {query_see_board})') . '
@@ -548,8 +577,8 @@  discard block
 block discarded – undo
548 577
 				'board' => $board,
549 578
 			)
550 579
 		);
551
-	else
552
-		$request = $smcFunc['db_query']('', '
580
+	} else {
581
+			$request = $smcFunc['db_query']('', '
553 582
 			SELECT COUNT(*)
554 583
 			FROM {db_prefix}messages AS m' . ($user_info['query_see_board'] == '1=1' ? '' : '
555 584
 				INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})') . '
@@ -562,6 +591,7 @@  discard block
 block discarded – undo
562 591
 				'board' => $board,
563 592
 			)
564 593
 		);
594
+	}
565 595
 	list ($msgCount) = $smcFunc['db_fetch_row']($request);
566 596
 	$smcFunc['db_free_result']($request);
567 597
 
@@ -582,10 +612,11 @@  discard block
 block discarded – undo
582 612
 
583 613
 	$range_limit = '';
584 614
 
585
-	if ($context['is_topics'])
586
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
587
-	else
588
-		$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
615
+	if ($context['is_topics']) {
616
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['topics_per_page']) ? $options['topics_per_page'] : $modSettings['defaultMaxTopics'];
617
+	} else {
618
+			$maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
619
+	}
589 620
 
590 621
 	$maxIndex = $maxPerPage;
591 622
 
@@ -611,9 +642,9 @@  discard block
 block discarded – undo
611 642
 		{
612 643
 			$margin *= 5;
613 644
 			$range_limit = $reverse ? 't.id_first_msg < ' . ($min_msg_member + $margin) : 't.id_first_msg > ' . ($max_msg_member - $margin);
645
+		} else {
646
+					$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
614 647
 		}
615
-		else
616
-			$range_limit = $reverse ? 'm.id_msg < ' . ($min_msg_member + $margin) : 'm.id_msg > ' . ($max_msg_member - $margin);
617 648
 	}
618 649
 
619 650
 	// Find this user's posts.  The left join on categories somehow makes this faster, weird as it looks.
@@ -645,8 +676,7 @@  discard block
 block discarded – undo
645 676
 					'max' => $maxIndex,
646 677
 				)
647 678
 			);
648
-		}
649
-		else
679
+		} else
650 680
 		{
651 681
 			$request = $smcFunc['db_query']('', '
652 682
 				SELECT
@@ -675,8 +705,9 @@  discard block
 block discarded – undo
675 705
 		}
676 706
 
677 707
 		// Make sure we quit this loop.
678
-		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped)
679
-			break;
708
+		if ($smcFunc['db_num_rows']($request) === $maxIndex || $looped) {
709
+					break;
710
+		}
680 711
 		$looped = true;
681 712
 		$range_limit = '';
682 713
 	}
@@ -720,19 +751,21 @@  discard block
 block discarded – undo
720 751
 			'css_class' => $row['approved'] ? 'windowbg' : 'approvebg',
721 752
 		);
722 753
 
723
-		if ($user_info['id'] == $row['id_member_started'])
724
-			$board_ids['own'][$row['id_board']][] = $counter;
754
+		if ($user_info['id'] == $row['id_member_started']) {
755
+					$board_ids['own'][$row['id_board']][] = $counter;
756
+		}
725 757
 		$board_ids['any'][$row['id_board']][] = $counter;
726 758
 	}
727 759
 	$smcFunc['db_free_result']($request);
728 760
 
729 761
 	// All posts were retrieved in reverse order, get them right again.
730
-	if ($reverse)
731
-		$context['posts'] = array_reverse($context['posts'], true);
762
+	if ($reverse) {
763
+			$context['posts'] = array_reverse($context['posts'], true);
764
+	}
732 765
 
733 766
 	// These are all the permissions that are different from board to board..
734
-	if ($context['is_topics'])
735
-		$permissions = array(
767
+	if ($context['is_topics']) {
768
+			$permissions = array(
736 769
 			'own' => array(
737 770
 				'post_reply_own' => 'can_reply',
738 771
 			),
@@ -740,8 +773,8 @@  discard block
 block discarded – undo
740 773
 				'post_reply_any' => 'can_reply',
741 774
 			)
742 775
 		);
743
-	else
744
-		$permissions = array(
776
+	} else {
777
+			$permissions = array(
745 778
 			'own' => array(
746 779
 				'post_reply_own' => 'can_reply',
747 780
 				'delete_own' => 'can_delete',
@@ -751,6 +784,7 @@  discard block
 block discarded – undo
751 784
 				'delete_any' => 'can_delete',
752 785
 			)
753 786
 		);
787
+	}
754 788
 
755 789
 	// For every permission in the own/any lists...
756 790
 	foreach ($permissions as $type => $list)
@@ -761,19 +795,22 @@  discard block
 block discarded – undo
761 795
 			$boards = boardsAllowedTo($permission);
762 796
 
763 797
 			// Hmm, they can do it on all boards, can they?
764
-			if (!empty($boards) && $boards[0] == 0)
765
-				$boards = array_keys($board_ids[$type]);
798
+			if (!empty($boards) && $boards[0] == 0) {
799
+							$boards = array_keys($board_ids[$type]);
800
+			}
766 801
 
767 802
 			// Now go through each board they can do the permission on.
768 803
 			foreach ($boards as $board_id)
769 804
 			{
770 805
 				// There aren't any posts displayed from this board.
771
-				if (!isset($board_ids[$type][$board_id]))
772
-					continue;
806
+				if (!isset($board_ids[$type][$board_id])) {
807
+									continue;
808
+				}
773 809
 
774 810
 				// Set the permission to true ;).
775
-				foreach ($board_ids[$type][$board_id] as $counter)
776
-					$context['posts'][$counter][$allowed] = true;
811
+				foreach ($board_ids[$type][$board_id] as $counter) {
812
+									$context['posts'][$counter][$allowed] = true;
813
+				}
777 814
 			}
778 815
 		}
779 816
 	}
@@ -804,8 +841,9 @@  discard block
 block discarded – undo
804 841
 	$boardsAllowed = boardsAllowedTo('view_attachments');
805 842
 
806 843
 	// Make sure we can't actually see anything...
807
-	if (empty($boardsAllowed))
808
-		$boardsAllowed = array(-1);
844
+	if (empty($boardsAllowed)) {
845
+			$boardsAllowed = array(-1);
846
+	}
809 847
 
810 848
 	require_once($sourcedir . '/Subs-List.php');
811 849
 
@@ -956,8 +994,8 @@  discard block
 block discarded – undo
956 994
 		)
957 995
 	);
958 996
 	$attachments = array();
959
-	while ($row = $smcFunc['db_fetch_assoc']($request))
960
-		$attachments[] = array(
997
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
998
+			$attachments[] = array(
961 999
 			'id' => $row['id_attach'],
962 1000
 			'filename' => $row['filename'],
963 1001
 			'downloads' => $row['downloads'],
@@ -969,6 +1007,7 @@  discard block
 block discarded – undo
969 1007
 			'board_name' => $row['name'],
970 1008
 			'approved' => $row['approved'],
971 1009
 		);
1010
+	}
972 1011
 
973 1012
 	$smcFunc['db_free_result']($request);
974 1013
 
@@ -1023,8 +1062,9 @@  discard block
 block discarded – undo
1023 1062
 	global $txt, $user_info, $scripturl, $modSettings, $context, $sourcedir;
1024 1063
 
1025 1064
 	// Only the owner can see the list (if the function is enabled of course)
1026
-	if ($user_info['id'] != $memID)
1027
-		return;
1065
+	if ($user_info['id'] != $memID) {
1066
+			return;
1067
+	}
1028 1068
 
1029 1069
 	require_once($sourcedir . '/Subs-List.php');
1030 1070
 
@@ -1170,8 +1210,9 @@  discard block
 block discarded – undo
1170 1210
 	);
1171 1211
 
1172 1212
 	$topics = array();
1173
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1174
-		$topics[] = $row['id_topic'];
1213
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1214
+			$topics[] = $row['id_topic'];
1215
+	}
1175 1216
 
1176 1217
 	$smcFunc['db_free_result']($request);
1177 1218
 
@@ -1191,8 +1232,9 @@  discard block
 block discarded – undo
1191 1232
 				'topics' => $topics,
1192 1233
 			)
1193 1234
 		);
1194
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1195
-			$topicsInfo[] = $row;
1235
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1236
+					$topicsInfo[] = $row;
1237
+		}
1196 1238
 		$smcFunc['db_free_result']($request);
1197 1239
 	}
1198 1240
 
@@ -1240,8 +1282,9 @@  discard block
 block discarded – undo
1240 1282
 	$context['page_title'] = $txt['statPanel_showStats'] . ' ' . $user_profile[$memID]['real_name'];
1241 1283
 
1242 1284
 	// Is the load average too high to allow searching just now?
1243
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats'])
1244
-		fatal_lang_error('loadavg_userstats_disabled', false);
1285
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_userstats']) && $context['load_average'] >= $modSettings['loadavg_userstats']) {
1286
+			fatal_lang_error('loadavg_userstats_disabled', false);
1287
+	}
1245 1288
 
1246 1289
 	// General user statistics.
1247 1290
 	$timeDays = floor($user_profile[$memID]['total_time_logged_in'] / 86400);
@@ -1399,11 +1442,13 @@  discard block
 block discarded – undo
1399 1442
 	}
1400 1443
 	$smcFunc['db_free_result']($result);
1401 1444
 
1402
-	if ($maxPosts > 0)
1403
-		for ($hour = 0; $hour < 24; $hour++)
1445
+	if ($maxPosts > 0) {
1446
+			for ($hour = 0;
1447
+	}
1448
+	$hour < 24; $hour++)
1404 1449
 		{
1405
-			if (!isset($context['posts_by_time'][$hour]))
1406
-				$context['posts_by_time'][$hour] = array(
1450
+			if (!isset($context['posts_by_time'][$hour])) {
1451
+							$context['posts_by_time'][$hour] = array(
1407 1452
 					'hour' => $hour,
1408 1453
 					'hour_format' => stripos($user_info['time_format'], '%p') === false ? $hour : date('g a', mktime($hour)),
1409 1454
 					'posts' => 0,
@@ -1411,7 +1456,7 @@  discard block
 block discarded – undo
1411 1456
 					'relative_percent' => 0,
1412 1457
 					'is_last' => $hour == 23,
1413 1458
 				);
1414
-			else
1459
+			} else
1415 1460
 			{
1416 1461
 				$context['posts_by_time'][$hour]['posts_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $realPosts);
1417 1462
 				$context['posts_by_time'][$hour]['relative_percent'] = round(($context['posts_by_time'][$hour]['posts'] * 100) / $maxPosts);
@@ -1444,8 +1489,9 @@  discard block
 block discarded – undo
1444 1489
 
1445 1490
 	foreach ($subActions as $sa => $action)
1446 1491
 	{
1447
-		if (!allowedTo($action[2]))
1448
-			unset($subActions[$sa]);
1492
+		if (!allowedTo($action[2])) {
1493
+					unset($subActions[$sa]);
1494
+		}
1449 1495
 	}
1450 1496
 
1451 1497
 	// Create the tabs for the template.
@@ -1463,15 +1509,18 @@  discard block
 block discarded – undo
1463 1509
 	);
1464 1510
 
1465 1511
 	// Moderation must be on to track edits.
1466
-	if (empty($modSettings['userlog_enabled']))
1467
-		unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1512
+	if (empty($modSettings['userlog_enabled'])) {
1513
+			unset($context[$context['profile_menu_name']]['tab_data']['edits'], $subActions['edits']);
1514
+	}
1468 1515
 
1469 1516
 	// Group requests must be active to show it...
1470
-	if (empty($modSettings['show_group_membership']))
1471
-		unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1517
+	if (empty($modSettings['show_group_membership'])) {
1518
+			unset($context[$context['profile_menu_name']]['tab_data']['groupreq'], $subActions['groupreq']);
1519
+	}
1472 1520
 
1473
-	if (empty($subActions))
1474
-		fatal_lang_error('no_access', false);
1521
+	if (empty($subActions)) {
1522
+			fatal_lang_error('no_access', false);
1523
+	}
1475 1524
 
1476 1525
 	$keys = array_keys($subActions);
1477 1526
 	$default = array_shift($keys);
@@ -1484,9 +1533,10 @@  discard block
 block discarded – undo
1484 1533
 	$context['sub_template'] = $subActions[$context['tracking_area']][0];
1485 1534
 	$call = call_helper($subActions[$context['tracking_area']][0], true);
1486 1535
 
1487
-	if (!empty($call))
1488
-		call_user_func($call, $memID);
1489
-}
1536
+	if (!empty($call)) {
1537
+			call_user_func($call, $memID);
1538
+	}
1539
+	}
1490 1540
 
1491 1541
 /**
1492 1542
  * Handles tracking a user's activity
@@ -1502,8 +1552,9 @@  discard block
 block discarded – undo
1502 1552
 	isAllowedTo('moderate_forum');
1503 1553
 
1504 1554
 	$context['last_ip'] = $user_profile[$memID]['member_ip'];
1505
-	if ($context['last_ip'] != $user_profile[$memID]['member_ip2'])
1506
-		$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1555
+	if ($context['last_ip'] != $user_profile[$memID]['member_ip2']) {
1556
+			$context['last_ip2'] = $user_profile[$memID]['member_ip2'];
1557
+	}
1507 1558
 	$context['member']['name'] = $user_profile[$memID]['real_name'];
1508 1559
 
1509 1560
 	// Set the options for the list component.
@@ -1669,8 +1720,9 @@  discard block
 block discarded – undo
1669 1720
 			)
1670 1721
 		);
1671 1722
 		$message_members = array();
1672
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1673
-			$message_members[] = $row['id_member'];
1723
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1724
+					$message_members[] = $row['id_member'];
1725
+		}
1674 1726
 		$smcFunc['db_free_result']($request);
1675 1727
 
1676 1728
 		// Fetch their names, cause of the GROUP BY doesn't like giving us that normally.
@@ -1685,8 +1737,9 @@  discard block
 block discarded – undo
1685 1737
 					'ip_list' => $ips,
1686 1738
 				)
1687 1739
 			);
1688
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1689
-				$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1740
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1741
+							$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1742
+			}
1690 1743
 			$smcFunc['db_free_result']($request);
1691 1744
 		}
1692 1745
 
@@ -1700,8 +1753,9 @@  discard block
 block discarded – undo
1700 1753
 				'ip_list' => $ips,
1701 1754
 			)
1702 1755
 		);
1703
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1704
-			$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1756
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1757
+					$context['members_in_range'][$row['id_member']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>';
1758
+		}
1705 1759
 		$smcFunc['db_free_result']($request);
1706 1760
 	}
1707 1761
 }
@@ -1761,8 +1815,8 @@  discard block
 block discarded – undo
1761 1815
 		))
1762 1816
 	);
1763 1817
 	$error_messages = array();
1764
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1765
-		$error_messages[] = array(
1818
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1819
+			$error_messages[] = array(
1766 1820
 			'ip' => inet_dtop($row['ip']),
1767 1821
 			'member_link' => $row['id_member'] > 0 ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>' : $row['display_name'],
1768 1822
 			'message' => strtr($row['message'], array('&lt;span class=&quot;remove&quot;&gt;' => '', '&lt;/span&gt;' => '')),
@@ -1770,6 +1824,7 @@  discard block
 block discarded – undo
1770 1824
 			'time' => timeformat($row['log_time']),
1771 1825
 			'timestamp' => forum_time(true, $row['log_time']),
1772 1826
 		);
1827
+	}
1773 1828
 	$smcFunc['db_free_result']($request);
1774 1829
 
1775 1830
 	return $error_messages;
@@ -1832,8 +1887,8 @@  discard block
 block discarded – undo
1832 1887
 		))
1833 1888
 	);
1834 1889
 	$messages = array();
1835
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1836
-		$messages[] = array(
1890
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1891
+			$messages[] = array(
1837 1892
 			'ip' => inet_dtop($row['poster_ip']),
1838 1893
 			'member_link' => empty($row['id_member']) ? $row['display_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>',
1839 1894
 			'board' => array(
@@ -1846,6 +1901,7 @@  discard block
 block discarded – undo
1846 1901
 			'time' => timeformat($row['poster_time']),
1847 1902
 			'timestamp' => forum_time(true, $row['poster_time'])
1848 1903
 		);
1904
+	}
1849 1905
 	$smcFunc['db_free_result']($request);
1850 1906
 
1851 1907
 	return $messages;
@@ -1872,19 +1928,20 @@  discard block
 block discarded – undo
1872 1928
 		$context['sub_template'] = 'trackIP';
1873 1929
 		$context['page_title'] = $txt['profile'];
1874 1930
 		$context['base_url'] = $scripturl . '?action=trackip';
1875
-	}
1876
-	else
1931
+	} else
1877 1932
 	{
1878 1933
 		$context['ip'] = $user_profile[$memID]['member_ip'];
1879 1934
 		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
1880 1935
 	}
1881 1936
 
1882 1937
 	// Searching?
1883
-	if (isset($_REQUEST['searchip']))
1884
-		$context['ip'] = trim($_REQUEST['searchip']);
1938
+	if (isset($_REQUEST['searchip'])) {
1939
+			$context['ip'] = trim($_REQUEST['searchip']);
1940
+	}
1885 1941
 
1886
-	if (isValidIP($context['ip']) === false)
1887
-		fatal_lang_error('invalid_tracking_ip', false);
1942
+	if (isValidIP($context['ip']) === false) {
1943
+			fatal_lang_error('invalid_tracking_ip', false);
1944
+	}
1888 1945
 
1889 1946
 	//mysql didn't support like search with varbinary
1890 1947
 	//$ip_var = str_replace('*', '%', $context['ip']);
@@ -1892,8 +1949,9 @@  discard block
 block discarded – undo
1892 1949
 	$ip_var = $context['ip'];
1893 1950
 	$ip_string = '= {inet:ip_address}';
1894 1951
 
1895
-	if (empty($context['tracking_area']))
1896
-		$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1952
+	if (empty($context['tracking_area'])) {
1953
+			$context['page_title'] = $txt['trackIP'] . ' - ' . $context['ip'];
1954
+	}
1897 1955
 
1898 1956
 	$request = $smcFunc['db_query']('', '
1899 1957
 		SELECT id_member, real_name AS display_name, member_ip
@@ -1904,8 +1962,9 @@  discard block
 block discarded – undo
1904 1962
 		)
1905 1963
 	);
1906 1964
 	$context['ips'] = array();
1907
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1908
-		$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
1965
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1966
+			$context['ips'][inet_dtop($row['member_ip'])][] = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['display_name'] . '</a>';
1967
+	}
1909 1968
 	$smcFunc['db_free_result']($request);
1910 1969
 
1911 1970
 	ksort($context['ips']);
@@ -2134,8 +2193,9 @@  discard block
 block discarded – undo
2134 2193
 		foreach ($context['whois_servers'] as $whois)
2135 2194
 		{
2136 2195
 			// Strip off the "decimal point" and anything following...
2137
-			if (in_array((int) $context['ip'], $whois['range']))
2138
-				$context['auto_whois_server'] = $whois;
2196
+			if (in_array((int) $context['ip'], $whois['range'])) {
2197
+							$context['auto_whois_server'] = $whois;
2198
+			}
2139 2199
 		}
2140 2200
 	}
2141 2201
 }
@@ -2152,10 +2212,11 @@  discard block
 block discarded – undo
2152 2212
 	// Gonna want this for the list.
2153 2213
 	require_once($sourcedir . '/Subs-List.php');
2154 2214
 
2155
-	if ($memID == 0)
2156
-		$context['base_url'] = $scripturl . '?action=trackip';
2157
-	else
2158
-		$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2215
+	if ($memID == 0) {
2216
+			$context['base_url'] = $scripturl . '?action=trackip';
2217
+	} else {
2218
+			$context['base_url'] = $scripturl . '?action=profile;area=tracking;sa=ip;u=' . $memID;
2219
+	}
2159 2220
 
2160 2221
 	// Start with the user messages.
2161 2222
 	$listOptions = array(
@@ -2265,12 +2326,13 @@  discard block
 block discarded – undo
2265 2326
 		)
2266 2327
 	);
2267 2328
 	$logins = array();
2268
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2269
-		$logins[] = array(
2329
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2330
+			$logins[] = array(
2270 2331
 			'time' => timeformat($row['time']),
2271 2332
 			'ip' => inet_dtop($row['ip']),
2272 2333
 			'ip2' => inet_dtop($row['ip2']),
2273 2334
 		);
2335
+	}
2274 2336
 	$smcFunc['db_free_result']($request);
2275 2337
 
2276 2338
 	return $logins;
@@ -2295,11 +2357,12 @@  discard block
 block discarded – undo
2295 2357
 		)
2296 2358
 	);
2297 2359
 	$context['custom_field_titles'] = array();
2298
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2299
-		$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2360
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2361
+			$context['custom_field_titles']['customfield_' . $row['col_name']] = array(
2300 2362
 			'title' => $row['field_name'],
2301 2363
 			'parse_bbc' => $row['bbc'],
2302 2364
 		);
2365
+	}
2303 2366
 	$smcFunc['db_free_result']($request);
2304 2367
 
2305 2368
 	// Set the options for the error lists.
@@ -2438,19 +2501,22 @@  discard block
 block discarded – undo
2438 2501
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2439 2502
 	{
2440 2503
 		$extra = smf_json_decode($row['extra'], true);
2441
-		if (!empty($extra['applicator']))
2442
-			$members[] = $extra['applicator'];
2504
+		if (!empty($extra['applicator'])) {
2505
+					$members[] = $extra['applicator'];
2506
+		}
2443 2507
 
2444 2508
 		// Work out what the name of the action is.
2445
-		if (isset($txt['trackEdit_action_' . $row['action']]))
2446
-			$action_text = $txt['trackEdit_action_' . $row['action']];
2447
-		elseif (isset($txt[$row['action']]))
2448
-			$action_text = $txt[$row['action']];
2509
+		if (isset($txt['trackEdit_action_' . $row['action']])) {
2510
+					$action_text = $txt['trackEdit_action_' . $row['action']];
2511
+		} elseif (isset($txt[$row['action']])) {
2512
+					$action_text = $txt[$row['action']];
2513
+		}
2449 2514
 		// Custom field?
2450
-		elseif (isset($context['custom_field_titles'][$row['action']]))
2451
-			$action_text = $context['custom_field_titles'][$row['action']]['title'];
2452
-		else
2453
-			$action_text = $row['action'];
2515
+		elseif (isset($context['custom_field_titles'][$row['action']])) {
2516
+					$action_text = $context['custom_field_titles'][$row['action']]['title'];
2517
+		} else {
2518
+					$action_text = $row['action'];
2519
+		}
2454 2520
 
2455 2521
 		// Parse BBC?
2456 2522
 		$parse_bbc = isset($context['custom_field_titles'][$row['action']]) && $context['custom_field_titles'][$row['action']]['parse_bbc'] ? true : false;
@@ -2482,13 +2548,15 @@  discard block
 block discarded – undo
2482 2548
 			)
2483 2549
 		);
2484 2550
 		$members = array();
2485
-		while ($row = $smcFunc['db_fetch_assoc']($request))
2486
-			$members[$row['id_member']] = $row['real_name'];
2551
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
2552
+					$members[$row['id_member']] = $row['real_name'];
2553
+		}
2487 2554
 		$smcFunc['db_free_result']($request);
2488 2555
 
2489
-		foreach ($edits as $key => $value)
2490
-			if (isset($members[$value['id_member']]))
2556
+		foreach ($edits as $key => $value) {
2557
+					if (isset($members[$value['id_member']]))
2491 2558
 				$edits[$key]['member_link'] = '<a href="' . $scripturl . '?action=profile;u=' . $value['id_member'] . '">' . $members[$value['id_member']] . '</a>';
2559
+		}
2492 2560
 	}
2493 2561
 
2494 2562
 	return $edits;
@@ -2689,10 +2757,11 @@  discard block
 block discarded – undo
2689 2757
 	$context['board'] = $board;
2690 2758
 
2691 2759
 	// Determine which groups this user is in.
2692
-	if (empty($user_profile[$memID]['additional_groups']))
2693
-		$curGroups = array();
2694
-	else
2695
-		$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2760
+	if (empty($user_profile[$memID]['additional_groups'])) {
2761
+			$curGroups = array();
2762
+	} else {
2763
+			$curGroups = explode(',', $user_profile[$memID]['additional_groups']);
2764
+	}
2696 2765
 	$curGroups[] = $user_profile[$memID]['id_group'];
2697 2766
 	$curGroups[] = $user_profile[$memID]['id_post_group'];
2698 2767
 
@@ -2712,28 +2781,30 @@  discard block
 block discarded – undo
2712 2781
 	$context['no_access_boards'] = array();
2713 2782
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2714 2783
 	{
2715
-		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod'])
2716
-			$context['no_access_boards'][] = array(
2784
+		if (count(array_intersect($curGroups, explode(',', $row['member_groups']))) === 0 && !$row['is_mod']) {
2785
+					$context['no_access_boards'][] = array(
2717 2786
 				'id' => $row['id_board'],
2718 2787
 				'name' => $row['name'],
2719 2788
 				'is_last' => false,
2720 2789
 			);
2721
-		elseif ($row['id_profile'] != 1 || $row['is_mod'])
2722
-			$context['boards'][$row['id_board']] = array(
2790
+		} elseif ($row['id_profile'] != 1 || $row['is_mod']) {
2791
+					$context['boards'][$row['id_board']] = array(
2723 2792
 				'id' => $row['id_board'],
2724 2793
 				'name' => $row['name'],
2725 2794
 				'selected' => $board == $row['id_board'],
2726 2795
 				'profile' => $row['id_profile'],
2727 2796
 				'profile_name' => $context['profiles'][$row['id_profile']]['name'],
2728 2797
 			);
2798
+		}
2729 2799
 	}
2730 2800
 	$smcFunc['db_free_result']($request);
2731 2801
 
2732 2802
 	require_once($sourcedir . '/Subs-Boards.php');
2733 2803
 	sortBoards($context['boards']);
2734 2804
 
2735
-	if (!empty($context['no_access_boards']))
2736
-		$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2805
+	if (!empty($context['no_access_boards'])) {
2806
+			$context['no_access_boards'][count($context['no_access_boards']) - 1]['is_last'] = true;
2807
+	}
2737 2808
 
2738 2809
 	$context['member']['permissions'] = array(
2739 2810
 		'general' => array(),
@@ -2742,8 +2813,9 @@  discard block
 block discarded – undo
2742 2813
 
2743 2814
 	// If you're an admin we know you can do everything, we might as well leave.
2744 2815
 	$context['member']['has_all_permissions'] = in_array(1, $curGroups);
2745
-	if ($context['member']['has_all_permissions'])
2746
-		return;
2816
+	if ($context['member']['has_all_permissions']) {
2817
+			return;
2818
+	}
2747 2819
 
2748 2820
 	$denied = array();
2749 2821
 
@@ -2762,21 +2834,24 @@  discard block
 block discarded – undo
2762 2834
 	while ($row = $smcFunc['db_fetch_assoc']($result))
2763 2835
 	{
2764 2836
 		// We don't know about this permission, it doesn't exist :P.
2765
-		if (!isset($txt['permissionname_' . $row['permission']]))
2766
-			continue;
2837
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2838
+					continue;
2839
+		}
2767 2840
 
2768
-		if (empty($row['add_deny']))
2769
-			$denied[] = $row['permission'];
2841
+		if (empty($row['add_deny'])) {
2842
+					$denied[] = $row['permission'];
2843
+		}
2770 2844
 
2771 2845
 		// Permissions that end with _own or _any consist of two parts.
2772
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2773
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2774
-		else
2775
-			$name = $txt['permissionname_' . $row['permission']];
2846
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2847
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2848
+		} else {
2849
+					$name = $txt['permissionname_' . $row['permission']];
2850
+		}
2776 2851
 
2777 2852
 		// Add this permission if it doesn't exist yet.
2778
-		if (!isset($context['member']['permissions']['general'][$row['permission']]))
2779
-			$context['member']['permissions']['general'][$row['permission']] = array(
2853
+		if (!isset($context['member']['permissions']['general'][$row['permission']])) {
2854
+					$context['member']['permissions']['general'][$row['permission']] = array(
2780 2855
 				'id' => $row['permission'],
2781 2856
 				'groups' => array(
2782 2857
 					'allowed' => array(),
@@ -2786,6 +2861,7 @@  discard block
 block discarded – undo
2786 2861
 				'is_denied' => false,
2787 2862
 				'is_global' => true,
2788 2863
 			);
2864
+		}
2789 2865
 
2790 2866
 		// Add the membergroup to either the denied or the allowed groups.
2791 2867
 		$context['member']['permissions']['general'][$row['permission']]['groups'][empty($row['add_deny']) ? 'denied' : 'allowed'][] = $row['id_group'] == 0 ? $txt['membergroups_members'] : $row['group_name'];
@@ -2819,18 +2895,20 @@  discard block
 block discarded – undo
2819 2895
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2820 2896
 	{
2821 2897
 		// We don't know about this permission, it doesn't exist :P.
2822
-		if (!isset($txt['permissionname_' . $row['permission']]))
2823
-			continue;
2898
+		if (!isset($txt['permissionname_' . $row['permission']])) {
2899
+					continue;
2900
+		}
2824 2901
 
2825 2902
 		// The name of the permission using the format 'permission name' - 'own/any topic/event/etc.'.
2826
-		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)]))
2827
-			$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2828
-		else
2829
-			$name = $txt['permissionname_' . $row['permission']];
2903
+		if (in_array(substr($row['permission'], -4), array('_own', '_any')) && isset($txt['permissionname_' . substr($row['permission'], 0, -4)])) {
2904
+					$name = $txt['permissionname_' . substr($row['permission'], 0, -4)] . ' - ' . $txt['permissionname_' . $row['permission']];
2905
+		} else {
2906
+					$name = $txt['permissionname_' . $row['permission']];
2907
+		}
2830 2908
 
2831 2909
 		// Create the structure for this permission.
2832
-		if (!isset($context['member']['permissions']['board'][$row['permission']]))
2833
-			$context['member']['permissions']['board'][$row['permission']] = array(
2910
+		if (!isset($context['member']['permissions']['board'][$row['permission']])) {
2911
+					$context['member']['permissions']['board'][$row['permission']] = array(
2834 2912
 				'id' => $row['permission'],
2835 2913
 				'groups' => array(
2836 2914
 					'allowed' => array(),
@@ -2840,6 +2918,7 @@  discard block
 block discarded – undo
2840 2918
 				'is_denied' => false,
2841 2919
 				'is_global' => empty($board),
2842 2920
 			);
2921
+		}
2843 2922
 
2844 2923
 		$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'];
2845 2924
 
@@ -2858,8 +2937,9 @@  discard block
 block discarded – undo
2858 2937
 	global $modSettings, $context, $sourcedir, $txt, $scripturl;
2859 2938
 
2860 2939
 	// Firstly, can we actually even be here?
2861
-	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum'))
2862
-		fatal_lang_error('no_access', false);
2940
+	if (!($context['user']['is_owner'] && allowedTo('view_warning_own')) && !allowedTo('view_warning_any') && !allowedTo('issue_warning') && !allowedTo('moderate_forum')) {
2941
+			fatal_lang_error('no_access', false);
2942
+	}
2863 2943
 
2864 2944
 	// Make sure things which are disabled stay disabled.
2865 2945
 	$modSettings['warning_watch'] = !empty($modSettings['warning_watch']) ? $modSettings['warning_watch'] : 110;
@@ -2946,9 +3026,10 @@  discard block
 block discarded – undo
2946 3026
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_own_muted'],
2947 3027
 	);
2948 3028
 	$context['current_level'] = 0;
2949
-	foreach ($context['level_effects'] as $limit => $dummy)
2950
-		if ($context['member']['warning'] >= $limit)
3029
+	foreach ($context['level_effects'] as $limit => $dummy) {
3030
+			if ($context['member']['warning'] >= $limit)
2951 3031
 			$context['current_level'] = $limit;
2952
-}
3032
+	}
3033
+	}
2953 3034
 
2954 3035
 ?>
2955 3036
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/ManageCalendar.php 1 patch
Braces   +37 added lines, -28 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * The main controlling function doesn't have much to do... yet.
@@ -43,8 +44,7 @@  discard block
 block discarded – undo
43 44
 			'settings' => 'ModifyCalendarSettings'
44 45
 		);
45 46
 		$default = 'holidays';
46
-	}
47
-	else
47
+	} else
48 48
 	{
49 49
 		$subActions = array(
50 50
 			'settings' => 'ModifyCalendarSettings'
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 		'help' => 'calendar',
61 61
 		'description' => $txt['calendar_settings_desc'],
62 62
 	);
63
-	if (!empty($modSettings['cal_enabled']))
64
-		$context[$context['admin_menu_name']]['tab_data']['tabs'] = array(
63
+	if (!empty($modSettings['cal_enabled'])) {
64
+			$context[$context['admin_menu_name']]['tab_data']['tabs'] = array(
65 65
 			'holidays' => array(
66 66
 				'description' => $txt['manage_holidays_desc'],
67 67
 			),
@@ -69,6 +69,7 @@  discard block
 block discarded – undo
69 69
 				'description' => $txt['calendar_settings_desc'],
70 70
 			),
71 71
 		);
72
+	}
72 73
 
73 74
 	call_integration_hook('integrate_manage_calendar', array(&$subActions));
74 75
 
@@ -88,8 +89,9 @@  discard block
 block discarded – undo
88 89
 		checkSession();
89 90
 		validateToken('admin-mc');
90 91
 
91
-		foreach ($_REQUEST['holiday'] as $id => $value)
92
-			$_REQUEST['holiday'][$id] = (int) $id;
92
+		foreach ($_REQUEST['holiday'] as $id => $value) {
93
+					$_REQUEST['holiday'][$id] = (int) $id;
94
+		}
93 95
 
94 96
 		// Now the IDs are "safe" do the delete...
95 97
 		require_once($sourcedir . '/Subs-Calendar.php');
@@ -209,8 +211,9 @@  discard block
 block discarded – undo
209 211
 	$context['sub_template'] = 'edit_holiday';
210 212
 
211 213
 	// Cast this for safety...
212
-	if (isset($_REQUEST['holiday']))
213
-		$_REQUEST['holiday'] = (int) $_REQUEST['holiday'];
214
+	if (isset($_REQUEST['holiday'])) {
215
+			$_REQUEST['holiday'] = (int) $_REQUEST['holiday'];
216
+	}
214 217
 
215 218
 	// Submitting?
216 219
 	if (isset($_POST[$context['session_var']]) && (isset($_REQUEST['delete']) || $_REQUEST['title'] != ''))
@@ -221,19 +224,19 @@  discard block
 block discarded – undo
221 224
 		$_REQUEST['title'] =  $smcFunc['substr']($_REQUEST['title'], 0, 60);
222 225
 		$_REQUEST['holiday'] = isset($_REQUEST['holiday']) ? (int) $_REQUEST['holiday'] : 0;
223 226
 
224
-		if (isset($_REQUEST['delete']))
225
-			$smcFunc['db_query']('', '
227
+		if (isset($_REQUEST['delete'])) {
228
+					$smcFunc['db_query']('', '
226 229
 				DELETE FROM {db_prefix}calendar_holidays
227 230
 				WHERE id_holiday = {int:selected_holiday}',
228 231
 				array(
229 232
 					'selected_holiday' => $_REQUEST['holiday'],
230 233
 				)
231 234
 			);
232
-		else
235
+		} else
233 236
 		{
234 237
 			$date = strftime($_REQUEST['year'] <= 1004 ? '1004-%m-%d' : '%Y-%m-%d', mktime(0, 0, 0, $_REQUEST['month'], $_REQUEST['day'], $_REQUEST['year']));
235
-			if (isset($_REQUEST['edit']))
236
-				$smcFunc['db_query']('', '
238
+			if (isset($_REQUEST['edit'])) {
239
+							$smcFunc['db_query']('', '
237 240
 					UPDATE {db_prefix}calendar_holidays
238 241
 					SET event_date = {date:holiday_date}, title = {string:holiday_title}
239 242
 					WHERE id_holiday = {int:selected_holiday}',
@@ -243,8 +246,8 @@  discard block
 block discarded – undo
243 246
 						'holiday_title' => $_REQUEST['title'],
244 247
 					)
245 248
 				);
246
-			else
247
-				$smcFunc['db_insert']('',
249
+			} else {
250
+							$smcFunc['db_insert']('',
248 251
 					'{db_prefix}calendar_holidays',
249 252
 					array(
250 253
 						'event_date' => 'date', 'title' => 'string-60',
@@ -254,6 +257,7 @@  discard block
 block discarded – undo
254 257
 					),
255 258
 					array('id_holiday')
256 259
 				);
260
+			}
257 261
 		}
258 262
 
259 263
 		updateSettings(array(
@@ -265,14 +269,15 @@  discard block
 block discarded – undo
265 269
 	}
266 270
 
267 271
 	// Default states...
268
-	if ($context['is_new'])
269
-		$context['holiday'] = array(
272
+	if ($context['is_new']) {
273
+			$context['holiday'] = array(
270 274
 			'id' => 0,
271 275
 			'day' => date('d'),
272 276
 			'month' => date('m'),
273 277
 			'year' => '0000',
274 278
 			'title' => ''
275 279
 		);
280
+	}
276 281
 	// If it's not new load the data.
277 282
 	else
278 283
 	{
@@ -285,14 +290,15 @@  discard block
 block discarded – undo
285 290
 				'selected_holiday' => $_REQUEST['holiday'],
286 291
 			)
287 292
 		);
288
-		while ($row = $smcFunc['db_fetch_assoc']($request))
289
-			$context['holiday'] = array(
293
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
294
+					$context['holiday'] = array(
290 295
 				'id' => $row['id_holiday'],
291 296
 				'day' => $row['day'],
292 297
 				'month' => $row['month'],
293 298
 				'year' => $row['year'] <= 4 ? 0 : $row['year'],
294 299
 				'title' => $row['title']
295 300
 			);
301
+		}
296 302
 		$smcFunc['db_free_result']($request);
297 303
 	}
298 304
 
@@ -319,16 +325,17 @@  discard block
 block discarded – undo
319 325
 		array(
320 326
 		)
321 327
 	);
322
-	while ($row = $smcFunc['db_fetch_assoc']($request))
323
-		$boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
328
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
329
+			$boards[$row['id_board']] = $row['cat_name'] . ' - ' . $row['board_name'];
330
+	}
324 331
 	$smcFunc['db_free_result']($request);
325 332
 
326 333
 	require_once($sourcedir . '/Subs-Boards.php');
327 334
 	sortBoards($boards);
328 335
 
329 336
 	// Look, all the calendar settings - of which there are many!
330
-	if (!empty($modSettings['cal_enabled']))
331
-		$config_vars = array(
337
+	if (!empty($modSettings['cal_enabled'])) {
338
+			$config_vars = array(
332 339
 				array('check', 'cal_enabled'),
333 340
 			'',
334 341
 				// All the permissions:
@@ -371,14 +378,16 @@  discard block
 block discarded – undo
371 378
 				array('check', 'cal_short_days'),
372 379
 				array('check', 'cal_short_months'),
373 380
 		);
374
-	else
375
-		$config_vars = array(
381
+	} else {
382
+			$config_vars = array(
376 383
 			array('check', 'cal_enabled'),
377 384
 		);
385
+	}
378 386
 
379 387
 	call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars));
380
-	if ($return_config)
381
-		return $config_vars;
388
+	if ($return_config) {
389
+			return $config_vars;
390
+	}
382 391
 
383 392
 	// Get the settings template fired up.
384 393
 	require_once($sourcedir . '/ManageServer.php');
Please login to merge, or discard this patch.
Sources/Profile-Modify.php 1 patch
Braces   +694 added lines, -518 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * @version 2.1 Beta 4
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * This defines every profile field known to man.
@@ -29,8 +30,9 @@  discard block
 block discarded – undo
29 30
 	global $sourcedir, $profile_vars;
30 31
 
31 32
 	// Don't load this twice!
32
-	if (!empty($profile_fields) && !$force_reload)
33
-		return;
33
+	if (!empty($profile_fields) && !$force_reload) {
34
+			return;
35
+	}
34 36
 
35 37
 	/* This horrific array defines all the profile fields in the whole world!
36 38
 		In general each "field" has one array - the key of which is the database column name associated with said field. Each item
@@ -103,13 +105,14 @@  discard block
 block discarded – undo
103 105
 				if (isset($_POST['bday2'], $_POST['bday3']) && $value > 0 && $_POST['bday2'] > 0)
104 106
 				{
105 107
 					// Set to blank?
106
-					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1)
107
-						$value = '1004-01-01';
108
-					else
109
-						$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
108
+					if ((int) $_POST['bday3'] == 1 && (int) $_POST['bday2'] == 1 && (int) $value == 1) {
109
+											$value = '1004-01-01';
110
+					} else {
111
+											$value = checkdate($value, $_POST['bday2'], $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3']) ? sprintf('%04d-%02d-%02d', $_POST['bday3'] < 1004 ? 1004 : $_POST['bday3'], $_POST['bday1'], $_POST['bday2']) : '1004-01-01';
112
+					}
113
+				} else {
114
+									$value = '1004-01-01';
110 115
 				}
111
-				else
112
-					$value = '1004-01-01';
113 116
 
114 117
 				$profile_vars['birthdate'] = $value;
115 118
 				$cur_profile['birthdate'] = $value;
@@ -127,8 +130,7 @@  discard block
 block discarded – undo
127 130
 				{
128 131
 					$value = checkdate($dates[2], $dates[3], $dates[1] < 4 ? 4 : $dates[1]) ? sprintf('%04d-%02d-%02d', $dates[1] < 4 ? 4 : $dates[1], $dates[2], $dates[3]) : '1004-01-01';
129 132
 					return true;
130
-				}
131
-				else
133
+				} else
132 134
 				{
133 135
 					$value = empty($cur_profile['birthdate']) ? '1004-01-01' : $cur_profile['birthdate'];
134 136
 					return false;
@@ -150,10 +152,11 @@  discard block
 block discarded – undo
150 152
 					return $txt['invalid_registration'] . ' ' . strftime('%d %b %Y ' . (strpos($user_info['time_format'], '%H') !== false ? '%I:%M:%S %p' : '%H:%M:%S'), forum_time(false));
151 153
 				}
152 154
 				// As long as it doesn't equal "N/A"...
153
-				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600)))
154
-					$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
155
-				else
156
-					$value = $cur_profile['date_registered'];
155
+				elseif ($value != $txt['not_applicable'] && $value != strtotime(strftime('%Y-%m-%d', $cur_profile['date_registered'] + ($user_info['time_offset'] + $modSettings['time_offset']) * 3600))) {
156
+									$value = $value - ($user_info['time_offset'] + $modSettings['time_offset']) * 3600;
157
+				} else {
158
+									$value = $cur_profile['date_registered'];
159
+				}
157 160
 
158 161
 				return true;
159 162
 			},
@@ -177,8 +180,9 @@  discard block
 block discarded – undo
177 180
 			{
178 181
 				global $context, $old_profile, $profile_vars, $sourcedir, $modSettings;
179 182
 
180
-				if (strtolower($value) == strtolower($old_profile['email_address']))
181
-					return false;
183
+				if (strtolower($value) == strtolower($old_profile['email_address'])) {
184
+									return false;
185
+				}
182 186
 
183 187
 				$isValid = profileValidateEmail($value, $context['id_member']);
184 188
 
@@ -254,11 +258,11 @@  discard block
 block discarded – undo
254 258
 
255 259
 				if (isset($context['profile_languages'][$value]))
256 260
 				{
257
-					if ($context['user']['is_owner'] && empty($context['password_auth_failed']))
258
-						$_SESSION['language'] = $value;
261
+					if ($context['user']['is_owner'] && empty($context['password_auth_failed'])) {
262
+											$_SESSION['language'] = $value;
263
+					}
259 264
 					return true;
260
-				}
261
-				else
265
+				} else
262 266
 				{
263 267
 					$value = $cur_profile['lngfile'];
264 268
 					return false;
@@ -282,13 +286,14 @@  discard block
 block discarded – undo
282 286
 
283 287
 					// Maybe they are trying to change their password as well?
284 288
 					$resetPassword = true;
285
-					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null)
286
-						$resetPassword = false;
289
+					if (isset($_POST['passwrd1']) && $_POST['passwrd1'] != '' && isset($_POST['passwrd2']) && $_POST['passwrd1'] == $_POST['passwrd2'] && validatePassword($_POST['passwrd1'], $value, array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email'])) == null) {
290
+											$resetPassword = false;
291
+					}
287 292
 
288 293
 					// Do the reset... this will send them an email too.
289
-					if ($resetPassword)
290
-						resetPassword($context['id_member'], $value);
291
-					elseif ($value !== null)
294
+					if ($resetPassword) {
295
+											resetPassword($context['id_member'], $value);
296
+					} elseif ($value !== null)
292 297
 					{
293 298
 						validateUsername($context['id_member'], trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value)));
294 299
 						updateMemberData($context['id_member'], array('member_name' => $value));
@@ -312,20 +317,23 @@  discard block
 block discarded – undo
312 317
 			'input_validate' => function(&$value) use ($sourcedir, $user_info, $smcFunc, $cur_profile)
313 318
 			{
314 319
 				// If we didn't try it then ignore it!
315
-				if ($value == '')
316
-					return false;
320
+				if ($value == '') {
321
+									return false;
322
+				}
317 323
 
318 324
 				// Do the two entries for the password even match?
319
-				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2'])
320
-					return 'bad_new_password';
325
+				if (!isset($_POST['passwrd2']) || $value != $_POST['passwrd2']) {
326
+									return 'bad_new_password';
327
+				}
321 328
 
322 329
 				// Let's get the validation function into play...
323 330
 				require_once($sourcedir . '/Subs-Auth.php');
324 331
 				$passwordErrors = validatePassword($value, $cur_profile['member_name'], array($cur_profile['real_name'], $user_info['username'], $user_info['name'], $user_info['email']));
325 332
 
326 333
 				// Were there errors?
327
-				if ($passwordErrors != null)
328
-					return 'password_' . $passwordErrors;
334
+				if ($passwordErrors != null) {
335
+									return 'password_' . $passwordErrors;
336
+				}
329 337
 
330 338
 				// Set up the new password variable... ready for storage.
331 339
 				$value = hash_password($cur_profile['member_name'], un_htmlspecialchars($value));
@@ -350,8 +358,9 @@  discard block
 block discarded – undo
350 358
 			'permission' => 'profile_blurb',
351 359
 			'input_validate' => function(&$value) use ($smcFunc)
352 360
 			{
353
-				if ($smcFunc['strlen']($value) > 50)
354
-					return 'personal_text_too_long';
361
+				if ($smcFunc['strlen']($value) > 50) {
362
+									return 'personal_text_too_long';
363
+				}
355 364
 
356 365
 				return true;
357 366
 			},
@@ -386,10 +395,11 @@  discard block
 block discarded – undo
386 395
 			'permission' => 'moderate_forum',
387 396
 			'input_validate' => function(&$value)
388 397
 			{
389
-				if (!is_numeric($value))
390
-					return 'digits_only';
391
-				else
392
-					$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
398
+				if (!is_numeric($value)) {
399
+									return 'digits_only';
400
+				} else {
401
+									$value = $value != '' ? strtr($value, array(',' => '', '.' => '', ' ' => '')) : 0;
402
+				}
393 403
 				return true;
394 404
 			},
395 405
 		),
@@ -405,15 +415,16 @@  discard block
 block discarded – undo
405 415
 			{
406 416
 				$value = trim(preg_replace('~[\t\n\r \x0B\0' . ($context['utf8'] ? '\x{A0}\x{AD}\x{2000}-\x{200F}\x{201F}\x{202F}\x{3000}\x{FEFF}' : '\x00-\x08\x0B\x0C\x0E-\x19\xA0') . ']+~' . ($context['utf8'] ? 'u' : ''), ' ', $value));
407 417
 
408
-				if (trim($value) == '')
409
-					return 'no_name';
410
-				elseif ($smcFunc['strlen']($value) > 60)
411
-					return 'name_too_long';
412
-				elseif ($cur_profile['real_name'] != $value)
418
+				if (trim($value) == '') {
419
+									return 'no_name';
420
+				} elseif ($smcFunc['strlen']($value) > 60) {
421
+									return 'name_too_long';
422
+				} elseif ($cur_profile['real_name'] != $value)
413 423
 				{
414 424
 					require_once($sourcedir . '/Subs-Members.php');
415
-					if (isReservedName($value, $context['id_member']))
416
-						return 'name_taken';
425
+					if (isReservedName($value, $context['id_member'])) {
426
+											return 'name_taken';
427
+					}
417 428
 				}
418 429
 				return true;
419 430
 			},
@@ -471,8 +482,9 @@  discard block
 block discarded – undo
471 482
 						'selected' => $set == $context['member']['smiley_set']['id']
472 483
 					);
473 484
 
474
-					if ($context['smiley_sets'][$i]['selected'])
475
-						$context['member']['smiley_set']['name'] = $set_names[$i];
485
+					if ($context['smiley_sets'][$i]['selected']) {
486
+											$context['member']['smiley_set']['name'] = $set_names[$i];
487
+					}
476 488
 				}
477 489
 				return true;
478 490
 			},
@@ -481,8 +493,9 @@  discard block
 block discarded – undo
481 493
 				global $modSettings;
482 494
 
483 495
 				$smiley_sets = explode(',', $modSettings['smiley_sets_known']);
484
-				if (!in_array($value, $smiley_sets) && $value != 'none')
485
-					$value = '';
496
+				if (!in_array($value, $smiley_sets) && $value != 'none') {
497
+									$value = '';
498
+				}
486 499
 				return true;
487 500
 			},
488 501
 		),
@@ -497,8 +510,9 @@  discard block
 block discarded – undo
497 510
 				loadLanguage('Settings');
498 511
 
499 512
 				$context['allow_no_censored'] = false;
500
-				if ($user_info['is_admin'] || $context['user']['is_owner'])
501
-					$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
513
+				if ($user_info['is_admin'] || $context['user']['is_owner']) {
514
+									$context['allow_no_censored'] = !empty($modSettings['allow_no_censored']);
515
+				}
502 516
 
503 517
 				return true;
504 518
 			},
@@ -545,8 +559,9 @@  discard block
 block discarded – undo
545 559
 			'input_validate' => function($value)
546 560
 			{
547 561
 				$tz = smf_list_timezones();
548
-				if (!isset($tz[$value]))
549
-					return 'bad_timezone';
562
+				if (!isset($tz[$value])) {
563
+									return 'bad_timezone';
564
+				}
550 565
 
551 566
 				return true;
552 567
 			},
@@ -561,8 +576,9 @@  discard block
 block discarded – undo
561 576
 			'enabled' => !empty($modSettings['titlesEnable']),
562 577
 			'input_validate' => function(&$value) use ($smcFunc)
563 578
 			{
564
-				if ($smcFunc['strlen']($value) > 50)
565
-					return 'user_title_too_long';
579
+				if ($smcFunc['strlen']($value) > 50) {
580
+									return 'user_title_too_long';
581
+				}
566 582
 
567 583
 				return true;
568 584
 			},
@@ -584,10 +600,12 @@  discard block
 block discarded – undo
584 600
 			// Fix the URL...
585 601
 			'input_validate' => function(&$value)
586 602
 			{
587
-				if (strlen(trim($value)) > 0 && strpos($value, '://') === false)
588
-					$value = 'http://' . $value;
589
-				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://'))
590
-					$value = '';
603
+				if (strlen(trim($value)) > 0 && strpos($value, '://') === false) {
604
+									$value = 'http://' . $value;
605
+				}
606
+				if (strlen($value) < 8 || (substr($value, 0, 7) !== 'http://' && substr($value, 0, 8) !== 'https://')) {
607
+									$value = '';
608
+				}
591 609
 				return true;
592 610
 			},
593 611
 			'link_with' => 'website',
@@ -601,16 +619,19 @@  discard block
 block discarded – undo
601 619
 	foreach ($profile_fields as $key => $field)
602 620
 	{
603 621
 		// Do we have permission to do this?
604
-		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission']))
605
-			unset($profile_fields[$key]);
622
+		if (isset($field['permission']) && !allowedTo(($context['user']['is_owner'] ? array($field['permission'] . '_own', $field['permission'] . '_any') : $field['permission'] . '_any')) && !allowedTo($field['permission'])) {
623
+					unset($profile_fields[$key]);
624
+		}
606 625
 
607 626
 		// Is it enabled?
608
-		if (isset($field['enabled']) && !$field['enabled'])
609
-			unset($profile_fields[$key]);
627
+		if (isset($field['enabled']) && !$field['enabled']) {
628
+					unset($profile_fields[$key]);
629
+		}
610 630
 
611 631
 		// Is it specifically disabled?
612
-		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields)))
613
-			unset($profile_fields[$key]);
632
+		if (in_array($key, $disabled_fields) || (isset($field['link_with']) && in_array($field['link_with'], $disabled_fields))) {
633
+					unset($profile_fields[$key]);
634
+		}
614 635
 	}
615 636
 }
616 637
 
@@ -635,9 +656,10 @@  discard block
 block discarded – undo
635 656
 	loadProfileFields(true);
636 657
 
637 658
 	// First check for any linked sets.
638
-	foreach ($profile_fields as $key => $field)
639
-		if (isset($field['link_with']) && in_array($field['link_with'], $fields))
659
+	foreach ($profile_fields as $key => $field) {
660
+			if (isset($field['link_with']) && in_array($field['link_with'], $fields))
640 661
 			$fields[] = $key;
662
+	}
641 663
 
642 664
 	$i = 0;
643 665
 	$last_type = '';
@@ -649,38 +671,46 @@  discard block
 block discarded – undo
649 671
 			$cur_field = &$profile_fields[$field];
650 672
 
651 673
 			// Does it have a preload and does that preload succeed?
652
-			if (isset($cur_field['preload']) && !$cur_field['preload']())
653
-				continue;
674
+			if (isset($cur_field['preload']) && !$cur_field['preload']()) {
675
+							continue;
676
+			}
654 677
 
655 678
 			// If this is anything but complex we need to do more cleaning!
656 679
 			if ($cur_field['type'] != 'callback' && $cur_field['type'] != 'hidden')
657 680
 			{
658
-				if (!isset($cur_field['label']))
659
-					$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
681
+				if (!isset($cur_field['label'])) {
682
+									$cur_field['label'] = isset($txt[$field]) ? $txt[$field] : $field;
683
+				}
660 684
 
661 685
 				// Everything has a value!
662
-				if (!isset($cur_field['value']))
663
-					$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
686
+				if (!isset($cur_field['value'])) {
687
+									$cur_field['value'] = isset($cur_profile[$field]) ? $cur_profile[$field] : '';
688
+				}
664 689
 
665 690
 				// Any input attributes?
666 691
 				$cur_field['input_attr'] = !empty($cur_field['input_attr']) ? implode(',', $cur_field['input_attr']) : '';
667 692
 			}
668 693
 
669 694
 			// Was there an error with this field on posting?
670
-			if (isset($context['profile_errors'][$field]))
671
-				$cur_field['is_error'] = true;
695
+			if (isset($context['profile_errors'][$field])) {
696
+							$cur_field['is_error'] = true;
697
+			}
672 698
 
673 699
 			// Any javascript stuff?
674
-			if (!empty($cur_field['js_submit']))
675
-				$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
676
-			if (!empty($cur_field['js']))
677
-				$context['profile_javascript'] .= $cur_field['js'];
700
+			if (!empty($cur_field['js_submit'])) {
701
+							$context['profile_onsubmit_javascript'] .= $cur_field['js_submit'];
702
+			}
703
+			if (!empty($cur_field['js'])) {
704
+							$context['profile_javascript'] .= $cur_field['js'];
705
+			}
678 706
 
679 707
 			// Any template stuff?
680
-			if (!empty($cur_field['prehtml']))
681
-				$context['profile_prehtml'] .= $cur_field['prehtml'];
682
-			if (!empty($cur_field['posthtml']))
683
-				$context['profile_posthtml'] .= $cur_field['posthtml'];
708
+			if (!empty($cur_field['prehtml'])) {
709
+							$context['profile_prehtml'] .= $cur_field['prehtml'];
710
+			}
711
+			if (!empty($cur_field['posthtml'])) {
712
+							$context['profile_posthtml'] .= $cur_field['posthtml'];
713
+			}
684 714
 
685 715
 			// Finally put it into context?
686 716
 			if ($cur_field['type'] != 'hidden')
@@ -713,12 +743,14 @@  discard block
 block discarded – undo
713 743
 	}, false);' : ''), true);
714 744
 
715 745
 	// Any onsubmit javascript?
716
-	if (!empty($context['profile_onsubmit_javascript']))
717
-		addInlineJavaScript($context['profile_onsubmit_javascript'], true);
746
+	if (!empty($context['profile_onsubmit_javascript'])) {
747
+			addInlineJavaScript($context['profile_onsubmit_javascript'], true);
748
+	}
718 749
 
719 750
 	// Any totally custom stuff?
720
-	if (!empty($context['profile_javascript']))
721
-		addInlineJavaScript($context['profile_javascript'], true);
751
+	if (!empty($context['profile_javascript'])) {
752
+			addInlineJavaScript($context['profile_javascript'], true);
753
+	}
722 754
 
723 755
 	// Free up some memory.
724 756
 	unset($profile_fields);
@@ -739,8 +771,9 @@  discard block
 block discarded – undo
739 771
 
740 772
 	// This allows variables to call activities when they save - by default just to reload their settings
741 773
 	$context['profile_execute_on_save'] = array();
742
-	if ($context['user']['is_owner'])
743
-		$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
774
+	if ($context['user']['is_owner']) {
775
+			$context['profile_execute_on_save']['reload_user'] = 'profileReloadUser';
776
+	}
744 777
 
745 778
 	// Assume we log nothing.
746 779
 	$context['log_changes'] = array();
@@ -748,8 +781,9 @@  discard block
 block discarded – undo
748 781
 	// Cycle through the profile fields working out what to do!
749 782
 	foreach ($profile_fields as $key => $field)
750 783
 	{
751
-		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature'))
752
-			continue;
784
+		if (!isset($_POST[$key]) || !empty($field['is_dummy']) || (isset($_POST['preview_signature']) && $key == 'signature')) {
785
+					continue;
786
+		}
753 787
 
754 788
 		// What gets updated?
755 789
 		$db_key = isset($field['save_key']) ? $field['save_key'] : $key;
@@ -777,12 +811,13 @@  discard block
 block discarded – undo
777 811
 		$field['cast_type'] = empty($field['cast_type']) ? $field['type'] : $field['cast_type'];
778 812
 
779 813
 		// Finally, clean up certain types.
780
-		if ($field['cast_type'] == 'int')
781
-			$_POST[$key] = (int) $_POST[$key];
782
-		elseif ($field['cast_type'] == 'float')
783
-			$_POST[$key] = (float) $_POST[$key];
784
-		elseif ($field['cast_type'] == 'check')
785
-			$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
814
+		if ($field['cast_type'] == 'int') {
815
+					$_POST[$key] = (int) $_POST[$key];
816
+		} elseif ($field['cast_type'] == 'float') {
817
+					$_POST[$key] = (float) $_POST[$key];
818
+		} elseif ($field['cast_type'] == 'check') {
819
+					$_POST[$key] = !empty($_POST[$key]) ? 1 : 0;
820
+		}
786 821
 
787 822
 		// If we got here we're doing OK.
788 823
 		if ($field['type'] != 'hidden' && (!isset($old_profile[$key]) || $_POST[$key] != $old_profile[$key]))
@@ -793,11 +828,12 @@  discard block
 block discarded – undo
793 828
 			$cur_profile[$key] = $_POST[$key];
794 829
 
795 830
 			// Are we logging it?
796
-			if (!empty($field['log_change']) && isset($old_profile[$key]))
797
-				$context['log_changes'][$key] = array(
831
+			if (!empty($field['log_change']) && isset($old_profile[$key])) {
832
+							$context['log_changes'][$key] = array(
798 833
 					'previous' => $old_profile[$key],
799 834
 					'new' => $_POST[$key],
800 835
 				);
836
+			}
801 837
 		}
802 838
 
803 839
 		// Logging group changes are a bit different...
@@ -830,10 +866,11 @@  discard block
 block discarded – undo
830 866
 				{
831 867
 					foreach ($groups as $id => $group)
832 868
 					{
833
-						if (isset($context['member_groups'][$group]))
834
-							$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
835
-						else
836
-							unset($additional_groups[$type][$id]);
869
+						if (isset($context['member_groups'][$group])) {
870
+													$additional_groups[$type][$id] = $context['member_groups'][$group]['name'];
871
+						} else {
872
+													unset($additional_groups[$type][$id]);
873
+						}
837 874
 					}
838 875
 					$additional_groups[$type] = implode(', ', $additional_groups[$type]);
839 876
 				}
@@ -844,10 +881,11 @@  discard block
 block discarded – undo
844 881
 	}
845 882
 
846 883
 	// @todo Temporary
847
-	if ($context['user']['is_owner'])
848
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
849
-	else
850
-		$changeOther = allowedTo('profile_extra_any');
884
+	if ($context['user']['is_owner']) {
885
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own'));
886
+	} else {
887
+			$changeOther = allowedTo('profile_extra_any');
888
+	}
851 889
 	if ($changeOther && empty($post_errors))
852 890
 	{
853 891
 		makeThemeChanges($context['id_member'], isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
@@ -855,8 +893,9 @@  discard block
 block discarded – undo
855 893
 		{
856 894
 			$custom_fields_errors = makeCustomFieldChanges($context['id_member'], $_REQUEST['sa'], false, true);
857 895
 
858
-			if (!empty($custom_fields_errors))
859
-				$post_errors = array_merge($post_errors, $custom_fields_errors);
896
+			if (!empty($custom_fields_errors)) {
897
+							$post_errors = array_merge($post_errors, $custom_fields_errors);
898
+			}
860 899
 		}
861 900
 	}
862 901
 
@@ -882,9 +921,9 @@  discard block
 block discarded – undo
882 921
 	if ($context['user']['is_owner'])
883 922
 	{
884 923
 		$changeOther = allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_website_any', 'profile_website_own', 'profile_signature_any', 'profile_signature_own'));
924
+	} else {
925
+			$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
885 926
 	}
886
-	else
887
-		$changeOther = allowedTo(array('profile_extra_any', 'profile_website_any', 'profile_signature_any'));
888 927
 
889 928
 	// Arrays of all the changes - makes things easier.
890 929
 	$profile_bools = array();
@@ -895,22 +934,25 @@  discard block
 block discarded – undo
895 934
 		'ignore_boards',
896 935
 	);
897 936
 
898
-	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd']))
899
-		$_POST['ignore_brd'] = array();
937
+	if (isset($_POST['sa']) && $_POST['sa'] == 'ignoreboards' && empty($_POST['ignore_brd'])) {
938
+			$_POST['ignore_brd'] = array();
939
+	}
900 940
 
901 941
 	unset($_POST['ignore_boards']); // Whatever it is set to is a dirty filthy thing.  Kinda like our minds.
902 942
 	if (isset($_POST['ignore_brd']))
903 943
 	{
904
-		if (!is_array($_POST['ignore_brd']))
905
-			$_POST['ignore_brd'] = array($_POST['ignore_brd']);
944
+		if (!is_array($_POST['ignore_brd'])) {
945
+					$_POST['ignore_brd'] = array($_POST['ignore_brd']);
946
+		}
906 947
 
907 948
 		foreach ($_POST['ignore_brd'] as $k => $d)
908 949
 		{
909 950
 			$d = (int) $d;
910
-			if ($d != 0)
911
-				$_POST['ignore_brd'][$k] = $d;
912
-			else
913
-				unset($_POST['ignore_brd'][$k]);
951
+			if ($d != 0) {
952
+							$_POST['ignore_brd'][$k] = $d;
953
+			} else {
954
+							unset($_POST['ignore_brd'][$k]);
955
+			}
914 956
 		}
915 957
 		$_POST['ignore_boards'] = implode(',', $_POST['ignore_brd']);
916 958
 		unset($_POST['ignore_brd']);
@@ -923,21 +965,26 @@  discard block
 block discarded – undo
923 965
 		makeThemeChanges($memID, isset($_POST['id_theme']) ? (int) $_POST['id_theme'] : $old_profile['id_theme']);
924 966
 		//makeAvatarChanges($memID, $post_errors);
925 967
 
926
-		if (!empty($_REQUEST['sa']))
927
-			makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
968
+		if (!empty($_REQUEST['sa'])) {
969
+					makeCustomFieldChanges($memID, $_REQUEST['sa'], false);
970
+		}
928 971
 
929
-		foreach ($profile_bools as $var)
930
-			if (isset($_POST[$var]))
972
+		foreach ($profile_bools as $var) {
973
+					if (isset($_POST[$var]))
931 974
 				$profile_vars[$var] = empty($_POST[$var]) ? '0' : '1';
932
-		foreach ($profile_ints as $var)
933
-			if (isset($_POST[$var]))
975
+		}
976
+		foreach ($profile_ints as $var) {
977
+					if (isset($_POST[$var]))
934 978
 				$profile_vars[$var] = $_POST[$var] != '' ? (int) $_POST[$var] : '';
935
-		foreach ($profile_floats as $var)
936
-			if (isset($_POST[$var]))
979
+		}
980
+		foreach ($profile_floats as $var) {
981
+					if (isset($_POST[$var]))
937 982
 				$profile_vars[$var] = (float) $_POST[$var];
938
-		foreach ($profile_strings as $var)
939
-			if (isset($_POST[$var]))
983
+		}
984
+		foreach ($profile_strings as $var) {
985
+					if (isset($_POST[$var]))
940 986
 				$profile_vars[$var] = $_POST[$var];
987
+		}
941 988
 	}
942 989
 }
943 990
 
@@ -971,8 +1018,9 @@  discard block
 block discarded – undo
971 1018
 	);
972 1019
 
973 1020
 	// Can't change reserved vars.
974
-	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0))
975
-		fatal_lang_error('no_access', false);
1021
+	if ((isset($_POST['options']) && count(array_intersect(array_keys($_POST['options']), $reservedVars)) != 0) || (isset($_POST['default_options']) && count(array_intersect(array_keys($_POST['default_options']), $reservedVars)) != 0)) {
1022
+			fatal_lang_error('no_access', false);
1023
+	}
976 1024
 
977 1025
 	// Don't allow any overriding of custom fields with default or non-default options.
978 1026
 	$request = $smcFunc['db_query']('', '
@@ -984,8 +1032,9 @@  discard block
 block discarded – undo
984 1032
 		)
985 1033
 	);
986 1034
 	$custom_fields = array();
987
-	while ($row = $smcFunc['db_fetch_assoc']($request))
988
-		$custom_fields[] = $row['col_name'];
1035
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1036
+			$custom_fields[] = $row['col_name'];
1037
+	}
989 1038
 	$smcFunc['db_free_result']($request);
990 1039
 
991 1040
 	// These are the theme changes...
@@ -994,33 +1043,39 @@  discard block
 block discarded – undo
994 1043
 	{
995 1044
 		foreach ($_POST['options'] as $opt => $val)
996 1045
 		{
997
-			if (in_array($opt, $custom_fields))
998
-				continue;
1046
+			if (in_array($opt, $custom_fields)) {
1047
+							continue;
1048
+			}
999 1049
 
1000 1050
 			// These need to be controlled.
1001
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1002
-				$val = max(0, min($val, 50));
1051
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1052
+							$val = max(0, min($val, 50));
1053
+			}
1003 1054
 			// We don't set this per theme anymore.
1004
-			elseif ($opt == 'allow_no_censored')
1005
-				continue;
1055
+			elseif ($opt == 'allow_no_censored') {
1056
+							continue;
1057
+			}
1006 1058
 
1007 1059
 			$themeSetArray[] = array($memID, $id_theme, $opt, is_array($val) ? implode(',', $val) : $val);
1008 1060
 		}
1009 1061
 	}
1010 1062
 
1011 1063
 	$erase_options = array();
1012
-	if (isset($_POST['default_options']) && is_array($_POST['default_options']))
1013
-		foreach ($_POST['default_options'] as $opt => $val)
1064
+	if (isset($_POST['default_options']) && is_array($_POST['default_options'])) {
1065
+			foreach ($_POST['default_options'] as $opt => $val)
1014 1066
 		{
1015 1067
 			if (in_array($opt, $custom_fields))
1016 1068
 				continue;
1069
+	}
1017 1070
 
1018 1071
 			// These need to be controlled.
1019
-			if ($opt == 'topics_per_page' || $opt == 'messages_per_page')
1020
-				$val = max(0, min($val, 50));
1072
+			if ($opt == 'topics_per_page' || $opt == 'messages_per_page') {
1073
+							$val = max(0, min($val, 50));
1074
+			}
1021 1075
 			// Only let admins and owners change the censor.
1022
-			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner'])
1023
-					continue;
1076
+			elseif ($opt == 'allow_no_censored' && !$user_info['is_admin'] && !$context['user']['is_owner']) {
1077
+								continue;
1078
+			}
1024 1079
 
1025 1080
 			$themeSetArray[] = array($memID, 1, $opt, is_array($val) ? implode(',', $val) : $val);
1026 1081
 			$erase_options[] = $opt;
@@ -1056,8 +1111,9 @@  discard block
 block discarded – undo
1056 1111
 
1057 1112
 		// Admins can choose any theme, even if it's not enabled...
1058 1113
 		$themes = allowedTo('admin_forum') ? explode(',', $modSettings['knownThemes']) : explode(',', $modSettings['enableThemes']);
1059
-		foreach ($themes as $t)
1060
-			cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1114
+		foreach ($themes as $t) {
1115
+					cache_put_data('theme_settings-' . $t . ':' . $memID, null, 60);
1116
+		}
1061 1117
 	}
1062 1118
 }
1063 1119
 
@@ -1076,8 +1132,9 @@  discard block
 block discarded – undo
1076 1132
 	if (isset($_POST['edit_notify_boards']) && !empty($_POST['notify_boards']))
1077 1133
 	{
1078 1134
 		// Make sure only integers are deleted.
1079
-		foreach ($_POST['notify_boards'] as $index => $id)
1080
-			$_POST['notify_boards'][$index] = (int) $id;
1135
+		foreach ($_POST['notify_boards'] as $index => $id) {
1136
+					$_POST['notify_boards'][$index] = (int) $id;
1137
+		}
1081 1138
 
1082 1139
 		// id_board = 0 is reserved for topic notifications.
1083 1140
 		$_POST['notify_boards'] = array_diff($_POST['notify_boards'], array(0));
@@ -1096,8 +1153,9 @@  discard block
 block discarded – undo
1096 1153
 	// We are editing topic notifications......
1097 1154
 	elseif (isset($_POST['edit_notify_topics']) && !empty($_POST['notify_topics']))
1098 1155
 	{
1099
-		foreach ($_POST['notify_topics'] as $index => $id)
1100
-			$_POST['notify_topics'][$index] = (int) $id;
1156
+		foreach ($_POST['notify_topics'] as $index => $id) {
1157
+					$_POST['notify_topics'][$index] = (int) $id;
1158
+		}
1101 1159
 
1102 1160
 		// Make sure there are no zeros left.
1103 1161
 		$_POST['notify_topics'] = array_diff($_POST['notify_topics'], array(0));
@@ -1111,16 +1169,18 @@  discard block
 block discarded – undo
1111 1169
 				'selected_member' => $memID,
1112 1170
 			)
1113 1171
 		);
1114
-		foreach ($_POST['notify_topics'] as $topic)
1115
-			setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1172
+		foreach ($_POST['notify_topics'] as $topic) {
1173
+					setNotifyPrefs($memID, array('topic_notify_' . $topic => 0));
1174
+		}
1116 1175
 	}
1117 1176
 
1118 1177
 	// We are removing topic preferences
1119 1178
 	elseif (isset($_POST['remove_notify_topics']) && !empty($_POST['notify_topics']))
1120 1179
 	{
1121 1180
 		$prefs = array();
1122
-		foreach ($_POST['notify_topics'] as $topic)
1123
-			$prefs[] = 'topic_notify_' . $topic;
1181
+		foreach ($_POST['notify_topics'] as $topic) {
1182
+					$prefs[] = 'topic_notify_' . $topic;
1183
+		}
1124 1184
 		deleteNotifyPrefs($memID, $prefs);
1125 1185
 	}
1126 1186
 
@@ -1128,8 +1188,9 @@  discard block
 block discarded – undo
1128 1188
 	elseif (isset($_POST['remove_notify_board']) && !empty($_POST['notify_boards']))
1129 1189
 	{
1130 1190
 		$prefs = array();
1131
-		foreach ($_POST['notify_boards'] as $board)
1132
-			$prefs[] = 'board_notify_' . $board;
1191
+		foreach ($_POST['notify_boards'] as $board) {
1192
+					$prefs[] = 'board_notify_' . $board;
1193
+		}
1133 1194
 		deleteNotifyPrefs($memID, $prefs);
1134 1195
 	}
1135 1196
 }
@@ -1150,8 +1211,9 @@  discard block
 block discarded – undo
1150 1211
 
1151 1212
 	$errors = array();
1152 1213
 
1153
-	if ($sanitize && isset($_POST['customfield']))
1154
-		$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1214
+	if ($sanitize && isset($_POST['customfield'])) {
1215
+			$_POST['customfield'] = htmlspecialchars__recursive($_POST['customfield']);
1216
+	}
1155 1217
 
1156 1218
 	$where = $area == 'register' ? 'show_reg != 0' : 'show_profile = {string:area}';
1157 1219
 
@@ -1176,48 +1238,49 @@  discard block
 block discarded – undo
1176 1238
 			- The data is not invisible to users but editable by the owner (or if it is the user is not the owner)
1177 1239
 			- The area isn't registration, and if it is that the field is not supposed to be shown there.
1178 1240
 		*/
1179
-		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0))
1180
-			continue;
1241
+		if ($row['private'] != 0 && !allowedTo('admin_forum') && ($memID != $user_info['id'] || $row['private'] != 2) && ($area != 'register' || $row['show_reg'] == 0)) {
1242
+					continue;
1243
+		}
1181 1244
 
1182 1245
 		// Validate the user data.
1183
-		if ($row['field_type'] == 'check')
1184
-			$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1185
-		elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1246
+		if ($row['field_type'] == 'check') {
1247
+					$value = isset($_POST['customfield'][$row['col_name']]) ? 1 : 0;
1248
+		} elseif ($row['field_type'] == 'select' || $row['field_type'] == 'radio')
1186 1249
 		{
1187 1250
 			$value = $row['default_value'];
1188
-			foreach (explode(',', $row['field_options']) as $k => $v)
1189
-				if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1251
+			foreach (explode(',', $row['field_options']) as $k => $v) {
1252
+							if (isset($_POST['customfield'][$row['col_name']]) && $_POST['customfield'][$row['col_name']] == $k)
1190 1253
 					$value = $v;
1254
+			}
1191 1255
 		}
1192 1256
 		// Otherwise some form of text!
1193 1257
 		else
1194 1258
 		{
1195 1259
 			$value = isset($_POST['customfield'][$row['col_name']]) ? $_POST['customfield'][$row['col_name']] : '';
1196
-			if ($row['field_length'])
1197
-				$value = $smcFunc['substr']($value, 0, $row['field_length']);
1260
+			if ($row['field_length']) {
1261
+							$value = $smcFunc['substr']($value, 0, $row['field_length']);
1262
+			}
1198 1263
 
1199 1264
 			// Any masks?
1200 1265
 			if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none')
1201 1266
 			{
1202 1267
 				if ($row['mask'] == 'email' && (!filter_var($value, FILTER_VALIDATE_EMAIL) || strlen($value) > 255))
1203 1268
 				{
1204
-					if ($returnErrors)
1205
-						$errors[] = 'custom_field_mail_fail';
1206
-
1207
-					else
1208
-						$value = '';
1209
-				}
1210
-				elseif ($row['mask'] == 'number')
1269
+					if ($returnErrors) {
1270
+											$errors[] = 'custom_field_mail_fail';
1271
+					} else {
1272
+											$value = '';
1273
+					}
1274
+				} elseif ($row['mask'] == 'number')
1211 1275
 				{
1212 1276
 					$value = (int) $value;
1213
-				}
1214
-				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1277
+				} elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
1215 1278
 				{
1216
-					if ($returnErrors)
1217
-						$errors[] = 'custom_field_regex_fail';
1218
-
1219
-					else
1220
-						$value = '';
1279
+					if ($returnErrors) {
1280
+											$errors[] = 'custom_field_regex_fail';
1281
+					} else {
1282
+											$value = '';
1283
+					}
1221 1284
 				}
1222 1285
 			}
1223 1286
 		}
@@ -1243,8 +1306,9 @@  discard block
 block discarded – undo
1243 1306
 
1244 1307
 	$hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array(&$changes, &$log_changes, &$errors, $returnErrors, $memID, $area, $sanitize));
1245 1308
 
1246
-	if (!empty($hook_errors) && is_array($hook_errors))
1247
-		$errors = array_merge($errors, $hook_errors);
1309
+	if (!empty($hook_errors) && is_array($hook_errors)) {
1310
+			$errors = array_merge($errors, $hook_errors);
1311
+	}
1248 1312
 
1249 1313
 	// Make those changes!
1250 1314
 	if (!empty($changes) && empty($context['password_auth_failed']) && empty($errors))
@@ -1262,9 +1326,10 @@  discard block
 block discarded – undo
1262 1326
 		}
1263 1327
 	}
1264 1328
 
1265
-	if ($returnErrors)
1266
-		return $errors;
1267
-}
1329
+	if ($returnErrors) {
1330
+			return $errors;
1331
+	}
1332
+	}
1268 1333
 
1269 1334
 /**
1270 1335
  * Show all the users buddies, as well as a add/delete interface.
@@ -1276,8 +1341,9 @@  discard block
 block discarded – undo
1276 1341
 	global $context, $txt, $modSettings;
1277 1342
 
1278 1343
 	// Do a quick check to ensure people aren't getting here illegally!
1279
-	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist']))
1280
-		fatal_lang_error('no_access', false);
1344
+	if (!$context['user']['is_owner'] || empty($modSettings['enable_buddylist'])) {
1345
+			fatal_lang_error('no_access', false);
1346
+	}
1281 1347
 
1282 1348
 	// Can we email the user direct?
1283 1349
 	$context['can_moderate_forum'] = allowedTo('moderate_forum');
@@ -1307,9 +1373,10 @@  discard block
 block discarded – undo
1307 1373
 	$context['sub_template'] = $subActions[$context['list_area']][0];
1308 1374
 	$call = call_helper($subActions[$context['list_area']][0], true);
1309 1375
 
1310
-	if (!empty($call))
1311
-		call_user_func($call, $memID);
1312
-}
1376
+	if (!empty($call)) {
1377
+			call_user_func($call, $memID);
1378
+	}
1379
+	}
1313 1380
 
1314 1381
 /**
1315 1382
  * Show all the users buddies, as well as a add/delete interface.
@@ -1323,9 +1390,10 @@  discard block
 block discarded – undo
1323 1390
 
1324 1391
 	// For making changes!
1325 1392
 	$buddiesArray = explode(',', $user_profile[$memID]['buddy_list']);
1326
-	foreach ($buddiesArray as $k => $dummy)
1327
-		if ($dummy == '')
1393
+	foreach ($buddiesArray as $k => $dummy) {
1394
+			if ($dummy == '')
1328 1395
 			unset($buddiesArray[$k]);
1396
+	}
1329 1397
 
1330 1398
 	// Removing a buddy?
1331 1399
 	if (isset($_GET['remove']))
@@ -1337,10 +1405,11 @@  discard block
 block discarded – undo
1337 1405
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1338 1406
 
1339 1407
 		// Heh, I'm lazy, do it the easy way...
1340
-		foreach ($buddiesArray as $key => $buddy)
1341
-			if ($buddy == (int) $_GET['remove'])
1408
+		foreach ($buddiesArray as $key => $buddy) {
1409
+					if ($buddy == (int) $_GET['remove'])
1342 1410
 			{
1343 1411
 				unset($buddiesArray[$key]);
1412
+		}
1344 1413
 				$_SESSION['prf-save'] = true;
1345 1414
 			}
1346 1415
 
@@ -1350,8 +1419,7 @@  discard block
 block discarded – undo
1350 1419
 
1351 1420
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1352 1421
 		redirectexit('action=profile;area=lists;sa=buddies;u=' . $memID);
1353
-	}
1354
-	elseif (isset($_POST['new_buddy']))
1422
+	} elseif (isset($_POST['new_buddy']))
1355 1423
 	{
1356 1424
 		checkSession();
1357 1425
 
@@ -1364,8 +1432,9 @@  discard block
 block discarded – undo
1364 1432
 		{
1365 1433
 			$new_buddies[$k] = strtr(trim($new_buddies[$k]), array('\'' => '&#039;'));
1366 1434
 
1367
-			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1368
-				unset($new_buddies[$k]);
1435
+			if (strlen($new_buddies[$k]) == 0 || in_array($new_buddies[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1436
+							unset($new_buddies[$k]);
1437
+			}
1369 1438
 		}
1370 1439
 
1371 1440
 		call_integration_hook('integrate_add_buddies', array($memID, &$new_buddies));
@@ -1385,16 +1454,18 @@  discard block
 block discarded – undo
1385 1454
 				)
1386 1455
 			);
1387 1456
 
1388
-			if ($smcFunc['db_num_rows']($request) != 0)
1389
-				$_SESSION['prf-save'] = true;
1457
+			if ($smcFunc['db_num_rows']($request) != 0) {
1458
+							$_SESSION['prf-save'] = true;
1459
+			}
1390 1460
 
1391 1461
 			// Add the new member to the buddies array.
1392 1462
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1393 1463
 			{
1394
-				if (in_array($row['id_member'], $buddiesArray))
1395
-					continue;
1396
-				else
1397
-					$buddiesArray[] = (int) $row['id_member'];
1464
+				if (in_array($row['id_member'], $buddiesArray)) {
1465
+									continue;
1466
+				} else {
1467
+									$buddiesArray[] = (int) $row['id_member'];
1468
+				}
1398 1469
 			}
1399 1470
 			$smcFunc['db_free_result']($request);
1400 1471
 
@@ -1424,18 +1495,20 @@  discard block
 block discarded – undo
1424 1495
 
1425 1496
 	$context['custom_pf'] = array();
1426 1497
 	$disabled_fields = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array();
1427
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1428
-		if (!isset($disabled_fields[$row['col_name']]))
1498
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1499
+			if (!isset($disabled_fields[$row['col_name']]))
1429 1500
 			$context['custom_pf'][$row['col_name']] = array(
1430 1501
 				'label' => $row['field_name'],
1431 1502
 				'type' => $row['field_type'],
1432 1503
 				'bbc' => !empty($row['bbc']),
1433 1504
 				'enclose' => $row['enclose'],
1434 1505
 			);
1506
+	}
1435 1507
 
1436 1508
 	// Gotta disable the gender option.
1437
-	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled')
1438
-		unset($context['custom_pf']['cust_gender']);
1509
+	if (isset($context['custom_pf']['cust_gender']) && $context['custom_pf']['cust_gender'] == 'Disabled') {
1510
+			unset($context['custom_pf']['cust_gender']);
1511
+	}
1439 1512
 
1440 1513
 	$smcFunc['db_free_result']($request);
1441 1514
 
@@ -1452,8 +1525,9 @@  discard block
 block discarded – undo
1452 1525
 				'buddy_list_count' => substr_count($user_profile[$memID]['buddy_list'], ',') + 1,
1453 1526
 			)
1454 1527
 		);
1455
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1456
-			$buddies[] = $row['id_member'];
1528
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1529
+					$buddies[] = $row['id_member'];
1530
+		}
1457 1531
 		$smcFunc['db_free_result']($result);
1458 1532
 	}
1459 1533
 
@@ -1481,30 +1555,32 @@  discard block
 block discarded – undo
1481 1555
 					continue;
1482 1556
 				}
1483 1557
 
1484
-				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key]))
1485
-					$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1486
-
1487
-				elseif ($column['type'] == 'check')
1488
-					$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1558
+				if ($column['bbc'] && !empty($context['buddies'][$buddy]['options'][$key])) {
1559
+									$context['buddies'][$buddy]['options'][$key] = strip_tags(parse_bbc($context['buddies'][$buddy]['options'][$key]));
1560
+				} elseif ($column['type'] == 'check') {
1561
+									$context['buddies'][$buddy]['options'][$key] = $context['buddies'][$buddy]['options'][$key] == 0 ? $txt['no'] : $txt['yes'];
1562
+				}
1489 1563
 
1490 1564
 				// Enclosing the user input within some other text?
1491
-				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key]))
1492
-					$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1565
+				if (!empty($column['enclose']) && !empty($context['buddies'][$buddy]['options'][$key])) {
1566
+									$context['buddies'][$buddy]['options'][$key] = strtr($column['enclose'], array(
1493 1567
 						'{SCRIPTURL}' => $scripturl,
1494 1568
 						'{IMAGES_URL}' => $settings['images_url'],
1495 1569
 						'{DEFAULT_IMAGES_URL}' => $settings['default_images_url'],
1496 1570
 						'{INPUT}' => $context['buddies'][$buddy]['options'][$key],
1497 1571
 					));
1572
+				}
1498 1573
 			}
1499 1574
 		}
1500 1575
 	}
1501 1576
 
1502 1577
 	if (isset($_SESSION['prf-save']))
1503 1578
 	{
1504
-		if ($_SESSION['prf-save'] === true)
1505
-			$context['saved_successful'] = true;
1506
-		else
1507
-			$context['saved_failed'] = $_SESSION['prf-save'];
1579
+		if ($_SESSION['prf-save'] === true) {
1580
+					$context['saved_successful'] = true;
1581
+		} else {
1582
+					$context['saved_failed'] = $_SESSION['prf-save'];
1583
+		}
1508 1584
 
1509 1585
 		unset($_SESSION['prf-save']);
1510 1586
 	}
@@ -1524,9 +1600,10 @@  discard block
 block discarded – undo
1524 1600
 
1525 1601
 	// For making changes!
1526 1602
 	$ignoreArray = explode(',', $user_profile[$memID]['pm_ignore_list']);
1527
-	foreach ($ignoreArray as $k => $dummy)
1528
-		if ($dummy == '')
1603
+	foreach ($ignoreArray as $k => $dummy) {
1604
+			if ($dummy == '')
1529 1605
 			unset($ignoreArray[$k]);
1606
+	}
1530 1607
 
1531 1608
 	// Removing a member from the ignore list?
1532 1609
 	if (isset($_GET['remove']))
@@ -1536,10 +1613,11 @@  discard block
 block discarded – undo
1536 1613
 		$_SESSION['prf-save'] = $txt['could_not_remove_person'];
1537 1614
 
1538 1615
 		// Heh, I'm lazy, do it the easy way...
1539
-		foreach ($ignoreArray as $key => $id_remove)
1540
-			if ($id_remove == (int) $_GET['remove'])
1616
+		foreach ($ignoreArray as $key => $id_remove) {
1617
+					if ($id_remove == (int) $_GET['remove'])
1541 1618
 			{
1542 1619
 				unset($ignoreArray[$key]);
1620
+		}
1543 1621
 				$_SESSION['prf-save'] = true;
1544 1622
 			}
1545 1623
 
@@ -1549,8 +1627,7 @@  discard block
 block discarded – undo
1549 1627
 
1550 1628
 		// Redirect off the page because we don't like all this ugly query stuff to stick in the history.
1551 1629
 		redirectexit('action=profile;area=lists;sa=ignore;u=' . $memID);
1552
-	}
1553
-	elseif (isset($_POST['new_ignore']))
1630
+	} elseif (isset($_POST['new_ignore']))
1554 1631
 	{
1555 1632
 		checkSession();
1556 1633
 		// Prepare the string for extraction...
@@ -1562,8 +1639,9 @@  discard block
 block discarded – undo
1562 1639
 		{
1563 1640
 			$new_entries[$k] = strtr(trim($new_entries[$k]), array('\'' => '&#039;'));
1564 1641
 
1565
-			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name'])))
1566
-				unset($new_entries[$k]);
1642
+			if (strlen($new_entries[$k]) == 0 || in_array($new_entries[$k], array($user_profile[$memID]['member_name'], $user_profile[$memID]['real_name']))) {
1643
+							unset($new_entries[$k]);
1644
+			}
1567 1645
 		}
1568 1646
 
1569 1647
 		$_SESSION['prf-save'] = $txt['could_not_add_person'];
@@ -1581,16 +1659,18 @@  discard block
 block discarded – undo
1581 1659
 				)
1582 1660
 			);
1583 1661
 
1584
-			if ($smcFunc['db_num_rows']($request) != 0)
1585
-				$_SESSION['prf-save'] = true;
1662
+			if ($smcFunc['db_num_rows']($request) != 0) {
1663
+							$_SESSION['prf-save'] = true;
1664
+			}
1586 1665
 
1587 1666
 			// Add the new member to the buddies array.
1588 1667
 			while ($row = $smcFunc['db_fetch_assoc']($request))
1589 1668
 			{
1590
-				if (in_array($row['id_member'], $ignoreArray))
1591
-					continue;
1592
-				else
1593
-					$ignoreArray[] = (int) $row['id_member'];
1669
+				if (in_array($row['id_member'], $ignoreArray)) {
1670
+									continue;
1671
+				} else {
1672
+									$ignoreArray[] = (int) $row['id_member'];
1673
+				}
1594 1674
 			}
1595 1675
 			$smcFunc['db_free_result']($request);
1596 1676
 
@@ -1619,8 +1699,9 @@  discard block
 block discarded – undo
1619 1699
 				'ignore_list_count' => substr_count($user_profile[$memID]['pm_ignore_list'], ',') + 1,
1620 1700
 			)
1621 1701
 		);
1622
-		while ($row = $smcFunc['db_fetch_assoc']($result))
1623
-			$ignored[] = $row['id_member'];
1702
+		while ($row = $smcFunc['db_fetch_assoc']($result)) {
1703
+					$ignored[] = $row['id_member'];
1704
+		}
1624 1705
 		$smcFunc['db_free_result']($result);
1625 1706
 	}
1626 1707
 
@@ -1639,10 +1720,11 @@  discard block
 block discarded – undo
1639 1720
 
1640 1721
 	if (isset($_SESSION['prf-save']))
1641 1722
 	{
1642
-		if ($_SESSION['prf-save'] === true)
1643
-			$context['saved_successful'] = true;
1644
-		else
1645
-			$context['saved_failed'] = $_SESSION['prf-save'];
1723
+		if ($_SESSION['prf-save'] === true) {
1724
+					$context['saved_successful'] = true;
1725
+		} else {
1726
+					$context['saved_failed'] = $_SESSION['prf-save'];
1727
+		}
1646 1728
 
1647 1729
 		unset($_SESSION['prf-save']);
1648 1730
 	}
@@ -1658,8 +1740,9 @@  discard block
 block discarded – undo
1658 1740
 	global $context, $txt;
1659 1741
 
1660 1742
 	loadThemeOptions($memID);
1661
-	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any')))
1662
-		loadCustomFields($memID, 'account');
1743
+	if (allowedTo(array('profile_identity_own', 'profile_identity_any', 'profile_password_own', 'profile_password_any'))) {
1744
+			loadCustomFields($memID, 'account');
1745
+	}
1663 1746
 
1664 1747
 	$context['sub_template'] = 'edit_options';
1665 1748
 	$context['page_desc'] = $txt['account_info'];
@@ -1686,8 +1769,9 @@  discard block
 block discarded – undo
1686 1769
 	global $context, $txt;
1687 1770
 
1688 1771
 	loadThemeOptions($memID);
1689
-	if (allowedTo(array('profile_forum_own', 'profile_forum_any')))
1690
-		loadCustomFields($memID, 'forumprofile');
1772
+	if (allowedTo(array('profile_forum_own', 'profile_forum_any'))) {
1773
+			loadCustomFields($memID, 'forumprofile');
1774
+	}
1691 1775
 
1692 1776
 	$context['sub_template'] = 'edit_options';
1693 1777
 	$context['page_desc'] = $txt['forumProfile_info'];
@@ -1720,18 +1804,21 @@  discard block
 block discarded – undo
1720 1804
 	$dirs = array();
1721 1805
 	$files = array();
1722 1806
 
1723
-	if (!$dir)
1724
-		return array();
1807
+	if (!$dir) {
1808
+			return array();
1809
+	}
1725 1810
 
1726 1811
 	while ($line = $dir->read())
1727 1812
 	{
1728
-		if (in_array($line, array('.', '..', 'blank.png', 'index.php')))
1729
-			continue;
1813
+		if (in_array($line, array('.', '..', 'blank.png', 'index.php'))) {
1814
+					continue;
1815
+		}
1730 1816
 
1731
-		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line))
1732
-			$dirs[] = $line;
1733
-		else
1734
-			$files[] = $line;
1817
+		if (is_dir($modSettings['avatar_directory'] . '/' . $directory . (!empty($directory) ? '/' : '') . $line)) {
1818
+					$dirs[] = $line;
1819
+		} else {
1820
+					$files[] = $line;
1821
+		}
1735 1822
 	}
1736 1823
 	$dir->close();
1737 1824
 
@@ -1752,14 +1839,15 @@  discard block
 block discarded – undo
1752 1839
 	foreach ($dirs as $line)
1753 1840
 	{
1754 1841
 		$tmp = getAvatars($directory . (!empty($directory) ? '/' : '') . $line, $level + 1);
1755
-		if (!empty($tmp))
1756
-			$result[] = array(
1842
+		if (!empty($tmp)) {
1843
+					$result[] = array(
1757 1844
 				'filename' => $smcFunc['htmlspecialchars']($line),
1758 1845
 				'checked' => strpos($context['member']['avatar']['server_pic'], $line . '/') !== false,
1759 1846
 				'name' => '[' . $smcFunc['htmlspecialchars'](str_replace('_', ' ', $line)) . ']',
1760 1847
 				'is_dir' => true,
1761 1848
 				'files' => $tmp
1762 1849
 		);
1850
+		}
1763 1851
 		unset($tmp);
1764 1852
 	}
1765 1853
 
@@ -1769,8 +1857,9 @@  discard block
 block discarded – undo
1769 1857
 		$extension = substr(strrchr($line, '.'), 1);
1770 1858
 
1771 1859
 		// Make sure it is an image.
1772
-		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0)
1773
-			continue;
1860
+		if (strcasecmp($extension, 'gif') != 0 && strcasecmp($extension, 'jpg') != 0 && strcasecmp($extension, 'jpeg') != 0 && strcasecmp($extension, 'png') != 0 && strcasecmp($extension, 'bmp') != 0) {
1861
+					continue;
1862
+		}
1774 1863
 
1775 1864
 		$result[] = array(
1776 1865
 			'filename' => $smcFunc['htmlspecialchars']($line),
@@ -1778,8 +1867,9 @@  discard block
 block discarded – undo
1778 1867
 			'name' => $smcFunc['htmlspecialchars'](str_replace('_', ' ', $filename)),
1779 1868
 			'is_dir' => false
1780 1869
 		);
1781
-		if ($level == 1)
1782
-			$context['avatar_list'][] = $directory . '/' . $line;
1870
+		if ($level == 1) {
1871
+					$context['avatar_list'][] = $directory . '/' . $line;
1872
+		}
1783 1873
 	}
1784 1874
 
1785 1875
 	return $result;
@@ -1798,8 +1888,9 @@  discard block
 block discarded – undo
1798 1888
 	loadSubTemplate('options');
1799 1889
 
1800 1890
 	loadThemeOptions($memID);
1801
-	if (allowedTo(array('profile_extra_own', 'profile_extra_any')))
1802
-		loadCustomFields($memID, 'theme');
1891
+	if (allowedTo(array('profile_extra_own', 'profile_extra_any'))) {
1892
+			loadCustomFields($memID, 'theme');
1893
+	}
1803 1894
 
1804 1895
 	$context['sub_template'] = 'edit_options';
1805 1896
 	$context['page_desc'] = $txt['theme_info'];
@@ -1853,16 +1944,19 @@  discard block
 block discarded – undo
1853 1944
 {
1854 1945
 	global $txt, $context, $modSettings, $smcFunc, $sourcedir;
1855 1946
 
1856
-	if (!isset($context['token_check']))
1857
-		$context['token_check'] = 'profile-nt' . $memID;
1947
+	if (!isset($context['token_check'])) {
1948
+			$context['token_check'] = 'profile-nt' . $memID;
1949
+	}
1858 1950
 
1859 1951
 	is_not_guest();
1860
-	if (!$context['user']['is_owner'])
1861
-		isAllowedTo('profile_extra_any');
1952
+	if (!$context['user']['is_owner']) {
1953
+			isAllowedTo('profile_extra_any');
1954
+	}
1862 1955
 
1863 1956
 	// Set the post action if we're coming from the profile...
1864
-	if (!isset($context['action']))
1865
-		$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1957
+	if (!isset($context['action'])) {
1958
+			$context['action'] = 'action=profile;area=notification;sa=alerts;u=' . $memID;
1959
+	}
1866 1960
 
1867 1961
 	// What options are set
1868 1962
 	loadThemeOptions($memID);
@@ -1949,28 +2043,34 @@  discard block
 block discarded – undo
1949 2043
 	);
1950 2044
 
1951 2045
 	// There are certain things that are disabled at the group level.
1952
-	if (empty($modSettings['cal_enabled']))
1953
-		unset($alert_types['calendar']);
2046
+	if (empty($modSettings['cal_enabled'])) {
2047
+			unset($alert_types['calendar']);
2048
+	}
1954 2049
 
1955 2050
 	// Disable paid subscriptions at group level if they're disabled
1956
-	if (empty($modSettings['paid_enabled']))
1957
-		unset($alert_types['paidsubs']);
2051
+	if (empty($modSettings['paid_enabled'])) {
2052
+			unset($alert_types['paidsubs']);
2053
+	}
1958 2054
 
1959 2055
 	// Disable membergroup requests at group level if they're disabled
1960
-	if (empty($modSettings['show_group_membership']))
1961
-		unset($alert_types['groupr'], $alert_types['members']['request_group']);
2056
+	if (empty($modSettings['show_group_membership'])) {
2057
+			unset($alert_types['groupr'], $alert_types['members']['request_group']);
2058
+	}
1962 2059
 
1963 2060
 	// Disable mentions if they're disabled
1964
-	if (empty($modSettings['enable_mentions']))
1965
-		unset($alert_types['msg']['msg_mention']);
2061
+	if (empty($modSettings['enable_mentions'])) {
2062
+			unset($alert_types['msg']['msg_mention']);
2063
+	}
1966 2064
 
1967 2065
 	// Disable likes if they're disabled
1968
-	if (empty($modSettings['enable_likes']))
1969
-		unset($alert_types['msg']['msg_like']);
2066
+	if (empty($modSettings['enable_likes'])) {
2067
+			unset($alert_types['msg']['msg_like']);
2068
+	}
1970 2069
 
1971 2070
 	// Disable buddy requests if they're disabled
1972
-	if (empty($modSettings['enable_buddylist']))
1973
-		unset($alert_types['members']['buddy_request']);
2071
+	if (empty($modSettings['enable_buddylist'])) {
2072
+			unset($alert_types['members']['buddy_request']);
2073
+	}
1974 2074
 
1975 2075
 	// Now, now, we could pass this through global but we should really get into the habit of
1976 2076
 	// passing content to hooks, not expecting hooks to splatter everything everywhere.
@@ -1998,15 +2098,17 @@  discard block
 block discarded – undo
1998 2098
 			$perms_cache['manage_membergroups'] = in_array($memID, $members);
1999 2099
 		}
2000 2100
 
2001
-		if (!($perms_cache['manage_membergroups'] || $can_mod != 0))
2002
-			unset($alert_types['members']['request_group']);
2101
+		if (!($perms_cache['manage_membergroups'] || $can_mod != 0)) {
2102
+					unset($alert_types['members']['request_group']);
2103
+		}
2003 2104
 
2004 2105
 		foreach ($alert_types as $group => $items)
2005 2106
 		{
2006 2107
 			foreach ($items as $alert_key => $alert_value)
2007 2108
 			{
2008
-				if (!isset($alert_value['permission']))
2009
-					continue;
2109
+				if (!isset($alert_value['permission'])) {
2110
+									continue;
2111
+				}
2010 2112
 				if (!isset($perms_cache[$alert_value['permission']['name']]))
2011 2113
 				{
2012 2114
 					$in_board = !empty($alert_value['permission']['is_board']) ? 0 : null;
@@ -2014,12 +2116,14 @@  discard block
 block discarded – undo
2014 2116
 					$perms_cache[$alert_value['permission']['name']] = in_array($memID, $members);
2015 2117
 				}
2016 2118
 
2017
-				if (!$perms_cache[$alert_value['permission']['name']])
2018
-					unset ($alert_types[$group][$alert_key]);
2119
+				if (!$perms_cache[$alert_value['permission']['name']]) {
2120
+									unset ($alert_types[$group][$alert_key]);
2121
+				}
2019 2122
 			}
2020 2123
 
2021
-			if (empty($alert_types[$group]))
2022
-				unset ($alert_types[$group]);
2124
+			if (empty($alert_types[$group])) {
2125
+							unset ($alert_types[$group]);
2126
+			}
2023 2127
 		}
2024 2128
 	}
2025 2129
 
@@ -2051,9 +2155,9 @@  discard block
 block discarded – undo
2051 2155
 						$update_prefs[$this_option[1]] = !empty($_POST['opt_' . $this_option[1]]) ? 1 : 0;
2052 2156
 						break;
2053 2157
 					case 'select':
2054
-						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]]))
2055
-							$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2056
-						else
2158
+						if (isset($_POST['opt_' . $this_option[1]], $this_option['opts'][$_POST['opt_' . $this_option[1]]])) {
2159
+													$update_prefs[$this_option[1]] = $_POST['opt_' . $this_option[1]];
2160
+						} else
2057 2161
 						{
2058 2162
 							// We didn't have a sane value. Let's grab the first item from the possibles.
2059 2163
 							$keys = array_keys($this_option['opts']);
@@ -2073,23 +2177,28 @@  discard block
 block discarded – undo
2073 2177
 				$this_value = 0;
2074 2178
 				foreach ($context['alert_bits'] as $type => $bitvalue)
2075 2179
 				{
2076
-					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always')
2077
-						$this_value |= $bitvalue;
2180
+					if ($this_options[$type] == 'yes' && !empty($_POST[$type . '_' . $item_key]) || $this_options[$type] == 'always') {
2181
+											$this_value |= $bitvalue;
2182
+					}
2183
+				}
2184
+				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value) {
2185
+									$update_prefs[$item_key] = $this_value;
2078 2186
 				}
2079
-				if (!isset($context['alert_prefs'][$item_key]) || $context['alert_prefs'][$item_key] != $this_value)
2080
-					$update_prefs[$item_key] = $this_value;
2081 2187
 			}
2082 2188
 		}
2083 2189
 
2084
-		if (!empty($_POST['opt_alert_timeout']))
2085
-			$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2190
+		if (!empty($_POST['opt_alert_timeout'])) {
2191
+					$update_prefs['alert_timeout'] = $context['member']['alert_timeout'] = (int) $_POST['opt_alert_timeout'];
2192
+		}
2086 2193
 
2087
-		if (!empty($_POST['notify_announcements']))
2088
-			$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2194
+		if (!empty($_POST['notify_announcements'])) {
2195
+					$update_prefs['announcements'] = $context['member']['notify_announcements'] = (int) $_POST['notify_announcements'];
2196
+		}
2089 2197
 
2090 2198
 		setNotifyPrefs((int) $memID, $update_prefs);
2091
-		foreach ($update_prefs as $pref => $value)
2092
-			$context['alert_prefs'][$pref] = $value;
2199
+		foreach ($update_prefs as $pref => $value) {
2200
+					$context['alert_prefs'][$pref] = $value;
2201
+		}
2093 2202
 
2094 2203
 		makeNotificationChanges($memID);
2095 2204
 
@@ -2119,8 +2228,9 @@  discard block
 block discarded – undo
2119 2228
 
2120 2229
 	// Now we're all set up.
2121 2230
 	is_not_guest();
2122
-	if (!$context['user']['is_owner'])
2123
-		fatal_error('no_access');
2231
+	if (!$context['user']['is_owner']) {
2232
+			fatal_error('no_access');
2233
+	}
2124 2234
 
2125 2235
 	checkSession('get');
2126 2236
 
@@ -2152,8 +2262,9 @@  discard block
 block discarded – undo
2152 2262
 {
2153 2263
 	global $smcFunc;
2154 2264
 
2155
-	if (empty($toMark) || empty($memID))
2156
-		return false;
2265
+	if (empty($toMark) || empty($memID)) {
2266
+			return false;
2267
+	}
2157 2268
 
2158 2269
 	$toMark = (array) $toMark;
2159 2270
 
@@ -2187,8 +2298,9 @@  discard block
 block discarded – undo
2187 2298
 {
2188 2299
 	global $smcFunc;
2189 2300
 
2190
-	if (empty($toDelete))
2191
-		return false;
2301
+	if (empty($toDelete)) {
2302
+			return false;
2303
+	}
2192 2304
 
2193 2305
 	$toDelete = (array) $toDelete;
2194 2306
 
@@ -2223,8 +2335,9 @@  discard block
 block discarded – undo
2223 2335
 {
2224 2336
 	global $smcFunc;
2225 2337
 
2226
-	if (empty($memID))
2227
-		return false;
2338
+	if (empty($memID)) {
2339
+			return false;
2340
+	}
2228 2341
 
2229 2342
 	$request = $smcFunc['db_query']('', '
2230 2343
 		SELECT id_alert
@@ -2301,8 +2414,9 @@  discard block
 block discarded – undo
2301 2414
 					{
2302 2415
 						$link = $topic['link'];
2303 2416
 
2304
-						if ($topic['new'])
2305
-							$link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>';
2417
+						if ($topic['new']) {
2418
+													$link .= ' <a href="' . $topic['new_href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>';
2419
+						}
2306 2420
 
2307 2421
 						$link .= '<br><span class="smalltext"><em>' . $txt['in'] . ' ' . $topic['board_link'] . '</em></span>';
2308 2422
 
@@ -2453,8 +2567,9 @@  discard block
 block discarded – undo
2453 2567
 					{
2454 2568
 						$link = $board['link'];
2455 2569
 
2456
-						if ($board['new'])
2457
-							$link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>';
2570
+						if ($board['new']) {
2571
+													$link .= ' <a href="' . $board['href'] . '"><span class="new_posts">' . $txt['new'] . '</span></a>';
2572
+						}
2458 2573
 
2459 2574
 						return $link;
2460 2575
 					},
@@ -2654,8 +2769,8 @@  discard block
 block discarded – undo
2654 2769
 		)
2655 2770
 	);
2656 2771
 	$notification_boards = array();
2657
-	while ($row = $smcFunc['db_fetch_assoc']($request))
2658
-		$notification_boards[] = array(
2772
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
2773
+			$notification_boards[] = array(
2659 2774
 			'id' => $row['id_board'],
2660 2775
 			'name' => $row['name'],
2661 2776
 			'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
@@ -2663,6 +2778,7 @@  discard block
 block discarded – undo
2663 2778
 			'new' => $row['board_read'] < $row['id_msg_updated'],
2664 2779
 			'notify_pref' => isset($prefs['board_notify_' . $row['id_board']]) ? $prefs['board_notify_' . $row['id_board']] : (!empty($prefs['board_notify']) ? $prefs['board_notify'] : 0),
2665 2780
 		);
2781
+	}
2666 2782
 	$smcFunc['db_free_result']($request);
2667 2783
 
2668 2784
 	return $notification_boards;
@@ -2677,17 +2793,18 @@  discard block
 block discarded – undo
2677 2793
 {
2678 2794
 	global $context, $options, $cur_profile, $smcFunc;
2679 2795
 
2680
-	if (isset($_POST['default_options']))
2681
-		$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2796
+	if (isset($_POST['default_options'])) {
2797
+			$_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
2798
+	}
2682 2799
 
2683 2800
 	if ($context['user']['is_owner'])
2684 2801
 	{
2685 2802
 		$context['member']['options'] = $options;
2686
-		if (isset($_POST['options']) && is_array($_POST['options']))
2687
-			foreach ($_POST['options'] as $k => $v)
2803
+		if (isset($_POST['options']) && is_array($_POST['options'])) {
2804
+					foreach ($_POST['options'] as $k => $v)
2688 2805
 				$context['member']['options'][$k] = $v;
2689
-	}
2690
-	else
2806
+		}
2807
+	} else
2691 2808
 	{
2692 2809
 		$request = $smcFunc['db_query']('', '
2693 2810
 			SELECT id_member, variable, value
@@ -2708,8 +2825,9 @@  discard block
 block discarded – undo
2708 2825
 				continue;
2709 2826
 			}
2710 2827
 
2711
-			if (isset($_POST['options'][$row['variable']]))
2712
-				$row['value'] = $_POST['options'][$row['variable']];
2828
+			if (isset($_POST['options'][$row['variable']])) {
2829
+							$row['value'] = $_POST['options'][$row['variable']];
2830
+			}
2713 2831
 			$context['member']['options'][$row['variable']] = $row['value'];
2714 2832
 		}
2715 2833
 		$smcFunc['db_free_result']($request);
@@ -2717,8 +2835,9 @@  discard block
 block discarded – undo
2717 2835
 		// Load up the default theme options for any missing.
2718 2836
 		foreach ($temp as $k => $v)
2719 2837
 		{
2720
-			if (!isset($context['member']['options'][$k]))
2721
-				$context['member']['options'][$k] = $v;
2838
+			if (!isset($context['member']['options'][$k])) {
2839
+							$context['member']['options'][$k] = $v;
2840
+			}
2722 2841
 		}
2723 2842
 	}
2724 2843
 }
@@ -2733,8 +2852,9 @@  discard block
 block discarded – undo
2733 2852
 	global $context, $modSettings, $smcFunc, $cur_profile, $sourcedir;
2734 2853
 
2735 2854
 	// Have the admins enabled this option?
2736
-	if (empty($modSettings['allow_ignore_boards']))
2737
-		fatal_lang_error('ignoreboards_disallowed', 'user');
2855
+	if (empty($modSettings['allow_ignore_boards'])) {
2856
+			fatal_lang_error('ignoreboards_disallowed', 'user');
2857
+	}
2738 2858
 
2739 2859
 	// Find all the boards this user is allowed to see.
2740 2860
 	$request = $smcFunc['db_query']('order_by_board_order', '
@@ -2754,12 +2874,13 @@  discard block
 block discarded – undo
2754 2874
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2755 2875
 	{
2756 2876
 		// This category hasn't been set up yet..
2757
-		if (!isset($context['categories'][$row['id_cat']]))
2758
-			$context['categories'][$row['id_cat']] = array(
2877
+		if (!isset($context['categories'][$row['id_cat']])) {
2878
+					$context['categories'][$row['id_cat']] = array(
2759 2879
 				'id' => $row['id_cat'],
2760 2880
 				'name' => $row['cat_name'],
2761 2881
 				'boards' => array()
2762 2882
 			);
2883
+		}
2763 2884
 
2764 2885
 		// Set this board up, and let the template know when it's a child.  (indent them..)
2765 2886
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -2789,18 +2910,20 @@  discard block
 block discarded – undo
2789 2910
 	}
2790 2911
 
2791 2912
 	$max_boards = ceil(count($temp_boards) / 2);
2792
-	if ($max_boards == 1)
2793
-		$max_boards = 2;
2913
+	if ($max_boards == 1) {
2914
+			$max_boards = 2;
2915
+	}
2794 2916
 
2795 2917
 	// Now, alternate them so they can be shown left and right ;).
2796 2918
 	$context['board_columns'] = array();
2797 2919
 	for ($i = 0; $i < $max_boards; $i++)
2798 2920
 	{
2799 2921
 		$context['board_columns'][] = $temp_boards[$i];
2800
-		if (isset($temp_boards[$i + $max_boards]))
2801
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
2802
-		else
2803
-			$context['board_columns'][] = array();
2922
+		if (isset($temp_boards[$i + $max_boards])) {
2923
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
2924
+		} else {
2925
+					$context['board_columns'][] = array();
2926
+		}
2804 2927
 	}
2805 2928
 
2806 2929
 	loadThemeOptions($memID);
@@ -2869,8 +2992,9 @@  discard block
 block discarded – undo
2869 2992
 	while ($row = $smcFunc['db_fetch_assoc']($request))
2870 2993
 	{
2871 2994
 		// We should skip the administrator group if they don't have the admin_forum permission!
2872
-		if ($row['id_group'] == 1 && !allowedTo('admin_forum'))
2873
-			continue;
2995
+		if ($row['id_group'] == 1 && !allowedTo('admin_forum')) {
2996
+					continue;
2997
+		}
2874 2998
 
2875 2999
 		$context['member_groups'][$row['id_group']] = array(
2876 3000
 			'id' => $row['id_group'],
@@ -2916,16 +3040,17 @@  discard block
 block discarded – undo
2916 3040
 	$context['max_signature_length'] = $context['signature_limits']['max_length'];
2917 3041
 	// Warning message for signature image limits?
2918 3042
 	$context['signature_warning'] = '';
2919
-	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height'])
2920
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
2921
-	elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height'])
2922
-		$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3043
+	if ($context['signature_limits']['max_image_width'] && $context['signature_limits']['max_image_height']) {
3044
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_size'], $context['signature_limits']['max_image_width'], $context['signature_limits']['max_image_height']);
3045
+	} elseif ($context['signature_limits']['max_image_width'] || $context['signature_limits']['max_image_height']) {
3046
+			$context['signature_warning'] = sprintf($txt['profile_error_signature_max_image_' . ($context['signature_limits']['max_image_width'] ? 'width' : 'height')], $context['signature_limits'][$context['signature_limits']['max_image_width'] ? 'max_image_width' : 'max_image_height']);
3047
+	}
2923 3048
 
2924 3049
 	$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && (function_exists('pspell_new') || (function_exists('enchant_broker_init') && ($txt['lang_charset'] == 'UTF-8' || function_exists('iconv'))));
2925 3050
 
2926
-	if (empty($context['do_preview']))
2927
-		$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
2928
-	else
3051
+	if (empty($context['do_preview'])) {
3052
+			$context['member']['signature'] = empty($cur_profile['signature']) ? '' : str_replace(array('<br>', '<', '>', '"', '\''), array("\n", '&lt;', '&gt;', '&quot;', '&#039;'), $cur_profile['signature']);
3053
+	} else
2929 3054
 	{
2930 3055
 		$signature = !empty($_POST['signature']) ? $_POST['signature'] : '';
2931 3056
 		$validation = profileValidateSignature($signature);
@@ -2935,8 +3060,9 @@  discard block
 block discarded – undo
2935 3060
 			$context['post_errors'] = array();
2936 3061
 		}
2937 3062
 		$context['post_errors'][] = 'signature_not_yet_saved';
2938
-		if ($validation !== true && $validation !== false)
2939
-			$context['post_errors'][] = $validation;
3063
+		if ($validation !== true && $validation !== false) {
3064
+					$context['post_errors'][] = $validation;
3065
+		}
2940 3066
 
2941 3067
 		censorText($context['member']['signature']);
2942 3068
 		$context['member']['current_signature'] = $context['member']['signature'];
@@ -2946,8 +3072,9 @@  discard block
 block discarded – undo
2946 3072
 	}
2947 3073
 
2948 3074
 	// Load the spell checker?
2949
-	if ($context['show_spellchecking'])
2950
-		loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
3075
+	if ($context['show_spellchecking']) {
3076
+			loadJavaScriptFile('spellcheck.js', array('defer' => false), 'smf_spellcheck');
3077
+	}
2951 3078
 
2952 3079
 	return true;
2953 3080
 }
@@ -2981,8 +3108,7 @@  discard block
 block discarded – undo
2981 3108
 			'external' => $cur_profile['avatar'] == 'gravatar://' || empty($modSettings['gravatarAllowExtraEmail']) || !empty($modSettings['gravatarOverride']) ? $cur_profile['email_address'] : substr($cur_profile['avatar'], 11)
2982 3109
 		);
2983 3110
 		$context['member']['avatar']['href'] = get_gravatar_url($context['member']['avatar']['external']);
2984
-	}
2985
-	elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
3111
+	} elseif ($cur_profile['avatar'] == '' && $cur_profile['id_attach'] > 0 && $context['member']['avatar']['allow_upload'])
2986 3112
 	{
2987 3113
 		$context['member']['avatar'] += array(
2988 3114
 			'choice' => 'upload',
@@ -2992,33 +3118,34 @@  discard block
 block discarded – undo
2992 3118
 		$context['member']['avatar']['href'] = empty($cur_profile['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $cur_profile['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $cur_profile['filename'];
2993 3119
 	}
2994 3120
 	// Use "avatar_original" here so we show what the user entered even if the image proxy is enabled
2995
-	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external'])
2996
-		$context['member']['avatar'] += array(
3121
+	elseif ((stristr($cur_profile['avatar'], 'http://') || stristr($cur_profile['avatar'], 'https://')) && $context['member']['avatar']['allow_external']) {
3122
+			$context['member']['avatar'] += array(
2997 3123
 			'choice' => 'external',
2998 3124
 			'server_pic' => 'blank.png',
2999 3125
 			'external' => $cur_profile['avatar_original']
3000 3126
 		);
3001
-	elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored'])
3002
-		$context['member']['avatar'] += array(
3127
+	} elseif ($cur_profile['avatar'] != '' && file_exists($modSettings['avatar_directory'] . '/' . $cur_profile['avatar']) && $context['member']['avatar']['allow_server_stored']) {
3128
+			$context['member']['avatar'] += array(
3003 3129
 			'choice' => 'server_stored',
3004 3130
 			'server_pic' => $cur_profile['avatar'] == '' ? 'blank.png' : $cur_profile['avatar'],
3005 3131
 			'external' => 'http://'
3006 3132
 		);
3007
-	else
3008
-		$context['member']['avatar'] += array(
3133
+	} else {
3134
+			$context['member']['avatar'] += array(
3009 3135
 			'choice' => 'none',
3010 3136
 			'server_pic' => 'blank.png',
3011 3137
 			'external' => 'http://'
3012 3138
 		);
3139
+	}
3013 3140
 
3014 3141
 	// Get a list of all the avatars.
3015 3142
 	if ($context['member']['avatar']['allow_server_stored'])
3016 3143
 	{
3017 3144
 		$context['avatar_list'] = array();
3018 3145
 		$context['avatars'] = is_dir($modSettings['avatar_directory']) ? getAvatars('', 0) : array();
3146
+	} else {
3147
+			$context['avatars'] = array();
3019 3148
 	}
3020
-	else
3021
-		$context['avatars'] = array();
3022 3149
 
3023 3150
 	// Second level selected avatar...
3024 3151
 	$context['avatar_selected'] = substr(strrchr($context['member']['avatar']['server_pic'], '/'), 1);
@@ -3047,19 +3174,22 @@  discard block
 block discarded – undo
3047 3174
 			)
3048 3175
 		);
3049 3176
 		$protected_groups = array(1);
3050
-		while ($row = $smcFunc['db_fetch_assoc']($request))
3051
-			$protected_groups[] = $row['id_group'];
3177
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
3178
+					$protected_groups[] = $row['id_group'];
3179
+		}
3052 3180
 		$smcFunc['db_free_result']($request);
3053 3181
 
3054 3182
 		$protected_groups = array_unique($protected_groups);
3055 3183
 	}
3056 3184
 
3057 3185
 	// The account page allows the change of your id_group - but not to a protected group!
3058
-	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0)
3059
-		$value = (int) $value;
3186
+	if (empty($protected_groups) || count(array_intersect(array((int) $value, $old_profile['id_group']), $protected_groups)) == 0) {
3187
+			$value = (int) $value;
3188
+	}
3060 3189
 	// ... otherwise it's the old group sir.
3061
-	else
3062
-		$value = $old_profile['id_group'];
3190
+	else {
3191
+			$value = $old_profile['id_group'];
3192
+	}
3063 3193
 
3064 3194
 	// Find the additional membergroups (if any)
3065 3195
 	if (isset($_POST['additional_groups']) && is_array($_POST['additional_groups']))
@@ -3068,16 +3198,18 @@  discard block
 block discarded – undo
3068 3198
 		foreach ($_POST['additional_groups'] as $group_id)
3069 3199
 		{
3070 3200
 			$group_id = (int) $group_id;
3071
-			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups)))
3072
-				$additional_groups[] = $group_id;
3201
+			if (!empty($group_id) && (empty($protected_groups) || !in_array($group_id, $protected_groups))) {
3202
+							$additional_groups[] = $group_id;
3203
+			}
3073 3204
 		}
3074 3205
 
3075 3206
 		// Put the protected groups back in there if you don't have permission to take them away.
3076 3207
 		$old_additional_groups = explode(',', $old_profile['additional_groups']);
3077 3208
 		foreach ($old_additional_groups as $group_id)
3078 3209
 		{
3079
-			if (!empty($protected_groups) && in_array($group_id, $protected_groups))
3080
-				$additional_groups[] = $group_id;
3210
+			if (!empty($protected_groups) && in_array($group_id, $protected_groups)) {
3211
+							$additional_groups[] = $group_id;
3212
+			}
3081 3213
 		}
3082 3214
 
3083 3215
 		if (implode(',', $additional_groups) !== $old_profile['additional_groups'])
@@ -3109,18 +3241,20 @@  discard block
 block discarded – undo
3109 3241
 			list ($another) = $smcFunc['db_fetch_row']($request);
3110 3242
 			$smcFunc['db_free_result']($request);
3111 3243
 
3112
-			if (empty($another))
3113
-				fatal_lang_error('at_least_one_admin', 'critical');
3244
+			if (empty($another)) {
3245
+							fatal_lang_error('at_least_one_admin', 'critical');
3246
+			}
3114 3247
 		}
3115 3248
 	}
3116 3249
 
3117 3250
 	// If we are changing group status, update permission cache as necessary.
3118 3251
 	if ($value != $old_profile['id_group'] || isset($profile_vars['additional_groups']))
3119 3252
 	{
3120
-		if ($context['user']['is_owner'])
3121
-			$_SESSION['mc']['time'] = 0;
3122
-		else
3123
-			updateSettings(array('settings_updated' => time()));
3253
+		if ($context['user']['is_owner']) {
3254
+					$_SESSION['mc']['time'] = 0;
3255
+		} else {
3256
+					updateSettings(array('settings_updated' => time()));
3257
+		}
3124 3258
 	}
3125 3259
 
3126 3260
 	// Announce to any hooks that we have changed groups, but don't allow them to change it.
@@ -3141,8 +3275,9 @@  discard block
 block discarded – undo
3141 3275
 	global $modSettings, $sourcedir, $smcFunc, $profile_vars, $cur_profile, $context;
3142 3276
 
3143 3277
 	$memID = $context['id_member'];
3144
-	if (empty($memID) && !empty($context['password_auth_failed']))
3145
-		return false;
3278
+	if (empty($memID) && !empty($context['password_auth_failed'])) {
3279
+			return false;
3280
+	}
3146 3281
 
3147 3282
 	require_once($sourcedir . '/ManageAttachments.php');
3148 3283
 
@@ -3153,8 +3288,9 @@  discard block
 block discarded – undo
3153 3288
 	$downloadedExternalAvatar = false;
3154 3289
 	if ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && strlen($_POST['userpicpersonal']) > 7 && !empty($modSettings['avatar_download_external']))
3155 3290
 	{
3156
-		if (!is_writable($uploadDir))
3157
-			fatal_lang_error('attachments_no_write', 'critical');
3291
+		if (!is_writable($uploadDir)) {
3292
+					fatal_lang_error('attachments_no_write', 'critical');
3293
+		}
3158 3294
 
3159 3295
 		require_once($sourcedir . '/Subs-Package.php');
3160 3296
 
@@ -3198,19 +3334,18 @@  discard block
 block discarded – undo
3198 3334
 
3199 3335
 		// Get rid of their old avatar. (if uploaded.)
3200 3336
 		removeAttachments(array('id_member' => $memID));
3201
-	}
3202
-	elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3337
+	} elseif ($value == 'gravatar' && !empty($modSettings['gravatarEnabled']))
3203 3338
 	{
3204 3339
 		// One wasn't specified, or it's not allowed to use extra email addresses, or it's not a valid one, reset to default Gravatar.
3205
-		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL))
3206
-			$profile_vars['avatar'] = 'gravatar://';
3207
-		else
3208
-			$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3340
+		if (empty($_POST['gravatarEmail']) || empty($modSettings['gravatarAllowExtraEmail']) || !filter_var($_POST['gravatarEmail'], FILTER_VALIDATE_EMAIL)) {
3341
+					$profile_vars['avatar'] = 'gravatar://';
3342
+		} else {
3343
+					$profile_vars['avatar'] = 'gravatar://' . ($_POST['gravatarEmail'] != $cur_profile['email_address'] ? $_POST['gravatarEmail'] : '');
3344
+		}
3209 3345
 
3210 3346
 		// Get rid of their old avatar. (if uploaded.)
3211 3347
 		removeAttachments(array('id_member' => $memID));
3212
-	}
3213
-	elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3348
+	} elseif ($value == 'external' && allowedTo('profile_remote_avatar') && (stripos($_POST['userpicpersonal'], 'http://') === 0 || stripos($_POST['userpicpersonal'], 'https://') === 0) && empty($modSettings['avatar_download_external']))
3214 3349
 	{
3215 3350
 		// We need these clean...
3216 3351
 		$cur_profile['id_attach'] = 0;
@@ -3222,11 +3357,13 @@  discard block
 block discarded – undo
3222 3357
 
3223 3358
 		$profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal']));
3224 3359
 
3225
-		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///')
3226
-			$profile_vars['avatar'] = '';
3360
+		if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') {
3361
+					$profile_vars['avatar'] = '';
3362
+		}
3227 3363
 		// Trying to make us do something we'll regret?
3228
-		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://')
3229
-			return 'bad_avatar_invalid_url';
3364
+		elseif (substr($profile_vars['avatar'], 0, 7) != 'http://' && substr($profile_vars['avatar'], 0, 8) != 'https://') {
3365
+					return 'bad_avatar_invalid_url';
3366
+		}
3230 3367
 		// Should we check dimensions?
3231 3368
 		elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external']))
3232 3369
 		{
@@ -3236,9 +3373,9 @@  discard block
 block discarded – undo
3236 3373
 			if (is_array($sizes) && (($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external'])) || ($sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))))
3237 3374
 			{
3238 3375
 				// Houston, we have a problem. The avatar is too large!!
3239
-				if ($modSettings['avatar_action_too_large'] == 'option_refuse')
3240
-					return 'bad_avatar_too_large';
3241
-				elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3376
+				if ($modSettings['avatar_action_too_large'] == 'option_refuse') {
3377
+									return 'bad_avatar_too_large';
3378
+				} elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize')
3242 3379
 				{
3243 3380
 					// @todo remove this if appropriate
3244 3381
 					require_once($sourcedir . '/Subs-Graphics.php');
@@ -3248,26 +3385,27 @@  discard block
 block discarded – undo
3248 3385
 						$cur_profile['id_attach'] = $modSettings['new_avatar_data']['id'];
3249 3386
 						$cur_profile['filename'] = $modSettings['new_avatar_data']['filename'];
3250 3387
 						$cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type'];
3388
+					} else {
3389
+											return 'bad_avatar';
3251 3390
 					}
3252
-					else
3253
-						return 'bad_avatar';
3254 3391
 				}
3255 3392
 			}
3256 3393
 		}
3257
-	}
3258
-	elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3394
+	} elseif (($value == 'upload' && allowedTo('profile_upload_avatar')) || $downloadedExternalAvatar)
3259 3395
 	{
3260 3396
 		if ((isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '') || $downloadedExternalAvatar)
3261 3397
 		{
3262 3398
 			// Get the dimensions of the image.
3263 3399
 			if (!$downloadedExternalAvatar)
3264 3400
 			{
3265
-				if (!is_writable($uploadDir))
3266
-					fatal_lang_error('attachments_no_write', 'critical');
3401
+				if (!is_writable($uploadDir)) {
3402
+									fatal_lang_error('attachments_no_write', 'critical');
3403
+				}
3267 3404
 
3268 3405
 				$new_filename = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true);
3269
-				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename))
3270
-					fatal_lang_error('attach_timeout', 'critical');
3406
+				if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_filename)) {
3407
+									fatal_lang_error('attach_timeout', 'critical');
3408
+				}
3271 3409
 
3272 3410
 				$_FILES['attachment']['tmp_name'] = $new_filename;
3273 3411
 			}
@@ -3380,17 +3518,19 @@  discard block
 block discarded – undo
3380 3518
 			$profile_vars['avatar'] = '';
3381 3519
 
3382 3520
 			// Delete any temporary file.
3383
-			if (file_exists($_FILES['attachment']['tmp_name']))
3384
-				@unlink($_FILES['attachment']['tmp_name']);
3521
+			if (file_exists($_FILES['attachment']['tmp_name'])) {
3522
+							@unlink($_FILES['attachment']['tmp_name']);
3523
+			}
3385 3524
 		}
3386 3525
 		// Selected the upload avatar option and had one already uploaded before or didn't upload one.
3387
-		else
3526
+		else {
3527
+					$profile_vars['avatar'] = '';
3528
+		}
3529
+	} elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar')) {
3530
+			$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3531
+	} else {
3388 3532
 			$profile_vars['avatar'] = '';
3389 3533
 	}
3390
-	elseif ($value == 'gravatar' && allowedTo('profile_gravatar_avatar'))
3391
-		$profile_vars['avatar'] = 'gravatar://www.gravatar.com/avatar/' . md5(strtolower(trim($cur_profile['email_address'])));
3392
-	else
3393
-		$profile_vars['avatar'] = '';
3394 3534
 
3395 3535
 	// Setup the profile variables so it shows things right on display!
3396 3536
 	$cur_profile['avatar'] = $profile_vars['avatar'];
@@ -3438,9 +3578,9 @@  discard block
 block discarded – undo
3438 3578
 		$smiley_parsed = $unparsed_signature;
3439 3579
 		parsesmileys($smiley_parsed);
3440 3580
 		$smiley_count = substr_count(strtolower($smiley_parsed), '<img') - substr_count(strtolower($unparsed_signature), '<img');
3441
-		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0)
3442
-			return 'signature_allow_smileys';
3443
-		elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3581
+		if (!empty($sig_limits[4]) && $sig_limits[4] == -1 && $smiley_count > 0) {
3582
+					return 'signature_allow_smileys';
3583
+		} elseif (!empty($sig_limits[4]) && $sig_limits[4] > 0 && $smiley_count > $sig_limits[4])
3444 3584
 		{
3445 3585
 			$txt['profile_error_signature_max_smileys'] = sprintf($txt['profile_error_signature_max_smileys'], $sig_limits[4]);
3446 3586
 			return 'signature_max_smileys';
@@ -3453,14 +3593,15 @@  discard block
 block discarded – undo
3453 3593
 			{
3454 3594
 				$limit_broke = 0;
3455 3595
 				// Attempt to allow all sizes of abuse, so to speak.
3456
-				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
3457
-					$limit_broke = $sig_limits[7] . 'px';
3458
-				elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
3459
-					$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3460
-				elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
3461
-					$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3462
-				elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
3463
-					$limit_broke = 'large';
3596
+				if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
3597
+									$limit_broke = $sig_limits[7] . 'px';
3598
+				} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
3599
+									$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
3600
+				} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
3601
+									$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
3602
+				} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
3603
+									$limit_broke = 'large';
3604
+				}
3464 3605
 
3465 3606
 				if ($limit_broke)
3466 3607
 				{
@@ -3502,24 +3643,26 @@  discard block
 block discarded – undo
3502 3643
 					$width = -1; $height = -1;
3503 3644
 
3504 3645
 					// Does it have predefined restraints? Width first.
3505
-					if ($matches[6][$key])
3506
-						$matches[2][$key] = $matches[6][$key];
3646
+					if ($matches[6][$key]) {
3647
+											$matches[2][$key] = $matches[6][$key];
3648
+					}
3507 3649
 					if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
3508 3650
 					{
3509 3651
 						$width = $sig_limits[5];
3510 3652
 						$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
3653
+					} elseif ($matches[2][$key]) {
3654
+											$width = $matches[2][$key];
3511 3655
 					}
3512
-					elseif ($matches[2][$key])
3513
-						$width = $matches[2][$key];
3514 3656
 					// ... and height.
3515 3657
 					if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
3516 3658
 					{
3517 3659
 						$height = $sig_limits[6];
3518
-						if ($width != -1)
3519
-							$width = $width * ($height / $matches[4][$key]);
3660
+						if ($width != -1) {
3661
+													$width = $width * ($height / $matches[4][$key]);
3662
+						}
3663
+					} elseif ($matches[4][$key]) {
3664
+											$height = $matches[4][$key];
3520 3665
 					}
3521
-					elseif ($matches[4][$key])
3522
-						$height = $matches[4][$key];
3523 3666
 
3524 3667
 					// If the dimensions are still not fixed - we need to check the actual image.
3525 3668
 					if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -3537,21 +3680,24 @@  discard block
 block discarded – undo
3537 3680
 							if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
3538 3681
 							{
3539 3682
 								$height = $sig_limits[6];
3540
-								if ($width == -1)
3541
-									$width = $sizes[0];
3683
+								if ($width == -1) {
3684
+																	$width = $sizes[0];
3685
+								}
3542 3686
 								$width = $width * ($height / $sizes[1]);
3687
+							} elseif ($width != -1) {
3688
+															$height = $sizes[1];
3543 3689
 							}
3544
-							elseif ($width != -1)
3545
-								$height = $sizes[1];
3546 3690
 						}
3547 3691
 					}
3548 3692
 
3549 3693
 					// Did we come up with some changes? If so remake the string.
3550
-					if ($width != -1 || $height != -1)
3551
-						$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3694
+					if ($width != -1 || $height != -1) {
3695
+											$replaces[$image] = '[img' . ($width != -1 ? ' width=' . round($width) : '') . ($height != -1 ? ' height=' . round($height) : '') . ']' . $matches[7][$key] . '[/img]';
3696
+					}
3697
+				}
3698
+				if (!empty($replaces)) {
3699
+									$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3552 3700
 				}
3553
-				if (!empty($replaces))
3554
-					$value = str_replace(array_keys($replaces), array_values($replaces), $value);
3555 3701
 			}
3556 3702
 		}
3557 3703
 
@@ -3595,10 +3741,12 @@  discard block
 block discarded – undo
3595 3741
 	$email = strtr($email, array('&#039;' => '\''));
3596 3742
 
3597 3743
 	// Check the name and email for validity.
3598
-	if (trim($email) == '')
3599
-		return 'no_email';
3600
-	if (!filter_var($email, FILTER_VALIDATE_EMAIL))
3601
-		return 'bad_email';
3744
+	if (trim($email) == '') {
3745
+			return 'no_email';
3746
+	}
3747
+	if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
3748
+			return 'bad_email';
3749
+	}
3602 3750
 
3603 3751
 	// Email addresses should be and stay unique.
3604 3752
 	$request = $smcFunc['db_query']('', '
@@ -3613,8 +3761,9 @@  discard block
 block discarded – undo
3613 3761
 		)
3614 3762
 	);
3615 3763
 
3616
-	if ($smcFunc['db_num_rows']($request) > 0)
3617
-		return 'email_taken';
3764
+	if ($smcFunc['db_num_rows']($request) > 0) {
3765
+			return 'email_taken';
3766
+	}
3618 3767
 	$smcFunc['db_free_result']($request);
3619 3768
 
3620 3769
 	return true;
@@ -3627,8 +3776,9 @@  discard block
 block discarded – undo
3627 3776
 {
3628 3777
 	global $modSettings, $context, $cur_profile;
3629 3778
 
3630
-	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '')
3631
-		setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3779
+	if (isset($_POST['passwrd2']) && $_POST['passwrd2'] != '') {
3780
+			setLoginCookie(60 * $modSettings['cookieTime'], $context['id_member'], hash_salt($_POST['passwrd1'], $cur_profile['password_salt']));
3781
+	}
3632 3782
 
3633 3783
 	loadUserSettings();
3634 3784
 	writeLog();
@@ -3644,8 +3794,9 @@  discard block
 block discarded – undo
3644 3794
 	require_once($sourcedir . '/Subs-Post.php');
3645 3795
 
3646 3796
 	// Shouldn't happen but just in case.
3647
-	if (empty($profile_vars['email_address']))
3648
-		return;
3797
+	if (empty($profile_vars['email_address'])) {
3798
+			return;
3799
+	}
3649 3800
 
3650 3801
 	$replacements = array(
3651 3802
 		'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $context['id_member'] . ';code=' . $profile_vars['validation_code'],
@@ -3668,8 +3819,9 @@  discard block
 block discarded – undo
3668 3819
 	$_SESSION['log_time'] = 0;
3669 3820
 	$_SESSION['login_' . $cookiename] = json_encode(array(0, '', 0));
3670 3821
 
3671
-	if (isset($_COOKIE[$cookiename]))
3672
-		$_COOKIE[$cookiename] = '';
3822
+	if (isset($_COOKIE[$cookiename])) {
3823
+			$_COOKIE[$cookiename] = '';
3824
+	}
3673 3825
 
3674 3826
 	loadUserSettings();
3675 3827
 
@@ -3702,11 +3854,13 @@  discard block
 block discarded – undo
3702 3854
 	$groups[] = $curMember['id_group'];
3703 3855
 
3704 3856
 	// Ensure the query doesn't croak!
3705
-	if (empty($groups))
3706
-		$groups = array(0);
3857
+	if (empty($groups)) {
3858
+			$groups = array(0);
3859
+	}
3707 3860
 	// Just to be sure...
3708
-	foreach ($groups as $k => $v)
3709
-		$groups[$k] = (int) $v;
3861
+	foreach ($groups as $k => $v) {
3862
+			$groups[$k] = (int) $v;
3863
+	}
3710 3864
 
3711 3865
 	// Get all the membergroups they can join.
3712 3866
 	$request = $smcFunc['db_query']('', '
@@ -3736,12 +3890,14 @@  discard block
 block discarded – undo
3736 3890
 	while ($row = $smcFunc['db_fetch_assoc']($request))
3737 3891
 	{
3738 3892
 		// Can they edit their primary group?
3739
-		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups)))
3740
-			$context['can_edit_primary'] = true;
3893
+		if (($row['id_group'] == $context['primary_group'] && $row['group_type'] > 1) || ($row['hidden'] != 2 && $context['primary_group'] == 0 && in_array($row['id_group'], $groups))) {
3894
+					$context['can_edit_primary'] = true;
3895
+		}
3741 3896
 
3742 3897
 		// If they can't manage (protected) groups, and it's not publically joinable or already assigned, they can't see it.
3743
-		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group'])
3744
-			continue;
3898
+		if (((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) && $row['id_group'] != $context['primary_group']) {
3899
+					continue;
3900
+		}
3745 3901
 
3746 3902
 		$context['groups'][in_array($row['id_group'], $groups) ? 'member' : 'available'][$row['id_group']] = array(
3747 3903
 			'id' => $row['id_group'],
@@ -3770,13 +3926,15 @@  discard block
 block discarded – undo
3770 3926
 	);
3771 3927
 
3772 3928
 	// No changing primary one unless you have enough groups!
3773
-	if (count($context['groups']['member']) < 2)
3774
-		$context['can_edit_primary'] = false;
3929
+	if (count($context['groups']['member']) < 2) {
3930
+			$context['can_edit_primary'] = false;
3931
+	}
3775 3932
 
3776 3933
 	// In the special case that someone is requesting membership of a group, setup some special context vars.
3777
-	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2)
3778
-		$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3779
-}
3934
+	if (isset($_REQUEST['request']) && isset($context['groups']['available'][(int) $_REQUEST['request']]) && $context['groups']['available'][(int) $_REQUEST['request']]['type'] == 2) {
3935
+			$context['group_request'] = $context['groups']['available'][(int) $_REQUEST['request']];
3936
+	}
3937
+	}
3780 3938
 
3781 3939
 /**
3782 3940
  * This function actually makes all the group changes
@@ -3791,10 +3949,12 @@  discard block
 block discarded – undo
3791 3949
 	global $user_info, $context, $user_profile, $modSettings, $smcFunc;
3792 3950
 
3793 3951
 	// Let's be extra cautious...
3794
-	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership']))
3795
-		isAllowedTo('manage_membergroups');
3796
-	if (!isset($_REQUEST['gid']) && !isset($_POST['primary']))
3797
-		fatal_lang_error('no_access', false);
3952
+	if (!$context['user']['is_owner'] || empty($modSettings['show_group_membership'])) {
3953
+			isAllowedTo('manage_membergroups');
3954
+	}
3955
+	if (!isset($_REQUEST['gid']) && !isset($_POST['primary'])) {
3956
+			fatal_lang_error('no_access', false);
3957
+	}
3798 3958
 
3799 3959
 	checkSession(isset($_GET['gid']) ? 'get' : 'post');
3800 3960
 
@@ -3813,8 +3973,9 @@  discard block
 block discarded – undo
3813 3973
 	$foundTarget = $changeType == 'primary' && $group_id == 0 ? true : false;
3814 3974
 
3815 3975
 	// Sanity check!!
3816
-	if ($group_id == 1)
3817
-		isAllowedTo('admin_forum');
3976
+	if ($group_id == 1) {
3977
+			isAllowedTo('admin_forum');
3978
+	}
3818 3979
 	// Protected groups too!
3819 3980
 	else
3820 3981
 	{
@@ -3831,8 +3992,9 @@  discard block
 block discarded – undo
3831 3992
 		list ($is_protected) = $smcFunc['db_fetch_row']($request);
3832 3993
 		$smcFunc['db_free_result']($request);
3833 3994
 
3834
-		if ($is_protected == 1)
3835
-			isAllowedTo('admin_forum');
3995
+		if ($is_protected == 1) {
3996
+					isAllowedTo('admin_forum');
3997
+		}
3836 3998
 	}
3837 3999
 
3838 4000
 	// What ever we are doing, we need to determine if changing primary is possible!
@@ -3854,36 +4016,43 @@  discard block
 block discarded – undo
3854 4016
 			$group_name = $row['group_name'];
3855 4017
 
3856 4018
 			// Does the group type match what we're doing - are we trying to request a non-requestable group?
3857
-			if ($changeType == 'request' && $row['group_type'] != 2)
3858
-				fatal_lang_error('no_access', false);
4019
+			if ($changeType == 'request' && $row['group_type'] != 2) {
4020
+							fatal_lang_error('no_access', false);
4021
+			}
3859 4022
 			// What about leaving a requestable group we are not a member of?
3860
-			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']]))
3861
-				fatal_lang_error('no_access', false);
3862
-			elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2)
3863
-				fatal_lang_error('no_access', false);
4023
+			elseif ($changeType == 'free' && $row['group_type'] == 2 && $old_profile['id_group'] != $row['id_group'] && !isset($addGroups[$row['id_group']])) {
4024
+							fatal_lang_error('no_access', false);
4025
+			} elseif ($changeType == 'free' && $row['group_type'] != 3 && $row['group_type'] != 2) {
4026
+							fatal_lang_error('no_access', false);
4027
+			}
3864 4028
 
3865 4029
 			// We can't change the primary group if this is hidden!
3866
-			if ($row['hidden'] == 2)
3867
-				$canChangePrimary = false;
4030
+			if ($row['hidden'] == 2) {
4031
+							$canChangePrimary = false;
4032
+			}
3868 4033
 		}
3869 4034
 
3870 4035
 		// If this is their old primary, can we change it?
3871
-		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false)
3872
-			$canChangePrimary = 1;
4036
+		if ($row['id_group'] == $old_profile['id_group'] && ($row['group_type'] > 1 || $context['can_manage_membergroups']) && $canChangePrimary !== false) {
4037
+					$canChangePrimary = 1;
4038
+		}
3873 4039
 
3874 4040
 		// If we are not doing a force primary move, don't do it automatically if current primary is not 0.
3875
-		if ($changeType != 'primary' && $old_profile['id_group'] != 0)
3876
-			$canChangePrimary = false;
4041
+		if ($changeType != 'primary' && $old_profile['id_group'] != 0) {
4042
+					$canChangePrimary = false;
4043
+		}
3877 4044
 
3878 4045
 		// If this is the one we are acting on, can we even act?
3879
-		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0))
3880
-			$canChangePrimary = false;
4046
+		if ((!$context['can_manage_protected'] && $row['group_type'] == 1) || (!$context['can_manage_membergroups'] && $row['group_type'] == 0)) {
4047
+					$canChangePrimary = false;
4048
+		}
3881 4049
 	}
3882 4050
 	$smcFunc['db_free_result']($request);
3883 4051
 
3884 4052
 	// Didn't find the target?
3885
-	if (!$foundTarget)
3886
-		fatal_lang_error('no_access', false);
4053
+	if (!$foundTarget) {
4054
+			fatal_lang_error('no_access', false);
4055
+	}
3887 4056
 
3888 4057
 	// Final security check, don't allow users to promote themselves to admin.
3889 4058
 	if ($context['can_manage_membergroups'] && !allowedTo('admin_forum'))
@@ -3903,8 +4072,9 @@  discard block
 block discarded – undo
3903 4072
 		list ($disallow) = $smcFunc['db_fetch_row']($request);
3904 4073
 		$smcFunc['db_free_result']($request);
3905 4074
 
3906
-		if ($disallow)
3907
-			isAllowedTo('admin_forum');
4075
+		if ($disallow) {
4076
+					isAllowedTo('admin_forum');
4077
+		}
3908 4078
 	}
3909 4079
 
3910 4080
 	// If we're requesting, add the note then return.
@@ -3922,8 +4092,9 @@  discard block
 block discarded – undo
3922 4092
 				'status_open' => 0,
3923 4093
 			)
3924 4094
 		);
3925
-		if ($smcFunc['db_num_rows']($request) != 0)
3926
-			fatal_lang_error('profile_error_already_requested_group');
4095
+		if ($smcFunc['db_num_rows']($request) != 0) {
4096
+					fatal_lang_error('profile_error_already_requested_group');
4097
+		}
3927 4098
 		$smcFunc['db_free_result']($request);
3928 4099
 
3929 4100
 		// Log the request.
@@ -3957,10 +4128,11 @@  discard block
 block discarded – undo
3957 4128
 		// Are we leaving?
3958 4129
 		if ($old_profile['id_group'] == $group_id || isset($addGroups[$group_id]))
3959 4130
 		{
3960
-			if ($old_profile['id_group'] == $group_id)
3961
-				$newPrimary = 0;
3962
-			else
3963
-				unset($addGroups[$group_id]);
4131
+			if ($old_profile['id_group'] == $group_id) {
4132
+							$newPrimary = 0;
4133
+			} else {
4134
+							unset($addGroups[$group_id]);
4135
+			}
3964 4136
 		}
3965 4137
 		// ... if not, must be joining.
3966 4138
 		else
@@ -3968,36 +4140,42 @@  discard block
 block discarded – undo
3968 4140
 			// Can we change the primary, and do we want to?
3969 4141
 			if ($canChangePrimary)
3970 4142
 			{
3971
-				if ($old_profile['id_group'] != 0)
3972
-					$addGroups[$old_profile['id_group']] = -1;
4143
+				if ($old_profile['id_group'] != 0) {
4144
+									$addGroups[$old_profile['id_group']] = -1;
4145
+				}
3973 4146
 				$newPrimary = $group_id;
3974 4147
 			}
3975 4148
 			// Otherwise it's an additional group...
3976
-			else
3977
-				$addGroups[$group_id] = -1;
4149
+			else {
4150
+							$addGroups[$group_id] = -1;
4151
+			}
3978 4152
 		}
3979 4153
 	}
3980 4154
 	// Finally, we must be setting the primary.
3981 4155
 	elseif ($canChangePrimary)
3982 4156
 	{
3983
-		if ($old_profile['id_group'] != 0)
3984
-			$addGroups[$old_profile['id_group']] = -1;
3985
-		if (isset($addGroups[$group_id]))
3986
-			unset($addGroups[$group_id]);
4157
+		if ($old_profile['id_group'] != 0) {
4158
+					$addGroups[$old_profile['id_group']] = -1;
4159
+		}
4160
+		if (isset($addGroups[$group_id])) {
4161
+					unset($addGroups[$group_id]);
4162
+		}
3987 4163
 		$newPrimary = $group_id;
3988 4164
 	}
3989 4165
 
3990 4166
 	// Finally, we can make the changes!
3991
-	foreach ($addGroups as $id => $dummy)
3992
-		if (empty($id))
4167
+	foreach ($addGroups as $id => $dummy) {
4168
+			if (empty($id))
3993 4169
 			unset($addGroups[$id]);
4170
+	}
3994 4171
 	$addGroups = implode(',', array_flip($addGroups));
3995 4172
 
3996 4173
 	// Ensure that we don't cache permissions if the group is changing.
3997
-	if ($context['user']['is_owner'])
3998
-		$_SESSION['mc']['time'] = 0;
3999
-	else
4000
-		updateSettings(array('settings_updated' => time()));
4174
+	if ($context['user']['is_owner']) {
4175
+			$_SESSION['mc']['time'] = 0;
4176
+	} else {
4177
+			updateSettings(array('settings_updated' => time()));
4178
+	}
4001 4179
 
4002 4180
 	updateMemberData($memID, array('id_group' => $newPrimary, 'additional_groups' => $addGroups));
4003 4181
 
@@ -4020,8 +4198,9 @@  discard block
 block discarded – undo
4020 4198
 	if (empty($user_settings['tfa_secret']) && $context['user']['is_owner'])
4021 4199
 	{
4022 4200
 		// Check to ensure we're forcing SSL for authentication
4023
-		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
4024
-			fatal_lang_error('login_ssl_required');
4201
+		if (!empty($modSettings['force_ssl']) && empty($maintenance) && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
4202
+					fatal_lang_error('login_ssl_required');
4203
+		}
4025 4204
 
4026 4205
 		// In some cases (forced 2FA or backup code) they would be forced to be redirected here,
4027 4206
 		// we do not want too much AJAX to confuse them.
@@ -4058,8 +4237,7 @@  discard block
 block discarded – undo
4058 4237
 				$context['sub_template'] = 'tfasetup_backup';
4059 4238
 
4060 4239
 				return;
4061
-			}
4062
-			else
4240
+			} else
4063 4241
 			{
4064 4242
 				$context['tfa_secret'] = $_SESSION['tfa_secret'];
4065 4243
 				$context['tfa_error'] = !$valid_code;
@@ -4067,8 +4245,7 @@  discard block
 block discarded – undo
4067 4245
 				$context['tfa_pass_value'] = $_POST['passwd'];
4068 4246
 				$context['tfa_value'] = $_POST['tfa_code'];
4069 4247
 			}
4070
-		}
4071
-		else
4248
+		} else
4072 4249
 		{
4073 4250
 			$totp = new \TOTP\Auth();
4074 4251
 			$secret = $totp->generateCode();
@@ -4078,17 +4255,16 @@  discard block
 block discarded – undo
4078 4255
 		}
4079 4256
 
4080 4257
 		$context['tfa_qr_url'] = $totp->getQrCodeUrl($context['forum_name'] . ':' . $user_info['name'], $context['tfa_secret']);
4081
-	}
4082
-	elseif (isset($_REQUEST['disable']))
4258
+	} elseif (isset($_REQUEST['disable']))
4083 4259
 	{
4084 4260
 		updateMemberData($memID, array(
4085 4261
 			'tfa_secret' => '',
4086 4262
 			'tfa_backup' => '',
4087 4263
 		));
4088 4264
 		redirectexit('action=profile;area=account;u=' . $memID);
4265
+	} else {
4266
+			redirectexit('action=profile;area=account;u=' . $memID);
4267
+	}
4089 4268
 	}
4090
-	else
4091
-		redirectexit('action=profile;area=account;u=' . $memID);
4092
-}
4093 4269
 
4094 4270
 ?>
4095 4271
\ No newline at end of file
Please login to merge, or discard this patch.