Completed
Push — release-2.1 ( 08aa48...ab4516 )
by Mathias
06:51
created
Sources/Subs-Password.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 				return null;
49 49
 			}
50 50
 			if (PasswordCompat\binary\_strlen($password) > 72) {
51
-				$password = PasswordCompat\binary\_substr($password, 0,72);
51
+				$password = PasswordCompat\binary\_substr($password, 0, 72);
52 52
 			}
53 53
 			$resultLength = 0;
54 54
 			switch ($algo) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 				return false;
237 237
 			}
238 238
 			if (PasswordCompat\binary\_strlen($password) > 72) {
239
-				$password = PasswordCompat\binary\_substr($password, 0,72);
239
+				$password = PasswordCompat\binary\_substr($password, 0, 72);
240 240
 			}
241 241
 			$ret = crypt($password, $hash);
242 242
 			if (!is_string($ret) || PasswordCompat\binary\_strlen($ret) != PasswordCompat\binary\_strlen($hash) || PasswordCompat\binary\_strlen($ret) <= 13) {
Please login to merge, or discard this patch.
Sources/SearchAPI-Standard.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,8 +11,9 @@
 block discarded – undo
11 11
  * @version 2.1 Beta 3
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
  * Standard non full index, non custom index search
Please login to merge, or discard this patch.
Sources/ManageMembergroups.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 					'value' => $txt['membergroups_name'],
102 102
 				),
103 103
 				'data' => array(
104
-					'function' => function ($rowData) use ($scripturl)
104
+					'function' => function($rowData) use ($scripturl)
105 105
 					{
106 106
 						// Since the moderator group has no explicit members, no link is needed.
107 107
 						if ($rowData['id_group'] == 3)
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 					'class' => 'centercol',
145 145
 				),
146 146
 				'data' => array(
147
-					'function' => function ($rowData) use ($txt)
147
+					'function' => function($rowData) use ($txt)
148 148
 					{
149 149
 						// No explicit members for the moderator group.
150 150
 						return $rowData['id_group'] == 3 ? $txt['membergroups_guests_na'] : comma_format($rowData['num_members']);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 					'value' => $txt['membergroups_name'],
211 211
 				),
212 212
 				'data' => array(
213
-					'function' => function ($rowData) use ($scripturl)
213
+					'function' => function($rowData) use ($scripturl)
214 214
 					{
215 215
 						$colorStyle = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']);
216 216
 						return sprintf('<a href="%1$s?action=moderate;area=viewgroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $colorStyle, $rowData['group_name']);
Please login to merge, or discard this patch.
Braces   +131 added lines, -90 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
 /**
@@ -44,8 +45,9 @@  discard block
 block discarded – undo
44 45
 	$_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings');
45 46
 
46 47
 	// Is it elsewhere?
47
-	if (isset($subActions[$_REQUEST['sa']][2]))
48
-		require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]);
48
+	if (isset($subActions[$_REQUEST['sa']][2])) {
49
+			require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]);
50
+	}
49 51
 
50 52
 	// Do the permission check, you might not be allowed her.
51 53
 	isAllowedTo($subActions[$_REQUEST['sa']][1]);
@@ -104,19 +106,20 @@  discard block
 block discarded – undo
104 106
 					'function' => function ($rowData) use ($scripturl)
105 107
 					{
106 108
 						// Since the moderator group has no explicit members, no link is needed.
107
-						if ($rowData['id_group'] == 3)
108
-							$group_name = $rowData['group_name'];
109
-						else
109
+						if ($rowData['id_group'] == 3) {
110
+													$group_name = $rowData['group_name'];
111
+						} else
110 112
 						{
111 113
 							$color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']);
112 114
 							$group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']);
113 115
 						}
114 116
 
115 117
 						// Add a help option for moderator and administrator.
116
-						if ($rowData['id_group'] == 1)
117
-							$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
118
-						elseif ($rowData['id_group'] == 3)
119
-							$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
118
+						if ($rowData['id_group'] == 1) {
119
+													$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
120
+						} elseif ($rowData['id_group'] == 3) {
121
+													$group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl);
122
+						}
120 123
 
121 124
 						return $group_name;
122 125
 					},
@@ -330,12 +333,14 @@  discard block
 block discarded – undo
330 333
 		call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup));
331 334
 
332 335
 		// Update the post groups now, if this is a post group!
333
-		if (isset($_POST['min_posts']))
334
-			updateStats('postgroups');
336
+		if (isset($_POST['min_posts'])) {
337
+					updateStats('postgroups');
338
+		}
335 339
 
336 340
 		// You cannot set permissions for post groups if they are disabled.
337
-		if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups']))
338
-			$_POST['perm_type'] = '';
341
+		if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) {
342
+					$_POST['perm_type'] = '';
343
+		}
339 344
 
340 345
 		if ($_POST['perm_type'] == 'predefined')
341 346
 		{
@@ -365,8 +370,9 @@  discard block
 block discarded – undo
365 370
 				$smcFunc['db_free_result']($request);
366 371
 
367 372
 				// Protected groups are... well, protected!
368
-				if ($copy_type == 1)
369
-					fatal_lang_error('membergroup_does_not_exist');
373
+				if ($copy_type == 1) {
374
+									fatal_lang_error('membergroup_does_not_exist');
375
+				}
370 376
 			}
371 377
 
372 378
 			// Don't allow copying of a real priviledged person!
@@ -384,18 +390,20 @@  discard block
 block discarded – undo
384 390
 			$inserts = array();
385 391
 			while ($row = $smcFunc['db_fetch_assoc']($request))
386 392
 			{
387
-				if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions']))
388
-					$inserts[] = array($id_group, $row['permission'], $row['add_deny']);
393
+				if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) {
394
+									$inserts[] = array($id_group, $row['permission'], $row['add_deny']);
395
+				}
389 396
 			}
390 397
 			$smcFunc['db_free_result']($request);
391 398
 
392
-			if (!empty($inserts))
393
-				$smcFunc['db_insert']('insert',
399
+			if (!empty($inserts)) {
400
+							$smcFunc['db_insert']('insert',
394 401
 					'{db_prefix}permissions',
395 402
 					array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
396 403
 					$inserts,
397 404
 					array('id_group', 'permission')
398 405
 				);
406
+			}
399 407
 
400 408
 			$request = $smcFunc['db_query']('', '
401 409
 				SELECT id_profile, permission, add_deny
@@ -406,17 +414,19 @@  discard block
 block discarded – undo
406 414
 				)
407 415
 			);
408 416
 			$inserts = array();
409
-			while ($row = $smcFunc['db_fetch_assoc']($request))
410
-				$inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']);
417
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
418
+							$inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']);
419
+			}
411 420
 			$smcFunc['db_free_result']($request);
412 421
 
413
-			if (!empty($inserts))
414
-				$smcFunc['db_insert']('insert',
422
+			if (!empty($inserts)) {
423
+							$smcFunc['db_insert']('insert',
415 424
 					'{db_prefix}board_permissions',
416 425
 					array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'),
417 426
 					$inserts,
418 427
 					array('id_group', 'id_profile', 'permission')
419 428
 				);
429
+			}
420 430
 
421 431
 			// Also get some membergroup information if we're copying and not copying from guests...
422 432
 			if ($copy_id > 0 && $_POST['perm_type'] == 'copy')
@@ -469,14 +479,15 @@  discard block
 block discarded – undo
469 479
 		$changed_boards['allow'] = array();
470 480
 		$changed_boards['deny'] = array();
471 481
 		$changed_boards['ignore'] = array();
472
-		foreach ($accesses as $group_id => $action)
473
-			$changed_boards[$action][] = (int) $group_id;
482
+		foreach ($accesses as $group_id => $action) {
483
+					$changed_boards[$action][] = (int) $group_id;
484
+		}
474 485
 
475 486
 		foreach (array('allow', 'deny') as $board_action)
476 487
 		{
477 488
 			// Only do this if they have special access requirements.
478
-			if (!empty($changed_boards[$board_action]))
479
-				$smcFunc['db_query']('', '
489
+			if (!empty($changed_boards[$board_action])) {
490
+							$smcFunc['db_query']('', '
480 491
 					UPDATE {db_prefix}boards
481 492
 					SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END
482 493
 					WHERE id_board IN ({array_int:board_list})',
@@ -488,11 +499,13 @@  discard block
 block discarded – undo
488 499
 						'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups',
489 500
 					)
490 501
 				);
502
+			}
491 503
 		}
492 504
 
493 505
 		// If this is joinable then set it to show group membership in people's profiles.
494
-		if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1)
495
-			updateSettings(array('show_group_membership' => 1));
506
+		if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) {
507
+					updateSettings(array('show_group_membership' => 1));
508
+		}
496 509
 
497 510
 		// Rebuild the group cache.
498 511
 		updateSettings(array(
@@ -513,8 +526,9 @@  discard block
 block discarded – undo
513 526
 	$context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']);
514 527
 	$context['allow_protected'] = allowedTo('admin_forum');
515 528
 
516
-	if (!empty($modSettings['deny_boards_access']))
517
-		loadLanguage('ManagePermissions');
529
+	if (!empty($modSettings['deny_boards_access'])) {
530
+			loadLanguage('ManagePermissions');
531
+	}
518 532
 
519 533
 	$result = $smcFunc['db_query']('', '
520 534
 		SELECT id_group, group_name
@@ -531,11 +545,12 @@  discard block
 block discarded – undo
531 545
 		)
532 546
 	);
533 547
 	$context['groups'] = array();
534
-	while ($row = $smcFunc['db_fetch_assoc']($result))
535
-		$context['groups'][] = array(
548
+	while ($row = $smcFunc['db_fetch_assoc']($result)) {
549
+			$context['groups'][] = array(
536 550
 			'id' => $row['id_group'],
537 551
 			'name' => $row['group_name']
538 552
 		);
553
+	}
539 554
 	$smcFunc['db_free_result']($result);
540 555
 
541 556
 	$request = $smcFunc['db_query']('', '
@@ -552,12 +567,13 @@  discard block
 block discarded – undo
552 567
 	while ($row = $smcFunc['db_fetch_assoc']($request))
553 568
 	{
554 569
 		// This category hasn't been set up yet..
555
-		if (!isset($context['categories'][$row['id_cat']]))
556
-			$context['categories'][$row['id_cat']] = array(
570
+		if (!isset($context['categories'][$row['id_cat']])) {
571
+					$context['categories'][$row['id_cat']] = array(
557 572
 				'id' => $row['id_cat'],
558 573
 				'name' => $row['cat_name'],
559 574
 				'boards' => array()
560 575
 			);
576
+		}
561 577
 
562 578
 		// Set this board up, and let the template know when it's a child.  (indent them..)
563 579
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -605,8 +621,9 @@  discard block
 block discarded – undo
605 621
 	require_once($sourcedir . '/Subs-Membergroups.php');
606 622
 	$result = deleteMembergroups((int) $_REQUEST['group']);
607 623
 	// Need to throw a warning if it went wrong, but this is the only one we have a message for...
608
-	if ($result === 'group_cannot_delete_sub')
609
-		fatal_lang_error('membergroups_cannot_delete_paid', false);
624
+	if ($result === 'group_cannot_delete_sub') {
625
+			fatal_lang_error('membergroups_cannot_delete_paid', false);
626
+	}
610 627
 
611 628
 	// Go back to the membergroup index.
612 629
 	redirectexit('action=admin;area=membergroups;');
@@ -628,8 +645,9 @@  discard block
 block discarded – undo
628 645
 
629 646
 	$_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0;
630 647
 
631
-	if (!empty($modSettings['deny_boards_access']))
632
-		loadLanguage('ManagePermissions');
648
+	if (!empty($modSettings['deny_boards_access'])) {
649
+			loadLanguage('ManagePermissions');
650
+	}
633 651
 
634 652
 	// Make sure this group is editable.
635 653
 	if (!empty($_REQUEST['group']))
@@ -651,8 +669,9 @@  discard block
 block discarded – undo
651 669
 	}
652 670
 
653 671
 	// Now, do we have a valid id?
654
-	if (empty($_REQUEST['group']))
655
-		fatal_lang_error('membergroup_does_not_exist', false);
672
+	if (empty($_REQUEST['group'])) {
673
+			fatal_lang_error('membergroup_does_not_exist', false);
674
+	}
656 675
 
657 676
 	// People who can manage boards are a bit special.
658 677
 	require_once($sourcedir . '/Subs-Members.php');
@@ -683,8 +702,9 @@  discard block
 block discarded – undo
683 702
 		require_once($sourcedir . '/Subs-Membergroups.php');
684 703
 		$result = deleteMembergroups($_REQUEST['group']);
685 704
 		// Need to throw a warning if it went wrong, but this is the only one we have a message for...
686
-		if ($result === 'group_cannot_delete_sub')
687
-			fatal_lang_error('membergroups_cannot_delete_paid', false);
705
+		if ($result === 'group_cannot_delete_sub') {
706
+					fatal_lang_error('membergroups_cannot_delete_paid', false);
707
+		}
688 708
 
689 709
 		redirectexit('action=admin;area=membergroups;');
690 710
 	}
@@ -761,16 +781,18 @@  discard block
 block discarded – undo
761 781
 				$request = $smcFunc['db_query']('', '
762 782
 					SELECT id_board
763 783
 					FROM {db_prefix}boards');
764
-				while ($row = $smcFunc['db_fetch_assoc']($request))
765
-					$accesses[(int) $row['id_board']] = 'allow';
784
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
785
+									$accesses[(int) $row['id_board']] = 'allow';
786
+				}
766 787
 				$smcFunc['db_free_result']($request);
767 788
 			}
768 789
 
769 790
 			$changed_boards['allow'] = array();
770 791
 			$changed_boards['deny'] = array();
771 792
 			$changed_boards['ignore'] = array();
772
-			foreach ($accesses as $group_id => $action)
773
-				$changed_boards[$action][] = (int) $group_id;
793
+			foreach ($accesses as $group_id => $action) {
794
+							$changed_boards[$action][] = (int) $group_id;
795
+			}
774 796
 
775 797
 			foreach (array('allow', 'deny') as $board_action)
776 798
 			{
@@ -786,8 +808,8 @@  discard block
 block discarded – undo
786 808
 						'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups',
787 809
 					)
788 810
 				);
789
-				while ($row = $smcFunc['db_fetch_assoc']($request))
790
-					$smcFunc['db_query']('', '
811
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
812
+									$smcFunc['db_query']('', '
791 813
 						UPDATE {db_prefix}boards
792 814
 						SET {raw:column} = {string:member_group_access}
793 815
 						WHERE id_board = {int:current_board}',
@@ -797,11 +819,12 @@  discard block
 block discarded – undo
797 819
 							'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups',
798 820
 						)
799 821
 					);
822
+				}
800 823
 				$smcFunc['db_free_result']($request);
801 824
 
802 825
 				// Add the membergroup to all boards that hadn't been set yet.
803
-				if (!empty($changed_boards[$board_action]))
804
-					$smcFunc['db_query']('', '
826
+				if (!empty($changed_boards[$board_action])) {
827
+									$smcFunc['db_query']('', '
805 828
 						UPDATE {db_prefix}boards
806 829
 						SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END
807 830
 						WHERE id_board IN ({array_int:board_list})
@@ -815,6 +838,7 @@  discard block
 block discarded – undo
815 838
 							'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups',
816 839
 						)
817 840
 					);
841
+				}
818 842
 			}
819 843
 		}
820 844
 
@@ -840,12 +864,14 @@  discard block
 block discarded – undo
840 864
 				)
841 865
 			);
842 866
 			$updates = array();
843
-			while ($row = $smcFunc['db_fetch_assoc']($request))
844
-				$updates[$row['additional_groups']][] = $row['id_member'];
867
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
868
+							$updates[$row['additional_groups']][] = $row['id_member'];
869
+			}
845 870
 			$smcFunc['db_free_result']($request);
846 871
 
847
-			foreach ($updates as $additional_groups => $memberArray)
848
-				updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group'])))));
872
+			foreach ($updates as $additional_groups => $memberArray) {
873
+							updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group'])))));
874
+			}
849 875
 
850 876
 			// Sorry, but post groups can't moderate boards
851 877
 			$request = $smcFunc['db_query']('', '
@@ -855,8 +881,7 @@  discard block
 block discarded – undo
855 881
 					'current_group' => (int) $_REQUEST['group'],
856 882
 				)
857 883
 			);
858
-		}
859
-		elseif ($_REQUEST['group'] != 3)
884
+		} elseif ($_REQUEST['group'] != 3)
860 885
 		{
861 886
 			// Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional).
862 887
 			if ($_POST['group_hidden'] == 2)
@@ -871,8 +896,9 @@  discard block
 block discarded – undo
871 896
 					)
872 897
 				);
873 898
 				$updates = array();
874
-				while ($row = $smcFunc['db_fetch_assoc']($request))
875
-					$updates[$row['additional_groups']][] = $row['id_member'];
899
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
900
+									$updates[$row['additional_groups']][] = $row['id_member'];
901
+				}
876 902
 				$smcFunc['db_free_result']($request);
877 903
 
878 904
 				foreach ($updates as $additional_groups => $memberArray)
@@ -914,8 +940,9 @@  discard block
 block discarded – undo
914 940
 			$smcFunc['db_free_result']($request);
915 941
 
916 942
 			// Do we need to update the setting?
917
-			if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable))
918
-				updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0));
943
+			if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) {
944
+							updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0));
945
+			}
919 946
 		}
920 947
 
921 948
 		// Do we need to set inherited permissions?
@@ -948,8 +975,9 @@  discard block
 block discarded – undo
948 975
 				{
949 976
 					$moderators[$k] = trim($moderators[$k]);
950 977
 
951
-					if (strlen($moderators[$k]) == 0)
952
-						unset($moderators[$k]);
978
+					if (strlen($moderators[$k]) == 0) {
979
+											unset($moderators[$k]);
980
+					}
953 981
 				}
954 982
 
955 983
 				// Find all the id_member's for the member_name's in the list.
@@ -965,8 +993,9 @@  discard block
 block discarded – undo
965 993
 							'count' => count($moderators),
966 994
 						)
967 995
 					);
968
-					while ($row = $smcFunc['db_fetch_assoc']($request))
969
-						$group_moderators[] = $row['id_member'];
996
+					while ($row = $smcFunc['db_fetch_assoc']($request)) {
997
+											$group_moderators[] = $row['id_member'];
998
+					}
970 999
 					$smcFunc['db_free_result']($request);
971 1000
 				}
972 1001
 			}
@@ -974,8 +1003,9 @@  discard block
 block discarded – undo
974 1003
 			if (!empty($_POST['moderator_list']))
975 1004
 			{
976 1005
 				$moderators = array();
977
-				foreach ($_POST['moderator_list'] as $moderator)
978
-					$moderators[] = (int) $moderator;
1006
+				foreach ($_POST['moderator_list'] as $moderator) {
1007
+									$moderators[] = (int) $moderator;
1008
+				}
979 1009
 
980 1010
 				if (!empty($moderators))
981 1011
 				{
@@ -989,8 +1019,9 @@  discard block
 block discarded – undo
989 1019
 							'num_moderators' => count($moderators),
990 1020
 						)
991 1021
 					);
992
-					while ($row = $smcFunc['db_fetch_assoc']($request))
993
-						$group_moderators[] = $row['id_member'];
1022
+					while ($row = $smcFunc['db_fetch_assoc']($request)) {
1023
+											$group_moderators[] = $row['id_member'];
1024
+					}
994 1025
 					$smcFunc['db_free_result']($request);
995 1026
 				}
996 1027
 			}
@@ -1002,8 +1033,9 @@  discard block
 block discarded – undo
1002 1033
 			if (!empty($group_moderators))
1003 1034
 			{
1004 1035
 				$mod_insert = array();
1005
-				foreach ($group_moderators as $moderator)
1006
-					$mod_insert[] = array($_REQUEST['group'], $moderator);
1036
+				foreach ($group_moderators as $moderator) {
1037
+									$mod_insert[] = array($_REQUEST['group'], $moderator);
1038
+				}
1007 1039
 
1008 1040
 				$smcFunc['db_insert']('insert',
1009 1041
 					'{db_prefix}group_moderators',
@@ -1037,8 +1069,9 @@  discard block
 block discarded – undo
1037 1069
 			'current_group' => (int) $_REQUEST['group'],
1038 1070
 		)
1039 1071
 	);
1040
-	if ($smcFunc['db_num_rows']($request) == 0)
1041
-		fatal_lang_error('membergroup_does_not_exist', false);
1072
+	if ($smcFunc['db_num_rows']($request) == 0) {
1073
+			fatal_lang_error('membergroup_does_not_exist', false);
1074
+	}
1042 1075
 	$row = $smcFunc['db_fetch_assoc']($request);
1043 1076
 	$smcFunc['db_free_result']($request);
1044 1077
 
@@ -1075,14 +1108,16 @@  discard block
 block discarded – undo
1075 1108
 		)
1076 1109
 	);
1077 1110
 	$context['group']['moderators'] = array();
1078
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1079
-		$context['group']['moderators'][$row['id_member']] = $row['real_name'];
1111
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1112
+			$context['group']['moderators'][$row['id_member']] = $row['real_name'];
1113
+	}
1080 1114
 	$smcFunc['db_free_result']($request);
1081 1115
 
1082 1116
 	$context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '&quot;' . implode('&quot;, &quot;', $context['group']['moderators']) . '&quot;';
1083 1117
 
1084
-	if (!empty($context['group']['moderators']))
1085
-		list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1);
1118
+	if (!empty($context['group']['moderators'])) {
1119
+			list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1);
1120
+	}
1086 1121
 
1087 1122
 	// Get a list of boards this membergroup is allowed to see.
1088 1123
 	$context['boards'] = array();
@@ -1102,12 +1137,13 @@  discard block
 block discarded – undo
1102 1137
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1103 1138
 		{
1104 1139
 			// This category hasn't been set up yet..
1105
-			if (!isset($context['categories'][$row['id_cat']]))
1106
-				$context['categories'][$row['id_cat']] = array(
1140
+			if (!isset($context['categories'][$row['id_cat']])) {
1141
+							$context['categories'][$row['id_cat']] = array(
1107 1142
 					'id' => $row['id_cat'],
1108 1143
 					'name' => $row['cat_name'],
1109 1144
 					'boards' => array()
1110 1145
 				);
1146
+			}
1111 1147
 
1112 1148
 			// Set this board up, and let the template know when it's a child.  (indent them..)
1113 1149
 			$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -1135,8 +1171,9 @@  discard block
 block discarded – undo
1135 1171
 		}
1136 1172
 
1137 1173
 		$max_boards = ceil(count($temp_boards) / 2);
1138
-		if ($max_boards == 1)
1139
-			$max_boards = 2;
1174
+		if ($max_boards == 1) {
1175
+					$max_boards = 2;
1176
+		}
1140 1177
 	}
1141 1178
 
1142 1179
 	// Get a list of all the image formats we can select.
@@ -1159,19 +1196,22 @@  discard block
 block discarded – undo
1159 1196
 				$image_info = getimagesize($settings['default_theme_dir'] . '/images/membericons/' . $value);
1160 1197
 
1161 1198
 				// If this is bigger than 128 in width or 32 in height, skip this one.
1162
-				if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32)
1163
-					continue;
1199
+				if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) {
1200
+									continue;
1201
+				}
1164 1202
 
1165 1203
 				// Else it's valid. Add it in.
1166
-				else
1167
-					$context['possible_icons'][] = $value;
1204
+				else {
1205
+									$context['possible_icons'][] = $value;
1206
+				}
1168 1207
 			}
1169 1208
 		}
1170 1209
 	}
1171 1210
 
1172 1211
 	// Insert our JS, if we have possible icons.
1173
-	if (!empty($context['possible_icons']))
1174
-		loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown');
1212
+	if (!empty($context['possible_icons'])) {
1213
+			loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown');
1214
+	}
1175 1215
 
1176 1216
 		loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest');
1177 1217
 
@@ -1193,8 +1233,9 @@  discard block
 block discarded – undo
1193 1233
 		)
1194 1234
 	);
1195 1235
 	$context['inheritable_groups'] = array();
1196
-	while ($row = $smcFunc['db_fetch_assoc']($request))
1197
-		$context['inheritable_groups'][$row['id_group']] = $row['group_name'];
1236
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
1237
+			$context['inheritable_groups'][$row['id_group']] = $row['group_name'];
1238
+	}
1198 1239
 	$smcFunc['db_free_result']($request);
1199 1240
 
1200 1241
 	call_integration_hook('integrate_view_membergroup');
Please login to merge, or discard this patch.
Sources/Profile-Actions.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 					'style' => 'width: 20%;',
303 303
 				),
304 304
 				'data' => array(
305
-					'function' => function ($warning)
305
+					'function' => function($warning)
306 306
 					{
307 307
 						return $warning['issuer']['link'];
308 308
 					},
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 					'value' => $txt['profile_warning_previous_reason'],
331 331
 				),
332 332
 				'data' => array(
333
-					'function' => function ($warning) use ($scripturl, $txt)
333
+					'function' => function($warning) use ($scripturl, $txt)
334 334
 					{
335 335
 						$ret = '
336 336
 						<div class="floatleft">
Please login to merge, or discard this patch.
Braces   +117 added lines, -86 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 3
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
  * Activate an account.
@@ -48,8 +49,9 @@  discard block
 block discarded – undo
48 49
 		logAction('approve_member', array('member' => $memID), 'admin');
49 50
 
50 51
 		// If we are doing approval, update the stats for the member just in case.
51
-		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15)))
52
-			updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
52
+		if (in_array($user_profile[$memID]['is_activated'], array(3, 4, 5, 13, 14, 15))) {
53
+					updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 1 ? $modSettings['unapprovedMembers'] - 1 : 0)));
54
+		}
53 55
 
54 56
 		// Make sure we update the stats too.
55 57
 		updateStats('member', false);
@@ -76,8 +78,9 @@  discard block
 block discarded – undo
76 78
 	$issueErrors = array();
77 79
 
78 80
 	// Doesn't hurt to be overly cautious.
79
-	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning'))
80
-		fatal_lang_error('no_access', false);
81
+	if (empty($modSettings['warning_enable']) || ($context['user']['is_owner'] && !$cur_profile['warning']) || !allowedTo('issue_warning')) {
82
+			fatal_lang_error('no_access', false);
83
+	}
81 84
 
82 85
 	// Get the base (errors related) stuff done.
83 86
 	loadLanguage('Errors');
@@ -135,16 +138,18 @@  discard block
 block discarded – undo
135 138
 
136 139
 		// This cannot be empty!
137 140
 		$_POST['warn_reason'] = isset($_POST['warn_reason']) ? trim($_POST['warn_reason']) : '';
138
-		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner'])
139
-			$issueErrors[] = 'warning_no_reason';
141
+		if ($_POST['warn_reason'] == '' && !$context['user']['is_owner']) {
142
+					$issueErrors[] = 'warning_no_reason';
143
+		}
140 144
 		$_POST['warn_reason'] = $smcFunc['htmlspecialchars']($_POST['warn_reason']);
141 145
 
142 146
 		$_POST['warning_level'] = (int) $_POST['warning_level'];
143 147
 		$_POST['warning_level'] = max(0, min(100, $_POST['warning_level']));
144
-		if ($_POST['warning_level'] < $context['min_allowed'])
145
-			$_POST['warning_level'] = $context['min_allowed'];
146
-		elseif ($_POST['warning_level'] > $context['max_allowed'])
147
-			$_POST['warning_level'] = $context['max_allowed'];
148
+		if ($_POST['warning_level'] < $context['min_allowed']) {
149
+					$_POST['warning_level'] = $context['min_allowed'];
150
+		} elseif ($_POST['warning_level'] > $context['max_allowed']) {
151
+					$_POST['warning_level'] = $context['max_allowed'];
152
+		}
148 153
 
149 154
 		// Do we actually have to issue them with a PM?
150 155
 		$id_notice = 0;
@@ -152,8 +157,9 @@  discard block
 block discarded – undo
152 157
 		{
153 158
 			$_POST['warn_sub'] = trim($_POST['warn_sub']);
154 159
 			$_POST['warn_body'] = trim($_POST['warn_body']);
155
-			if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
156
-				$issueErrors[] = 'warning_notify_blank';
160
+			if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
161
+							$issueErrors[] = 'warning_notify_blank';
162
+			}
157 163
 			// Send the PM?
158 164
 			else
159 165
 			{
@@ -190,8 +196,8 @@  discard block
 block discarded – undo
190 196
 		if (empty($issueErrors))
191 197
 		{
192 198
 			// Log what we've done!
193
-			if (!$context['user']['is_owner'])
194
-				$smcFunc['db_insert']('',
199
+			if (!$context['user']['is_owner']) {
200
+							$smcFunc['db_insert']('',
195 201
 					'{db_prefix}log_comments',
196 202
 					array(
197 203
 						'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'id_recipient' => 'int', 'recipient_name' => 'string-255',
@@ -203,14 +209,14 @@  discard block
 block discarded – undo
203 209
 					),
204 210
 					array('id_comment')
205 211
 				);
212
+			}
206 213
 
207 214
 			// Make the change.
208 215
 			updateMemberData($memID, array('warning' => $_POST['warning_level']));
209 216
 
210 217
 			// Leave a lovely message.
211 218
 			$context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : $txt['profile_warning_success'];
212
-		}
213
-		else
219
+		} else
214 220
 		{
215 221
 			// Try to remember some bits.
216 222
 			$context['warning_data'] = array(
@@ -229,8 +235,9 @@  discard block
 block discarded – undo
229 235
 	{
230 236
 		$warning_body = !empty($_POST['warn_body']) ? trim(censorText($_POST['warn_body'])) : '';
231 237
 		$context['preview_subject'] = !empty($_POST['warn_sub']) ? trim($smcFunc['htmlspecialchars']($_POST['warn_sub'])) : '';
232
-		if (empty($_POST['warn_sub']) || empty($_POST['warn_body']))
233
-			$issueErrors[] = 'warning_notify_blank';
238
+		if (empty($_POST['warn_sub']) || empty($_POST['warn_body'])) {
239
+					$issueErrors[] = 'warning_notify_blank';
240
+		}
234 241
 
235 242
 		if (!empty($_POST['warn_body']))
236 243
 		{
@@ -254,8 +261,9 @@  discard block
 block discarded – undo
254 261
 	{
255 262
 		// Fill in the suite of errors.
256 263
 		$context['post_errors'] = array();
257
-		foreach ($issueErrors as $error)
258
-			$context['post_errors'][] = $txt[$error];
264
+		foreach ($issueErrors as $error) {
265
+					$context['post_errors'][] = $txt[$error];
266
+		}
259 267
 	}
260 268
 
261 269
 
@@ -272,9 +280,10 @@  discard block
 block discarded – undo
272 280
 		$modSettings['warning_mute'] => $txt['profile_warning_effect_mute'],
273 281
 	);
274 282
 	$context['current_level'] = 0;
275
-	foreach ($context['level_effects'] as $limit => $dummy)
276
-		if ($context['member']['warning'] >= $limit)
283
+	foreach ($context['level_effects'] as $limit => $dummy) {
284
+			if ($context['member']['warning'] >= $limit)
277 285
 			$context['current_level'] = $limit;
286
+	}
278 287
 
279 288
 	$listOptions = array(
280 289
 		'id' => 'view_warnings',
@@ -337,11 +346,12 @@  discard block
 block discarded – undo
337 346
 							' . $warning['reason'] . '
338 347
 						</div>';
339 348
 
340
-						if (!empty($warning['id_notice']))
341
-							$ret .= '
349
+						if (!empty($warning['id_notice'])) {
350
+													$ret .= '
342 351
 						<div class="floatright">
343 352
 							<a href="' . $scripturl . '?action=moderate;area=notice;nid=' . $warning['id_notice'] . '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="' . $txt['profile_warning_previous_notice'] . '"><span class="generic_icons filter centericon"></span></a>
344 353
 						</div>';
354
+						}
345 355
 
346 356
 						return $ret;
347 357
 					},
@@ -413,8 +423,9 @@  discard block
 block discarded – undo
413 423
 	while ($row = $smcFunc['db_fetch_assoc']($request))
414 424
 	{
415 425
 		// If we're not warning for a message skip any that are.
416
-		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false)
417
-			continue;
426
+		if (!$context['warning_for_message'] && strpos($row['body'], '{MESSAGE}') !== false) {
427
+					continue;
428
+		}
418 429
 
419 430
 		$context['notification_templates'][] = array(
420 431
 			'title' => $row['template_title'],
@@ -424,16 +435,18 @@  discard block
 block discarded – undo
424 435
 	$smcFunc['db_free_result']($request);
425 436
 
426 437
 	// Setup the "default" templates.
427
-	foreach (array('spamming', 'offence', 'insulting') as $type)
428
-		$context['notification_templates'][] = array(
438
+	foreach (array('spamming', 'offence', 'insulting') as $type) {
439
+			$context['notification_templates'][] = array(
429 440
 			'title' => $txt['profile_warning_notify_title_' . $type],
430 441
 			'body' => sprintf($txt['profile_warning_notify_template_outline' . (!empty($context['warning_for_message']) ? '_post' : '')], $txt['profile_warning_notify_for_' . $type]),
431 442
 		);
443
+	}
432 444
 
433 445
 	// Replace all the common variables in the templates.
434
-	foreach ($context['notification_templates'] as $k => $name)
435
-		$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
436
-}
446
+	foreach ($context['notification_templates'] as $k => $name) {
447
+			$context['notification_templates'][$k]['body'] = strtr($name['body'], array('{MEMBER}' => un_htmlspecialchars($context['member']['name']), '{MESSAGE}' => '[url=' . $scripturl . '?msg=' . $context['warning_for_message'] . ']' . un_htmlspecialchars($context['warned_message_subject']) . '[/url]', '{SCRIPTURL}' => $scripturl, '{FORUMNAME}' => $mbname, '{REGARDS}' => $txt['regards_team']));
448
+	}
449
+	}
437 450
 
438 451
 /**
439 452
  * Get the number of warnings a user has. Callback for $listOptions['get_count'] in issueWarning()
@@ -517,10 +530,11 @@  discard block
 block discarded – undo
517 530
 {
518 531
 	global $txt, $context, $modSettings, $cur_profile;
519 532
 
520
-	if (!$context['user']['is_owner'])
521
-		isAllowedTo('profile_remove_any');
522
-	elseif (!allowedTo('profile_remove_any'))
523
-		isAllowedTo('profile_remove_own');
533
+	if (!$context['user']['is_owner']) {
534
+			isAllowedTo('profile_remove_any');
535
+	} elseif (!allowedTo('profile_remove_any')) {
536
+			isAllowedTo('profile_remove_own');
537
+	}
524 538
 
525 539
 	// Permissions for removing stuff...
526 540
 	$context['can_delete_posts'] = !$context['user']['is_owner'] && allowedTo('moderate_forum');
@@ -547,10 +561,11 @@  discard block
 block discarded – undo
547 561
 
548 562
 	// @todo Add a way to delete pms as well?
549 563
 
550
-	if (!$context['user']['is_owner'])
551
-		isAllowedTo('profile_remove_any');
552
-	elseif (!allowedTo('profile_remove_any'))
553
-		isAllowedTo('profile_remove_own');
564
+	if (!$context['user']['is_owner']) {
565
+			isAllowedTo('profile_remove_any');
566
+	} elseif (!allowedTo('profile_remove_any')) {
567
+			isAllowedTo('profile_remove_own');
568
+	}
554 569
 
555 570
 	checkSession();
556 571
 
@@ -576,8 +591,9 @@  discard block
 block discarded – undo
576 591
 		list ($another) = $smcFunc['db_fetch_row']($request);
577 592
 		$smcFunc['db_free_result']($request);
578 593
 
579
-		if (empty($another))
580
-			fatal_lang_error('at_least_one_admin', 'critical');
594
+		if (empty($another)) {
595
+					fatal_lang_error('at_least_one_admin', 'critical');
596
+		}
581 597
 	}
582 598
 
583 599
 	// This file is needed for the deleteMembers function.
@@ -656,8 +672,9 @@  discard block
 block discarded – undo
656 672
 					)
657 673
 				);
658 674
 				$topicIDs = array();
659
-				while ($row = $smcFunc['db_fetch_assoc']($request))
660
-					$topicIDs[] = $row['id_topic'];
675
+				while ($row = $smcFunc['db_fetch_assoc']($request)) {
676
+									$topicIDs[] = $row['id_topic'];
677
+				}
661 678
 				$smcFunc['db_free_result']($request);
662 679
 
663 680
 				// Actually remove the topics. Ignore recycling if we want to perma-delete things...
@@ -680,8 +697,9 @@  discard block
 block discarded – undo
680 697
 			// This could take a while... but ya know it's gonna be worth it in the end.
681 698
 			while ($row = $smcFunc['db_fetch_assoc']($request))
682 699
 			{
683
-				if (function_exists('apache_reset_timeout'))
684
-					@apache_reset_timeout();
700
+				if (function_exists('apache_reset_timeout')) {
701
+									@apache_reset_timeout();
702
+				}
685 703
 
686 704
 				removeMessage($row['id_msg']);
687 705
 			}
@@ -689,8 +707,9 @@  discard block
 block discarded – undo
689 707
 		}
690 708
 
691 709
 		// Only delete this poor members account if they are actually being booted out of camp.
692
-		if (isset($_POST['deleteAccount']))
693
-			deleteMembers($memID);
710
+		if (isset($_POST['deleteAccount'])) {
711
+					deleteMembers($memID);
712
+		}
694 713
 	}
695 714
 	// Do they need approval to delete?
696 715
 	elseif (!empty($modSettings['approveAccountDeletion']) && !allowedTo('moderate_forum'))
@@ -741,18 +760,18 @@  discard block
 block discarded – undo
741 760
 		{
742 761
 			foreach ($costs as $duration => $cost)
743 762
 			{
744
-				if ($cost != 0)
745
-					$cost_array[$duration] = $cost;
763
+				if ($cost != 0) {
764
+									$cost_array[$duration] = $cost;
765
+				}
746 766
 			}
747
-		}
748
-		else
767
+		} else
749 768
 		{
750 769
 			$cost_array['fixed'] = $costs['fixed'];
751 770
 		}
752 771
 
753
-		if (empty($cost_array))
754
-			unset($context['subscriptions'][$id]);
755
-		else
772
+		if (empty($cost_array)) {
773
+					unset($context['subscriptions'][$id]);
774
+		} else
756 775
 		{
757 776
 			$context['subscriptions'][$id]['member'] = 0;
758 777
 			$context['subscriptions'][$id]['subscribed'] = false;
@@ -765,13 +784,15 @@  discard block
 block discarded – undo
765 784
 	foreach ($gateways as $id => $gateway)
766 785
 	{
767 786
 		$gateways[$id] = new $gateway['display_class']();
768
-		if (!$gateways[$id]->gatewayEnabled())
769
-			unset($gateways[$id]);
787
+		if (!$gateways[$id]->gatewayEnabled()) {
788
+					unset($gateways[$id]);
789
+		}
770 790
 	}
771 791
 
772 792
 	// No gateways yet?
773
-	if (empty($gateways))
774
-		fatal_error($txt['paid_admin_not_setup_gateway']);
793
+	if (empty($gateways)) {
794
+			fatal_error($txt['paid_admin_not_setup_gateway']);
795
+	}
775 796
 
776 797
 	// Get the current subscriptions.
777 798
 	$request = $smcFunc['db_query']('', '
@@ -786,8 +807,9 @@  discard block
 block discarded – undo
786 807
 	while ($row = $smcFunc['db_fetch_assoc']($request))
787 808
 	{
788 809
 		// The subscription must exist!
789
-		if (!isset($context['subscriptions'][$row['id_subscribe']]))
790
-			continue;
810
+		if (!isset($context['subscriptions'][$row['id_subscribe']])) {
811
+					continue;
812
+		}
791 813
 
792 814
 		$context['current'][$row['id_subscribe']] = array(
793 815
 			'id' => $row['id_sublog'],
@@ -801,8 +823,9 @@  discard block
 block discarded – undo
801 823
 			'status_text' => $row['status'] == 0 ? ($row['payments_pending'] ? $txt['paid_pending'] : $txt['paid_finished']) : $txt['paid_active'],
802 824
 		);
803 825
 
804
-		if ($row['status'] == 1)
805
-			$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
826
+		if ($row['status'] == 1) {
827
+					$context['subscriptions'][$row['id_subscribe']]['subscribed'] = true;
828
+		}
806 829
 	}
807 830
 	$smcFunc['db_free_result']($request);
808 831
 
@@ -853,21 +876,25 @@  discard block
 block discarded – undo
853 876
 	if (isset($_GET['confirm']) && isset($_POST['sub_id']) && is_array($_POST['sub_id']))
854 877
 	{
855 878
 		// Hopefully just one.
856
-		foreach ($_POST['sub_id'] as $k => $v)
857
-			$ID_SUB = (int) $k;
879
+		foreach ($_POST['sub_id'] as $k => $v) {
880
+					$ID_SUB = (int) $k;
881
+		}
858 882
 
859
-		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0)
860
-			fatal_lang_error('paid_sub_not_active');
883
+		if (!isset($context['subscriptions'][$ID_SUB]) || $context['subscriptions'][$ID_SUB]['active'] == 0) {
884
+					fatal_lang_error('paid_sub_not_active');
885
+		}
861 886
 
862 887
 		// Simplify...
863 888
 		$context['sub'] = $context['subscriptions'][$ID_SUB];
864 889
 		$period = 'xx';
865
-		if ($context['sub']['flexible'])
866
-			$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
890
+		if ($context['sub']['flexible']) {
891
+					$period = isset($_POST['cur'][$ID_SUB]) && isset($context['sub']['costs'][$_POST['cur'][$ID_SUB]]) ? $_POST['cur'][$ID_SUB] : 'xx';
892
+		}
867 893
 
868 894
 		// Check we have a valid cost.
869
-		if ($context['sub']['flexible'] && $period == 'xx')
870
-			fatal_lang_error('paid_sub_not_active');
895
+		if ($context['sub']['flexible'] && $period == 'xx') {
896
+					fatal_lang_error('paid_sub_not_active');
897
+		}
871 898
 
872 899
 		// Sort out the cost/currency.
873 900
 		$context['currency'] = $modSettings['paid_currency_code'];
@@ -880,8 +907,7 @@  discard block
 block discarded – undo
880 907
 			$context['cost'] = sprintf($modSettings['paid_currency_symbol'], $context['value']) . '/' . $txt[$_POST['cur'][$ID_SUB]];
881 908
 			// The period value for paypal.
882 909
 			$context['paypal_period'] = strtoupper(substr($_POST['cur'][$ID_SUB], 0, 1));
883
-		}
884
-		else
910
+		} else
885 911
 		{
886 912
 			// Real cost...
887 913
 			$context['value'] = $context['sub']['costs']['fixed'];
@@ -898,13 +924,15 @@  discard block
 block discarded – undo
898 924
 		foreach ($gateways as $id => $gateway)
899 925
 		{
900 926
 			$fields = $gateways[$id]->fetchGatewayFields($context['sub']['id'] . '+' . $memID, $context['sub'], $context['value'], $period, $scripturl . '?action=profile;u=' . $memID . ';area=subscriptions;sub_id=' . $context['sub']['id'] . ';done');
901
-			if (!empty($fields['form']))
902
-				$context['gateways'][] = $fields;
927
+			if (!empty($fields['form'])) {
928
+							$context['gateways'][] = $fields;
929
+			}
903 930
 		}
904 931
 
905 932
 		// Bugger?!
906
-		if (empty($context['gateways']))
907
-			fatal_error($txt['paid_admin_not_setup_gateway']);
933
+		if (empty($context['gateways'])) {
934
+					fatal_error($txt['paid_admin_not_setup_gateway']);
935
+		}
908 936
 
909 937
 		// Now we are going to assume they want to take this out ;)
910 938
 		$new_data = array($context['sub']['id'], $context['value'], $period, 'prepay');
@@ -912,16 +940,19 @@  discard block
 block discarded – undo
912 940
 		{
913 941
 			// What are the details like?
914 942
 			$current_pending = array();
915
-			if ($context['current'][$context['sub']['id']]['pending_details'] != '')
916
-				$current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true);
943
+			if ($context['current'][$context['sub']['id']]['pending_details'] != '') {
944
+							$current_pending = smf_json_decode($context['current'][$context['sub']['id']]['pending_details'], true);
945
+			}
917 946
 			// Don't get silly.
918
-			if (count($current_pending) > 9)
919
-				$current_pending = array();
947
+			if (count($current_pending) > 9) {
948
+							$current_pending = array();
949
+			}
920 950
 			$pending_count = 0;
921 951
 			// Only record real pending payments as will otherwise confuse the admin!
922
-			foreach ($current_pending as $pending)
923
-				if ($pending[3] == 'payback')
952
+			foreach ($current_pending as $pending) {
953
+							if ($pending[3] == 'payback')
924 954
 					$pending_count++;
955
+			}
925 956
 
926 957
 			if (!in_array($new_data, $current_pending))
927 958
 			{
@@ -966,9 +997,9 @@  discard block
 block discarded – undo
966 997
 
967 998
 		// Quit.
968 999
 		return;
1000
+	} else {
1001
+			$context['sub_template'] = 'user_subscription';
1002
+	}
969 1003
 	}
970
-	else
971
-		$context['sub_template'] = 'user_subscription';
972
-}
973 1004
 
974 1005
 ?>
975 1006
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/Poll.php 1 patch
Braces   +163 added lines, -119 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 3
15 15
  */
16 16
 
17
-if (!defined('SMF'))
17
+if (!defined('SMF')) {
18 18
 	die('No direct access...');
19
+}
19 20
 
20 21
 /**
21 22
  * Allow the user to vote.
@@ -51,8 +52,9 @@  discard block
 block discarded – undo
51 52
 			'not_guest' => 0,
52 53
 		)
53 54
 	);
54
-	if ($smcFunc['db_num_rows']($request) == 0)
55
-		fatal_lang_error('poll_error', false);
55
+	if ($smcFunc['db_num_rows']($request) == 0) {
56
+			fatal_lang_error('poll_error', false);
57
+	}
56 58
 	$row = $smcFunc['db_fetch_assoc']($request);
57 59
 	$smcFunc['db_free_result']($request);
58 60
 
@@ -60,8 +62,9 @@  discard block
 block discarded – undo
60 62
 	if ($user_info['is_guest'])
61 63
 	{
62 64
 		// Guest voting disabled?
63
-		if (!$row['guest_vote'])
64
-			fatal_lang_error('guest_vote_disabled');
65
+		if (!$row['guest_vote']) {
66
+					fatal_lang_error('guest_vote_disabled');
67
+		}
65 68
 		// Guest already voted?
66 69
 		elseif (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $row['id_poll'] . ',') !== false)
67 70
 		{
@@ -71,32 +74,36 @@  discard block
 block discarded – undo
71 74
 			foreach ($guestinfo as $i => $guestvoted)
72 75
 			{
73 76
 				$guestvoted = explode(',', $guestvoted);
74
-				if ($guestvoted[0] == $row['id_poll'])
75
-					break;
77
+				if ($guestvoted[0] == $row['id_poll']) {
78
+									break;
79
+				}
76 80
 			}
77 81
 			// Has the poll been reset since guest voted?
78 82
 			if ($row['reset_poll'] > $guestvoted[1])
79 83
 			{
80 84
 				// Remove the poll info from the cookie to allow guest to vote again
81 85
 				unset($guestinfo[$i]);
82
-				if (!empty($guestinfo))
83
-					$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
84
-				else
85
-					unset($_COOKIE['guest_poll_vote']);
86
+				if (!empty($guestinfo)) {
87
+									$_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo);
88
+				} else {
89
+									unset($_COOKIE['guest_poll_vote']);
90
+				}
91
+			} else {
92
+							fatal_lang_error('poll_error', false);
86 93
 			}
87
-			else
88
-				fatal_lang_error('poll_error', false);
89 94
 			unset($guestinfo, $guestvoted, $i);
90 95
 		}
91 96
 	}
92 97
 
93 98
 	// Is voting locked or has it expired?
94
-	if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time']))
95
-		fatal_lang_error('poll_error', false);
99
+	if (!empty($row['voting_locked']) || (!empty($row['expire_time']) && time() > $row['expire_time'])) {
100
+			fatal_lang_error('poll_error', false);
101
+	}
96 102
 
97 103
 	// If they have already voted and aren't allowed to change their vote - hence they are outta here!
98
-	if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote']))
99
-		fatal_lang_error('poll_error', false);
104
+	if (!$user_info['is_guest'] && $row['selected'] != -1 && empty($row['change_vote'])) {
105
+			fatal_lang_error('poll_error', false);
106
+	}
100 107
 	// Otherwise if they can change their vote yet they haven't sent any options... remove their vote and redirect.
101 108
 	elseif (!empty($row['change_vote']) && !$user_info['is_guest'] && empty($_POST['options']))
102 109
 	{
@@ -114,8 +121,9 @@  discard block
 block discarded – undo
114 121
 				'id_poll' => $row['id_poll'],
115 122
 			)
116 123
 		);
117
-		while ($choice = $smcFunc['db_fetch_row']($request))
118
-			$pollOptions[] = $choice[0];
124
+		while ($choice = $smcFunc['db_fetch_row']($request)) {
125
+					$pollOptions[] = $choice[0];
126
+		}
119 127
 		$smcFunc['db_free_result']($request);
120 128
 
121 129
 		// Just skip it if they had voted for nothing before.
@@ -148,19 +156,22 @@  discard block
 block discarded – undo
148 156
 		}
149 157
 
150 158
 		// Redirect back to the topic so the user can vote again!
151
-		if (empty($_POST['options']))
152
-			redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
159
+		if (empty($_POST['options'])) {
160
+					redirectexit('topic=' . $topic . '.' . $_REQUEST['start']);
161
+		}
153 162
 	}
154 163
 
155 164
 	checkSession('request');
156 165
 
157 166
 	// Make sure the option(s) are valid.
158
-	if (empty($_POST['options']))
159
-		fatal_lang_error('didnt_select_vote', false);
167
+	if (empty($_POST['options'])) {
168
+			fatal_lang_error('didnt_select_vote', false);
169
+	}
160 170
 
161 171
 	// Too many options checked!
162
-	if (count($_REQUEST['options']) > $row['max_votes'])
163
-		fatal_lang_error('poll_too_many_votes', false, array($row['max_votes']));
172
+	if (count($_REQUEST['options']) > $row['max_votes']) {
173
+			fatal_lang_error('poll_too_many_votes', false, array($row['max_votes']));
174
+	}
164 175
 
165 176
 	$pollOptions = array();
166 177
 	$inserts = array();
@@ -250,24 +261,30 @@  discard block
 block discarded – undo
250 261
 	list ($memberID, $pollID, $voting_locked) = $smcFunc['db_fetch_row']($request);
251 262
 
252 263
 	// If the user _can_ modify the poll....
253
-	if (!allowedTo('poll_lock_any'))
254
-		isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any'));
264
+	if (!allowedTo('poll_lock_any')) {
265
+			isAllowedTo('poll_lock_' . ($user_info['id'] == $memberID ? 'own' : 'any'));
266
+	}
255 267
 
256 268
 	// It's been locked by a non-moderator.
257
-	if ($voting_locked == '1')
258
-		$voting_locked = '0';
269
+	if ($voting_locked == '1') {
270
+			$voting_locked = '0';
271
+	}
259 272
 	// Locked by a moderator, and this is a moderator.
260
-	elseif ($voting_locked == '2' && allowedTo('moderate_board'))
261
-		$voting_locked = '0';
273
+	elseif ($voting_locked == '2' && allowedTo('moderate_board')) {
274
+			$voting_locked = '0';
275
+	}
262 276
 	// Sorry, a moderator locked it.
263
-	elseif ($voting_locked == '2' && !allowedTo('moderate_board'))
264
-		fatal_lang_error('locked_by_admin', 'user');
277
+	elseif ($voting_locked == '2' && !allowedTo('moderate_board')) {
278
+			fatal_lang_error('locked_by_admin', 'user');
279
+	}
265 280
 	// A moderator *is* locking it.
266
-	elseif ($voting_locked == '0' && allowedTo('moderate_board'))
267
-		$voting_locked = '2';
281
+	elseif ($voting_locked == '0' && allowedTo('moderate_board')) {
282
+			$voting_locked = '2';
283
+	}
268 284
 	// Well, it's gonna be locked one way or another otherwise...
269
-	else
270
-		$voting_locked = '1';
285
+	else {
286
+			$voting_locked = '1';
287
+	}
271 288
 
272 289
 	// Lock!  *Poof* - no one can vote.
273 290
 	$smcFunc['db_query']('', '
@@ -302,8 +319,9 @@  discard block
 block discarded – undo
302 319
 {
303 320
 	global $txt, $user_info, $context, $topic, $board, $smcFunc, $sourcedir, $scripturl;
304 321
 
305
-	if (empty($topic))
306
-		fatal_lang_error('no_access', false);
322
+	if (empty($topic)) {
323
+			fatal_lang_error('no_access', false);
324
+	}
307 325
 
308 326
 	loadLanguage('Post');
309 327
 	loadTemplate('Poll');
@@ -327,24 +345,28 @@  discard block
 block discarded – undo
327 345
 	);
328 346
 
329 347
 	// Assume the the topic exists, right?
330
-	if ($smcFunc['db_num_rows']($request) == 0)
331
-		fatal_lang_error('no_board');
348
+	if ($smcFunc['db_num_rows']($request) == 0) {
349
+			fatal_lang_error('no_board');
350
+	}
332 351
 	// Get the poll information.
333 352
 	$pollinfo = $smcFunc['db_fetch_assoc']($request);
334 353
 	$smcFunc['db_free_result']($request);
335 354
 
336 355
 	// If we are adding a new poll - make sure that there isn't already a poll there.
337
-	if (!$context['is_edit'] && !empty($pollinfo['id_poll']))
338
-		fatal_lang_error('poll_already_exists');
356
+	if (!$context['is_edit'] && !empty($pollinfo['id_poll'])) {
357
+			fatal_lang_error('poll_already_exists');
358
+	}
339 359
 	// Otherwise, if we're editing it, it does exist I assume?
340
-	elseif ($context['is_edit'] && empty($pollinfo['id_poll']))
341
-		fatal_lang_error('poll_not_found');
360
+	elseif ($context['is_edit'] && empty($pollinfo['id_poll'])) {
361
+			fatal_lang_error('poll_not_found');
362
+	}
342 363
 
343 364
 	// Can you do this?
344
-	if ($context['is_edit'] && !allowedTo('poll_edit_any'))
345
-		isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any'));
346
-	elseif (!$context['is_edit'] && !allowedTo('poll_add_any'))
347
-		isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any'));
365
+	if ($context['is_edit'] && !allowedTo('poll_edit_any')) {
366
+			isAllowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any'));
367
+	} elseif (!$context['is_edit'] && !allowedTo('poll_add_any')) {
368
+			isAllowedTo('poll_add_' . ($user_info['id'] == $pollinfo['id_member_started'] ? 'own' : 'any'));
369
+	}
348 370
 	$context['can_moderate_poll'] = isset($_REQUEST['add']) ? true : allowedTo('poll_edit_' . ($user_info['id'] == $pollinfo['id_member_started'] || ($pollinfo['poll_starter'] != 0 && $user_info['id'] == $pollinfo['poll_starter']) ? 'own' : 'any'));
349 371
 
350 372
 	// Do we enable guest voting?
@@ -386,12 +408,14 @@  discard block
 block discarded – undo
386 408
 			while ($row = $smcFunc['db_fetch_assoc']($request))
387 409
 			{
388 410
 				// Get the highest id so we can add more without reusing.
389
-				if ($row['id_choice'] >= $last_id)
390
-					$last_id = $row['id_choice'] + 1;
411
+				if ($row['id_choice'] >= $last_id) {
412
+									$last_id = $row['id_choice'] + 1;
413
+				}
391 414
 
392 415
 				// They cleared this by either omitting it or emptying it.
393
-				if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '')
394
-					continue;
416
+				if (!isset($_POST['options'][$row['id_choice']]) || $_POST['options'][$row['id_choice']] == '') {
417
+									continue;
418
+				}
395 419
 
396 420
 				censorText($row['label']);
397 421
 
@@ -409,9 +433,10 @@  discard block
 block discarded – undo
409 433
 
410 434
 		// Work out how many options we have, so we get the 'is_last' field right...
411 435
 		$totalPostOptions = 0;
412
-		foreach ($_POST['options'] as $id => $label)
413
-			if ($label != '')
436
+		foreach ($_POST['options'] as $id => $label) {
437
+					if ($label != '')
414 438
 				$totalPostOptions++;
439
+		}
415 440
 
416 441
 		$count = 1;
417 442
 		// If an option exists, update it.  If it is new, add it - but don't reuse ids!
@@ -420,30 +445,32 @@  discard block
 block discarded – undo
420 445
 			$label = $smcFunc['htmlspecialchars']($label);
421 446
 			censorText($label);
422 447
 
423
-			if (isset($context['choices'][$id]))
424
-				$context['choices'][$id]['label'] = $label;
425
-			elseif ($label != '')
426
-				$context['choices'][] = array(
448
+			if (isset($context['choices'][$id])) {
449
+							$context['choices'][$id]['label'] = $label;
450
+			} elseif ($label != '') {
451
+							$context['choices'][] = array(
427 452
 					'id' => $last_id++,
428 453
 					'number' => $number++,
429 454
 					'label' => $label,
430 455
 					'votes' => -1,
431 456
 					'is_last' => $count++ == $totalPostOptions && $totalPostOptions > 1 ? true : false,
432 457
 				);
458
+			}
433 459
 		}
434 460
 
435 461
 		// Make sure we have two choices for sure!
436 462
 		if ($totalPostOptions < 2)
437 463
 		{
438 464
 			// Need two?
439
-			if ($totalPostOptions == 0)
440
-				$context['choices'][] = array(
465
+			if ($totalPostOptions == 0) {
466
+							$context['choices'][] = array(
441 467
 					'id' => $last_id++,
442 468
 					'number' => $number++,
443 469
 					'label' => '',
444 470
 					'votes' => -1,
445 471
 					'is_last' => false
446 472
 				);
473
+			}
447 474
 			$poll_errors[] = 'poll_few';
448 475
 		}
449 476
 
@@ -458,12 +485,14 @@  discard block
 block discarded – undo
458 485
 
459 486
 		$context['last_choice_id'] = $last_id;
460 487
 
461
-		if ($context['can_moderate_poll'])
462
-			$context['poll']['expiration'] = $_POST['poll_expire'];
488
+		if ($context['can_moderate_poll']) {
489
+					$context['poll']['expiration'] = $_POST['poll_expire'];
490
+		}
463 491
 
464 492
 		// Check the question/option count for errors.
465
-		if (trim($_POST['question']) == '' && empty($context['poll_error']))
466
-			$poll_errors[] = 'no_question';
493
+		if (trim($_POST['question']) == '' && empty($context['poll_error'])) {
494
+					$poll_errors[] = 'no_question';
495
+		}
467 496
 
468 497
 		// No check is needed, since nothing is really posted.
469 498
 		checkSubmitOnce('free');
@@ -480,8 +509,7 @@  discard block
 block discarded – undo
480 509
 				$context['poll_error']['messages'][] = $txt['error_' . $poll_error];
481 510
 			}
482 511
 		}
483
-	}
484
-	else
512
+	} else
485 513
 	{
486 514
 		// Basic theme info...
487 515
 		$context['poll'] = array(
@@ -596,18 +624,22 @@  discard block
 block discarded – undo
596 624
 	global $user_info, $smcFunc, $sourcedir;
597 625
 
598 626
 	// Sneaking off, are we?
599
-	if (empty($_POST))
600
-		redirectexit('action=editpoll;topic=' . $topic . '.0');
627
+	if (empty($_POST)) {
628
+			redirectexit('action=editpoll;topic=' . $topic . '.0');
629
+	}
601 630
 
602
-	if (checkSession('post', '', false) != '')
603
-		$poll_errors[] = 'session_timeout';
631
+	if (checkSession('post', '', false) != '') {
632
+			$poll_errors[] = 'session_timeout';
633
+	}
604 634
 
605
-	if (isset($_POST['preview']))
606
-		return EditPoll();
635
+	if (isset($_POST['preview'])) {
636
+			return EditPoll();
637
+	}
607 638
 
608 639
 	// HACKERS (!!) can't edit :P.
609
-	if (empty($topic))
610
-		fatal_lang_error('no_access', false);
640
+	if (empty($topic)) {
641
+			fatal_lang_error('no_access', false);
642
+	}
611 643
 
612 644
 	// Is this a new poll, or editing an existing?
613 645
 	$isEdit = isset($_REQUEST['add']) ? 0 : 1;
@@ -623,23 +655,27 @@  discard block
 block discarded – undo
623 655
 			'current_topic' => $topic,
624 656
 		)
625 657
 	);
626
-	if ($smcFunc['db_num_rows']($request) == 0)
627
-		fatal_lang_error('no_board');
658
+	if ($smcFunc['db_num_rows']($request) == 0) {
659
+			fatal_lang_error('no_board');
660
+	}
628 661
 	$bcinfo = $smcFunc['db_fetch_assoc']($request);
629 662
 	$smcFunc['db_free_result']($request);
630 663
 
631 664
 	// Check their adding/editing is valid.
632
-	if (!$isEdit && !empty($bcinfo['id_poll']))
633
-		fatal_lang_error('poll_already_exists');
665
+	if (!$isEdit && !empty($bcinfo['id_poll'])) {
666
+			fatal_lang_error('poll_already_exists');
667
+	}
634 668
 	// Are we editing a poll which doesn't exist?
635
-	elseif ($isEdit && empty($bcinfo['id_poll']))
636
-		fatal_lang_error('poll_not_found');
669
+	elseif ($isEdit && empty($bcinfo['id_poll'])) {
670
+			fatal_lang_error('poll_not_found');
671
+	}
637 672
 
638 673
 	// Check if they have the power to add or edit the poll.
639
-	if ($isEdit && !allowedTo('poll_edit_any'))
640
-		isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any'));
641
-	elseif (!$isEdit && !allowedTo('poll_add_any'))
642
-		isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any'));
674
+	if ($isEdit && !allowedTo('poll_edit_any')) {
675
+			isAllowedTo('poll_edit_' . ($user_info['id'] == $bcinfo['id_member_started'] || ($bcinfo['poll_starter'] != 0 && $user_info['id'] == $bcinfo['poll_starter']) ? 'own' : 'any'));
676
+	} elseif (!$isEdit && !allowedTo('poll_add_any')) {
677
+			isAllowedTo('poll_add_' . ($user_info['id'] == $bcinfo['id_member_started'] ? 'own' : 'any'));
678
+	}
643 679
 
644 680
 	$optionCount = 0;
645 681
 	$idCount = 0;
@@ -652,14 +688,16 @@  discard block
 block discarded – undo
652 688
 			$idCount = max($idCount, $k);
653 689
 		}
654 690
 	}
655
-	if ($optionCount < 2)
656
-		$poll_errors[] = 'poll_few';
657
-	elseif ($optionCount > 256 || $idCount > 255)
658
-		$poll_errors[] = 'poll_many';
691
+	if ($optionCount < 2) {
692
+			$poll_errors[] = 'poll_few';
693
+	} elseif ($optionCount > 256 || $idCount > 255) {
694
+			$poll_errors[] = 'poll_many';
695
+	}
659 696
 
660 697
 	// Also - ensure they are not removing the question.
661
-	if (trim($_POST['question']) == '')
662
-		$poll_errors[] = 'no_question';
698
+	if (trim($_POST['question']) == '') {
699
+			$poll_errors[] = 'no_question';
700
+	}
663 701
 
664 702
 	// Got any errors to report?
665 703
 	if (!empty($poll_errors))
@@ -695,8 +733,9 @@  discard block
 block discarded – undo
695 733
 	{
696 734
 		require_once($sourcedir . '/Subs-Members.php');
697 735
 		$allowedGroups = groupsAllowedTo('poll_vote', $board);
698
-		if (!in_array(-1, $allowedGroups['allowed']))
699
-			$_POST['poll_guest_vote'] = 0;
736
+		if (!in_array(-1, $allowedGroups['allowed'])) {
737
+					$_POST['poll_guest_vote'] = 0;
738
+		}
700 739
 	}
701 740
 
702 741
 	// Ensure that the number options allowed makes sense, and the expiration date is valid.
@@ -704,17 +743,19 @@  discard block
 block discarded – undo
704 743
 	{
705 744
 		$_POST['poll_expire'] = $_POST['poll_expire'] > 9999 ? 9999 : ($_POST['poll_expire'] < 0 ? 0 : $_POST['poll_expire']);
706 745
 
707
-		if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2)
708
-			$_POST['poll_hide'] = 1;
709
-		elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24)))
710
-			$_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24;
711
-		else
712
-			$_POST['poll_expire'] = $bcinfo['expire_time'];
746
+		if (empty($_POST['poll_expire']) && $_POST['poll_hide'] == 2) {
747
+					$_POST['poll_hide'] = 1;
748
+		} elseif (!$isEdit || $_POST['poll_expire'] != ceil($bcinfo['expire_time'] <= time() ? -1 : ($bcinfo['expire_time'] - time()) / (3600 * 24))) {
749
+					$_POST['poll_expire'] = empty($_POST['poll_expire']) ? '0' : time() + $_POST['poll_expire'] * 3600 * 24;
750
+		} else {
751
+					$_POST['poll_expire'] = $bcinfo['expire_time'];
752
+		}
713 753
 
714
-		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0)
715
-			$_POST['poll_max_votes'] = 1;
716
-		else
717
-			$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
754
+		if (empty($_POST['poll_max_votes']) || $_POST['poll_max_votes'] <= 0) {
755
+					$_POST['poll_max_votes'] = 1;
756
+		} else {
757
+					$_POST['poll_max_votes'] = (int) $_POST['poll_max_votes'];
758
+		}
718 759
 	}
719 760
 
720 761
 	// If we're editing, let's commit the changes.
@@ -781,8 +822,9 @@  discard block
 block discarded – undo
781 822
 		)
782 823
 	);
783 824
 	$choices = array();
784
-	while ($row = $smcFunc['db_fetch_assoc']($request))
785
-		$choices[] = $row['id_choice'];
825
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
826
+			$choices[] = $row['id_choice'];
827
+	}
786 828
 	$smcFunc['db_free_result']($request);
787 829
 
788 830
 	$delete_options = array();
@@ -795,8 +837,9 @@  discard block
 block discarded – undo
795 837
 		if (trim($option) == '')
796 838
 		{
797 839
 			// They want it deleted.  Bye.
798
-			if (in_array($k, $choices))
799
-				$delete_options[] = $k;
840
+			if (in_array($k, $choices)) {
841
+							$delete_options[] = $k;
842
+			}
800 843
 
801 844
 			// Skip the rest...
802 845
 			continue;
@@ -806,8 +849,8 @@  discard block
 block discarded – undo
806 849
 		$option = $smcFunc['htmlspecialchars']($option);
807 850
 
808 851
 		// If it's already there, update it.  If it's not... add it.
809
-		if (in_array($k, $choices))
810
-			$smcFunc['db_query']('', '
852
+		if (in_array($k, $choices)) {
853
+					$smcFunc['db_query']('', '
811 854
 				UPDATE {db_prefix}poll_choices
812 855
 				SET label = {string:option_name}
813 856
 				WHERE id_poll = {int:id_poll}
@@ -818,8 +861,8 @@  discard block
 block discarded – undo
818 861
 					'option_name' => $option,
819 862
 				)
820 863
 			);
821
-		else
822
-			$smcFunc['db_insert']('',
864
+		} else {
865
+					$smcFunc['db_insert']('',
823 866
 				'{db_prefix}poll_choices',
824 867
 				array(
825 868
 					'id_poll' => 'int', 'id_choice' => 'int', 'label' => 'string-255', 'votes' => 'int',
@@ -829,6 +872,7 @@  discard block
 block discarded – undo
829 872
 				),
830 873
 				array()
831 874
 			);
875
+		}
832 876
 	}
833 877
 
834 878
 	// I'm sorry, but... well, no one was choosing you.  Poor options, I'll put you out of your misery.
@@ -894,13 +938,11 @@  discard block
 block discarded – undo
894 938
 	{
895 939
 		// Added a poll
896 940
 		logAction('add_poll', array('topic' => $topic));
897
-	}
898
-	elseif (isset($_REQUEST['deletevotes']))
941
+	} elseif (isset($_REQUEST['deletevotes']))
899 942
 	{
900 943
 		// Reset votes
901 944
 		logAction('reset_poll', array('topic' => $topic));
902
-	}
903
-	else
945
+	} else
904 946
 	{
905 947
 		// Something else
906 948
 		logAction('editpoll', array('topic' => $topic));
@@ -923,8 +965,9 @@  discard block
 block discarded – undo
923 965
 	global $topic, $user_info, $smcFunc;
924 966
 
925 967
 	// Make sure the topic is not empty.
926
-	if (empty($topic))
927
-		fatal_lang_error('no_access', false);
968
+	if (empty($topic)) {
969
+			fatal_lang_error('no_access', false);
970
+	}
928 971
 
929 972
 	// Verify the session.
930 973
 	checkSession('get');
@@ -942,8 +985,9 @@  discard block
 block discarded – undo
942 985
 				'current_topic' => $topic,
943 986
 			)
944 987
 		);
945
-		if ($smcFunc['db_num_rows']($request) == 0)
946
-			fatal_lang_error('no_access', false);
988
+		if ($smcFunc['db_num_rows']($request) == 0) {
989
+					fatal_lang_error('no_access', false);
990
+		}
947 991
 		list ($topicStarter, $pollStarter) = $smcFunc['db_fetch_row']($request);
948 992
 		$smcFunc['db_free_result']($request);
949 993
 
Please login to merge, or discard this patch.
Sources/tasks/UpdateTldRegex.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@
 block discarded – undo
18 18
  */
19 19
 class Update_TLD_Regex extends SMF_BackgroundTask
20 20
 {
21
-    /**
22
-     * This executes the task. It just calls set_tld_regex() in Subs.php
23
-     * @return bool Always returns true
24
-     */
21
+	/**
22
+	 * This executes the task. It just calls set_tld_regex() in Subs.php
23
+	 * @return bool Always returns true
24
+	 */
25 25
 	public function execute()
26 26
  	{
27 27
 		global $sourcedir;
Please login to merge, or discard this patch.
Sources/tasks/ApprovePost-Notify.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 class ApprovePost_Notify_Background extends SMF_BackgroundTask
19 19
 {
20 20
 	/**
21
-     * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed.
21
+	 * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed.
22 22
 	 * @return bool Always returns true
23 23
 	 */
24 24
 	public function execute()
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,8 +54,9 @@  discard block
 block discarded – undo
54 54
 		}
55 55
 		$smcFunc['db_free_result']($request);
56 56
 
57
-		if (empty($members))
58
-			return true;
57
+		if (empty($members)) {
58
+					return true;
59
+		}
59 60
 
60 61
 		require_once($sourcedir . '/Subs-Notify.php');
61 62
 		$members = array_unique($members);
@@ -103,14 +104,15 @@  discard block
 block discarded – undo
103 104
 		}
104 105
 
105 106
 		// Insert the alerts if any
106
-		if (!empty($alert_rows))
107
-			$smcFunc['db_insert']('',
107
+		if (!empty($alert_rows)) {
108
+					$smcFunc['db_insert']('',
108 109
 				'{db_prefix}user_alerts',
109 110
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
110 111
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
111 112
 				$alert_rows,
112 113
 				array()
113 114
 			);
115
+		}
114 116
 
115 117
 		return true;
116 118
 	}
Please login to merge, or discard this patch.
Sources/tasks/Register-Notify.php 2 patches
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,9 +43,10 @@  discard block
 block discarded – undo
43 43
 
44 44
 		foreach ($prefs as $member => $pref_option)
45 45
 		{
46
-			foreach ($alert_bits as $type => $bitvalue)
47
-				if ($pref_option['member_register'] & $bitvalue)
46
+			foreach ($alert_bits as $type => $bitvalue) {
47
+							if ($pref_option['member_register'] & $bitvalue)
48 48
 					$notifies[$type][] = $member;
49
+			}
49 50
 		}
50 51
 
51 52
 		// Firstly, anyone who wants alerts.
@@ -101,8 +102,9 @@  discard block
 block discarded – undo
101 102
 			);
102 103
 			while ($row = $smcFunc['db_fetch_assoc']($request))
103 104
 			{
104
-				if (empty($row['lngfile']))
105
-					$row['lngfile'] = $language;
105
+				if (empty($row['lngfile'])) {
106
+									$row['lngfile'] = $language;
107
+				}
106 108
 				$emails[$row['lngfile']][$row['id_member']] = $row['email_address'];
107 109
 			}
108 110
 			$smcFunc['db_free_result']($request);
@@ -126,8 +128,9 @@  discard block
 block discarded – undo
126 128
 				$emaildata = loadEmailTemplate($emailtype, $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang);
127 129
 
128 130
 				// And do the actual sending...
129
-				foreach ($recipients as $id_member => $email_address)
130
-					sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'newmember' . $this->_details['new_member_id'], $emaildata['is_html'], 0);
131
+				foreach ($recipients as $id_member => $email_address) {
132
+									sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'newmember' . $this->_details['new_member_id'], $emaildata['is_html'], 0);
133
+				}
131 134
 			}
132 135
 		}
133 136
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 class Likes_Notify_Background extends SMF_BackgroundTask
20 20
 {
21 21
 	/**
22
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
22
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
23 23
 	 * @return bool Always returns true
24 24
 	 */
25 25
 	public function execute()
Please login to merge, or discard this patch.
Sources/tasks/MemberReportReply-Notify.php 2 patches
Braces   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,8 +40,9 @@  discard block
 block discarded – undo
40 40
 				'last_comment' => $this->_details['comment_id'],
41 41
 			)
42 42
 		);
43
-		while ($row = $smcFunc['db_fetch_row']($request))
44
-			$possible_members[] = $row[0];
43
+		while ($row = $smcFunc['db_fetch_row']($request)) {
44
+					$possible_members[] = $row[0];
45
+		}
45 46
 		$smcFunc['db_free_result']($request);
46 47
 
47 48
 		// Presumably, there are some people?
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 			$possible_members = array_flip(array_flip($possible_members));
51 52
 			$possible_members = array_diff($possible_members, array($this->_details['sender_id']));
52 53
 		}
53
-		if (empty($possible_members))
54
-			return true;
54
+		if (empty($possible_members)) {
55
+					return true;
56
+		}
55 57
 
56 58
 		// We need to know who can moderate this board - and therefore who can see this report.
57 59
 		// First up, people who have moderate_board in the board this topic was in.
@@ -73,8 +75,9 @@  discard block
 block discarded – undo
73 75
 		{
74 76
 			foreach ($alert_bits as $type => $bitvalue)
75 77
 			{
76
-				if ($pref_option['member_report_reply'] & $bitvalue)
77
-					$notifies[$type][] = $member;
78
+				if ($pref_option['member_report_reply'] & $bitvalue) {
79
+									$notifies[$type][] = $member;
80
+				}
78 81
 			}
79 82
 		}
80 83
 
@@ -136,8 +139,9 @@  discard block
 block discarded – undo
136 139
 			);
137 140
 			while ($row = $smcFunc['db_fetch_assoc']($request))
138 141
 			{
139
-				if (empty($row['lngfile']))
140
-					$row['lngfile'] = $language;
142
+				if (empty($row['lngfile'])) {
143
+									$row['lngfile'] = $language;
144
+				}
141 145
 				$emails[$row['lngfile']][$row['id_member']] = $row['email_address'];
142 146
 			}
143 147
 			$smcFunc['db_free_result']($request);
@@ -155,8 +159,9 @@  discard block
 block discarded – undo
155 159
 				$emaildata = loadEmailTemplate('reply_to_user_reports', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang);
156 160
 
157 161
 				// And do the actual sending...
158
-				foreach ($recipients as $id_member => $email_address)
159
-					sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3);
162
+				foreach ($recipients as $id_member => $email_address) {
163
+									sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3);
164
+				}
160 165
 			}
161 166
 		}
162 167
 
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 class Likes_Notify_Background extends SMF_BackgroundTask
20 20
 {
21 21
 	/**
22
-     * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
22
+	 * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed.
23 23
 	 * @return bool Always returns true
24 24
 	 */
25 25
 	public function execute()
Please login to merge, or discard this patch.