Completed
Push — release-2.1 ( 15f485...0da2ef )
by Mathias
07:51
created
Sources/ManageSettings.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
 					'class' => 'centercol',
1324 1324
 				),
1325 1325
 				'data' => array(
1326
-					'function' => function ($rowData)
1326
+					'function' => function($rowData)
1327 1327
 					{
1328 1328
 						$isChecked = $rowData['disabled'] ? '' : ' checked';
1329 1329
 						$onClickHandler = $rowData['can_show_register'] ? sprintf(' onclick="document.getElementById(\'reg_%1$s\').disabled = !this.checked;"', $rowData['id']) : '';
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 					'class' => 'centercol',
1340 1340
 				),
1341 1341
 				'data' => array(
1342
-					'function' => function ($rowData)
1342
+					'function' => function($rowData)
1343 1343
 					{
1344 1344
 						$isChecked = $rowData['on_register'] && !$rowData['disabled'] ? ' checked' : '';
1345 1345
 						$isDisabled = $rowData['can_show_register'] ? '' : ' disabled';
@@ -1386,15 +1386,15 @@  discard block
 block discarded – undo
1386 1386
 					'value' => $txt['custom_profile_fieldorder'],
1387 1387
 				),
1388 1388
 				'data' => array(
1389
-					'function' => function ($rowData) use ($context, $txt, $scripturl)
1389
+					'function' => function($rowData) use ($context, $txt, $scripturl)
1390 1390
 					{
1391
-						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />';
1391
+						$return = '<p class="centertext bold_text">' . $rowData['field_order'] . '<br />';
1392 1392
 
1393 1393
 						if ($rowData['field_order'] > 1)
1394
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1394
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_up'] . '"></span></a>';
1395 1395
 
1396 1396
 						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1397
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1397
+							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="' . $txt['custom_edit_order_move'] . ' ' . $txt['custom_edit_order_down'] . '"></span></a>';
1398 1398
 
1399 1399
 						$return .= '</p>';
1400 1400
 
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 					'value' => $txt['custom_profile_fieldname'],
1413 1413
 				),
1414 1414
 				'data' => array(
1415
-					'function' => function ($rowData) use ($scripturl)
1415
+					'function' => function($rowData) use ($scripturl)
1416 1416
 					{
1417 1417
 						return sprintf('<a href="%1$s?action=admin;area=featuresettings;sa=profileedit;fid=%2$d">%3$s</a><div class="smalltext">%4$s</div>', $scripturl, $rowData['id_field'], $rowData['field_name'], $rowData['field_desc']);
1418 1418
 					},
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 					'value' => $txt['custom_profile_fieldtype'],
1429 1429
 				),
1430 1430
 				'data' => array(
1431
-					'function' => function ($rowData) use ($txt)
1431
+					'function' => function($rowData) use ($txt)
1432 1432
 					{
1433 1433
 						$textKey = sprintf('custom_profile_type_%1$s', $rowData['field_type']);
1434 1434
 						return isset($txt[$textKey]) ? $txt[$textKey] : $textKey;
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
 					'value' => $txt['custom_profile_active'],
1447 1447
 				),
1448 1448
 				'data' => array(
1449
-					'function' => function ($rowData) use ($txt)
1449
+					'function' => function($rowData) use ($txt)
1450 1450
 					{
1451 1451
 						return $rowData['active'] ? $txt['yes'] : $txt['no'];
1452 1452
 					},
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
 					'value' => $txt['custom_profile_placement'],
1464 1464
 				),
1465 1465
 				'data' => array(
1466
-					'function' => function ($rowData)
1466
+					'function' => function($rowData)
1467 1467
 					{
1468 1468
 						global $txt, $context;
1469 1469
 
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1699 1699
 
1700 1700
 		// All good, proceed.
1701
-		$smcFunc['db_query']('','
1701
+		$smcFunc['db_query']('', '
1702 1702
 			UPDATE {db_prefix}custom_fields
1703 1703
 			SET field_order = {int:old_order}
1704 1704
 			WHERE field_order = {int:new_order}',
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 				'old_order' => $context['field']['order'],
1708 1708
 			)
1709 1709
 		);
1710
-		$smcFunc['db_query']('','
1710
+		$smcFunc['db_query']('', '
1711 1711
 			UPDATE {db_prefix}custom_fields
1712 1712
 			SET field_order = {int:new_order}
1713 1713
 			WHERE id_field = {int:id_field}',
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
 			$smcFunc['db_free_result']($request);
1810 1810
 
1811 1811
 			$unique = false;
1812
-			for ($i = 0; !$unique && $i < 9; $i ++)
1812
+			for ($i = 0; !$unique && $i < 9; $i++)
1813 1813
 			{
1814 1814
 				if (!in_array($col_name, $current_fields))
1815 1815
 					$unique = true;
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 		);
1983 1983
 
1984 1984
 		// Re-arrange the order.
1985
-		$smcFunc['db_query']('','
1985
+		$smcFunc['db_query']('', '
1986 1986
 			UPDATE {db_prefix}custom_fields
1987 1987
 			SET field_order = field_order - 1
1988 1988
 			WHERE field_order > {int:current_order}',
@@ -2246,7 +2246,7 @@  discard block
 block discarded – undo
2246 2246
 	$context['token_check'] = 'noti-admin';
2247 2247
 
2248 2248
 	// Specify our action since we'll want to post back here instead of the profile
2249
-	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;'. $context['session_var'] .'='. $context['session_id'];
2249
+	$context['action'] = 'action=admin;area=featuresettings;sa=alerts;' . $context['session_var'] . '=' . $context['session_id'];
2250 2250
 
2251 2251
 	loadTemplate('Profile');
2252 2252
 	loadLanguage('Profile');
Please login to merge, or discard this patch.
Braces   +273 added lines, -199 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@  discard block
 block discarded – undo
14 14
  * @version 2.1 Beta 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
  * This function makes sure the requested subaction does exists, if it doesn't, it sets a default action or.
@@ -202,16 +203,18 @@  discard block
 block discarded – undo
202 203
 	{
203 204
 		$all_zones = timezone_identifiers_list();
204 205
 		// Make sure we set the value to the same as the printed value.
205
-		foreach ($all_zones as $zone)
206
-			$config_vars['default_timezone'][2][$zone] = $zone;
206
+		foreach ($all_zones as $zone) {
207
+					$config_vars['default_timezone'][2][$zone] = $zone;
208
+		}
209
+	} else {
210
+			unset($config_vars['default_timezone']);
207 211
 	}
208
-	else
209
-		unset($config_vars['default_timezone']);
210 212
 
211 213
 	call_integration_hook('integrate_modify_basic_settings', array(&$config_vars));
212 214
 
213
-	if ($return_config)
214
-		return $config_vars;
215
+	if ($return_config) {
216
+			return $config_vars;
217
+	}
215 218
 
216 219
 	// Saving?
217 220
 	if (isset($_GET['save']))
@@ -219,8 +222,9 @@  discard block
 block discarded – undo
219 222
 		checkSession();
220 223
 
221 224
 		// Prevent absurd boundaries here - make it a day tops.
222
-		if (isset($_POST['lastActive']))
223
-			$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
225
+		if (isset($_POST['lastActive'])) {
226
+					$_POST['lastActive'] = min((int) $_POST['lastActive'], 1440);
227
+		}
224 228
 
225 229
 		call_integration_hook('integrate_save_basic_settings');
226 230
 
@@ -265,8 +269,9 @@  discard block
 block discarded – undo
265 269
 
266 270
 	call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars));
267 271
 
268
-	if ($return_config)
269
-		return $config_vars;
272
+	if ($return_config) {
273
+			return $config_vars;
274
+	}
270 275
 
271 276
 	// Setup the template.
272 277
 	require_once($sourcedir . '/ManageServer.php');
@@ -283,13 +288,15 @@  discard block
 block discarded – undo
283 288
 
284 289
 		// Clean up the tags.
285 290
 		$bbcTags = array();
286
-		foreach (parse_bbc(false) as $tag)
287
-			$bbcTags[] = $tag['tag'];
291
+		foreach (parse_bbc(false) as $tag) {
292
+					$bbcTags[] = $tag['tag'];
293
+		}
288 294
 
289
-		if (!isset($_POST['disabledBBC_enabledTags']))
290
-			$_POST['disabledBBC_enabledTags'] = array();
291
-		elseif (!is_array($_POST['disabledBBC_enabledTags']))
292
-			$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
295
+		if (!isset($_POST['disabledBBC_enabledTags'])) {
296
+					$_POST['disabledBBC_enabledTags'] = array();
297
+		} elseif (!is_array($_POST['disabledBBC_enabledTags'])) {
298
+					$_POST['disabledBBC_enabledTags'] = array($_POST['disabledBBC_enabledTags']);
299
+		}
293 300
 		// Work out what is actually disabled!
294 301
 		$_POST['disabledBBC'] = implode(',', array_diff($bbcTags, $_POST['disabledBBC_enabledTags']));
295 302
 
@@ -333,8 +340,9 @@  discard block
 block discarded – undo
333 340
 
334 341
 	call_integration_hook('integrate_layout_settings', array(&$config_vars));
335 342
 
336
-	if ($return_config)
337
-		return $config_vars;
343
+	if ($return_config) {
344
+			return $config_vars;
345
+	}
338 346
 
339 347
 	// Saving?
340 348
 	if (isset($_GET['save']))
@@ -375,8 +383,9 @@  discard block
 block discarded – undo
375 383
 
376 384
 	call_integration_hook('integrate_likes_settings', array(&$config_vars));
377 385
 
378
-	if ($return_config)
379
-		return $config_vars;
386
+	if ($return_config) {
387
+			return $config_vars;
388
+	}
380 389
 
381 390
 	// Saving?
382 391
 	if (isset($_GET['save']))
@@ -414,8 +423,9 @@  discard block
 block discarded – undo
414 423
 
415 424
 	call_integration_hook('integrate_mentions_settings', array(&$config_vars));
416 425
 
417
-	if ($return_config)
418
-		return $config_vars;
426
+	if ($return_config) {
427
+			return $config_vars;
428
+	}
419 429
 
420 430
 	// Saving?
421 431
 	if (isset($_GET['save']))
@@ -459,8 +469,8 @@  discard block
 block discarded – undo
459 469
 			'enable' => array('check', 'warning_enable'),
460 470
 	);
461 471
 
462
-	if (!empty($modSettings['warning_settings']) && $currently_enabled)
463
-		$config_vars += array(
472
+	if (!empty($modSettings['warning_settings']) && $currently_enabled) {
473
+			$config_vars += array(
464 474
 			'',
465 475
 				array('int', 'warning_watch', 'subtext' => $txt['setting_warning_watch_note'] . ' ' . $txt['zero_to_disable']),
466 476
 				'moderate' => array('int', 'warning_moderate', 'subtext' => $txt['setting_warning_moderate_note'] . ' ' . $txt['zero_to_disable']),
@@ -469,15 +479,18 @@  discard block
 block discarded – undo
469 479
 				'rem2' => array('int', 'warning_decrement', 'subtext' => $txt['setting_warning_decrement_note'] . ' ' . $txt['zero_to_disable']),
470 480
 				array('permissions', 'view_warning'),
471 481
 		);
482
+	}
472 483
 
473 484
 	call_integration_hook('integrate_warning_settings', array(&$config_vars));
474 485
 
475
-	if ($return_config)
476
-		return $config_vars;
486
+	if ($return_config) {
487
+			return $config_vars;
488
+	}
477 489
 
478 490
 	// Cannot use moderation if post moderation is not enabled.
479
-	if (!$modSettings['postmod_active'])
480
-		unset($config_vars['moderate']);
491
+	if (!$modSettings['postmod_active']) {
492
+			unset($config_vars['moderate']);
493
+	}
481 494
 
482 495
 	// Will need the utility functions from here.
483 496
 	require_once($sourcedir . '/ManageServer.php');
@@ -502,16 +515,16 @@  discard block
 block discarded – undo
502 515
 				'warning_watch' => 10,
503 516
 				'warning_mute' => 60,
504 517
 			);
505
-			if ($modSettings['postmod_active'])
506
-				$vars['warning_moderate'] = 35;
518
+			if ($modSettings['postmod_active']) {
519
+							$vars['warning_moderate'] = 35;
520
+			}
507 521
 
508 522
 			foreach ($vars as $var => $value)
509 523
 			{
510 524
 				$config_vars[] = array('int', $var);
511 525
 				$_POST[$var] = $value;
512 526
 			}
513
-		}
514
-		else
527
+		} else
515 528
 		{
516 529
 			$_POST['warning_watch'] = min($_POST['warning_watch'], 100);
517 530
 			$_POST['warning_moderate'] = $modSettings['postmod_active'] ? min($_POST['warning_moderate'], 100) : 0;
@@ -592,8 +605,9 @@  discard block
 block discarded – undo
592 605
 
593 606
 	call_integration_hook('integrate_spam_settings', array(&$config_vars));
594 607
 
595
-	if ($return_config)
596
-		return $config_vars;
608
+	if ($return_config) {
609
+			return $config_vars;
610
+	}
597 611
 
598 612
 	// You need to be an admin to edit settings!
599 613
 	isAllowedTo('admin_forum');
@@ -627,8 +641,9 @@  discard block
 block discarded – undo
627 641
 
628 642
 	if (empty($context['qa_by_lang'][strtr($language, array('-utf8' => ''))]) && !empty($context['question_answers']))
629 643
 	{
630
-		if (empty($context['settings_insert_above']))
631
-			$context['settings_insert_above'] = '';
644
+		if (empty($context['settings_insert_above'])) {
645
+					$context['settings_insert_above'] = '';
646
+		}
632 647
 
633 648
 		$context['settings_insert_above'] .= '<div class="noticebox">' . sprintf($txt['question_not_defined'], $context['languages'][$language]['name']) . '</div>';
634 649
 	}
@@ -671,8 +686,9 @@  discard block
 block discarded – undo
671 686
 		$_POST['pm_spam_settings'] = (int) $_POST['max_pm_recipients'] . ',' . (int) $_POST['pm_posts_verification'] . ',' . (int) $_POST['pm_posts_per_hour'];
672 687
 
673 688
 		// Hack in guest requiring verification!
674
-		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha']))
675
-			$_POST['posts_require_captcha'] = -1;
689
+		if (empty($_POST['posts_require_captcha']) && !empty($_POST['guests_require_captcha'])) {
690
+					$_POST['posts_require_captcha'] = -1;
691
+		}
676 692
 
677 693
 		$save_vars = $config_vars;
678 694
 		unset($save_vars['pm1'], $save_vars['pm2'], $save_vars['pm3'], $save_vars['guest_verify']);
@@ -689,14 +705,16 @@  discard block
 block discarded – undo
689 705
 		foreach ($context['qa_languages'] as $lang_id => $dummy)
690 706
 		{
691 707
 			// If we had some questions for this language before, but don't now, delete everything from that language.
692
-			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id]))
693
-				$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
708
+			if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty($context['qa_by_lang'][$lang_id])) {
709
+							$changes['delete'] = array_merge($questions['delete'], $context['qa_by_lang'][$lang_id]);
710
+			}
694 711
 
695 712
 			// Now step through and see if any existing questions no longer exist.
696
-			if (!empty($context['qa_by_lang'][$lang_id]))
697
-				foreach ($context['qa_by_lang'][$lang_id] as $q_id)
713
+			if (!empty($context['qa_by_lang'][$lang_id])) {
714
+							foreach ($context['qa_by_lang'][$lang_id] as $q_id)
698 715
 					if (empty($_POST['question'][$lang_id][$q_id]))
699 716
 						$changes['delete'][] = $q_id;
717
+			}
700 718
 
701 719
 			// Now let's see if there are new questions or ones that need updating.
702 720
 			if (isset($_POST['question'][$lang_id]))
@@ -705,14 +723,16 @@  discard block
 block discarded – undo
705 723
 				{
706 724
 					// Ignore junky ids.
707 725
 					$q_id = (int) $q_id;
708
-					if ($q_id <= 0)
709
-						continue;
726
+					if ($q_id <= 0) {
727
+											continue;
728
+					}
710 729
 
711 730
 					// Check the question isn't empty (because they want to delete it?)
712 731
 					if (empty($question) || trim($question) == '')
713 732
 					{
714
-						if (isset($context['question_answers'][$q_id]))
715
-							$changes['delete'][] = $q_id;
733
+						if (isset($context['question_answers'][$q_id])) {
734
+													$changes['delete'][] = $q_id;
735
+						}
716 736
 						continue;
717 737
 					}
718 738
 					$question = $smcFunc['htmlspecialchars'](trim($question));
@@ -720,19 +740,22 @@  discard block
 block discarded – undo
720 740
 					// Get the answers. Firstly check there actually might be some.
721 741
 					if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id]))
722 742
 					{
723
-						if (isset($context['question_answers'][$q_id]))
724
-							$changes['delete'][] = $q_id;
743
+						if (isset($context['question_answers'][$q_id])) {
744
+													$changes['delete'][] = $q_id;
745
+						}
725 746
 						continue;
726 747
 					}
727 748
 					// Now get them and check that they might be viable.
728 749
 					$answers = array();
729
-					foreach ($_POST['answer'][$lang_id][$q_id] as $answer)
730
-						if (!empty($answer) && trim($answer) !== '')
750
+					foreach ($_POST['answer'][$lang_id][$q_id] as $answer) {
751
+											if (!empty($answer) && trim($answer) !== '')
731 752
 							$answers[] = $smcFunc['htmlspecialchars'](trim($answer));
753
+					}
732 754
 					if (empty($answers))
733 755
 					{
734
-						if (isset($context['question_answers'][$q_id]))
735
-							$changes['delete'][] = $q_id;
756
+						if (isset($context['question_answers'][$q_id])) {
757
+													$changes['delete'][] = $q_id;
758
+						}
736 759
 						continue;
737 760
 					}
738 761
 					$answers = json_encode($answers);
@@ -742,16 +765,17 @@  discard block
 block discarded – undo
742 765
 					{
743 766
 						// New question. Now, we don't want to randomly consume ids, so we'll set those, rather than trusting the browser's supplied ids.
744 767
 						$changes['insert'][] = array($lang_id, $question, $answers);
745
-					}
746
-					else
768
+					} else
747 769
 					{
748 770
 						// It's an existing question. Let's see what's changed, if anything.
749
-						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers'])
750
-							$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
771
+						if ($lang_id != $context['question_answers'][$q_id]['lngfile'] || $question != $context['question_answers'][$q_id]['question'] || $answers != $context['question_answers'][$q_id]['answers']) {
772
+													$changes['replace'][$q_id] = array('lngfile' => $lang_id, 'question' => $question, 'answers' => $answers);
773
+						}
751 774
 					}
752 775
 
753
-					if (!isset($qs_per_lang[$lang_id]))
754
-						$qs_per_lang[$lang_id] = 0;
776
+					if (!isset($qs_per_lang[$lang_id])) {
777
+											$qs_per_lang[$lang_id] = 0;
778
+					}
755 779
 					$qs_per_lang[$lang_id]++;
756 780
 				}
757 781
 			}
@@ -801,8 +825,9 @@  discard block
 block discarded – undo
801 825
 
802 826
 		// Lastly, the count of messages needs to be no more than the lowest number of questions for any one language.
803 827
 		$count_questions = empty($qs_per_lang) ? 0 : min($qs_per_lang);
804
-		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions)
805
-			$_POST['qa_verification_number'] = $count_questions;
828
+		if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) {
829
+					$_POST['qa_verification_number'] = $count_questions;
830
+		}
806 831
 
807 832
 		call_integration_hook('integrate_save_spam_settings', array(&$save_vars));
808 833
 
@@ -817,24 +842,27 @@  discard block
 block discarded – undo
817 842
 
818 843
 	$character_range = array_merge(range('A', 'H'), array('K', 'M', 'N', 'P', 'R'), range('T', 'Y'));
819 844
 	$_SESSION['visual_verification_code'] = '';
820
-	for ($i = 0; $i < 6; $i++)
821
-		$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
845
+	for ($i = 0; $i < 6; $i++) {
846
+			$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
847
+	}
822 848
 
823 849
 	// Some javascript for CAPTCHA.
824 850
 	$context['settings_post_javascript'] = '';
825
-	if ($context['use_graphic_library'])
826
-		$context['settings_post_javascript'] .= '
851
+	if ($context['use_graphic_library']) {
852
+			$context['settings_post_javascript'] .= '
827 853
 		function refreshImages()
828 854
 		{
829 855
 			var imageType = document.getElementById(\'visual_verification_type\').value;
830 856
 			document.getElementById(\'verification_image\').src = \'' . $context['verification_image_href'] . ';type=\' + imageType;
831 857
 		}';
858
+	}
832 859
 
833 860
 	// Show the image itself, or text saying we can't.
834
-	if ($context['use_graphic_library'])
835
-		$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
836
-	else
837
-		$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
861
+	if ($context['use_graphic_library']) {
862
+			$config_vars['vv']['postinput'] = '<br><img src="' . $context['verification_image_href'] . ';type=' . (empty($modSettings['visual_verification_type']) ? 0 : $modSettings['visual_verification_type']) . '" alt="' . $txt['setting_image_verification_sample'] . '" id="verification_image"><br>';
863
+	} else {
864
+			$config_vars['vv']['postinput'] = '<br><span class="smalltext">' . $txt['setting_image_verification_nogd'] . '</span>';
865
+	}
838 866
 
839 867
 	// Hack for PM spam settings.
840 868
 	list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);
@@ -844,9 +872,10 @@  discard block
 block discarded – undo
844 872
 	$modSettings['posts_require_captcha'] = !isset($modSettings['posts_require_captcha']) || $modSettings['posts_require_captcha'] == -1 ? 0 : $modSettings['posts_require_captcha'];
845 873
 
846 874
 	// Some minor javascript for the guest post setting.
847
-	if ($modSettings['posts_require_captcha'])
848
-		$context['settings_post_javascript'] .= '
875
+	if ($modSettings['posts_require_captcha']) {
876
+			$context['settings_post_javascript'] .= '
849 877
 		document.getElementById(\'guests_require_captcha\').disabled = true;';
878
+	}
850 879
 
851 880
 	// And everything else.
852 881
 	$context['post_url'] = $scripturl . '?action=admin;area=antispam;save';
@@ -893,8 +922,9 @@  discard block
 block discarded – undo
893 922
 
894 923
 	call_integration_hook('integrate_signature_settings', array(&$config_vars));
895 924
 
896
-	if ($return_config)
897
-		return $config_vars;
925
+	if ($return_config) {
926
+			return $config_vars;
927
+	}
898 928
 
899 929
 	// Setup the template.
900 930
 	$context['page_title'] = $txt['signature_settings'];
@@ -949,8 +979,9 @@  discard block
 block discarded – undo
949 979
 				$sig = strtr($row['signature'], array('<br>' => "\n"));
950 980
 
951 981
 				// Max characters...
952
-				if (!empty($sig_limits[1]))
953
-					$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
982
+				if (!empty($sig_limits[1])) {
983
+									$sig = $smcFunc['substr']($sig, 0, $sig_limits[1]);
984
+				}
954 985
 				// Max lines...
955 986
 				if (!empty($sig_limits[2]))
956 987
 				{
@@ -960,8 +991,9 @@  discard block
 block discarded – undo
960 991
 						if ($sig[$i] == "\n")
961 992
 						{
962 993
 							$count++;
963
-							if ($count >= $sig_limits[2])
964
-								$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
994
+							if ($count >= $sig_limits[2]) {
995
+															$sig = substr($sig, 0, $i) . strtr(substr($sig, $i), array("\n" => ' '));
996
+							}
965 997
 						}
966 998
 					}
967 999
 				}
@@ -972,17 +1004,19 @@  discard block
 block discarded – undo
972 1004
 					{
973 1005
 						$limit_broke = 0;
974 1006
 						// Attempt to allow all sizes of abuse, so to speak.
975
-						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7])
976
-							$limit_broke = $sig_limits[7] . 'px';
977
-						elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75))
978
-							$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
979
-						elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16))
980
-							$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
981
-						elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18)
982
-							$limit_broke = 'large';
983
-
984
-						if ($limit_broke)
985
-							$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1007
+						if ($matches[2][$ind] == 'px' && $size > $sig_limits[7]) {
1008
+													$limit_broke = $sig_limits[7] . 'px';
1009
+						} elseif ($matches[2][$ind] == 'pt' && $size > ($sig_limits[7] * 0.75)) {
1010
+													$limit_broke = ((int) $sig_limits[7] * 0.75) . 'pt';
1011
+						} elseif ($matches[2][$ind] == 'em' && $size > ((float) $sig_limits[7] / 16)) {
1012
+													$limit_broke = ((float) $sig_limits[7] / 16) . 'em';
1013
+						} elseif ($matches[2][$ind] != 'px' && $matches[2][$ind] != 'pt' && $matches[2][$ind] != 'em' && $sig_limits[7] < 18) {
1014
+													$limit_broke = 'large';
1015
+						}
1016
+
1017
+						if ($limit_broke) {
1018
+													$sig = str_replace($matches[0][$ind], '[size=' . $sig_limits[7] . 'px', $sig);
1019
+						}
986 1020
 					}
987 1021
 				}
988 1022
 
@@ -1038,32 +1072,34 @@  discard block
 block discarded – undo
1038 1072
 											$img_offset = false;
1039 1073
 										}
1040 1074
 									}
1075
+								} else {
1076
+																	$replaces[$image] = '';
1041 1077
 								}
1042
-								else
1043
-									$replaces[$image] = '';
1044 1078
 
1045 1079
 								continue;
1046 1080
 							}
1047 1081
 
1048 1082
 							// Does it have predefined restraints? Width first.
1049
-							if ($matches[6][$key])
1050
-								$matches[2][$key] = $matches[6][$key];
1083
+							if ($matches[6][$key]) {
1084
+															$matches[2][$key] = $matches[6][$key];
1085
+							}
1051 1086
 							if ($matches[2][$key] && $sig_limits[5] && $matches[2][$key] > $sig_limits[5])
1052 1087
 							{
1053 1088
 								$width = $sig_limits[5];
1054 1089
 								$matches[4][$key] = $matches[4][$key] * ($width / $matches[2][$key]);
1090
+							} elseif ($matches[2][$key]) {
1091
+															$width = $matches[2][$key];
1055 1092
 							}
1056
-							elseif ($matches[2][$key])
1057
-								$width = $matches[2][$key];
1058 1093
 							// ... and height.
1059 1094
 							if ($matches[4][$key] && $sig_limits[6] && $matches[4][$key] > $sig_limits[6])
1060 1095
 							{
1061 1096
 								$height = $sig_limits[6];
1062
-								if ($width != -1)
1063
-									$width = $width * ($height / $matches[4][$key]);
1097
+								if ($width != -1) {
1098
+																	$width = $width * ($height / $matches[4][$key]);
1099
+								}
1100
+							} elseif ($matches[4][$key]) {
1101
+															$height = $matches[4][$key];
1064 1102
 							}
1065
-							elseif ($matches[4][$key])
1066
-								$height = $matches[4][$key];
1067 1103
 
1068 1104
 							// If the dimensions are still not fixed - we need to check the actual image.
1069 1105
 							if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6]))
@@ -1081,12 +1117,13 @@  discard block
 block discarded – undo
1081 1117
 									if ($sizes[1] > $sig_limits[6] && $sig_limits[6])
1082 1118
 									{
1083 1119
 										$height = $sig_limits[6];
1084
-										if ($width == -1)
1085
-											$width = $sizes[0];
1120
+										if ($width == -1) {
1121
+																					$width = $sizes[0];
1122
+										}
1086 1123
 										$width = $width * ($height / $sizes[1]);
1124
+									} elseif ($width != -1) {
1125
+																			$height = $sizes[1];
1087 1126
 									}
1088
-									elseif ($width != -1)
1089
-										$height = $sizes[1];
1090 1127
 								}
1091 1128
 							}
1092 1129
 
@@ -1099,8 +1136,9 @@  discard block
 block discarded – undo
1099 1136
 							// Record that we got one.
1100 1137
 							$image_count_holder[$image] = isset($image_count_holder[$image]) ? $image_count_holder[$image] + 1 : 1;
1101 1138
 						}
1102
-						if (!empty($replaces))
1103
-							$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1139
+						if (!empty($replaces)) {
1140
+													$sig = str_replace(array_keys($replaces), array_values($replaces), $sig);
1141
+						}
1104 1142
 					}
1105 1143
 				}
1106 1144
 				// Try to fix disabled tags.
@@ -1112,18 +1150,20 @@  discard block
 block discarded – undo
1112 1150
 
1113 1151
 				$sig = strtr($sig, array("\n" => '<br>'));
1114 1152
 				call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags));
1115
-				if ($sig != $row['signature'])
1116
-					$changes[$row['id_member']] = $sig;
1153
+				if ($sig != $row['signature']) {
1154
+									$changes[$row['id_member']] = $sig;
1155
+				}
1156
+			}
1157
+			if ($smcFunc['db_num_rows']($request) == 0) {
1158
+							$done = true;
1117 1159
 			}
1118
-			if ($smcFunc['db_num_rows']($request) == 0)
1119
-				$done = true;
1120 1160
 			$smcFunc['db_free_result']($request);
1121 1161
 
1122 1162
 			// Do we need to delete what we have?
1123 1163
 			if (!empty($changes))
1124 1164
 			{
1125
-				foreach ($changes as $id => $sig)
1126
-					$smcFunc['db_query']('', '
1165
+				foreach ($changes as $id => $sig) {
1166
+									$smcFunc['db_query']('', '
1127 1167
 						UPDATE {db_prefix}members
1128 1168
 						SET signature = {string:signature}
1129 1169
 						WHERE id_member = {int:id_member}',
@@ -1132,11 +1172,13 @@  discard block
 block discarded – undo
1132 1172
 							'signature' => $sig,
1133 1173
 						)
1134 1174
 					);
1175
+				}
1135 1176
 			}
1136 1177
 
1137 1178
 			$_GET['step'] += 50;
1138
-			if (!$done)
1139
-				pauseSignatureApplySettings();
1179
+			if (!$done) {
1180
+							pauseSignatureApplySettings();
1181
+			}
1140 1182
 		}
1141 1183
 		$settings_applied = true;
1142 1184
 	}
@@ -1154,8 +1196,9 @@  discard block
 block discarded – undo
1154 1196
 	);
1155 1197
 
1156 1198
 	// Temporarily make each setting a modSetting!
1157
-	foreach ($context['signature_settings'] as $key => $value)
1158
-		$modSettings['signature_' . $key] = $value;
1199
+	foreach ($context['signature_settings'] as $key => $value) {
1200
+			$modSettings['signature_' . $key] = $value;
1201
+	}
1159 1202
 
1160 1203
 	// Make sure we check the right tags!
1161 1204
 	$modSettings['bbc_disabled_signature_bbc'] = $disabledTags;
@@ -1167,23 +1210,26 @@  discard block
 block discarded – undo
1167 1210
 
1168 1211
 		// Clean up the tag stuff!
1169 1212
 		$bbcTags = array();
1170
-		foreach (parse_bbc(false) as $tag)
1171
-			$bbcTags[] = $tag['tag'];
1213
+		foreach (parse_bbc(false) as $tag) {
1214
+					$bbcTags[] = $tag['tag'];
1215
+		}
1172 1216
 
1173
-		if (!isset($_POST['signature_bbc_enabledTags']))
1174
-			$_POST['signature_bbc_enabledTags'] = array();
1175
-		elseif (!is_array($_POST['signature_bbc_enabledTags']))
1176
-			$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1217
+		if (!isset($_POST['signature_bbc_enabledTags'])) {
1218
+					$_POST['signature_bbc_enabledTags'] = array();
1219
+		} elseif (!is_array($_POST['signature_bbc_enabledTags'])) {
1220
+					$_POST['signature_bbc_enabledTags'] = array($_POST['signature_bbc_enabledTags']);
1221
+		}
1177 1222
 
1178 1223
 		$sig_limits = array();
1179 1224
 		foreach ($context['signature_settings'] as $key => $value)
1180 1225
 		{
1181
-			if ($key == 'allow_smileys')
1182
-				continue;
1183
-			elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys']))
1184
-				$sig_limits[] = -1;
1185
-			else
1186
-				$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1226
+			if ($key == 'allow_smileys') {
1227
+							continue;
1228
+			} elseif ($key == 'max_smileys' && empty($_POST['signature_allow_smileys'])) {
1229
+							$sig_limits[] = -1;
1230
+			} else {
1231
+							$sig_limits[] = !empty($_POST['signature_' . $key]) ? max(1, (int) $_POST['signature_' . $key]) : 0;
1232
+			}
1187 1233
 		}
1188 1234
 
1189 1235
 		call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags));
@@ -1216,12 +1262,14 @@  discard block
 block discarded – undo
1216 1262
 
1217 1263
 	// Try get more time...
1218 1264
 	@set_time_limit(600);
1219
-	if (function_exists('apache_reset_timeout'))
1220
-		@apache_reset_timeout();
1265
+	if (function_exists('apache_reset_timeout')) {
1266
+			@apache_reset_timeout();
1267
+	}
1221 1268
 
1222 1269
 	// Have we exhausted all the time we allowed?
1223
-	if (time() - array_sum(explode(' ', $sig_start)) < 3)
1224
-		return;
1270
+	if (time() - array_sum(explode(' ', $sig_start)) < 3) {
1271
+			return;
1272
+	}
1225 1273
 
1226 1274
 	$context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $_GET['step'] . ';' . $context['session_var'] . '=' . $context['session_id'];
1227 1275
 	$context['page_title'] = $txt['not_done_title'];
@@ -1267,9 +1315,10 @@  discard block
 block discarded – undo
1267 1315
 		$disable_fields = array_flip($standard_fields);
1268 1316
 		if (!empty($_POST['active']))
1269 1317
 		{
1270
-			foreach ($_POST['active'] as $value)
1271
-				if (isset($disable_fields[$value]))
1318
+			foreach ($_POST['active'] as $value) {
1319
+							if (isset($disable_fields[$value]))
1272 1320
 					unset($disable_fields[$value]);
1321
+			}
1273 1322
 		}
1274 1323
 		// What we have left!
1275 1324
 		$changes['disabled_profile_fields'] = empty($disable_fields) ? '' : implode(',', array_keys($disable_fields));
@@ -1278,16 +1327,18 @@  discard block
 block discarded – undo
1278 1327
 		$reg_fields = array();
1279 1328
 		if (!empty($_POST['reg']))
1280 1329
 		{
1281
-			foreach ($_POST['reg'] as $value)
1282
-				if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1330
+			foreach ($_POST['reg'] as $value) {
1331
+							if (in_array($value, $standard_fields) && !isset($disable_fields[$value]))
1283 1332
 					$reg_fields[] = $value;
1333
+			}
1284 1334
 		}
1285 1335
 		// What we have left!
1286 1336
 		$changes['registration_fields'] = empty($reg_fields) ? '' : implode(',', $reg_fields);
1287 1337
 
1288 1338
 		$_SESSION['adm-save'] = true;
1289
-		if (!empty($changes))
1290
-			updateSettings($changes);
1339
+		if (!empty($changes)) {
1340
+					updateSettings($changes);
1341
+		}
1291 1342
 	}
1292 1343
 
1293 1344
 	createToken('admin-scp');
@@ -1390,11 +1441,13 @@  discard block
 block discarded – undo
1390 1441
 					{
1391 1442
 						$return = '<p class="centertext bold_text">'. $rowData['field_order'] .'<br />';
1392 1443
 
1393
-						if ($rowData['field_order'] > 1)
1394
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1444
+						if ($rowData['field_order'] > 1) {
1445
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=up"><span class="toggle_up" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_up'] .'"></span></a>';
1446
+						}
1395 1447
 
1396
-						if ($rowData['field_order'] < $context['custFieldsMaxOrder'])
1397
-							$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1448
+						if ($rowData['field_order'] < $context['custFieldsMaxOrder']) {
1449
+													$return .= '<a href="' . $scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $rowData['id_field'] . ';move=down"><span class="toggle_down" title="'. $txt['custom_edit_order_move'] .' '. $txt['custom_edit_order_down'] .'"></span></a>';
1450
+						}
1398 1451
 
1399 1452
 						$return .= '</p>';
1400 1453
 
@@ -1532,16 +1585,16 @@  discard block
 block discarded – undo
1532 1585
 		$disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
1533 1586
 		$registration_fields = isset($modSettings['registration_fields']) ? explode(',', $modSettings['registration_fields']) : array();
1534 1587
 
1535
-		foreach ($standard_fields as $field)
1536
-			$list[] = array(
1588
+		foreach ($standard_fields as $field) {
1589
+					$list[] = array(
1537 1590
 				'id' => $field,
1538 1591
 				'label' => isset($txt['standard_profile_field_' . $field]) ? $txt['standard_profile_field_' . $field] : (isset($txt[$field]) ? $txt[$field] : $field),
1539 1592
 				'disabled' => in_array($field, $disabled_fields),
1540 1593
 				'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration),
1541 1594
 				'can_show_register' => !in_array($field, $fields_no_registration),
1542 1595
 			);
1543
-	}
1544
-	else
1596
+		}
1597
+	} else
1545 1598
 	{
1546 1599
 		// Load all the fields.
1547 1600
 		$request = $smcFunc['db_query']('', '
@@ -1555,8 +1608,9 @@  discard block
 block discarded – undo
1555 1608
 				'items_per_page' => $items_per_page,
1556 1609
 			)
1557 1610
 		);
1558
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1559
-			$list[] = $row;
1611
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1612
+					$list[] = $row;
1613
+		}
1560 1614
 		$smcFunc['db_free_result']($request);
1561 1615
 	}
1562 1616
 
@@ -1622,9 +1676,9 @@  discard block
 block discarded – undo
1622 1676
 		$context['field'] = array();
1623 1677
 		while ($row = $smcFunc['db_fetch_assoc']($request))
1624 1678
 		{
1625
-			if ($row['field_type'] == 'textarea')
1626
-				@list ($rows, $cols) = @explode(',', $row['default_value']);
1627
-			else
1679
+			if ($row['field_type'] == 'textarea') {
1680
+							@list ($rows, $cols) = @explode(',', $row['default_value']);
1681
+			} else
1628 1682
 			{
1629 1683
 				$rows = 3;
1630 1684
 				$cols = 30;
@@ -1660,8 +1714,8 @@  discard block
 block discarded – undo
1660 1714
 	}
1661 1715
 
1662 1716
 	// Setup the default values as needed.
1663
-	if (empty($context['field']))
1664
-		$context['field'] = array(
1717
+	if (empty($context['field'])) {
1718
+			$context['field'] = array(
1665 1719
 			'name' => '',
1666 1720
 			'col_name' => '???',
1667 1721
 			'desc' => '',
@@ -1686,6 +1740,7 @@  discard block
 block discarded – undo
1686 1740
 			'enclose' => '',
1687 1741
 			'placement' => 0,
1688 1742
 		);
1743
+	}
1689 1744
 
1690 1745
 	// Are we moving it?
1691 1746
 	if (isset($_GET['move']) && in_array($smcFunc['htmlspecialchars']($_GET['move']), $move_to))
@@ -1694,8 +1749,10 @@  discard block
 block discarded – undo
1694 1749
 		$new_order = ($_GET['move'] == 'up' ? ($context['field']['order'] - 1) : ($context['field']['order'] + 1));
1695 1750
 
1696 1751
 		// Is this a valid position?
1697
-		if ($new_order <= 0 || $new_order > $order_count)
1698
-			redirectexit('action=admin;area=featuresettings;sa=profile'); // @todo implement an error handler
1752
+		if ($new_order <= 0 || $new_order > $order_count) {
1753
+					redirectexit('action=admin;area=featuresettings;sa=profile');
1754
+		}
1755
+		// @todo implement an error handler
1699 1756
 
1700 1757
 		// All good, proceed.
1701 1758
 		$smcFunc['db_query']('','
@@ -1726,12 +1783,14 @@  discard block
 block discarded – undo
1726 1783
 		validateToken('admin-ecp');
1727 1784
 
1728 1785
 		// Everyone needs a name - even the (bracket) unknown...
1729
-		if (trim($_POST['field_name']) == '')
1730
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1786
+		if (trim($_POST['field_name']) == '') {
1787
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=need_name');
1788
+		}
1731 1789
 
1732 1790
 		// Regex you say?  Do a very basic test to see if the pattern is valid
1733
-		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false)
1734
-			redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1791
+		if (!empty($_POST['regex']) && @preg_match($_POST['regex'], 'dummy') === false) {
1792
+					redirectexit($scripturl . '?action=admin;area=featuresettings;sa=profileedit;fid=' . $_GET['fid'] . ';msg=regex_error');
1793
+		}
1735 1794
 
1736 1795
 		$_POST['field_name'] = $smcFunc['htmlspecialchars']($_POST['field_name']);
1737 1796
 		$_POST['field_desc'] = $smcFunc['htmlspecialchars']($_POST['field_desc']);
@@ -1748,8 +1807,9 @@  discard block
 block discarded – undo
1748 1807
 
1749 1808
 		// Some masking stuff...
1750 1809
 		$mask = isset($_POST['mask']) ? $_POST['mask'] : '';
1751
-		if ($mask == 'regex' && isset($_POST['regex']))
1752
-			$mask .= $_POST['regex'];
1810
+		if ($mask == 'regex' && isset($_POST['regex'])) {
1811
+					$mask .= $_POST['regex'];
1812
+		}
1753 1813
 
1754 1814
 		$field_length = isset($_POST['max_length']) ? (int) $_POST['max_length'] : 255;
1755 1815
 		$enclose = isset($_POST['enclose']) ? $_POST['enclose'] : '';
@@ -1768,8 +1828,9 @@  discard block
 block discarded – undo
1768 1828
 				$v = strtr($v, array(',' => ''));
1769 1829
 
1770 1830
 				// Nada, zip, etc...
1771
-				if (trim($v) == '')
1772
-					continue;
1831
+				if (trim($v) == '') {
1832
+									continue;
1833
+				}
1773 1834
 
1774 1835
 				// Otherwise, save it boy.
1775 1836
 				$field_options .= $v . ',';
@@ -1777,15 +1838,17 @@  discard block
 block discarded – undo
1777 1838
 				$newOptions[$k] = $v;
1778 1839
 
1779 1840
 				// Is it default?
1780
-				if (isset($_POST['default_select']) && $_POST['default_select'] == $k)
1781
-					$default = $v;
1841
+				if (isset($_POST['default_select']) && $_POST['default_select'] == $k) {
1842
+									$default = $v;
1843
+				}
1782 1844
 			}
1783 1845
 			$field_options = substr($field_options, 0, -1);
1784 1846
 		}
1785 1847
 
1786 1848
 		// Text area has default has dimensions
1787
-		if ($_POST['field_type'] == 'textarea')
1788
-			$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1849
+		if ($_POST['field_type'] == 'textarea') {
1850
+					$default = (int) $_POST['rows'] . ',' . (int) $_POST['cols'];
1851
+		}
1789 1852
 
1790 1853
 		// Come up with the unique name?
1791 1854
 		if (empty($context['fid']))
@@ -1794,32 +1857,36 @@  discard block
 block discarded – undo
1794 1857
 			preg_match('~([\w\d_-]+)~', $col_name, $matches);
1795 1858
 
1796 1859
 			// If there is nothing to the name, then let's start out own - for foreign languages etc.
1797
-			if (isset($matches[1]))
1798
-				$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1799
-			else
1800
-				$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1860
+			if (isset($matches[1])) {
1861
+							$col_name = $initial_col_name = 'cust_' . strtolower($matches[1]);
1862
+			} else {
1863
+							$col_name = $initial_col_name = 'cust_' . mt_rand(1, 9999);
1864
+			}
1801 1865
 
1802 1866
 			// Make sure this is unique.
1803 1867
 			$current_fields = array();
1804 1868
 			$request = $smcFunc['db_query']('', '
1805 1869
 				SELECT id_field, col_name
1806 1870
 				FROM {db_prefix}custom_fields');
1807
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1808
-				$current_fields[$row['id_field']] = $row['col_name'];
1871
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1872
+							$current_fields[$row['id_field']] = $row['col_name'];
1873
+			}
1809 1874
 			$smcFunc['db_free_result']($request);
1810 1875
 
1811 1876
 			$unique = false;
1812 1877
 			for ($i = 0; !$unique && $i < 9; $i ++)
1813 1878
 			{
1814
-				if (!in_array($col_name, $current_fields))
1815
-					$unique = true;
1816
-				else
1817
-					$col_name = $initial_col_name . $i;
1879
+				if (!in_array($col_name, $current_fields)) {
1880
+									$unique = true;
1881
+				} else {
1882
+									$col_name = $initial_col_name . $i;
1883
+				}
1818 1884
 			}
1819 1885
 
1820 1886
 			// Still not a unique column name? Leave it up to the user, then.
1821
-			if (!$unique)
1822
-				fatal_lang_error('custom_option_not_unique');
1887
+			if (!$unique) {
1888
+							fatal_lang_error('custom_option_not_unique');
1889
+			}
1823 1890
 		}
1824 1891
 		// Work out what to do with the user data otherwise...
1825 1892
 		else
@@ -1847,8 +1914,9 @@  discard block
 block discarded – undo
1847 1914
 				// Work out what's changed!
1848 1915
 				foreach ($context['field']['options'] as $k => $option)
1849 1916
 				{
1850
-					if (trim($option) == '')
1851
-						continue;
1917
+					if (trim($option) == '') {
1918
+											continue;
1919
+					}
1852 1920
 
1853 1921
 					// Still exists?
1854 1922
 					if (in_array($option, $newOptions))
@@ -1862,8 +1930,8 @@  discard block
 block discarded – undo
1862 1930
 				foreach ($optionChanges as $k => $option)
1863 1931
 				{
1864 1932
 					// Just been renamed?
1865
-					if (!in_array($k, $takenKeys) && !empty($newOptions[$k]))
1866
-						$smcFunc['db_query']('', '
1933
+					if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) {
1934
+											$smcFunc['db_query']('', '
1867 1935
 							UPDATE {db_prefix}themes
1868 1936
 							SET value = {string:new_value}
1869 1937
 							WHERE variable = {string:current_column}
@@ -1876,6 +1944,7 @@  discard block
 block discarded – undo
1876 1944
 								'old_value' => $option,
1877 1945
 							)
1878 1946
 						);
1947
+					}
1879 1948
 				}
1880 1949
 			}
1881 1950
 			// @todo Maybe we should adjust based on new text length limits?
@@ -1918,8 +1987,8 @@  discard block
 block discarded – undo
1918 1987
 			);
1919 1988
 
1920 1989
 			// Just clean up any old selects - these are a pain!
1921
-			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions))
1922
-				$smcFunc['db_query']('', '
1990
+			if (($_POST['field_type'] == 'select' || $_POST['field_type'] == 'radio') && !empty($newOptions)) {
1991
+							$smcFunc['db_query']('', '
1923 1992
 					DELETE FROM {db_prefix}themes
1924 1993
 					WHERE variable = {string:current_column}
1925 1994
 						AND value NOT IN ({array_string:new_option_values})
@@ -1930,8 +1999,8 @@  discard block
 block discarded – undo
1930 1999
 						'current_column' => $context['field']['col_name'],
1931 2000
 					)
1932 2001
 				);
1933
-		}
1934
-		else
2002
+			}
2003
+		} else
1935 2004
 		{
1936 2005
 			// Gotta figure it out the order.
1937 2006
 			$new_order = $order_count > 1 ? ($order_count + 1) : 1;
@@ -2105,11 +2174,13 @@  discard block
 block discarded – undo
2105 2174
 	call_integration_hook('integrate_prune_settings', array(&$config_vars, &$prune_toggle, false));
2106 2175
 
2107 2176
 	$prune_toggle_dt = array();
2108
-	foreach ($prune_toggle as $item)
2109
-		$prune_toggle_dt[] = 'setting_' . $item;
2177
+	foreach ($prune_toggle as $item) {
2178
+			$prune_toggle_dt[] = 'setting_' . $item;
2179
+	}
2110 2180
 
2111
-	if ($return_config)
2112
-		return $config_vars;
2181
+	if ($return_config) {
2182
+			return $config_vars;
2183
+	}
2113 2184
 
2114 2185
 	addInlineJavaScript('
2115 2186
 	function togglePruned()
@@ -2147,15 +2218,16 @@  discard block
 block discarded – undo
2147 2218
 			$vals = array();
2148 2219
 			foreach ($config_vars as $index => $dummy)
2149 2220
 			{
2150
-				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle))
2151
-					continue;
2221
+				if (!is_array($dummy) || $index == 'pruningOptions' || !in_array($dummy[1], $prune_toggle)) {
2222
+									continue;
2223
+				}
2152 2224
 
2153 2225
 				$vals[] = empty($_POST[$dummy[1]]) || $_POST[$dummy[1]] < 0 ? 0 : (int) $_POST[$dummy[1]];
2154 2226
 			}
2155 2227
 			$_POST['pruningOptions'] = implode(',', $vals);
2228
+		} else {
2229
+					$_POST['pruningOptions'] = '';
2156 2230
 		}
2157
-		else
2158
-			$_POST['pruningOptions'] = '';
2159 2231
 
2160 2232
 		saveDBSettings($savevar);
2161 2233
 		$_SESSION['adm-save'] = true;
@@ -2167,10 +2239,11 @@  discard block
 block discarded – undo
2167 2239
 	$context['sub_template'] = 'show_settings';
2168 2240
 
2169 2241
 	// Get the actual values
2170
-	if (!empty($modSettings['pruningOptions']))
2171
-		@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2172
-	else
2173
-		$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2242
+	if (!empty($modSettings['pruningOptions'])) {
2243
+			@list ($modSettings['pruneErrorLog'], $modSettings['pruneModLog'], $modSettings['pruneBanLog'], $modSettings['pruneReportLog'], $modSettings['pruneScheduledTaskLog'], $modSettings['pruneSpiderHitLog']) = explode(',', $modSettings['pruningOptions']);
2244
+	} else {
2245
+			$modSettings['pruneErrorLog'] = $modSettings['pruneModLog'] = $modSettings['pruneBanLog'] = $modSettings['pruneReportLog'] = $modSettings['pruneScheduledTaskLog'] = $modSettings['pruneSpiderHitLog'] = 0;
2246
+	}
2174 2247
 
2175 2248
 	prepareDBSettingContext($config_vars);
2176 2249
 }
@@ -2192,8 +2265,9 @@  discard block
 block discarded – undo
2192 2265
 	// Make it even easier to add new settings.
2193 2266
 	call_integration_hook('integrate_general_mod_settings', array(&$config_vars));
2194 2267
 
2195
-	if ($return_config)
2196
-		return $config_vars;
2268
+	if ($return_config) {
2269
+			return $config_vars;
2270
+	}
2197 2271
 
2198 2272
 	$context['post_url'] = $scripturl . '?action=admin;area=modsettings;save;sa=general';
2199 2273
 	$context['settings_title'] = $txt['mods_cat_modifications_misc'];
Please login to merge, or discard this patch.
Sources/Search.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 
660 660
 	// Remove the phrase parts and extract the words.
661 661
 	$wordArray = preg_replace('~(?:^|\s)(?:[-]?)"(?:[^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), ' ', $search_params['search']);
662
-	$wordArray = explode(' ',  $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES));
662
+	$wordArray = explode(' ', $smcFunc['htmlspecialchars'](un_htmlspecialchars($wordArray), ENT_QUOTES));
663 663
 
664 664
 	// A minus sign in front of a word excludes the word.... so...
665 665
 	$excludedWords = array();
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 						SELECT
1105 1105
 							{int:id_search},
1106 1106
 							t.id_topic,
1107
-							' . $relevance. ',
1107
+							' . $relevance . ',
1108 1108
 							' . (empty($userQuery) ? 't.id_first_msg' : 'm.id_msg') . ',
1109 1109
 							1
1110 1110
 						FROM ' . $subject_query['from'] . (empty($subject_query['inner_join']) ? '' : '
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 						if (empty($subject_query['where']))
1340 1340
 							continue;
1341 1341
 
1342
-						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( '
1342
+						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ('
1343 1343
 							INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics
1344 1344
 								(' . ($createTemporary ? '' : 'id_search, ') . 'id_topic)') : '') . '
1345 1345
 							SELECT ' . ($createTemporary ? '' : $_SESSION['search_cache']['id_search'] . ', ') . 't.id_topic
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
 					}
1569 1569
 					$main_query['select']['relevance'] = substr($relevance, 0, -3) . ') / ' . $new_weight_total . ' AS relevance';
1570 1570
 
1571
-					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ( '
1571
+					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_no_index', ($smcFunc['db_support_ignore'] ? ('
1572 1572
 						INSERT IGNORE INTO ' . '{db_prefix}log_search_results
1573 1573
 							(' . implode(', ', array_keys($main_query['select'])) . ')') : '') . '
1574 1574
 						SELECT
@@ -1636,7 +1636,7 @@  discard block
 block discarded – undo
1636 1636
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
1637 1637
 
1638 1638
 					$usedIDs = array_flip(empty($inserts) ? array() : array_keys($inserts));
1639
-					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ( '
1639
+					$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_results_sub_only', ($smcFunc['db_support_ignore'] ? ('
1640 1640
 						INSERT IGNORE INTO {db_prefix}log_search_results
1641 1641
 							(id_search, id_topic, relevance, id_msg, num_matches)') : '') . '
1642 1642
 						SELECT
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
 		$query = trim($query, "\*+");
2103 2103
 		$query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\''));
2104 2104
 
2105
-		$body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function ($m)
2105
+		$body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/i' . ($context['utf8'] ? 'u' : ''), function($m)
2106 2106
 		{
2107 2107
 			return isset($m[2]) && "$m[2]" == "$m[1]" ? stripslashes("$m[1]") : "<strong class=\"highlight\">$m[1]</strong>";
2108 2108
 		}, $body_highlighted);
Please login to merge, or discard this patch.
Braces   +416 added lines, -309 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
 // This defines two version types for checking the API's are compatible with this version of SMF.
20 21
 $GLOBALS['search_versions'] = array(
@@ -39,8 +40,9 @@  discard block
 block discarded – undo
39 40
 	global $txt, $scripturl, $modSettings, $user_info, $context, $smcFunc, $sourcedir;
40 41
 
41 42
 	// Is the load average too high to allow searching just now?
42
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
43
-		fatal_lang_error('loadavg_search_disabled', false);
43
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
44
+			fatal_lang_error('loadavg_search_disabled', false);
45
+	}
44 46
 
45 47
 	loadLanguage('Search');
46 48
 	// Don't load this in XML mode.
@@ -88,23 +90,30 @@  discard block
 block discarded – undo
88 90
 			@list ($k, $v) = explode('|\'|', $data);
89 91
 			$context['search_params'][$k] = $v;
90 92
 		}
91
-		if (isset($context['search_params']['brd']))
92
-			$context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']);
93
+		if (isset($context['search_params']['brd'])) {
94
+					$context['search_params']['brd'] = $context['search_params']['brd'] == '' ? array() : explode(',', $context['search_params']['brd']);
95
+		}
93 96
 	}
94 97
 
95
-	if (isset($_REQUEST['search']))
96
-		$context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);
98
+	if (isset($_REQUEST['search'])) {
99
+			$context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']);
100
+	}
97 101
 
98
-	if (isset($context['search_params']['search']))
99
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
100
-	if (isset($context['search_params']['userspec']))
101
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
102
-	if (!empty($context['search_params']['searchtype']))
103
-		$context['search_params']['searchtype'] = 2;
104
-	if (!empty($context['search_params']['minage']))
105
-		$context['search_params']['minage'] = (int) $context['search_params']['minage'];
106
-	if (!empty($context['search_params']['maxage']))
107
-		$context['search_params']['maxage'] = (int) $context['search_params']['maxage'];
102
+	if (isset($context['search_params']['search'])) {
103
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
104
+	}
105
+	if (isset($context['search_params']['userspec'])) {
106
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
107
+	}
108
+	if (!empty($context['search_params']['searchtype'])) {
109
+			$context['search_params']['searchtype'] = 2;
110
+	}
111
+	if (!empty($context['search_params']['minage'])) {
112
+			$context['search_params']['minage'] = (int) $context['search_params']['minage'];
113
+	}
114
+	if (!empty($context['search_params']['maxage'])) {
115
+			$context['search_params']['maxage'] = (int) $context['search_params']['maxage'];
116
+	}
108 117
 
109 118
 	$context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']);
110 119
 	$context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']);
@@ -116,11 +125,13 @@  discard block
 block discarded – undo
116 125
 		$context['search_errors']['messages'] = array();
117 126
 		foreach ($context['search_errors'] as $search_error => $dummy)
118 127
 		{
119
-			if ($search_error === 'messages')
120
-				continue;
128
+			if ($search_error === 'messages') {
129
+							continue;
130
+			}
121 131
 
122
-			if ($search_error == 'string_too_long')
123
-				$txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);
132
+			if ($search_error == 'string_too_long') {
133
+							$txt['error_string_too_long'] = sprintf($txt['error_string_too_long'], $context['search_string_limit']);
134
+			}
124 135
 
125 136
 			$context['search_errors']['messages'][] = $txt['error_' . $search_error];
126 137
 		}
@@ -143,12 +154,13 @@  discard block
 block discarded – undo
143 154
 	while ($row = $smcFunc['db_fetch_assoc']($request))
144 155
 	{
145 156
 		// This category hasn't been set up yet..
146
-		if (!isset($context['categories'][$row['id_cat']]))
147
-			$context['categories'][$row['id_cat']] = array(
157
+		if (!isset($context['categories'][$row['id_cat']])) {
158
+					$context['categories'][$row['id_cat']] = array(
148 159
 				'id' => $row['id_cat'],
149 160
 				'name' => $row['cat_name'],
150 161
 				'boards' => array()
151 162
 			);
163
+		}
152 164
 
153 165
 		// Set this board up, and let the template know when it's a child.  (indent them..)
154 166
 		$context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
@@ -159,8 +171,9 @@  discard block
 block discarded – undo
159 171
 		);
160 172
 
161 173
 		// If a board wasn't checked that probably should have been ensure the board selection is selected, yo!
162
-		if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board']))
163
-			$context['boards_check_all'] = false;
174
+		if (!$context['categories'][$row['id_cat']]['boards'][$row['id_board']]['selected'] && (empty($modSettings['recycle_enable']) || $row['id_board'] != $modSettings['recycle_board'])) {
175
+					$context['boards_check_all'] = false;
176
+		}
164 177
 	}
165 178
 	$smcFunc['db_free_result']($request);
166 179
 
@@ -182,18 +195,20 @@  discard block
 block discarded – undo
182 195
 	}
183 196
 
184 197
 	$max_boards = ceil(count($temp_boards) / 2);
185
-	if ($max_boards == 1)
186
-		$max_boards = 2;
198
+	if ($max_boards == 1) {
199
+			$max_boards = 2;
200
+	}
187 201
 
188 202
 	// Now, alternate them so they can be shown left and right ;).
189 203
 	$context['board_columns'] = array();
190 204
 	for ($i = 0; $i < $max_boards; $i++)
191 205
 	{
192 206
 		$context['board_columns'][] = $temp_boards[$i];
193
-		if (isset($temp_boards[$i + $max_boards]))
194
-			$context['board_columns'][] = $temp_boards[$i + $max_boards];
195
-		else
196
-			$context['board_columns'][] = array();
207
+		if (isset($temp_boards[$i + $max_boards])) {
208
+					$context['board_columns'][] = $temp_boards[$i + $max_boards];
209
+		} else {
210
+					$context['board_columns'][] = array();
211
+		}
197 212
 	}
198 213
 
199 214
 	if (!empty($_REQUEST['topic']))
@@ -225,8 +240,9 @@  discard block
 block discarded – undo
225 240
 			)
226 241
 		);
227 242
 
228
-		if ($smcFunc['db_num_rows']($request) == 0)
229
-			fatal_lang_error('topic_gone', false);
243
+		if ($smcFunc['db_num_rows']($request) == 0) {
244
+					fatal_lang_error('topic_gone', false);
245
+		}
230 246
 
231 247
 		list ($context['search_topic']['subject']) = $smcFunc['db_fetch_row']($request);
232 248
 		$smcFunc['db_free_result']($request);
@@ -256,11 +272,13 @@  discard block
 block discarded – undo
256 272
 	global $excludedWords, $participants, $smcFunc;
257 273
 
258 274
 	// if comming from the quick search box, and we want to search on members, well we need to do that ;)
259
-	if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members')
260
-		redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search']));
275
+	if (isset($_REQUEST['search_selection']) && $_REQUEST['search_selection'] === 'members') {
276
+			redirectexit($scripturl . '?action=mlist;sa=search;fields=name,email;search=' . urlencode($_REQUEST['search']));
277
+	}
261 278
 
262
-	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search'])
263
-		fatal_lang_error('loadavg_search_disabled', false);
279
+	if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) {
280
+			fatal_lang_error('loadavg_search_disabled', false);
281
+	}
264 282
 
265 283
 	// No, no, no... this is a bit hard on the server, so don't you go prefetching it!
266 284
 	if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] == 'prefetch')
@@ -307,8 +325,9 @@  discard block
 block discarded – undo
307 325
 	}
308 326
 
309 327
 	// Zero weight.  Weightless :P.
310
-	if (empty($weight_total))
311
-		fatal_lang_error('search_invalid_weights');
328
+	if (empty($weight_total)) {
329
+			fatal_lang_error('search_invalid_weights');
330
+	}
312 331
 
313 332
 	// These vars don't require an interface, they're just here for tweaking.
314 333
 	$recentPercentage = 0.30;
@@ -326,11 +345,13 @@  discard block
 block discarded – undo
326 345
 	$context['search_string_limit'] = 100;
327 346
 
328 347
 	loadLanguage('Search');
329
-	if (!isset($_REQUEST['xml']))
330
-		loadTemplate('Search');
348
+	if (!isset($_REQUEST['xml'])) {
349
+			loadTemplate('Search');
350
+	}
331 351
 	//If we're doing XML we need to use the results template regardless really.
332
-	else
333
-		$context['sub_template'] = 'results';
352
+	else {
353
+			$context['sub_template'] = 'results';
354
+	}
334 355
 
335 356
 	// Are you allowed?
336 357
 	isAllowedTo('search_posts');
@@ -363,34 +384,39 @@  discard block
 block discarded – undo
363 384
 			$search_params[$k] = $v;
364 385
 		}
365 386
 
366
-		if (isset($search_params['brd']))
367
-			$search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
387
+		if (isset($search_params['brd'])) {
388
+					$search_params['brd'] = empty($search_params['brd']) ? array() : explode(',', $search_params['brd']);
389
+		}
368 390
 	}
369 391
 
370 392
 	// Store whether simple search was used (needed if the user wants to do another query).
371
-	if (!isset($search_params['advanced']))
372
-		$search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
393
+	if (!isset($search_params['advanced'])) {
394
+			$search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1;
395
+	}
373 396
 
374 397
 	// 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'.
375
-	if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2))
376
-		$search_params['searchtype'] = 2;
398
+	if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) {
399
+			$search_params['searchtype'] = 2;
400
+	}
377 401
 
378 402
 	// Minimum age of messages. Default to zero (don't set param in that case).
379
-	if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0))
380
-		$search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
403
+	if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) {
404
+			$search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage'];
405
+	}
381 406
 
382 407
 	// Maximum age of messages. Default to infinite (9999 days: param not set).
383
-	if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999))
384
-		$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
408
+	if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] < 9999)) {
409
+			$search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage'];
410
+	}
385 411
 
386 412
 	// Searching a specific topic?
387 413
 	if (!empty($_REQUEST['topic']) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'topic'))
388 414
 	{
389 415
 		$search_params['topic'] = empty($_REQUEST['search_selection']) ? (int) $_REQUEST['topic'] : (isset($_REQUEST['sd_topic']) ? (int) $_REQUEST['sd_topic'] : '');
390 416
 		$search_params['show_complete'] = true;
417
+	} elseif (!empty($search_params['topic'])) {
418
+			$search_params['topic'] = (int) $search_params['topic'];
391 419
 	}
392
-	elseif (!empty($search_params['topic']))
393
-		$search_params['topic'] = (int) $search_params['topic'];
394 420
 
395 421
 	if (!empty($search_params['minage']) || !empty($search_params['maxage']))
396 422
 	{
@@ -408,19 +434,21 @@  discard block
 block discarded – undo
408 434
 			)
409 435
 		);
410 436
 		list ($minMsgID, $maxMsgID) = $smcFunc['db_fetch_row']($request);
411
-		if ($minMsgID < 0 || $maxMsgID < 0)
412
-			$context['search_errors']['no_messages_in_time_frame'] = true;
437
+		if ($minMsgID < 0 || $maxMsgID < 0) {
438
+					$context['search_errors']['no_messages_in_time_frame'] = true;
439
+		}
413 440
 		$smcFunc['db_free_result']($request);
414 441
 	}
415 442
 
416 443
 	// Default the user name to a wildcard matching every user (*).
417
-	if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*'))
418
-		$search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
444
+	if (!empty($search_params['userspec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) {
445
+			$search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec'];
446
+	}
419 447
 
420 448
 	// If there's no specific user, then don't mention it in the main query.
421
-	if (empty($search_params['userspec']))
422
-		$userQuery = '';
423
-	else
449
+	if (empty($search_params['userspec'])) {
450
+			$userQuery = '';
451
+	} else
424 452
 	{
425 453
 		$userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('&quot;' => '"'));
426 454
 		$userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_'));
@@ -432,19 +460,21 @@  discard block
 block discarded – undo
432 460
 		{
433 461
 			$possible_users[$k] = trim($possible_users[$k]);
434 462
 
435
-			if (strlen($possible_users[$k]) == 0)
436
-				unset($possible_users[$k]);
463
+			if (strlen($possible_users[$k]) == 0) {
464
+							unset($possible_users[$k]);
465
+			}
437 466
 		}
438 467
 
439 468
 		// Create a list of database-escaped search names.
440 469
 		$realNameMatches = array();
441
-		foreach ($possible_users as $possible_user)
442
-			$realNameMatches[] = $smcFunc['db_quote'](
470
+		foreach ($possible_users as $possible_user) {
471
+					$realNameMatches[] = $smcFunc['db_quote'](
443 472
 				'{string:possible_user}',
444 473
 				array(
445 474
 					'possible_user' => $possible_user
446 475
 				)
447 476
 			);
477
+		}
448 478
 
449 479
 		// Retrieve a list of possible members.
450 480
 		$request = $smcFunc['db_query']('', '
@@ -456,9 +486,9 @@  discard block
 block discarded – undo
456 486
 			)
457 487
 		);
458 488
 		// Simply do nothing if there're too many members matching the criteria.
459
-		if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch)
460
-			$userQuery = '';
461
-		elseif ($smcFunc['db_num_rows']($request) == 0)
489
+		if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) {
490
+					$userQuery = '';
491
+		} elseif ($smcFunc['db_num_rows']($request) == 0)
462 492
 		{
463 493
 			$userQuery = $smcFunc['db_quote'](
464 494
 				'm.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})',
@@ -467,12 +497,12 @@  discard block
 block discarded – undo
467 497
 					'match_possible_guest_names' => 'm.poster_name LIKE ' . implode(' OR m.poster_name LIKE ', $realNameMatches),
468 498
 				)
469 499
 			);
470
-		}
471
-		else
500
+		} else
472 501
 		{
473 502
 			$memberlist = array();
474
-			while ($row = $smcFunc['db_fetch_assoc']($request))
475
-				$memberlist[] = $row['id_member'];
503
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
504
+							$memberlist[] = $row['id_member'];
505
+			}
476 506
 			$userQuery = $smcFunc['db_quote'](
477 507
 				'(m.id_member IN ({array_int:matched_members}) OR (m.id_member = {int:id_member_guest} AND ({raw:match_possible_guest_names})))',
478 508
 				array(
@@ -486,22 +516,25 @@  discard block
 block discarded – undo
486 516
 	}
487 517
 
488 518
 	// If the boards were passed by URL (params=), temporarily put them back in $_REQUEST.
489
-	if (!empty($search_params['brd']) && is_array($search_params['brd']))
490
-		$_REQUEST['brd'] = $search_params['brd'];
519
+	if (!empty($search_params['brd']) && is_array($search_params['brd'])) {
520
+			$_REQUEST['brd'] = $search_params['brd'];
521
+	}
491 522
 
492 523
 	// Ensure that brd is an array.
493 524
 	if ((!empty($_REQUEST['brd']) && !is_array($_REQUEST['brd'])) || (!empty($_REQUEST['search_selection']) && $_REQUEST['search_selection'] == 'board'))
494 525
 	{
495
-		if (!empty($_REQUEST['brd']))
496
-			$_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']);
497
-		else
498
-			$_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array();
526
+		if (!empty($_REQUEST['brd'])) {
527
+					$_REQUEST['brd'] = strpos($_REQUEST['brd'], ',') !== false ? explode(',', $_REQUEST['brd']) : array($_REQUEST['brd']);
528
+		} else {
529
+					$_REQUEST['brd'] = isset($_REQUEST['sd_brd']) ? array($_REQUEST['sd_brd']) : array();
530
+		}
499 531
 	}
500 532
 
501 533
 	// Make sure all boards are integers.
502
-	if (!empty($_REQUEST['brd']))
503
-		foreach ($_REQUEST['brd'] as $id => $brd)
534
+	if (!empty($_REQUEST['brd'])) {
535
+			foreach ($_REQUEST['brd'] as $id => $brd)
504 536
 			$_REQUEST['brd'][$id] = (int) $brd;
537
+	}
505 538
 
506 539
 	// Special case for boards: searching just one topic?
507 540
 	if (!empty($search_params['topic']))
@@ -520,17 +553,18 @@  discard block
 block discarded – undo
520 553
 			)
521 554
 		);
522 555
 
523
-		if ($smcFunc['db_num_rows']($request) == 0)
524
-			fatal_lang_error('topic_gone', false);
556
+		if ($smcFunc['db_num_rows']($request) == 0) {
557
+					fatal_lang_error('topic_gone', false);
558
+		}
525 559
 
526 560
 		$search_params['brd'] = array();
527 561
 		list ($search_params['brd'][0]) = $smcFunc['db_fetch_row']($request);
528 562
 		$smcFunc['db_free_result']($request);
529 563
 	}
530 564
 	// Select all boards you've selected AND are allowed to see.
531
-	elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd'])))
532
-		$search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'];
533
-	else
565
+	elseif ($user_info['is_admin'] && (!empty($search_params['advanced']) || !empty($_REQUEST['brd']))) {
566
+			$search_params['brd'] = empty($_REQUEST['brd']) ? array() : $_REQUEST['brd'];
567
+	} else
534 568
 	{
535 569
 		$see_board = empty($search_params['advanced']) ? 'query_wanna_see_board' : 'query_see_board';
536 570
 		$request = $smcFunc['db_query']('', '
@@ -548,19 +582,22 @@  discard block
 block discarded – undo
548 582
 			)
549 583
 		);
550 584
 		$search_params['brd'] = array();
551
-		while ($row = $smcFunc['db_fetch_assoc']($request))
552
-			$search_params['brd'][] = $row['id_board'];
585
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
586
+					$search_params['brd'][] = $row['id_board'];
587
+		}
553 588
 		$smcFunc['db_free_result']($request);
554 589
 
555 590
 		// This error should pro'bly only happen for hackers.
556
-		if (empty($search_params['brd']))
557
-			$context['search_errors']['no_boards_selected'] = true;
591
+		if (empty($search_params['brd'])) {
592
+					$context['search_errors']['no_boards_selected'] = true;
593
+		}
558 594
 	}
559 595
 
560 596
 	if (count($search_params['brd']) != 0)
561 597
 	{
562
-		foreach ($search_params['brd'] as $k => $v)
563
-			$search_params['brd'][$k] = (int) $v;
598
+		foreach ($search_params['brd'] as $k => $v) {
599
+					$search_params['brd'][$k] = (int) $v;
600
+		}
564 601
 
565 602
 		// If we've selected all boards, this parameter can be left empty.
566 603
 		$request = $smcFunc['db_query']('', '
@@ -574,15 +611,16 @@  discard block
 block discarded – undo
574 611
 		list ($num_boards) = $smcFunc['db_fetch_row']($request);
575 612
 		$smcFunc['db_free_result']($request);
576 613
 
577
-		if (count($search_params['brd']) == $num_boards)
614
+		if (count($search_params['brd']) == $num_boards) {
615
+					$boardQuery = '';
616
+		} elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd'])) {
617
+					$boardQuery = '!= ' . $modSettings['recycle_board'];
618
+		} else {
619
+					$boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')';
620
+		}
621
+	} else {
578 622
 			$boardQuery = '';
579
-		elseif (count($search_params['brd']) == $num_boards - 1 && !empty($modSettings['recycle_board']) && !in_array($modSettings['recycle_board'], $search_params['brd']))
580
-			$boardQuery = '!= ' . $modSettings['recycle_board'];
581
-		else
582
-			$boardQuery = 'IN (' . implode(', ', $search_params['brd']) . ')';
583 623
 	}
584
-	else
585
-		$boardQuery = '';
586 624
 
587 625
 	$search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']);
588 626
 	$search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']);
@@ -596,11 +634,13 @@  discard block
 block discarded – undo
596 634
 		'id_msg',
597 635
 	);
598 636
 	call_integration_hook('integrate_search_sort_columns', array(&$sort_columns));
599
-	if (empty($search_params['sort']) && !empty($_REQUEST['sort']))
600
-		list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
637
+	if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) {
638
+			list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, '');
639
+	}
601 640
 	$search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'relevance';
602
-	if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies')
603
-		$search_params['sort'] = 'id_msg';
641
+	if (!empty($search_params['topic']) && $search_params['sort'] === 'num_replies') {
642
+			$search_params['sort'] = 'id_msg';
643
+	}
604 644
 
605 645
 	// Sorting direction: descending unless stated otherwise.
606 646
 	$search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc';
@@ -624,17 +664,19 @@  discard block
 block discarded – undo
624 664
 	// What are we searching for?
625 665
 	if (empty($search_params['search']))
626 666
 	{
627
-		if (isset($_GET['search']))
628
-			$search_params['search'] = un_htmlspecialchars($_GET['search']);
629
-		elseif (isset($_POST['search']))
630
-			$search_params['search'] = $_POST['search'];
631
-		else
632
-			$search_params['search'] = '';
667
+		if (isset($_GET['search'])) {
668
+					$search_params['search'] = un_htmlspecialchars($_GET['search']);
669
+		} elseif (isset($_POST['search'])) {
670
+					$search_params['search'] = $_POST['search'];
671
+		} else {
672
+					$search_params['search'] = '';
673
+		}
633 674
 	}
634 675
 
635 676
 	// Nothing??
636
-	if (!isset($search_params['search']) || $search_params['search'] == '')
637
-		$context['search_errors']['invalid_search_string'] = true;
677
+	if (!isset($search_params['search']) || $search_params['search'] == '') {
678
+			$context['search_errors']['invalid_search_string'] = true;
679
+	}
638 680
 	// Too long?
639 681
 	elseif ($smcFunc['strlen']($search_params['search']) > $context['search_string_limit'])
640 682
 	{
@@ -648,8 +690,9 @@  discard block
 block discarded – undo
648 690
 	$stripped_query = un_htmlspecialchars($smcFunc['strtolower']($stripped_query));
649 691
 
650 692
 	// This (hidden) setting will do fulltext searching in the most basic way.
651
-	if (!empty($modSettings['search_simple_fulltext']))
652
-		$stripped_query = strtr($stripped_query, array('"' => ''));
693
+	if (!empty($modSettings['search_simple_fulltext'])) {
694
+			$stripped_query = strtr($stripped_query, array('"' => ''));
695
+	}
653 696
 
654 697
 	$no_regexp = preg_match('~&#(?:\d{1,7}|x[0-9a-fA-F]{1,6});~', $stripped_query) === 1;
655 698
 
@@ -672,8 +715,9 @@  discard block
 block discarded – undo
672 715
 	{
673 716
 		if ($word === '-')
674 717
 		{
675
-			if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words))
676
-				$excludedWords[] = $word;
718
+			if (($word = trim($phraseArray[$index], '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) {
719
+							$excludedWords[] = $word;
720
+			}
677 721
 			unset($phraseArray[$index]);
678 722
 		}
679 723
 	}
@@ -683,8 +727,9 @@  discard block
 block discarded – undo
683 727
 	{
684 728
 		if (strpos(trim($word), '-') === 0)
685 729
 		{
686
-			if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words))
687
-				$excludedWords[] = $word;
730
+			if (($word = trim($word, '-_\' ')) !== '' && !in_array($word, $blacklisted_words)) {
731
+							$excludedWords[] = $word;
732
+			}
688 733
 			unset($wordArray[$index]);
689 734
 		}
690 735
 	}
@@ -697,8 +742,9 @@  discard block
 block discarded – undo
697 742
 	foreach ($searchArray as $index => $value)
698 743
 	{
699 744
 		// Skip anything practically empty.
700
-		if (($searchArray[$index] = trim($value, '-_\' ')) === '')
701
-			unset($searchArray[$index]);
745
+		if (($searchArray[$index] = trim($value, '-_\' ')) === '') {
746
+					unset($searchArray[$index]);
747
+		}
702 748
 		// Skip blacklisted words. Make sure to note we skipped them in case we end up with nothing.
703 749
 		elseif (in_array($searchArray[$index], $blacklisted_words))
704 750
 		{
@@ -710,39 +756,45 @@  discard block
 block discarded – undo
710 756
 		{
711 757
 			$context['search_ignored'][] = $value;
712 758
 			unset($searchArray[$index]);
759
+		} else {
760
+					$searchArray[$index] = $searchArray[$index];
713 761
 		}
714
-		else
715
-			$searchArray[$index] = $searchArray[$index];
716 762
 	}
717 763
 	$searchArray = array_slice(array_unique($searchArray), 0, 10);
718 764
 
719 765
 	// Create an array of replacements for highlighting.
720 766
 	$context['mark'] = array();
721
-	foreach ($searchArray as $word)
722
-		$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
767
+	foreach ($searchArray as $word) {
768
+			$context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>';
769
+	}
723 770
 
724 771
 	// Initialize two arrays storing the words that have to be searched for.
725 772
 	$orParts = array();
726 773
 	$searchWords = array();
727 774
 
728 775
 	// Make sure at least one word is being searched for.
729
-	if (empty($searchArray))
730
-		$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
776
+	if (empty($searchArray)) {
777
+			$context['search_errors']['invalid_search_string' . (!empty($foundBlackListedWords) ? '_blacklist' : '')] = true;
778
+	}
731 779
 	// All words/sentences must match.
732
-	elseif (empty($search_params['searchtype']))
733
-		$orParts[0] = $searchArray;
780
+	elseif (empty($search_params['searchtype'])) {
781
+			$orParts[0] = $searchArray;
782
+	}
734 783
 	// Any word/sentence must match.
735
-	else
736
-		foreach ($searchArray as $index => $value)
784
+	else {
785
+			foreach ($searchArray as $index => $value)
737 786
 			$orParts[$index] = array($value);
787
+	}
738 788
 
739 789
 	// Don't allow duplicate error messages if one string is too short.
740
-	if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string']))
741
-		unset($context['search_errors']['invalid_search_string']);
790
+	if (isset($context['search_errors']['search_string_small_words'], $context['search_errors']['invalid_search_string'])) {
791
+			unset($context['search_errors']['invalid_search_string']);
792
+	}
742 793
 	// Make sure the excluded words are in all or-branches.
743
-	foreach ($orParts as $orIndex => $andParts)
744
-		foreach ($excludedWords as $word)
794
+	foreach ($orParts as $orIndex => $andParts) {
795
+			foreach ($excludedWords as $word)
745 796
 			$orParts[$orIndex][] = $word;
797
+	}
746 798
 
747 799
 	// Determine the or-branches and the fulltext search words.
748 800
 	foreach ($orParts as $orIndex => $andParts)
@@ -756,8 +808,9 @@  discard block
 block discarded – undo
756 808
 		);
757 809
 
758 810
 		// Sort the indexed words (large words -> small words -> excluded words).
759
-		if ($searchAPI->supportsMethod('searchSort'))
760
-			usort($orParts[$orIndex], 'searchSort');
811
+		if ($searchAPI->supportsMethod('searchSort')) {
812
+					usort($orParts[$orIndex], 'searchSort');
813
+		}
761 814
 
762 815
 		foreach ($orParts[$orIndex] as $word)
763 816
 		{
@@ -769,15 +822,17 @@  discard block
 block discarded – undo
769 822
 			if (!$is_excluded || count($subjectWords) === 1)
770 823
 			{
771 824
 				$searchWords[$orIndex]['subject_words'] = array_merge($searchWords[$orIndex]['subject_words'], $subjectWords);
772
-				if ($is_excluded)
773
-					$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
825
+				if ($is_excluded) {
826
+									$excludedSubjectWords = array_merge($excludedSubjectWords, $subjectWords);
827
+				}
828
+			} else {
829
+							$excludedPhrases[] = $word;
774 830
 			}
775
-			else
776
-				$excludedPhrases[] = $word;
777 831
 
778 832
 			// Have we got indexes to prepare?
779
-			if ($searchAPI->supportsMethod('prepareIndexes'))
780
-				$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
833
+			if ($searchAPI->supportsMethod('prepareIndexes')) {
834
+							$searchAPI->prepareIndexes($word, $searchWords[$orIndex], $excludedIndexWords, $is_excluded);
835
+			}
781 836
 		}
782 837
 
783 838
 		// Search_force_index requires all AND parts to have at least one fulltext word.
@@ -785,8 +840,7 @@  discard block
 block discarded – undo
785 840
 		{
786 841
 			$context['search_errors']['query_not_specific_enough'] = true;
787 842
 			break;
788
-		}
789
-		elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
843
+		} elseif ($search_params['subject_only'] && empty($searchWords[$orIndex]['subject_words']) && empty($excludedSubjectWords))
790 844
 		{
791 845
 			$context['search_errors']['query_not_specific_enough'] = true;
792 846
 			break;
@@ -814,8 +868,9 @@  discard block
 block discarded – undo
814 868
 		$found_misspelling = false;
815 869
 		foreach ($searchArray as $word)
816 870
 		{
817
-			if (empty($link))
818
-				continue;
871
+			if (empty($link)) {
872
+							continue;
873
+			}
819 874
 
820 875
 			// Don't check phrases.
821 876
 			if (preg_match('~^\w+$~', $word) === 0)
@@ -830,8 +885,7 @@  discard block
 block discarded – undo
830 885
 				$did_you_mean['search'][] = $word;
831 886
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
832 887
 				continue;
833
-			}
834
-			elseif (spell_check($link, $word))
888
+			} elseif (spell_check($link, $word))
835 889
 			{
836 890
 				$did_you_mean['search'][] = $word;
837 891
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
@@ -842,11 +896,13 @@  discard block
 block discarded – undo
842 896
 			foreach ($suggestions as $i => $s)
843 897
 			{
844 898
 				// Search is case insensitive.
845
-				if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word))
846
-					unset($suggestions[$i]);
899
+				if ($smcFunc['strtolower']($s) == $smcFunc['strtolower']($word)) {
900
+									unset($suggestions[$i]);
901
+				}
847 902
 				// Plus, don't suggest something the user thinks is rude!
848
-				elseif ($suggestions[$i] != censorText($s))
849
-					unset($suggestions[$i]);
903
+				elseif ($suggestions[$i] != censorText($s)) {
904
+									unset($suggestions[$i]);
905
+				}
850 906
 			}
851 907
 
852 908
 			// Anything found?  If so, correct it!
@@ -856,8 +912,7 @@  discard block
 block discarded – undo
856 912
 				$did_you_mean['search'][] = $suggestions[0];
857 913
 				$did_you_mean['display'][] = '<em><strong>' . $smcFunc['htmlspecialchars']($suggestions[0]) . '</strong></em>';
858 914
 				$found_misspelling = true;
859
-			}
860
-			else
915
+			} else
861 916
 			{
862 917
 				$did_you_mean['search'][] = $word;
863 918
 				$did_you_mean['display'][] = $smcFunc['htmlspecialchars']($word);
@@ -874,8 +929,7 @@  discard block
 block discarded – undo
874 929
 				{
875 930
 					$temp_excluded['search'][] = '-"' . $word . '"';
876 931
 					$temp_excluded['display'][] = '-&quot;' . $smcFunc['htmlspecialchars']($word) . '&quot;';
877
-				}
878
-				else
932
+				} else
879 933
 				{
880 934
 					$temp_excluded['search'][] = '-' . $word;
881 935
 					$temp_excluded['display'][] = '-' . $smcFunc['htmlspecialchars']($word);
@@ -887,11 +941,13 @@  discard block
 block discarded – undo
887 941
 
888 942
 			$temp_params = $search_params;
889 943
 			$temp_params['search'] = implode(' ', $did_you_mean['search']);
890
-			if (isset($temp_params['brd']))
891
-				$temp_params['brd'] = implode(',', $temp_params['brd']);
944
+			if (isset($temp_params['brd'])) {
945
+							$temp_params['brd'] = implode(',', $temp_params['brd']);
946
+			}
892 947
 			$context['params'] = array();
893
-			foreach ($temp_params as $k => $v)
894
-				$context['did_you_mean_params'][] = $k . '|\'|' . $v;
948
+			foreach ($temp_params as $k => $v) {
949
+							$context['did_you_mean_params'][] = $k . '|\'|' . $v;
950
+			}
895 951
 			$context['did_you_mean_params'] = base64_encode(implode('|"|', $context['did_you_mean_params']));
896 952
 			$context['did_you_mean'] = implode(' ', $did_you_mean['display']);
897 953
 		}
@@ -899,18 +955,20 @@  discard block
 block discarded – undo
899 955
 
900 956
 	// Let the user adjust the search query, should they wish?
901 957
 	$context['search_params'] = $search_params;
902
-	if (isset($context['search_params']['search']))
903
-		$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
904
-	if (isset($context['search_params']['userspec']))
905
-		$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
958
+	if (isset($context['search_params']['search'])) {
959
+			$context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']);
960
+	}
961
+	if (isset($context['search_params']['userspec'])) {
962
+			$context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']);
963
+	}
906 964
 
907 965
 	// Do we have captcha enabled?
908 966
 	if ($user_info['is_guest'] && !empty($modSettings['search_enable_captcha']) && empty($_SESSION['ss_vv_passed']) && (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']))
909 967
 	{
910 968
 		// If we come from another search box tone down the error...
911
-		if (!isset($_REQUEST['search_vv']))
912
-			$context['search_errors']['need_verification_code'] = true;
913
-		else
969
+		if (!isset($_REQUEST['search_vv'])) {
970
+					$context['search_errors']['need_verification_code'] = true;
971
+		} else
914 972
 		{
915 973
 			require_once($sourcedir . '/Subs-Editor.php');
916 974
 			$verificationOptions = array(
@@ -920,12 +978,14 @@  discard block
 block discarded – undo
920 978
 
921 979
 			if (is_array($context['require_verification']))
922 980
 			{
923
-				foreach ($context['require_verification'] as $error)
924
-					$context['search_errors'][$error] = true;
981
+				foreach ($context['require_verification'] as $error) {
982
+									$context['search_errors'][$error] = true;
983
+				}
925 984
 			}
926 985
 			// Don't keep asking for it - they've proven themselves worthy.
927
-			else
928
-				$_SESSION['ss_vv_passed'] = true;
986
+			else {
987
+							$_SESSION['ss_vv_passed'] = true;
988
+			}
929 989
 		}
930 990
 	}
931 991
 
@@ -933,19 +993,22 @@  discard block
 block discarded – undo
933 993
 
934 994
 	// All search params have been checked, let's compile them to a single string... made less simple by PHP 4.3.9 and below.
935 995
 	$temp_params = $search_params;
936
-	if (isset($temp_params['brd']))
937
-		$temp_params['brd'] = implode(',', $temp_params['brd']);
996
+	if (isset($temp_params['brd'])) {
997
+			$temp_params['brd'] = implode(',', $temp_params['brd']);
998
+	}
938 999
 	$context['params'] = array();
939
-	foreach ($temp_params as $k => $v)
940
-		$context['params'][] = $k . '|\'|' . $v;
1000
+	foreach ($temp_params as $k => $v) {
1001
+			$context['params'][] = $k . '|\'|' . $v;
1002
+	}
941 1003
 
942 1004
 	if (!empty($context['params']))
943 1005
 	{
944 1006
 		// Due to old IE's 2083 character limit, we have to compress long search strings
945 1007
 		$params = @gzcompress(implode('|"|', $context['params']));
946 1008
 		// Gzcompress failed, use try non-gz
947
-		if (empty($params))
948
-			$params = implode('|"|', $context['params']);
1009
+		if (empty($params)) {
1010
+					$params = implode('|"|', $context['params']);
1011
+		}
949 1012
 		// Base64 encode, then replace +/= with uri safe ones that can be reverted
950 1013
 		$context['params'] = str_replace(array('+', '/', '='), array('-', '_', '.'), base64_encode($params));
951 1014
 	}
@@ -971,8 +1034,9 @@  discard block
 block discarded – undo
971 1034
 	}
972 1035
 
973 1036
 	// Spam me not, Spam-a-lot?
974
-	if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search'])
975
-		spamProtection('search');
1037
+	if (empty($_SESSION['last_ss']) || $_SESSION['last_ss'] != $search_params['search']) {
1038
+			spamProtection('search');
1039
+	}
976 1040
 	// Store the last search string to allow pages of results to be browsed.
977 1041
 	$_SESSION['last_ss'] = $search_params['search'];
978 1042
 
@@ -1032,8 +1096,9 @@  discard block
 block discarded – undo
1032 1096
 						'where' => array(),
1033 1097
 					);
1034 1098
 
1035
-					if ($modSettings['postmod_active'])
1036
-						$subject_query['where'][] = 't.approved = {int:is_approved}';
1099
+					if ($modSettings['postmod_active']) {
1100
+											$subject_query['where'][] = 't.approved = {int:is_approved}';
1101
+					}
1037 1102
 
1038 1103
 					$numTables = 0;
1039 1104
 					$prev_join = 0;
@@ -1045,8 +1110,7 @@  discard block
 block discarded – undo
1045 1110
 						{
1046 1111
 							$subject_query['left_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}') . ' AND subj' . $numTables . '.id_topic = t.id_topic)';
1047 1112
 							$subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
1048
-						}
1049
-						else
1113
+						} else
1050 1114
 						{
1051 1115
 							$subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)';
1052 1116
 							$subject_query['where'][] = 'subj' . $numTables . '.word ' . (empty($modSettings['search_match_words']) ? 'LIKE {string:subject_words_' . $numTables . '_wild}' : '= {string:subject_words_' . $numTables . '}');
@@ -1064,14 +1128,18 @@  discard block
 block discarded – undo
1064 1128
 						}
1065 1129
 						$subject_query['where'][] = $userQuery;
1066 1130
 					}
1067
-					if (!empty($search_params['topic']))
1068
-						$subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
1069
-					if (!empty($minMsgID))
1070
-						$subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
1071
-					if (!empty($maxMsgID))
1072
-						$subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
1073
-					if (!empty($boardQuery))
1074
-						$subject_query['where'][] = 't.id_board ' . $boardQuery;
1131
+					if (!empty($search_params['topic'])) {
1132
+											$subject_query['where'][] = 't.id_topic = ' . $search_params['topic'];
1133
+					}
1134
+					if (!empty($minMsgID)) {
1135
+											$subject_query['where'][] = 't.id_first_msg >= ' . $minMsgID;
1136
+					}
1137
+					if (!empty($maxMsgID)) {
1138
+											$subject_query['where'][] = 't.id_last_msg <= ' . $maxMsgID;
1139
+					}
1140
+					if (!empty($boardQuery)) {
1141
+											$subject_query['where'][] = 't.id_board ' . $boardQuery;
1142
+					}
1075 1143
 					if (!empty($excludedPhrases))
1076 1144
 					{
1077 1145
 						if ($subject_query['from'] != '{db_prefix}messages AS m')
@@ -1091,8 +1159,9 @@  discard block
 block discarded – undo
1091 1159
 					foreach ($weight_factors as $type => $value)
1092 1160
 					{
1093 1161
 						$relevance .= $weight[$type];
1094
-						if (!empty($value['results']))
1095
-							$relevance .= ' * ' . $value['results'];
1162
+						if (!empty($value['results'])) {
1163
+													$relevance .= ' * ' . $value['results'];
1164
+						}
1096 1165
 						$relevance .= ' + ';
1097 1166
 					}
1098 1167
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
@@ -1130,20 +1199,23 @@  discard block
 block discarded – undo
1130 1199
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1131 1200
 						{
1132 1201
 							// No duplicates!
1133
-							if (isset($inserts[$row[1]]))
1134
-								continue;
1202
+							if (isset($inserts[$row[1]])) {
1203
+															continue;
1204
+							}
1135 1205
 
1136
-							foreach ($row as $key => $value)
1137
-								$inserts[$row[1]][] = (int) $row[$key];
1206
+							foreach ($row as $key => $value) {
1207
+															$inserts[$row[1]][] = (int) $row[$key];
1208
+							}
1138 1209
 						}
1139 1210
 						$smcFunc['db_free_result']($ignoreRequest);
1140 1211
 						$numSubjectResults = count($inserts);
1212
+					} else {
1213
+											$numSubjectResults += $smcFunc['db_affected_rows']();
1141 1214
 					}
1142
-					else
1143
-						$numSubjectResults += $smcFunc['db_affected_rows']();
1144 1215
 
1145
-					if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
1146
-						break;
1216
+					if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) {
1217
+											break;
1218
+					}
1147 1219
 				}
1148 1220
 
1149 1221
 				// If there's data to be inserted for non-IGNORE databases do it here!
@@ -1158,8 +1230,7 @@  discard block
 block discarded – undo
1158 1230
 				}
1159 1231
 
1160 1232
 				$_SESSION['search_cache']['num_results'] = $numSubjectResults;
1161
-			}
1162
-			else
1233
+			} else
1163 1234
 			{
1164 1235
 				$main_query = array(
1165 1236
 					'select' => array(
@@ -1191,8 +1262,7 @@  discard block
 block discarded – undo
1191 1262
 					$main_query['weights'] = $weight_factors;
1192 1263
 
1193 1264
 					$main_query['group_by'][] = 't.id_topic';
1194
-				}
1195
-				else
1265
+				} else
1196 1266
 				{
1197 1267
 					// This is outrageous!
1198 1268
 					$main_query['select']['id_topic'] = 'm.id_msg AS id_topic';
@@ -1213,8 +1283,9 @@  discard block
 block discarded – undo
1213 1283
 						$main_query['where'][] = 't.id_topic = {int:topic}';
1214 1284
 						$main_query['parameters']['topic'] = $search_params['topic'];
1215 1285
 					}
1216
-					if (!empty($search_params['show_complete']))
1217
-						$main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
1286
+					if (!empty($search_params['show_complete'])) {
1287
+											$main_query['group_by'][] = 'm.id_msg, t.id_first_msg, t.id_last_msg';
1288
+					}
1218 1289
 				}
1219 1290
 
1220 1291
 				// *** Get the subject results.
@@ -1241,14 +1312,15 @@  discard block
 block discarded – undo
1241 1312
 					) !== false;
1242 1313
 
1243 1314
 					// Clean up some previous cache.
1244
-					if (!$createTemporary)
1245
-						$smcFunc['db_search_query']('delete_log_search_topics', '
1315
+					if (!$createTemporary) {
1316
+											$smcFunc['db_search_query']('delete_log_search_topics', '
1246 1317
 							DELETE FROM {db_prefix}log_search_topics
1247 1318
 							WHERE id_search = {int:search_id}',
1248 1319
 							array(
1249 1320
 								'search_id' => $_SESSION['search_cache']['id_search'],
1250 1321
 							)
1251 1322
 						);
1323
+					}
1252 1324
 
1253 1325
 					foreach ($searchWords as $orIndex => $words)
1254 1326
 					{
@@ -1280,8 +1352,7 @@  discard block
 block discarded – undo
1280 1352
 								$subject_query['where'][] = '(subj' . $numTables . '.word IS NULL)';
1281 1353
 								$subject_query['where'][] = 'm.body NOT ' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:body_not_' . $count . '}';
1282 1354
 								$subject_query['params']['body_not_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($subjectWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $subjectWord), '\\\'') . '[[:>:]]';
1283
-							}
1284
-							else
1355
+							} else
1285 1356
 							{
1286 1357
 								$subject_query['inner_join'][] = '{db_prefix}log_search_subjects AS subj' . $numTables . ' ON (subj' . $numTables . '.id_topic = ' . ($prev_join === 0 ? 't' : 'subj' . $prev_join) . '.id_topic)';
1287 1358
 								$subject_query['where'][] = 'subj' . $numTables . '.word LIKE {string:subject_like_' . $count . '}';
@@ -1336,8 +1407,9 @@  discard block
 block discarded – undo
1336 1407
 						call_integration_hook('integrate_subject_search_query', array(&$subject_query));
1337 1408
 
1338 1409
 						// Nothing to search for?
1339
-						if (empty($subject_query['where']))
1340
-							continue;
1410
+						if (empty($subject_query['where'])) {
1411
+													continue;
1412
+						}
1341 1413
 
1342 1414
 						$ignoreRequest = $smcFunc['db_search_query']('insert_log_search_topics', ($smcFunc['db_support_ignore'] ? ( '
1343 1415
 							INSERT IGNORE INTO {db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics
@@ -1360,19 +1432,21 @@  discard block
 block discarded – undo
1360 1432
 							{
1361 1433
 								$ind = $createTemporary ? 0 : 1;
1362 1434
 								// No duplicates!
1363
-								if (isset($inserts[$row[$ind]]))
1364
-									continue;
1435
+								if (isset($inserts[$row[$ind]])) {
1436
+																	continue;
1437
+								}
1365 1438
 
1366 1439
 								$inserts[$row[$ind]] = $row;
1367 1440
 							}
1368 1441
 							$smcFunc['db_free_result']($ignoreRequest);
1369 1442
 							$numSubjectResults = count($inserts);
1443
+						} else {
1444
+													$numSubjectResults += $smcFunc['db_affected_rows']();
1370 1445
 						}
1371
-						else
1372
-							$numSubjectResults += $smcFunc['db_affected_rows']();
1373 1446
 
1374
-						if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results'])
1375
-							break;
1447
+						if (!empty($modSettings['search_max_results']) && $numSubjectResults >= $modSettings['search_max_results']) {
1448
+													break;
1449
+						}
1376 1450
 					}
1377 1451
 
1378 1452
 					// Got some non-MySQL data to plonk in?
@@ -1390,8 +1464,9 @@  discard block
 block discarded – undo
1390 1464
 					{
1391 1465
 						$main_query['weights']['subject']['search'] = 'CASE WHEN MAX(lst.id_topic) IS NULL THEN 0 ELSE 1 END';
1392 1466
 						$main_query['left_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_topics AS lst ON (' . ($createTemporary ? '' : 'lst.id_search = {int:id_search} AND ') . 'lst.id_topic = t.id_topic)';
1393
-						if (!$createTemporary)
1394
-							$main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
1467
+						if (!$createTemporary) {
1468
+													$main_query['parameters']['id_search'] = $_SESSION['search_cache']['id_search'];
1469
+						}
1395 1470
 					}
1396 1471
 				}
1397 1472
 
@@ -1419,14 +1494,15 @@  discard block
 block discarded – undo
1419 1494
 					) !== false;
1420 1495
 
1421 1496
 					// Clear, all clear!
1422
-					if (!$createTemporary)
1423
-						$smcFunc['db_search_query']('delete_log_search_messages', '
1497
+					if (!$createTemporary) {
1498
+											$smcFunc['db_search_query']('delete_log_search_messages', '
1424 1499
 							DELETE FROM {db_prefix}log_search_messages
1425 1500
 							WHERE id_search = {int:id_search}',
1426 1501
 							array(
1427 1502
 								'id_search' => $_SESSION['search_cache']['id_search'],
1428 1503
 							)
1429 1504
 						);
1505
+					}
1430 1506
 
1431 1507
 					foreach ($searchWords as $orIndex => $words)
1432 1508
 					{
@@ -1460,19 +1536,21 @@  discard block
 block discarded – undo
1460 1536
 								while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1461 1537
 								{
1462 1538
 									// No duplicates!
1463
-									if (isset($inserts[$row[0]]))
1464
-										continue;
1539
+									if (isset($inserts[$row[0]])) {
1540
+																			continue;
1541
+									}
1465 1542
 
1466 1543
 									$inserts[$row[0]] = $row;
1467 1544
 								}
1468 1545
 								$smcFunc['db_free_result']($ignoreRequest);
1469 1546
 								$indexedResults = count($inserts);
1547
+							} else {
1548
+															$indexedResults += $smcFunc['db_affected_rows']();
1470 1549
 							}
1471
-							else
1472
-								$indexedResults += $smcFunc['db_affected_rows']();
1473 1550
 
1474
-							if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults)
1475
-								break;
1551
+							if (!empty($maxMessageResults) && $indexedResults >= $maxMessageResults) {
1552
+															break;
1553
+							}
1476 1554
 						}
1477 1555
 					}
1478 1556
 
@@ -1492,8 +1570,7 @@  discard block
 block discarded – undo
1492 1570
 						$context['search_errors']['query_not_specific_enough'] = true;
1493 1571
 						$_REQUEST['params'] = $context['params'];
1494 1572
 						return PlushSearch1();
1495
-					}
1496
-					elseif (!empty($indexedResults))
1573
+					} elseif (!empty($indexedResults))
1497 1574
 					{
1498 1575
 						$main_query['inner_join'][] = '{db_prefix}' . ($createTemporary ? 'tmp_' : '') . 'log_search_messages AS lsm ON (lsm.id_msg = m.id_msg)';
1499 1576
 						if (!$createTemporary)
@@ -1515,15 +1592,18 @@  discard block
 block discarded – undo
1515 1592
 						foreach ($words['all_words'] as $regularWord)
1516 1593
 						{
1517 1594
 							$where[] = 'm.body' . (in_array($regularWord, $excludedWords) ? ' NOT' : '') . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1518
-							if (in_array($regularWord, $excludedWords))
1519
-								$where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1595
+							if (in_array($regularWord, $excludedWords)) {
1596
+															$where[] = 'm.subject NOT' . (empty($modSettings['search_match_words']) || $no_regexp ? ' LIKE ' : ' RLIKE ') . '{string:all_word_body_' . $count . '}';
1597
+							}
1520 1598
 							$main_query['parameters']['all_word_body_' . $count++] = empty($modSettings['search_match_words']) || $no_regexp ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]';
1521 1599
 						}
1522
-						if (!empty($where))
1523
-							$orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
1600
+						if (!empty($where)) {
1601
+													$orWhere[] = count($where) > 1 ? '(' . implode(' AND ', $where) . ')' : $where[0];
1602
+						}
1603
+					}
1604
+					if (!empty($orWhere)) {
1605
+											$main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];
1524 1606
 					}
1525
-					if (!empty($orWhere))
1526
-						$main_query['where'][] = count($orWhere) > 1 ? '(' . implode(' OR ', $orWhere) . ')' : $orWhere[0];
1527 1607
 
1528 1608
 					if (!empty($userQuery))
1529 1609
 					{
@@ -1561,8 +1641,9 @@  discard block
 block discarded – undo
1561 1641
 					foreach ($main_query['weights'] as $type => $value)
1562 1642
 					{
1563 1643
 						$relevance .= $weight[$type];
1564
-						if (!empty($value['search']))
1565
-							$relevance .= ' * ' . $value['search'];
1644
+						if (!empty($value['search'])) {
1645
+													$relevance .= ' * ' . $value['search'];
1646
+						}
1566 1647
 						$relevance .= ' + ';
1567 1648
 						$new_weight_total += $weight[$type];
1568 1649
 					}
@@ -1593,11 +1674,13 @@  discard block
 block discarded – undo
1593 1674
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1594 1675
 						{
1595 1676
 							// No duplicates!
1596
-							if (isset($inserts[$row[2]]))
1597
-								continue;
1677
+							if (isset($inserts[$row[2]])) {
1678
+															continue;
1679
+							}
1598 1680
 
1599
-							foreach ($row as $key => $value)
1600
-								$inserts[$row[2]][] = (int) $row[$key];
1681
+							foreach ($row as $key => $value) {
1682
+															$inserts[$row[2]][] = (int) $row[$key];
1683
+							}
1601 1684
 						}
1602 1685
 						$smcFunc['db_free_result']($ignoreRequest);
1603 1686
 
@@ -1605,8 +1688,9 @@  discard block
 block discarded – undo
1605 1688
 						if (!empty($inserts))
1606 1689
 						{
1607 1690
 							$query_columns = array();
1608
-							foreach ($main_query['select'] as $k => $v)
1609
-								$query_columns[$k] = 'int';
1691
+							foreach ($main_query['select'] as $k => $v) {
1692
+															$query_columns[$k] = 'int';
1693
+							}
1610 1694
 
1611 1695
 							$smcFunc['db_insert']('',
1612 1696
 								'{db_prefix}log_search_results',
@@ -1616,21 +1700,23 @@  discard block
 block discarded – undo
1616 1700
 							);
1617 1701
 						}
1618 1702
 						$_SESSION['search_cache']['num_results'] += count($inserts);
1703
+					} else {
1704
+											$_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
1619 1705
 					}
1620
-					else
1621
-						$_SESSION['search_cache']['num_results'] = $smcFunc['db_affected_rows']();
1622 1706
 				}
1623 1707
 
1624 1708
 				// Insert subject-only matches.
1625 1709
 				if ($_SESSION['search_cache']['num_results'] < $modSettings['search_max_results'] && $numSubjectResults !== 0)
1626 1710
 				{
1627 1711
 					$relevance = '1000 * (';
1628
-					foreach ($weight_factors as $type => $value)
1629
-						if (isset($value['results']))
1712
+					foreach ($weight_factors as $type => $value) {
1713
+											if (isset($value['results']))
1630 1714
 						{
1631 1715
 							$relevance .= $weight[$type];
1632
-							if (!empty($value['results']))
1633
-								$relevance .= ' * ' . $value['results'];
1716
+					}
1717
+							if (!empty($value['results'])) {
1718
+															$relevance .= ' * ' . $value['results'];
1719
+							}
1634 1720
 							$relevance .= ' + ';
1635 1721
 						}
1636 1722
 					$relevance = substr($relevance, 0, -3) . ') / ' . $weight_total . ' AS relevance';
@@ -1664,8 +1750,9 @@  discard block
 block discarded – undo
1664 1750
 						while ($row = $smcFunc['db_fetch_row']($ignoreRequest))
1665 1751
 						{
1666 1752
 							// No duplicates!
1667
-							if (isset($usedIDs[$row[1]]))
1668
-								continue;
1753
+							if (isset($usedIDs[$row[1]])) {
1754
+															continue;
1755
+							}
1669 1756
 
1670 1757
 							$usedIDs[$row[1]] = true;
1671 1758
 							$inserts[] = $row;
@@ -1683,12 +1770,12 @@  discard block
 block discarded – undo
1683 1770
 							);
1684 1771
 						}
1685 1772
 						$_SESSION['search_cache']['num_results'] += count($inserts);
1773
+					} else {
1774
+											$_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
1686 1775
 					}
1687
-					else
1688
-						$_SESSION['search_cache']['num_results'] += $smcFunc['db_affected_rows']();
1776
+				} elseif ($_SESSION['search_cache']['num_results'] == -1) {
1777
+									$_SESSION['search_cache']['num_results'] = 0;
1689 1778
 				}
1690
-				elseif ($_SESSION['search_cache']['num_results'] == -1)
1691
-					$_SESSION['search_cache']['num_results'] = 0;
1692 1779
 			}
1693 1780
 		}
1694 1781
 
@@ -1758,14 +1845,16 @@  discard block
 block discarded – undo
1758 1845
 			)
1759 1846
 		);
1760 1847
 		$posters = array();
1761
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1762
-			$posters[] = $row['id_member'];
1848
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1849
+					$posters[] = $row['id_member'];
1850
+		}
1763 1851
 		$smcFunc['db_free_result']($request);
1764 1852
 
1765 1853
 		call_integration_hook('integrate_search_message_list', array(&$msg_list, &$posters));
1766 1854
 
1767
-		if (!empty($posters))
1768
-			loadMemberData(array_unique($posters));
1855
+		if (!empty($posters)) {
1856
+					loadMemberData(array_unique($posters));
1857
+		}
1769 1858
 
1770 1859
 		// Get the messages out for the callback - select enough that it can be made to look just like Display.
1771 1860
 		$messages_request = $smcFunc['db_query']('', '
@@ -1799,8 +1888,9 @@  discard block
 block discarded – undo
1799 1888
 		);
1800 1889
 
1801 1890
 		// If there are no results that means the things in the cache got deleted, so pretend we have no topics anymore.
1802
-		if ($smcFunc['db_num_rows']($messages_request) == 0)
1803
-			$context['topics'] = array();
1891
+		if ($smcFunc['db_num_rows']($messages_request) == 0) {
1892
+					$context['topics'] = array();
1893
+		}
1804 1894
 
1805 1895
 		// If we want to know who participated in what then load this now.
1806 1896
 		if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'])
@@ -1818,8 +1908,9 @@  discard block
 block discarded – undo
1818 1908
 					'limit' => count($participants),
1819 1909
 				)
1820 1910
 			);
1821
-			while ($row = $smcFunc['db_fetch_assoc']($result))
1822
-				$participants[$row['id_topic']] = true;
1911
+			while ($row = $smcFunc['db_fetch_assoc']($result)) {
1912
+							$participants[$row['id_topic']] = true;
1913
+			}
1823 1914
 			$smcFunc['db_free_result']($result);
1824 1915
 		}
1825 1916
 	}
@@ -1828,15 +1919,17 @@  discard block
 block discarded – undo
1828 1919
 	$context['page_index'] = constructPageIndex($scripturl . '?action=search2;params=' . $context['params'], $_REQUEST['start'], $num_results, $modSettings['search_results_per_page'], false);
1829 1920
 
1830 1921
 	// Consider the search complete!
1831
-	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
1832
-		cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);
1922
+	if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
1923
+			cache_put_data('search_start:' . ($user_info['is_guest'] ? $user_info['ip'] : $user_info['id']), null, 90);
1924
+	}
1833 1925
 
1834 1926
 	$context['key_words'] = &$searchArray;
1835 1927
 
1836 1928
 	// Setup the default topic icons... for checking they exist and the like!
1837 1929
 	$context['icon_sources'] = array();
1838
-	foreach ($context['stable_icons'] as $icon)
1839
-		$context['icon_sources'][$icon] = 'images_url';
1930
+	foreach ($context['stable_icons'] as $icon) {
1931
+			$context['icon_sources'][$icon] = 'images_url';
1932
+	}
1840 1933
 
1841 1934
 	$context['sub_template'] = 'results';
1842 1935
 	$context['page_title'] = $txt['search_results'];
@@ -1867,26 +1960,31 @@  discard block
 block discarded – undo
1867 1960
 	global $boards_can, $participants, $smcFunc;
1868 1961
 	static $recycle_board = null;
1869 1962
 
1870
-	if ($recycle_board === null)
1871
-		$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
1963
+	if ($recycle_board === null) {
1964
+			$recycle_board = !empty($modSettings['recycle_enable']) && !empty($modSettings['recycle_board']) ? (int) $modSettings['recycle_board'] : 0;
1965
+	}
1872 1966
 
1873 1967
 	// Remember which message this is.  (ie. reply #83)
1874 1968
 	static $counter = null;
1875
-	if ($counter == null || $reset)
1876
-		$counter = $_REQUEST['start'] + 1;
1969
+	if ($counter == null || $reset) {
1970
+			$counter = $_REQUEST['start'] + 1;
1971
+	}
1877 1972
 
1878 1973
 	// If the query returned false, bail.
1879
-	if ($messages_request == false)
1880
-		return false;
1974
+	if ($messages_request == false) {
1975
+			return false;
1976
+	}
1881 1977
 
1882 1978
 	// Start from the beginning...
1883
-	if ($reset)
1884
-		return @$smcFunc['db_data_seek']($messages_request, 0);
1979
+	if ($reset) {
1980
+			return @$smcFunc['db_data_seek']($messages_request, 0);
1981
+	}
1885 1982
 
1886 1983
 	// Attempt to get the next message.
1887 1984
 	$message = $smcFunc['db_fetch_assoc']($messages_request);
1888
-	if (!$message)
1889
-		return false;
1985
+	if (!$message) {
1986
+			return false;
1987
+	}
1890 1988
 
1891 1989
 	// Can't have an empty subject can we?
1892 1990
 	$message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject'];
@@ -1925,9 +2023,9 @@  discard block
 block discarded – undo
1925 2023
 
1926 2024
 		if ($smcFunc['strlen']($message['body']) > $charLimit)
1927 2025
 		{
1928
-			if (empty($context['key_words']))
1929
-				$message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
1930
-			else
2026
+			if (empty($context['key_words'])) {
2027
+							$message['body'] = $smcFunc['substr']($message['body'], 0, $charLimit) . '<strong>...</strong>';
2028
+			} else
1931 2029
 			{
1932 2030
 				$matchString = '';
1933 2031
 				$force_partial_word = false;
@@ -1936,18 +2034,20 @@  discard block
 block discarded – undo
1936 2034
 					$keyword = un_htmlspecialchars($keyword);
1937 2035
 					$keyword = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&amp;')));
1938 2036
 
1939
-					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0)
1940
-						$force_partial_word = true;
2037
+					if (preg_match('~[\'\.,/@%&;:(){}\[\]_\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\.,/@%&;:(){}\[\]_\-+\\\\]~', $keyword) != 0) {
2038
+											$force_partial_word = true;
2039
+					}
1941 2040
 					$matchString .= strtr(preg_quote($keyword, '/'), array('\*' => '.+?')) . '|';
1942 2041
 				}
1943 2042
 				$matchString = un_htmlspecialchars(substr($matchString, 0, -1));
1944 2043
 
1945 2044
 				$message['body'] = un_htmlspecialchars(strtr($message['body'], array('&nbsp;' => ' ', '<br>' => "\n", '&#91;' => '[', '&#93;' => ']', '&#58;' => ':', '&#64;' => '@')));
1946 2045
 
1947
-				if (empty($modSettings['search_method']) || $force_partial_word)
1948
-					preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
1949
-				else
1950
-					preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2046
+				if (empty($modSettings['search_method']) || $force_partial_word) {
2047
+									preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\s\W]|[^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2048
+				} else {
2049
+									preg_match_all('/([^\s\W]{' . $charLimit . '}[\s\W]|[\s\W].{0,' . $charLimit . '}?[\s\W]|^)(' . $matchString . ')([\s\W].{0,' . $charLimit . '}[\s\W]|[\s\W][^\s\W]{0,' . $charLimit . '})/is' . ($context['utf8'] ? 'u' : ''), $message['body'], $matches);
2050
+				}
1951 2051
 
1952 2052
 				$message['body'] = '';
1953 2053
 				foreach ($matches[0] as $index => $match)
@@ -1960,8 +2060,7 @@  discard block
 block discarded – undo
1960 2060
 			// Re-fix the international characters.
1961 2061
 			$message['body'] = preg_replace_callback('~(&amp;#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']);
1962 2062
 		}
1963
-	}
1964
-	else
2063
+	} else
1965 2064
 	{
1966 2065
 		// Run BBC interpreter on the message.
1967 2066
 		$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
@@ -1980,21 +2079,26 @@  discard block
 block discarded – undo
1980 2079
 	// Sadly, we need to check the icon ain't broke.
1981 2080
 	if (!empty($modSettings['messageIconChecks_enable']))
1982 2081
 	{
1983
-		if (!isset($context['icon_sources'][$message['first_icon']]))
1984
-			$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
1985
-		if (!isset($context['icon_sources'][$message['last_icon']]))
1986
-			$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
1987
-		if (!isset($context['icon_sources'][$message['icon']]))
1988
-			$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
1989
-	}
1990
-	else
2082
+		if (!isset($context['icon_sources'][$message['first_icon']])) {
2083
+					$context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
2084
+		}
2085
+		if (!isset($context['icon_sources'][$message['last_icon']])) {
2086
+					$context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
2087
+		}
2088
+		if (!isset($context['icon_sources'][$message['icon']])) {
2089
+					$context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
2090
+		}
2091
+	} else
1991 2092
 	{
1992
-		if (!isset($context['icon_sources'][$message['first_icon']]))
1993
-			$context['icon_sources'][$message['first_icon']] = 'images_url';
1994
-		if (!isset($context['icon_sources'][$message['last_icon']]))
1995
-			$context['icon_sources'][$message['last_icon']] = 'images_url';
1996
-		if (!isset($context['icon_sources'][$message['icon']]))
1997
-			$context['icon_sources'][$message['icon']] = 'images_url';
2093
+		if (!isset($context['icon_sources'][$message['first_icon']])) {
2094
+					$context['icon_sources'][$message['first_icon']] = 'images_url';
2095
+		}
2096
+		if (!isset($context['icon_sources'][$message['last_icon']])) {
2097
+					$context['icon_sources'][$message['last_icon']] = 'images_url';
2098
+		}
2099
+		if (!isset($context['icon_sources'][$message['icon']])) {
2100
+					$context['icon_sources'][$message['icon']] = 'images_url';
2101
+		}
1998 2102
 	}
1999 2103
 
2000 2104
 	// Do we have quote tag enabled?
@@ -2004,12 +2108,14 @@  discard block
 block discarded – undo
2004 2108
 	$colorClass = 'windowbg';
2005 2109
 
2006 2110
 	// Sticky topics should get a different color, too.
2007
-	if ($message['is_sticky'])
2008
-		$colorClass .= ' sticky';
2111
+	if ($message['is_sticky']) {
2112
+			$colorClass .= ' sticky';
2113
+	}
2009 2114
 
2010 2115
 	// Locked topics get special treatment as well.
2011
-	if ($message['locked'])
2012
-		$colorClass .= ' locked';
2116
+	if ($message['locked']) {
2117
+			$colorClass .= ' locked';
2118
+	}
2013 2119
 
2014 2120
 	$output = array_merge($context['topics'][$message['id_msg']], array(
2015 2121
 		'id' => $message['id_topic'],
@@ -2153,8 +2259,9 @@  discard block
 block discarded – undo
2153 2259
 
2154 2260
 	// Load up the search API we are going to use.
2155 2261
 	$modSettings['search_index'] = empty($modSettings['search_index']) ? 'standard' : $modSettings['search_index'];
2156
-	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php'))
2157
-		fatal_lang_error('search_api_missing');
2262
+	if (!file_exists($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php')) {
2263
+			fatal_lang_error('search_api_missing');
2264
+	}
2158 2265
 	require_once($sourcedir . '/SearchAPI-' . ucwords($modSettings['search_index']) . '.php');
2159 2266
 
2160 2267
 	// Create an instance of the search API and check it is valid for this version of SMF.
Please login to merge, or discard this patch.
Themes/default/ManageMaintenance.template.php 1 patch
Braces   +36 added lines, -25 removed lines patch added patch discarded remove patch
@@ -18,11 +18,12 @@  discard block
 block discarded – undo
18 18
 	global $context, $txt, $scripturl, $modSettings;
19 19
 
20 20
 	// If maintenance has finished tell the user.
21
-	if (!empty($context['maintenance_finished']))
22
-		echo '
21
+	if (!empty($context['maintenance_finished'])) {
22
+			echo '
23 23
 			<div class="infobox">
24 24
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
25 25
 			</div>';
26
+	}
26 27
 
27 28
 	echo '
28 29
 	<div id="manage_maintenance">
@@ -107,11 +108,12 @@  discard block
 block discarded – undo
107 108
 	<div id="manage_maintenance">';
108 109
 
109 110
 	// If maintenance has finished tell the user.
110
-	if (!empty($context['maintenance_finished']))
111
-		echo '
111
+	if (!empty($context['maintenance_finished'])) {
112
+			echo '
112 113
 			<div class="infobox">
113 114
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
114 115
 			</div>';
116
+	}
115 117
 
116 118
 	echo '
117 119
 		<div class="cat_bar">
@@ -238,11 +240,12 @@  discard block
 block discarded – undo
238 240
 	<div id="manage_maintenance">';
239 241
 
240 242
 	// If maintenance has finished tell the user.
241
-	if (!empty($context['maintenance_finished']))
242
-	echo '
243
+	if (!empty($context['maintenance_finished'])) {
244
+		echo '
243 245
 		<div class="infobox">
244 246
 			', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
245 247
 		</div>';
248
+	}
246 249
 
247 250
 	echo '
248 251
 		<div class="cat_bar">
@@ -300,9 +303,10 @@  discard block
 block discarded – undo
300 303
 				<p><a href="#membersLink" onclick="swapMembers();"><img src="', $settings['images_url'], '/selected.png" alt="+" id="membersIcon"></a> <a href="#membersLink" onclick="swapMembers();" id="membersText" style="font-weight: bold;">', $txt['maintain_members_all'], '</a></p>
301 304
 				<div style="display: none; padding: 3px" id="membersPanel">';
302 305
 
303
-	foreach ($context['membergroups'] as $group)
304
-		echo '
306
+	foreach ($context['membergroups'] as $group) {
307
+			echo '
305 308
 					<label for="groups', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups', $group['id'], '" checked class="input_check"> ', $group['name'], '</label><br>';
309
+	}
306 310
 
307 311
 	echo '
308 312
 				</div>
@@ -346,11 +350,12 @@  discard block
 block discarded – undo
346 350
 	global $scripturl, $txt, $context, $settings, $modSettings;
347 351
 
348 352
 	// If maintenance has finished tell the user.
349
-	if (!empty($context['maintenance_finished']))
350
-		echo '
353
+	if (!empty($context['maintenance_finished'])) {
354
+			echo '
351 355
 			<div class="infobox">
352 356
 				', sprintf($txt['maintain_done'], $context['maintenance_finished']), '
353 357
 			</div>';
358
+	}
354 359
 
355 360
 	// Bit of javascript for showing which boards to prune in an otherwise hidden list.
356 361
 	echo '
@@ -418,19 +423,21 @@  discard block
 block discarded – undo
418 423
 								<ul>';
419 424
 
420 425
 		// Display a checkbox with every board.
421
-		foreach ($category['boards'] as $board)
422
-			echo '
426
+		foreach ($category['boards'] as $board) {
427
+					echo '
423 428
 									<li style="margin-', $context['right_to_left'] ? 'right' : 'left', ': ', $board['child_level'] * 1.5, 'em;"><label for="boards_', $board['id'], '"><input type="checkbox" name="boards[', $board['id'], ']" id="boards_', $board['id'], '" checked class="input_check">', $board['name'], '</label></li>';
429
+		}
424 430
 
425 431
 		echo '
426 432
 								</ul>
427 433
 							</fieldset>';
428 434
 
429 435
 		// Increase $i, and check if we're at the middle yet.
430
-		if (++$i == $middle)
431
-			echo '
436
+		if (++$i == $middle) {
437
+					echo '
432 438
 						</div>
433 439
 						<div class="floatright" style="width: 49%;">';
440
+		}
434 441
 	}
435 442
 
436 443
 	echo '
@@ -469,9 +476,10 @@  discard block
 block discarded – undo
469 476
 		echo '
470 477
 					<optgroup label="', $category['name'], '">';
471 478
 
472
-		foreach ($category['boards'] as $board)
473
-			echo '
479
+		foreach ($category['boards'] as $board) {
480
+					echo '
474 481
 						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
482
+		}
475 483
 
476 484
 		echo '
477 485
 					</optgroup>';
@@ -489,9 +497,10 @@  discard block
 block discarded – undo
489 497
 		echo '
490 498
 					<optgroup label="', $category['name'], '">';
491 499
 
492
-		foreach ($category['boards'] as $board)
493
-			echo '
500
+		foreach ($category['boards'] as $board) {
501
+					echo '
494 502
 						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
503
+		}
495 504
 
496 505
 		echo '
497 506
 					</optgroup>';
@@ -531,9 +540,10 @@  discard block
 block discarded – undo
531 540
 				', $txt['database_optimize_attempt'], '<br>';
532 541
 
533 542
 	// List each table being optimized...
534
-	foreach ($context['optimized_tables'] as $table)
535
-		echo '
543
+	foreach ($context['optimized_tables'] as $table) {
544
+			echo '
536 545
 				', sprintf($txt['database_optimizing'], $table['name'], $table['data_freed']), '<br>';
546
+	}
537 547
 
538 548
 	// How did we go?
539 549
 	echo '
@@ -590,13 +600,14 @@  discard block
 block discarded – undo
590 600
 				', implode('</li><li>', $context['exceeding_messages']), '
591 601
 				</li>
592 602
 			</ul>';
593
-		if (!empty($context['exceeding_messages_morethan']))
594
-			echo '
603
+		if (!empty($context['exceeding_messages_morethan'])) {
604
+					echo '
595 605
 			<p>', $context['exceeding_messages_morethan'], '</p>';
596
-	}
597
-	else
598
-		echo '
606
+		}
607
+	} else {
608
+			echo '
599 609
 			<p class="infobox">', $txt['convert_to_text'], '</p>';
610
+	}
600 611
 
601 612
 	echo '
602 613
 			<form action="', $scripturl, '?action=admin;area=maintain;sa=database;activity=convertmsgbody" method="post" accept-charset="', $context['character_set'], '">
Please login to merge, or discard this patch.
Themes/default/Reports.template.php 1 patch
Braces   +32 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,9 +29,10 @@  discard block
 block discarded – undo
29 29
 	// Go through each type of report they can run.
30 30
 	foreach ($context['report_types'] as $type)
31 31
 	{
32
-		if (isset($type['description']))
33
-			echo '
32
+		if (isset($type['description'])) {
33
+					echo '
34 34
 					<dt>', $type['description'], '</dt>';
35
+		}
35 36
 		echo '
36 37
 					<dd>
37 38
 						<input type="radio" id="rt_', $type['id'], '" name="rt" value="', $type['id'], '"', $type['is_first'] ? ' checked' : '', ' class="input_radio">
@@ -61,8 +62,9 @@  discard block
 block discarded – undo
61 62
 		</div>
62 63
 		<div id="report_buttons">';
63 64
 
64
-	if (!empty($context['report_buttons']))
65
-		template_button_strip($context['report_buttons'], 'right');
65
+	if (!empty($context['report_buttons'])) {
66
+			template_button_strip($context['report_buttons'], 'right');
67
+	}
66 68
 
67 69
 	echo '
68 70
 		</div>';
@@ -73,25 +75,27 @@  discard block
 block discarded – undo
73 75
 		echo '
74 76
 		<table class="table_grid report_results">';
75 77
 
76
-		if (!empty($table['title']))
77
-			echo '
78
+		if (!empty($table['title'])) {
79
+					echo '
78 80
 			<thead>
79 81
 				<tr class="title_bar">
80 82
 					<th scope="col" colspan="', $table['column_count'], '">', $table['title'], '</th>
81 83
 				</tr>
82 84
 			</thead>
83 85
 			<tbody>';
86
+		}
84 87
 
85 88
 		// Now do each row!
86 89
 		$row_number = 0;
87 90
 		foreach ($table['data'] as $row)
88 91
 		{
89
-			if ($row_number == 0 && !empty($table['shading']['top']))
90
-				echo '
92
+			if ($row_number == 0 && !empty($table['shading']['top'])) {
93
+							echo '
91 94
 				<tr class="windowbg table_caption">';
92
-			else
93
-				echo '
95
+			} else {
96
+							echo '
94 97
 				<tr class="', !empty($row[0]['separator']) ? 'title_bar' : 'windowbg', '">';
98
+			}
95 99
 
96 100
 			// Now do each column.
97 101
 			$column_number = 0;
@@ -109,16 +113,17 @@  discard block
 block discarded – undo
109 113
 				}
110 114
 
111 115
 				// Shaded?
112
-				if ($column_number == 0 && !empty($table['shading']['left']))
113
-					echo '
116
+				if ($column_number == 0 && !empty($table['shading']['left'])) {
117
+									echo '
114 118
 					<td class="table_caption ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '>
115 119
 						', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), '
116 120
 					</td>';
117
-				else
118
-					echo '
121
+				} else {
122
+									echo '
119 123
 					<td class="smalltext centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '>
120 124
 						', $data['v'], '
121 125
 					</td>';
126
+				}
122 127
 
123 128
 				$column_number++;
124 129
 			}
@@ -167,24 +172,26 @@  discard block
 block discarded – undo
167 172
 		<div style="overflow: visible;', $table['max_width'] != 'auto' ? ' width: ' . $table['max_width'] . 'px;' : '', '">
168 173
 			<table class="bordercolor">';
169 174
 
170
-		if (!empty($table['title']))
171
-			echo '
175
+		if (!empty($table['title'])) {
176
+					echo '
172 177
 				<tr class="title_bar">
173 178
 					<td colspan="', $table['column_count'], '">
174 179
 						', $table['title'], '
175 180
 					</td>
176 181
 				</tr>';
182
+		}
177 183
 
178 184
 		// Now do each row!
179 185
 		$row_number = 0;
180 186
 		foreach ($table['data'] as $row)
181 187
 		{
182
-			if ($row_number == 0 && !empty($table['shading']['top']))
183
-				echo '
188
+			if ($row_number == 0 && !empty($table['shading']['top'])) {
189
+							echo '
184 190
 				<tr class="titlebg">';
185
-			else
186
-				echo '
191
+			} else {
192
+							echo '
187 193
 				<tr class="windowbg">';
194
+			}
188 195
 
189 196
 			// Now do each column!!
190 197
 			$column_number = 0;
@@ -201,16 +208,17 @@  discard block
 block discarded – undo
201 208
 				}
202 209
 
203 210
 				// Shaded?
204
-				if ($column_number == 0 && !empty($table['shading']['left']))
205
-					echo '
211
+				if ($column_number == 0 && !empty($table['shading']['left'])) {
212
+									echo '
206 213
 					<td class="titlebg ', $table['align']['shaded'], 'text"', $table['width']['shaded'] != 'auto' ? ' width="' . $table['width']['shaded'] . '"' : '', '>
207 214
 						', $data['v'] == $table['default_value'] ? '' : ($data['v'] . (empty($data['v']) ? '' : ':')), '
208 215
 					</td>';
209
-				else
210
-					echo '
216
+				} else {
217
+									echo '
211 218
 					<td class="centertext" ', $table['width']['normal'] != 'auto' ? ' width="' . $table['width']['normal'] . '"' : '', !empty($data['style']) ? ' style="' . $data['style'] . '"' : '', '>
212 219
 						', $data['v'], '
213 220
 					</td>';
221
+				}
214 222
 
215 223
 				$column_number++;
216 224
 			}
Please login to merge, or discard this patch.
Themes/default/Memberlist.template.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,9 +26,10 @@  discard block
 block discarded – undo
26 26
 		<div class="cat_bar">
27 27
 			<h3 class="catbg">
28 28
 				<span class="floatleft">', $txt['members_list'], '</span>';
29
-		if (!isset($context['old_search']))
30
-				echo '
29
+		if (!isset($context['old_search'])) {
30
+						echo '
31 31
 				<span class="floatright">', $context['letter_links'], '</span>';
32
+		}
32 33
 		echo '
33 34
 			</h3>
34 35
 		</div>';
@@ -43,19 +44,22 @@  discard block
 block discarded – undo
43 44
 	foreach ($context['columns'] as $key => $column)
44 45
 	{
45 46
 		// @TODO maybe find something nicer?
46
-		if ($key == 'email_address' && !$context['can_send_email'])
47
-			continue;
47
+		if ($key == 'email_address' && !$context['can_send_email']) {
48
+					continue;
49
+		}
48 50
 
49 51
 		// This is a selected column, so underline it or some such.
50
-		if ($column['selected'])
51
-			echo '
52
+		if ($column['selected']) {
53
+					echo '
52 54
 					<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', ' selected" style="width: auto;"' . (isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '') . '>
53 55
 						<a href="' . $column['href'] . '" rel="nofollow">' . $column['label'] . '</a><span class="generic_icons sort_' . $context['sort_direction'] . '"></span></th>';
56
+		}
54 57
 		// This is just some column... show the link and be done with it.
55
-		else
56
-			echo '
58
+		else {
59
+					echo '
57 60
 					<th scope="col" class="', $key, isset($column['class']) ? ' ' . $column['class'] : '', '"', isset($column['width']) ? ' style="width: ' . $column['width'] . '"' : '', isset($column['colspan']) ? ' colspan="' . $column['colspan'] . '"' : '', '>
58 61
 						', $column['link'], '</th>';
62
+		}
59 63
 	}
60 64
 	echo '
61 65
 				</tr>
@@ -74,9 +78,10 @@  discard block
 block discarded – undo
74 78
 					</td>
75 79
 					<td class="lefttext">', $member['link'], '</td>';
76 80
 
77
-		if (!isset($context['disabled_fields']['website']))
78
-			echo '
81
+		if (!isset($context['disabled_fields']['website'])) {
82
+					echo '
79 83
 					<td class="centertext website_url">', $member['website']['url'] != '' ? '<a href="' . $member['website']['url'] . '" target="_blank" class="new_win"><span class="generic_icons www" title="' . $member['website']['title'] . '"></span></a>' : '', '</td>';
84
+		}
80 85
 
81 86
 		// Group and date.
82 87
 		echo '
@@ -89,11 +94,12 @@  discard block
 block discarded – undo
89 94
 					<td class="centertext" style="white-space: nowrap; width: 15px">', $member['posts'], '</td>
90 95
 					<td class="centertext statsbar" style="width: 120px">';
91 96
 
92
-			if (!empty($member['post_percent']))
93
-				echo '
97
+			if (!empty($member['post_percent'])) {
98
+							echo '
94 99
 						<div class="bar" style="width: ', $member['post_percent'] + 4, 'px;">
95 100
 							<div style="width: ', $member['post_percent'], 'px;"></div>
96 101
 						</div>';
102
+			}
97 103
 
98 104
 			echo '
99 105
 					</td>';
@@ -102,9 +108,10 @@  discard block
 block discarded – undo
102 108
 		// Show custom fields marked to be shown here
103 109
 		if (!empty($context['custom_profile_fields']['columns']))
104 110
 		{
105
-			foreach ($context['custom_profile_fields']['columns'] as $key => $column)
106
-				echo '
111
+			foreach ($context['custom_profile_fields']['columns'] as $key => $column) {
112
+							echo '
107 113
 					<td class="righttext">', $member['options'][$key], '</td>';
114
+			}
108 115
 		}
109 116
 
110 117
 		echo '
@@ -112,11 +119,12 @@  discard block
 block discarded – undo
112 119
 		}
113 120
 	}
114 121
 	// No members?
115
-	else
116
-		echo '
122
+	else {
123
+			echo '
117 124
 				<tr>
118 125
 					<td colspan="', $context['colspan'], '" class="windowbg">', $txt['search_no_results'], '</td>
119 126
 				</tr>';
127
+	}
120 128
 
121 129
 				echo '
122 130
 			</tbody>
@@ -129,9 +137,10 @@  discard block
 block discarded – undo
129 137
 			<div class="pagelinks floatleft">', $context['page_index'], '</div>';
130 138
 
131 139
 	// If it is displaying the result of a search show a "search again" link to edit their criteria.
132
-	if (isset($context['old_search']))
133
-		echo '
140
+	if (isset($context['old_search'])) {
141
+			echo '
134 142
 			<a class="button_link" href="', $scripturl, '?action=mlist;sa=search;search=', $context['old_search_value'], '">', $txt['mlist_search_again'], '</a>';
143
+	}
135 144
 	echo '
136 145
 		</div>
137 146
 	</div>';
Please login to merge, or discard this patch.
Themes/default/ReportToMod.template.php 1 patch
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,16 +62,17 @@
 block discarded – undo
62 62
 					<div id="error_box" class="errorbox">
63 63
 						<ul id="error_list">';
64 64
 
65
-		foreach ($context['post_errors'] as $key => $error)
66
-			echo '
65
+		foreach ($context['post_errors'] as $key => $error) {
66
+					echo '
67 67
 							<li id="error_', $key, '" class="error">', $error, '</li>';
68
+		}
68 69
 
69 70
 		echo '
70 71
 						</ul>';
71
-	}
72
-	else
73
-		echo '
72
+	} else {
73
+			echo '
74 74
 						<div style="display:none" id="error_box" class="errorbox">';
75
+	}
75 76
 
76 77
 	echo '
77 78
 					</div>';
Please login to merge, or discard this patch.
Themes/default/PersonalMessage.template.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 			foreach ($message['custom_fields']['above_member'] as $custom)
233 233
 				echo '
234
-					<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
234
+					<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
235 235
 
236 236
 			echo '
237 237
 				</ul>
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		if (!empty($message['custom_fields']['below_avatar']))
269 269
 			foreach ($message['custom_fields']['below_avatar'] as $custom)
270 270
 				echo '
271
-				<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
271
+				<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
272 272
 
273 273
 			if (!$message['member']['is_guest'])
274 274
 				echo '
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 					foreach ($message['custom_fields']['icons'] as $custom)
312 312
 						echo '
313
-						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
313
+						<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
314 314
 
315 315
 					echo '
316 316
 					</ol>
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 				if (!empty($message['custom_fields']['standard']))
369 369
 					foreach ($message['custom_fields']['standard'] as $custom)
370 370
 						echo '
371
-				<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
371
+				<li class="custom ', $custom['col_name'], '">', $custom['title'], ': ', $custom['value'], '</li>';
372 372
 
373 373
 				// Are we showing the warning status?
374 374
 				if ($message['member']['can_see_warning'])
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 				if (!empty($message['custom_fields']['bottom_poster']))
380 380
 					foreach ($message['custom_fields']['bottom_poster'] as $custom)
381 381
 						echo '
382
-				<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
382
+				<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
383 383
 			}
384 384
 
385 385
 			// Done with the information about the poster... on to the post itself.
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 
479 479
 				foreach ($message['custom_fields']['above_signature'] as $custom)
480 480
 					echo '
481
-							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
481
+							<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
482 482
 
483 483
 				echo '
484 484
 						</ul>
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 
500 500
 				foreach ($message['custom_fields']['below_signature'] as $custom)
501 501
 					echo '
502
-							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
502
+							<li class="custom ', $custom['col_name'], '">', $custom['value'], '</li>';
503 503
 
504 504
 				echo '
505 505
 						</ul>
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 	while ($message = $context['get_pmessage']('subject'))
632 632
 	{
633 633
 		echo '
634
-		<tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '','">
634
+		<tr class="windowbg', $message['is_unread'] ? ' unread_pm' : '', '">
635 635
 			<td class="table_icon">
636 636
 			<script>
637 637
 				currentLabels[', $message['id'], '] = {';
@@ -903,12 +903,12 @@  discard block
 block discarded – undo
903 903
 					// You can only reply if they are not a guest...
904 904
 					if (!$message['member']['is_guest'])
905 905
 						echo '
906
-							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
907
-							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
906
+							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button, '</a>', $context['menu_separator'], '
907
+							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button, '</a> ', $context['menu_separator'];
908 908
 					// This is for "forwarding" - even if the member is gone.
909 909
 					else
910 910
 						echo '
911
-							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
911
+							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button, '</a>', $context['menu_separator'];
912 912
 				}
913 913
 
914 914
 				echo '
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 			<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
1009 1009
 				<dl>
1010 1010
 					<dt>
1011
-						<strong id="error_serious">', $txt['error_while_submitting'] , '</strong>
1011
+						<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
1012 1012
 					</dt>
1013 1013
 					<dd class="error" id="error_list">
1014 1014
 						', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), '
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 					<span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span>
1065 1065
 				</dt>
1066 1066
 				<dd id="pm_subject">
1067
-					<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"',isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
1067
+					<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
1068 1068
 				</dd>
1069 1069
 			</dl><hr>';
1070 1070
 
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 		echo '
1428 1428
 		<div class="padding">
1429 1429
 			<input type="submit" name="save" value="', $txt['save'], '" class="button_submit">
1430
-			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button_submit you_sure">
1430
+			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'], '" class="button_submit you_sure">
1431 1431
 		</div>';
1432 1432
 
1433 1433
 	echo '
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 	if (!empty($context['rules']))
1592 1592
 		echo '
1593 1593
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1594
-			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button_submit smalltext you_sure">';
1594
+			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'], '" class="button_submit smalltext you_sure">';
1595 1595
 
1596 1596
 	echo '
1597 1597
 		</div>
@@ -1832,9 +1832,9 @@  discard block
 block discarded – undo
1832 1832
 
1833 1833
 		echo '
1834 1834
 				<select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
1835
-					<option value="">', $txt['pm_rule_sel_action'] , ':</option>
1836
-					<option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'] , '</option>
1837
-					<option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'] , '</option>
1835
+					<option value="">', $txt['pm_rule_sel_action'], ':</option>
1836
+					<option value="lab"', $action['t'] == 'lab' ? ' selected' : '', '>', $txt['pm_rule_label'], '</option>
1837
+					<option value="del"', $action['t'] == 'del' ? ' selected' : '', '>', $txt['pm_rule_delete'], '</option>
1838 1838
 				</select>
1839 1839
 				<span id="labdiv', $k, '">
1840 1840
 					<select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
 					</div>
1952 1952
 					<ul class="quickbuttons">
1953 1953
 						<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;id_draft=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="generic_icons modifybutton"></span>', $txt['draft_edit'], '</a></li>
1954
-						<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'] ,'?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
1954
+						<li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['draft_remove'], '?" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['draft_delete'], '</a></li>
1955 1955
 					</ul>
1956 1956
 				</div>';
1957 1957
 		}
Please login to merge, or discard this patch.
Braces   +262 added lines, -181 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	<div id="personal_messages">';
22 22
 
23 23
 	// Show the capacity bar, if available.
24
-	if (!empty($context['limit_bar']))
25
-		echo '
24
+	if (!empty($context['limit_bar'])) {
25
+			echo '
26 26
 		<div class="cat_bar">
27 27
 			<h3 class="catbg">
28 28
 				<span class="floatleft">', $txt['pm_capacity'], ':</span>
@@ -32,14 +32,16 @@  discard block
 block discarded – undo
32 32
 				<span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span>
33 33
 			</h3>
34 34
 		</div>';
35
+	}
35 36
 
36 37
 	// Message sent? Show a small indication.
37
-	if (isset($context['pm_sent']))
38
-		echo '
38
+	if (isset($context['pm_sent'])) {
39
+			echo '
39 40
 		<div class="infobox">
40 41
 			', $txt['pm_sent'], '
41 42
 		</div>';
42
-}
43
+	}
44
+	}
43 45
 
44 46
 /**
45 47
  * Just the end of the index bar, nothing special.
@@ -72,8 +74,7 @@  discard block
 block discarded – undo
72 74
 	{
73 75
 		echo '
74 76
 			<div class="no_unread">', $txt['pm_no_unread'], '</div>';
75
-	}
76
-	else
77
+	} else
77 78
 	{
78 79
 		foreach ($context['unread_pms'] as $id_pm => $pm_details)
79 80
 		{
@@ -193,14 +194,15 @@  discard block
 block discarded – undo
193 194
 	if ($context['get_pmessage']('message', true))
194 195
 	{
195 196
 		// Show the helpful titlebar - generally.
196
-		if ($context['display_mode'] != 1)
197
-			echo '
197
+		if ($context['display_mode'] != 1) {
198
+					echo '
198 199
 				<div class="cat_bar">
199 200
 					<h3 class="catbg">
200 201
 						<span id="author">', $txt['author'], '</span>
201 202
 						<span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span>
202 203
 					</h3>
203 204
 				</div>';
205
+		}
204 206
 
205 207
 		// Show a few buttons if we are in conversation mode and outputting the first message.
206 208
 		if ($context['display_mode'] == 2)
@@ -229,9 +231,10 @@  discard block
 block discarded – undo
229 231
 			<div class="custom_fields_above_member">
230 232
 				<ul class="nolist">';
231 233
 
232
-			foreach ($message['custom_fields']['above_member'] as $custom)
233
-				echo '
234
+			foreach ($message['custom_fields']['above_member'] as $custom) {
235
+							echo '
234 236
 					<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
237
+			}
235 238
 
236 239
 			echo '
237 240
 				</ul>
@@ -243,9 +246,10 @@  discard block
 block discarded – undo
243 246
 				<a id="msg', $message['id'], '"></a>';
244 247
 
245 248
 		// Show online and offline buttons?
246
-		if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
247
-			echo '
249
+		if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest']) {
250
+					echo '
248 251
 				<span class="' . ($message['member']['online']['is_online'] == 1 ? 'on' : 'off') . '" title="' . $message['member']['online']['text'] . '"></span>';
252
+		}
249 253
 
250 254
 		// Show a link to the member's profile (but only if the sender isn't a guest).
251 255
 				echo '
@@ -258,48 +262,56 @@  discard block
 block discarded – undo
258 262
 			<ul class="user_info">';
259 263
 
260 264
 			// Show the user's avatar.
261
-			if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
262
-				echo '
265
+			if (!empty($modSettings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
266
+							echo '
263 267
 				<li class="avatar">
264 268
 					<a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a>
265 269
 				</li>';
270
+			}
266 271
 
267 272
 		// Are there any custom fields below the avatar?
268
-		if (!empty($message['custom_fields']['below_avatar']))
269
-			foreach ($message['custom_fields']['below_avatar'] as $custom)
273
+		if (!empty($message['custom_fields']['below_avatar'])) {
274
+					foreach ($message['custom_fields']['below_avatar'] as $custom)
270 275
 				echo '
271 276
 				<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
277
+		}
272 278
 
273
-			if (!$message['member']['is_guest'])
274
-				echo '
279
+			if (!$message['member']['is_guest']) {
280
+							echo '
275 281
 				<li class="icons">', $message['member']['group_icons'], '</li>';
282
+			}
276 283
 			// Show the member's primary group (like 'Administrator') if they have one.
277
-			if (isset($message['member']['group']) && $message['member']['group'] != '')
278
-				echo '
284
+			if (isset($message['member']['group']) && $message['member']['group'] != '') {
285
+							echo '
279 286
 				<li class="membergroup">', $message['member']['group'], '</li>';
287
+			}
280 288
 
281 289
 			// Show the member's custom title, if they have one.
282
-			if (isset($message['member']['title']) && $message['member']['title'] != '')
283
-				echo '
290
+			if (isset($message['member']['title']) && $message['member']['title'] != '') {
291
+							echo '
284 292
 				<li class="title">', $message['member']['title'], '</li>';
293
+			}
285 294
 
286 295
 			// Don't show these things for guests.
287 296
 			if (!$message['member']['is_guest'])
288 297
 			{
289 298
 				// Show the post group if and only if they have no other group or the option is on, and they are in a post group.
290
-				if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
291
-					echo '
299
+				if ((empty($modSettings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') {
300
+									echo '
292 301
 				<li class="postgroup">', $message['member']['post_group'], '</li>';
302
+				}
293 303
 
294 304
 				// Show how many posts they have made.
295
-				if (!isset($context['disabled_fields']['posts']))
296
-					echo '
305
+				if (!isset($context['disabled_fields']['posts'])) {
306
+									echo '
297 307
 				<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
308
+				}
298 309
 
299 310
 				// Show their personal text?
300
-				if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '')
301
-					echo '
311
+				if (!empty($modSettings['show_blurb']) && $message['member']['blurb'] != '') {
312
+									echo '
302 313
 				<li class="blurb">', $message['member']['blurb'], '</li>';
314
+				}
303 315
 
304 316
 				// Any custom fields to show as icons?
305 317
 				if (!empty($message['custom_fields']['icons']))
@@ -308,9 +320,10 @@  discard block
 block discarded – undo
308 320
 				<li class="im_icons">
309 321
 					<ol>';
310 322
 
311
-					foreach ($message['custom_fields']['icons'] as $custom)
312
-						echo '
323
+					foreach ($message['custom_fields']['icons'] as $custom) {
324
+											echo '
313 325
 						<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
326
+					}
314 327
 
315 328
 					echo '
316 329
 					</ol>
@@ -318,19 +331,22 @@  discard block
 block discarded – undo
318 331
 				}
319 332
 
320 333
 		// Show the IP to this user for this post - because you can moderate?
321
-		if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
322
-			echo '
334
+		if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
335
+					echo '
323 336
 				<li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
337
+		}
324 338
 
325 339
 		// Or, should we show it because this is you?
326
-		elseif ($message['can_see_ip'])
327
-			echo '
340
+		elseif ($message['can_see_ip']) {
341
+					echo '
328 342
 				<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
343
+		}
329 344
 
330 345
 		// Okay, you are logged in, then we can show something about why IPs are logged...
331
-		else
332
-			echo '
346
+		else {
347
+					echo '
333 348
 				<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
349
+		}
334 350
 
335 351
 				// Show the profile, website, email address, and personal message buttons.
336 352
 				if ($message['member']['show_profile_buttons'])
@@ -340,24 +356,28 @@  discard block
 block discarded – undo
340 356
 					<ol class="profile_icons">';
341 357
 
342 358
 					// Show the profile button
343
-					if ($message['member']['can_view_profile'])
344
-						echo '
359
+					if ($message['member']['can_view_profile']) {
360
+											echo '
345 361
 						<li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '">' : $txt['view_profile']), '</a></li>';
362
+					}
346 363
 
347 364
 					// Don't show an icon if they haven't specified a website.
348
-					if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
349
-						echo '
365
+					if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) {
366
+											echo '
350 367
 						<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
368
+					}
351 369
 
352 370
 					// Don't show the email address if they want it hidden.
353
-					if ($message['member']['show_email'])
354
-						echo '
371
+					if ($message['member']['show_email']) {
372
+											echo '
355 373
 						<li><a href="mailto:', $message['member']['email'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
374
+					}
356 375
 
357 376
 					// Since we know this person isn't a guest, you *can* message them.
358
-					if ($context['can_send_pm'])
359
-						echo '
377
+					if ($context['can_send_pm']) {
378
+											echo '
360 379
 						<li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="generic_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span> ' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
380
+					}
361 381
 
362 382
 					echo '
363 383
 					</ol>
@@ -365,21 +385,24 @@  discard block
 block discarded – undo
365 385
 				}
366 386
 
367 387
 				// Any custom fields for standard placement?
368
-				if (!empty($message['custom_fields']['standard']))
369
-					foreach ($message['custom_fields']['standard'] as $custom)
388
+				if (!empty($message['custom_fields']['standard'])) {
389
+									foreach ($message['custom_fields']['standard'] as $custom)
370 390
 						echo '
371 391
 				<li class="custom ', $custom['col_name'] ,'">', $custom['title'], ': ', $custom['value'], '</li>';
392
+				}
372 393
 
373 394
 				// Are we showing the warning status?
374
-				if ($message['member']['can_see_warning'])
375
-					echo '
395
+				if ($message['member']['can_see_warning']) {
396
+									echo '
376 397
 				<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<span class="generic_icons warning_', $message['member']['warning_status'], '"></span>', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
398
+				}
377 399
 
378 400
 				// Are there any custom fields to show at the bottom of the poster info?
379
-				if (!empty($message['custom_fields']['bottom_poster']))
380
-					foreach ($message['custom_fields']['bottom_poster'] as $custom)
401
+				if (!empty($message['custom_fields']['bottom_poster'])) {
402
+									foreach ($message['custom_fields']['bottom_poster'] as $custom)
381 403
 						echo '
382 404
 				<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
405
+				}
383 406
 			}
384 407
 
385 408
 			// Done with the information about the poster... on to the post itself.
@@ -398,24 +421,28 @@  discard block
 block discarded – undo
398 421
 					<span class="smalltext">&#171; <strong> ', $txt['sent_to'], ':</strong> ';
399 422
 
400 423
 			// People it was sent directly to....
401
-			if (!empty($message['recipients']['to']))
402
-				echo implode(', ', $message['recipients']['to']);
424
+			if (!empty($message['recipients']['to'])) {
425
+							echo implode(', ', $message['recipients']['to']);
426
+			}
403 427
 			// Otherwise, we're just going to say "some people"...
404
-			elseif ($context['folder'] != 'sent')
405
-				echo '(', $txt['pm_undisclosed_recipients'], ')';
428
+			elseif ($context['folder'] != 'sent') {
429
+							echo '(', $txt['pm_undisclosed_recipients'], ')';
430
+			}
406 431
 
407 432
 			echo '
408 433
 						<strong> ', $txt['on'], ':</strong> ', $message['time'], ' &#187;
409 434
 					</span>';
410 435
 
411 436
 			// If we're in the sent items, show who it was sent to besides the "To:" people.
412
-			if (!empty($message['recipients']['bcc']))
413
-				echo '
437
+			if (!empty($message['recipients']['bcc'])) {
438
+							echo '
414 439
 					<br><span class="smalltext">&#171; <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' &#187;</span>';
440
+			}
415 441
 
416
-			if (!empty($message['is_replied_to']))
417
-				echo '
442
+			if (!empty($message['is_replied_to'])) {
443
+							echo '
418 444
 					<br><span class="smalltext">&#171; ', $context['folder'] == 'sent' ? $txt['pm_sent_is_replied_to'] : $txt['pm_is_replied_to'], ' &#187;</span>';
445
+			}
419 446
 
420 447
 			echo '
421 448
 				</div>
@@ -423,13 +450,15 @@  discard block
 block discarded – undo
423 450
 			<div class="post">
424 451
 				<div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>';
425 452
 
426
-			if ($message['can_report'] || $context['can_send_pm'])
427
-			echo '
453
+			if ($message['can_report'] || $context['can_send_pm']) {
454
+						echo '
428 455
 				<div class="under_message">';
456
+			}
429 457
 
430
-				if ($message['can_report'])
431
-				echo '
458
+				if ($message['can_report']) {
459
+								echo '
432 460
 					<a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '" class="floatright">' . $txt['pm_report_to_admin'] . '</a>';
461
+				}
433 462
 
434 463
 				echo '
435 464
 					<ul class="quickbuttons">';
@@ -441,32 +470,36 @@  discard block
 block discarded – undo
441 470
 					if (!$message['member']['is_guest'])
442 471
 					{
443 472
 						// Is there than more than one recipient you can reply to?
444
-						if ($message['number_recipients'] > 1)
445
-							echo '
473
+						if ($message['number_recipients'] > 1) {
474
+													echo '
446 475
 						<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all"><span class="generic_icons reply_all_button"></span>', $txt['reply_to_all'], '</a></li>';
476
+						}
447 477
 
448 478
 						echo '
449 479
 						<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>
450 480
 						<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>';
451 481
 					}
452 482
 					// This is for "forwarding" - even if the member is gone.
453
-					else
454
-						echo '
483
+					else {
484
+											echo '
455 485
 						<li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote"><span class="generic_icons quote"></span>', $txt['reply_quote'], '</a></li>';
486
+					}
456 487
 				}
457 488
 				echo '
458 489
 						<li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions%5b', $message['id'], '%5D=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" data-confirm="', addslashes($txt['remove_message_question']), '" class="you_sure"><span class="generic_icons remove_button"></span>', $txt['delete'], '</a></li>';
459 490
 
460
-				if (empty($context['display_mode']))
461
-					echo '
491
+				if (empty($context['display_mode'])) {
492
+									echo '
462 493
 						<li><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;" class="input_check"></li>';
494
+				}
463 495
 
464 496
 				echo '
465 497
 					</ul>';
466 498
 
467
-			if ($message['can_report'] || $context['can_send_pm'])
468
-			echo '
499
+			if ($message['can_report'] || $context['can_send_pm']) {
500
+						echo '
469 501
 				</div>';
502
+			}
470 503
 
471 504
 			// Are there any custom profile fields for above the signature?
472 505
 			if (!empty($message['custom_fields']['above_signature']))
@@ -475,9 +508,10 @@  discard block
 block discarded – undo
475 508
 					<div class="custom_fields_above_signature">
476 509
 						<ul class="nolist">';
477 510
 
478
-				foreach ($message['custom_fields']['above_signature'] as $custom)
479
-					echo '
511
+				foreach ($message['custom_fields']['above_signature'] as $custom) {
512
+									echo '
480 513
 							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
514
+				}
481 515
 
482 516
 				echo '
483 517
 						</ul>
@@ -485,9 +519,10 @@  discard block
 block discarded – undo
485 519
 			}
486 520
 
487 521
 			// Show the member's signature?
488
-			if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
489
-				echo '
522
+			if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
523
+							echo '
490 524
 				<div class="signature">', $message['member']['signature'], '</div>';
525
+			}
491 526
 
492 527
 			// Are there any custom profile fields for below the signature?
493 528
 			if (!empty($message['custom_fields']['below_signature']))
@@ -496,9 +531,10 @@  discard block
 block discarded – undo
496 531
 					<div class="custom_fields_below_signature">
497 532
 						<ul class="nolist">';
498 533
 
499
-				foreach ($message['custom_fields']['below_signature'] as $custom)
500
-					echo '
534
+				foreach ($message['custom_fields']['below_signature'] as $custom) {
535
+									echo '
501 536
 							<li class="custom ', $custom['col_name'] ,'">', $custom['value'], '</li>';
537
+				}
502 538
 
503 539
 				echo '
504 540
 						</ul>
@@ -523,19 +559,21 @@  discard block
 block discarded – undo
523 559
 					{
524 560
 						echo '
525 561
 						<option value="" disabled>', $txt['pm_msg_label_apply'], ':</option>';
526
-						foreach ($context['labels'] as $label)
527
-							if (!isset($message['labels'][$label['id']]))
562
+						foreach ($context['labels'] as $label) {
563
+													if (!isset($message['labels'][$label['id']]))
528 564
 								echo '
529 565
 							<option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
566
+						}
530 567
 					}
531 568
 					// ... and are there any that can be removed?
532 569
 					if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1])))
533 570
 					{
534 571
 						echo '
535 572
 						<option value="" disabled>', $txt['pm_msg_label_remove'], ':</option>';
536
-						foreach ($message['labels'] as $label)
537
-							echo '
573
+						foreach ($message['labels'] as $label) {
574
+													echo '
538 575
 							<option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
576
+						}
539 577
 					}
540 578
 					echo '
541 579
 					</select>
@@ -555,13 +593,14 @@  discard block
 block discarded – undo
555 593
 	</div>';
556 594
 		}
557 595
 
558
-		if (empty($context['display_mode']))
559
-			echo '
596
+		if (empty($context['display_mode'])) {
597
+					echo '
560 598
 
561 599
 	<div class="pagesection">
562 600
 		<div class="floatleft">', $context['page_index'], '</div>
563 601
 		<div class="floatright"><input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" style="font-weight: normal;" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit"></div>
564 602
 	</div>';
603
+		}
565 604
 
566 605
 		// Show a few buttons if we are in conversation mode and outputting the first message.
567 606
 		elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons']))
@@ -621,11 +660,12 @@  discard block
 block discarded – undo
621 660
 		</tr>
622 661
 	</thead>
623 662
 	<tbody>';
624
-	if (!$context['show_delete'])
625
-		echo '
663
+	if (!$context['show_delete']) {
664
+			echo '
626 665
 		<tr class="windowbg">
627 666
 			<td colspan="5">', $txt['pm_alert_none'], '</td>
628 667
 		</tr>';
668
+	}
629 669
 
630 670
 	while ($message = $context['get_pmessage']('subject'))
631 671
 	{
@@ -678,9 +718,10 @@  discard block
 block discarded – undo
678 718
 
679 719
 			foreach ($context['labels'] as $label)
680 720
 			{
681
-				if ($label['id'] != $context['current_label_id'])
682
-					echo '
721
+				if ($label['id'] != $context['current_label_id']) {
722
+									echo '
683 723
 					<option value="add_', $label['id'], '">&nbsp;', $label['name'], '</option>';
724
+				}
684 725
 			}
685 726
 
686 727
 			echo '
@@ -765,9 +806,10 @@  discard block
 block discarded – undo
765 806
 					<dt class="between">', $txt['pm_search_post_age'], ':</dt>
766 807
 					<dd>', $txt['pm_search_between'], ' <input type="number" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" class="input_text" min="0" max="9999">&nbsp;', $txt['pm_search_between_and'], '&nbsp;<input type="number" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" class="input_text" min="0" max="9999"> ', $txt['pm_search_between_days'], '</dd>
767 808
 				</dl>';
768
-	if (!$context['currently_using_labels'])
769
-		echo '
809
+	if (!$context['currently_using_labels']) {
810
+			echo '
770 811
 				<input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit">';
812
+	}
771 813
 		echo '
772 814
 				<br class="clear_right">
773 815
 			</div>
@@ -787,12 +829,13 @@  discard block
 block discarded – undo
787 829
 				<div id="advanced_panel_div">
788 830
 					<ul id="searchLabelsExpand">';
789 831
 
790
-		foreach ($context['search_labels'] as $label)
791
-			echo '
832
+		foreach ($context['search_labels'] as $label) {
833
+					echo '
792 834
 						<li>
793 835
 							<label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '"', $label['checked'] ? ' checked' : '', ' class="input_check">
794 836
 							', $label['name'], '</label>
795 837
 						</li>';
838
+		}
796 839
 
797 840
 		echo '
798 841
 					</ul>
@@ -852,8 +895,8 @@  discard block
 block discarded – undo
852 895
 		</div>';
853 896
 
854 897
 	// complete results ?
855
-	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
856
-		echo '
898
+	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) {
899
+			echo '
857 900
 	<table class="table_grid">
858 901
 	<thead>
859 902
 		<tr class="title_bar">
@@ -863,6 +906,7 @@  discard block
 block discarded – undo
863 906
 		</tr>
864 907
 	</thead>
865 908
 	<tbody>';
909
+	}
866 910
 
867 911
 	// Print each message out...
868 912
 	foreach ($context['personal_messages'] as $message)
@@ -882,11 +926,13 @@  discard block
 block discarded – undo
882 926
 
883 927
 				// Show the recipients.
884 928
 				// @todo This doesn't deal with the sent item searching quite right for bcc.
885
-				if (!empty($message['recipients']['to']))
886
-					echo implode(', ', $message['recipients']['to']);
929
+				if (!empty($message['recipients']['to'])) {
930
+									echo implode(', ', $message['recipients']['to']);
931
+				}
887 932
 				// Otherwise, we're just going to say "some people"...
888
-				elseif ($context['folder'] != 'sent')
889
-					echo '(', $txt['pm_undisclosed_recipients'], ')';
933
+				elseif ($context['folder'] != 'sent') {
934
+									echo '(', $txt['pm_undisclosed_recipients'], ')';
935
+				}
890 936
 
891 937
 					echo '
892 938
 				</h3>
@@ -900,14 +946,16 @@  discard block
 block discarded – undo
900 946
 					$quote_button = create_button('quote.png', 'reply_quote', 'reply_quote', 'class="centericon"');
901 947
 					$reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"');
902 948
 					// You can only reply if they are not a guest...
903
-					if (!$message['member']['is_guest'])
904
-						echo '
949
+					if (!$message['member']['is_guest']) {
950
+											echo '
905 951
 							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
906 952
 							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
953
+					}
907 954
 					// This is for "forwarding" - even if the member is gone.
908
-					else
909
-						echo '
955
+					else {
956
+											echo '
910 957
 							<a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
958
+					}
911 959
 				}
912 960
 
913 961
 				echo '
@@ -928,17 +976,19 @@  discard block
 block discarded – undo
928 976
 	}
929 977
 
930 978
 	// Finish off the page...
931
-	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
932
-		echo '
979
+	if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages'])) {
980
+			echo '
933 981
 		</tbody>
934 982
 		</table>';
983
+	}
935 984
 
936 985
 	// No results?
937
-	if (empty($context['personal_messages']))
938
-		echo '
986
+	if (empty($context['personal_messages'])) {
987
+			echo '
939 988
 		<div class="windowbg">
940 989
 			<p class="centertext">', $txt['pm_search_none_found'], '</p>
941 990
 		</div>';
991
+	}
942 992
 
943 993
 	echo '
944 994
 		<div class="pagesection">
@@ -962,12 +1012,14 @@  discard block
 block discarded – undo
962 1012
 				<h3 class="catbg">', $txt['pm_send_report'], '</h3>
963 1013
 			</div>
964 1014
 			<div class="windowbg">';
965
-				if (!empty($context['send_log']['sent']))
966
-					foreach ($context['send_log']['sent'] as $log_entry)
1015
+				if (!empty($context['send_log']['sent'])) {
1016
+									foreach ($context['send_log']['sent'] as $log_entry)
967 1017
 						echo '<span class="error">', $log_entry, '</span><br>';
968
-				if (!empty($context['send_log']['failed']))
969
-					foreach ($context['send_log']['failed'] as $log_entry)
1018
+				}
1019
+				if (!empty($context['send_log']['failed'])) {
1020
+									foreach ($context['send_log']['failed'] as $log_entry)
970 1021
 						echo '<span class="error">', $log_entry, '</span><br>';
1022
+				}
971 1023
 				echo '
972 1024
 			</div>
973 1025
 			<br>';
@@ -1015,12 +1067,13 @@  discard block
 block discarded – undo
1015 1067
 				</dl>
1016 1068
 			</div>';
1017 1069
 
1018
-	if (!empty($modSettings['drafts_pm_enabled']))
1019
-		echo '
1070
+	if (!empty($modSettings['drafts_pm_enabled'])) {
1071
+			echo '
1020 1072
 			<div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
1021 1073
 				sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), '
1022 1074
 				', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
1023 1075
 			</div>';
1076
+	}
1024 1077
 
1025 1078
 	echo '
1026 1079
 			<dl id="post_header">';
@@ -1075,9 +1128,10 @@  discard block
 block discarded – undo
1075 1128
 	}
1076 1129
 
1077 1130
 	// What about smileys?
1078
-	if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
1079
-		echo '
1131
+	if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
1132
+			echo '
1080 1133
 			<div id="smileyBox_message"></div>';
1134
+	}
1081 1135
 
1082 1136
 	// Show BBC buttons, smileys and textbox.
1083 1137
 	echo '
@@ -1124,10 +1178,11 @@  discard block
 block discarded – undo
1124 1178
 					<dt><strong>', $txt['subject'], '</strong></dt>
1125 1179
 					<dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
1126 1180
 
1127
-		foreach ($context['drafts'] as $draft)
1128
-			echo '
1181
+		foreach ($context['drafts'] as $draft) {
1182
+					echo '
1129 1183
 					<dt>', $draft['link'], '</dt>
1130 1184
 					<dd>', $draft['poster_time'], '</dd>';
1185
+		}
1131 1186
 		echo '
1132 1187
 				</dl>
1133 1188
 			</div>';
@@ -1233,8 +1288,8 @@  discard block
 block discarded – undo
1233 1288
 			}';
1234 1289
 
1235 1290
 	// Code for showing and hiding drafts
1236
-	if (!empty($context['drafts']))
1237
-		echo '
1291
+	if (!empty($context['drafts'])) {
1292
+			echo '
1238 1293
 			var oSwapDraftOptions = new smc_Toggle({
1239 1294
 				bToggleEnabled: true,
1240 1295
 				bCurrentlyCollapsed: true,
@@ -1256,13 +1311,14 @@  discard block
 block discarded – undo
1256 1311
 					}
1257 1312
 				]
1258 1313
 			});';
1314
+	}
1259 1315
 
1260 1316
 	echo '
1261 1317
 		</script>';
1262 1318
 
1263 1319
 	// Show the message you're replying to.
1264
-	if ($context['reply'])
1265
-		echo '
1320
+	if ($context['reply']) {
1321
+			echo '
1266 1322
 	<br>
1267 1323
 	<br>
1268 1324
 	<div class="cat_bar">
@@ -1276,6 +1332,7 @@  discard block
 block discarded – undo
1276 1332
 		<hr>
1277 1333
 		', $context['quoted_message']['body'], '
1278 1334
 	</div><br class="clear">';
1335
+	}
1279 1336
 
1280 1337
 	echo '
1281 1338
 		<script>
@@ -1286,22 +1343,24 @@  discard block
 block discarded – undo
1286 1343
 				sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
1287 1344
 				sToControlId: \'to_control\',
1288 1345
 				aToRecipients: [';
1289
-	foreach ($context['recipients']['to'] as $i => $member)
1290
-		echo '
1346
+	foreach ($context['recipients']['to'] as $i => $member) {
1347
+			echo '
1291 1348
 					{
1292 1349
 						sItemId: ', JavaScriptEscape($member['id']), ',
1293 1350
 						sItemName: ', JavaScriptEscape($member['name']), '
1294 1351
 					}', $i == count($context['recipients']['to']) - 1 ? '' : ',';
1352
+	}
1295 1353
 
1296 1354
 	echo '
1297 1355
 				],
1298 1356
 				aBccRecipients: [';
1299
-	foreach ($context['recipients']['bcc'] as $i => $member)
1300
-		echo '
1357
+	foreach ($context['recipients']['bcc'] as $i => $member) {
1358
+			echo '
1301 1359
 					{
1302 1360
 						sItemId: ', JavaScriptEscape($member['id']), ',
1303 1361
 						sItemName: ', JavaScriptEscape($member['name']), '
1304 1362
 					}', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
1363
+	}
1305 1364
 
1306 1365
 	echo '
1307 1366
 				],
@@ -1388,26 +1447,28 @@  discard block
 block discarded – undo
1388 1447
 				</th>
1389 1448
 				<th class="centertext table_icon">';
1390 1449
 
1391
-	if (count($context['labels']) > 2)
1392
-		echo '
1450
+	if (count($context['labels']) > 2) {
1451
+			echo '
1393 1452
 					<input type="checkbox" class="input_check" onclick="invertAll(this, this.form);">';
1453
+	}
1394 1454
 
1395 1455
 	echo '
1396 1456
 				</th>
1397 1457
 			</tr>
1398 1458
 		</thead>
1399 1459
 		<tbody>';
1400
-	if (count($context['labels']) < 2)
1401
-		echo '
1460
+	if (count($context['labels']) < 2) {
1461
+			echo '
1402 1462
 			<tr class="windowbg">
1403 1463
 				<td colspan="2">', $txt['pm_labels_no_exist'], '</td>
1404 1464
 			</tr>';
1405
-	else
1465
+	} else
1406 1466
 	{
1407 1467
 		foreach ($context['labels'] as $label)
1408 1468
 		{
1409
-			if ($label['id'] == -1)
1410
-				continue;
1469
+			if ($label['id'] == -1) {
1470
+							continue;
1471
+			}
1411 1472
 
1412 1473
 				echo '
1413 1474
 			<tr class="windowbg">
@@ -1422,12 +1483,13 @@  discard block
 block discarded – undo
1422 1483
 		</tbody>
1423 1484
 		</table>';
1424 1485
 
1425
-	if (!count($context['labels']) < 2)
1426
-		echo '
1486
+	if (!count($context['labels']) < 2) {
1487
+			echo '
1427 1488
 		<div class="padding">
1428 1489
 			<input type="submit" name="save" value="', $txt['save'], '" class="button_submit">
1429 1490
 			<input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" data-confirm="', $txt['pm_labels_delete'] ,'" class="button_submit you_sure">
1430 1491
 		</div>';
1492
+	}
1431 1493
 
1432 1494
 	echo '
1433 1495
 		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
@@ -1482,9 +1544,10 @@  discard block
 block discarded – undo
1482 1544
 				<dd>
1483 1545
 					<select name="id_admin">
1484 1546
 						<option value="0">', $txt['pm_report_all_admins'], '</option>';
1485
-		foreach ($context['admins'] as $id => $name)
1486
-			echo '
1547
+		foreach ($context['admins'] as $id => $name) {
1548
+					echo '
1487 1549
 						<option value="', $id, '">', $name, '</option>';
1550
+		}
1488 1551
 		echo '
1489 1552
 					</select>
1490 1553
 				</dd>';
@@ -1546,9 +1609,10 @@  discard block
 block discarded – undo
1546 1609
 				</th>
1547 1610
 				<th class="centertext table_icon">';
1548 1611
 
1549
-	if (!empty($context['rules']))
1550
-		echo '
1612
+	if (!empty($context['rules'])) {
1613
+			echo '
1551 1614
 					<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check">';
1615
+	}
1552 1616
 
1553 1617
 	echo '
1554 1618
 				</th>
@@ -1556,13 +1620,14 @@  discard block
 block discarded – undo
1556 1620
 		</thead>
1557 1621
 		<tbody>';
1558 1622
 
1559
-	if (empty($context['rules']))
1560
-		echo '
1623
+	if (empty($context['rules'])) {
1624
+			echo '
1561 1625
 			<tr class="windowbg">
1562 1626
 				<td colspan="2">
1563 1627
 					', $txt['pm_rules_none'], '
1564 1628
 				</td>
1565 1629
 			</tr>';
1630
+	}
1566 1631
 
1567 1632
 	foreach ($context['rules'] as $rule)
1568 1633
 	{
@@ -1583,14 +1648,16 @@  discard block
 block discarded – undo
1583 1648
 		<div class="righttext">
1584 1649
 			<a class="button_link" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>';
1585 1650
 
1586
-	if (!empty($context['rules']))
1587
-		echo '
1651
+	if (!empty($context['rules'])) {
1652
+			echo '
1588 1653
 			[<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]';
1654
+	}
1589 1655
 
1590
-	if (!empty($context['rules']))
1591
-		echo '
1656
+	if (!empty($context['rules'])) {
1657
+			echo '
1592 1658
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
1593 1659
 			<input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" data-confirm="', $txt['pm_js_delete_rule_confirm'] ,'" class="button_submit smalltext you_sure">';
1660
+	}
1594 1661
 
1595 1662
 	echo '
1596 1663
 		</div>
@@ -1612,14 +1679,16 @@  discard block
 block discarded – undo
1612 1679
 			var groups = new Array()
1613 1680
 			var labels = new Array()';
1614 1681
 
1615
-	foreach ($context['groups'] as $id => $title)
1616
-		echo '
1682
+	foreach ($context['groups'] as $id => $title) {
1683
+			echo '
1617 1684
 			groups[', $id, '] = "', addslashes($title), '";';
1685
+	}
1618 1686
 
1619
-	foreach ($context['labels'] as $label)
1620
-		if ($label['id'] != -1)
1687
+	foreach ($context['labels'] as $label) {
1688
+			if ($label['id'] != -1)
1621 1689
 			echo '
1622 1690
 			labels[', ($label['id']), '] = "', addslashes($label['name']), '";';
1691
+	}
1623 1692
 
1624 1693
 	echo '
1625 1694
 			function addCriteriaOption()
@@ -1634,8 +1703,9 @@  discard block
 block discarded – undo
1634 1703
 
1635 1704
 				setOuterHTML(document.getElementById("criteriaAddHere"), \'<br><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select>&nbsp;<span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value="" class="input_text"><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>';
1636 1705
 
1637
-	foreach ($context['groups'] as $id => $group)
1638
-		echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
1706
+	foreach ($context['groups'] as $id => $group) {
1707
+			echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
1708
+	}
1639 1709
 
1640 1710
 	echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\');
1641 1711
 			}
@@ -1652,9 +1722,10 @@  discard block
 block discarded – undo
1652 1722
 
1653 1723
 				setOuterHTML(document.getElementById("actionAddHere"), \'<br><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select>&nbsp;<span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>';
1654 1724
 
1655
-	foreach ($context['labels'] as $label)
1656
-		if ($label['id'] != -1)
1725
+	foreach ($context['labels'] as $label) {
1726
+			if ($label['id'] != -1)
1657 1727
 			echo '<option value="', ($label['id']), '">', addslashes($label['name']), '<\' + \'/option>';
1728
+	}
1658 1729
 
1659 1730
 	echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\');
1660 1731
 			}
@@ -1768,18 +1839,20 @@  discard block
 block discarded – undo
1768 1839
 	$isFirst = true;
1769 1840
 	foreach ($context['rule']['criteria'] as $k => $criteria)
1770 1841
 	{
1771
-		if (!$isFirst && $criteria['t'] == '')
1772
-			echo '<div id="removeonjs1">';
1773
-		elseif (!$isFirst)
1774
-			echo '<br>';
1842
+		if (!$isFirst && $criteria['t'] == '') {
1843
+					echo '<div id="removeonjs1">';
1844
+		} elseif (!$isFirst) {
1845
+					echo '<br>';
1846
+		}
1775 1847
 
1776 1848
 		echo '
1777 1849
 				<select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();">
1778 1850
 					<option value="">', $txt['pm_rule_criteria_pick'], ':</option>';
1779 1851
 
1780
-		foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr)
1781
-			echo '
1852
+		foreach (array('mid', 'gid', 'sub', 'msg', 'bud') as $cr) {
1853
+					echo '
1782 1854
 					<option value="', $cr, '"', $criteria['t'] == $cr ? ' selected' : '', '>', $txt['pm_rule_' . $cr], '</option>';
1855
+		}
1783 1856
 
1784 1857
 		echo '
1785 1858
 				</select>
@@ -1790,18 +1863,20 @@  discard block
 block discarded – undo
1790 1863
 					<select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();">
1791 1864
 						<option value="">', $txt['pm_rule_sel_group'], '</option>';
1792 1865
 
1793
-		foreach ($context['groups'] as $id => $group)
1794
-			echo '
1866
+		foreach ($context['groups'] as $id => $group) {
1867
+					echo '
1795 1868
 						<option value="', $id, '"', $criteria['t'] == 'gid' && $criteria['v'] == $id ? ' selected' : '', '>', $group, '</option>';
1869
+		}
1796 1870
 		echo '
1797 1871
 					</select>
1798 1872
 				</span>';
1799 1873
 
1800 1874
 		// If this is the dummy we add a means to hide for non js users.
1801
-		if ($isFirst)
1802
-			$isFirst = false;
1803
-		elseif ($criteria['t'] == '')
1804
-			echo '</div>';
1875
+		if ($isFirst) {
1876
+					$isFirst = false;
1877
+		} elseif ($criteria['t'] == '') {
1878
+					echo '</div>';
1879
+		}
1805 1880
 	}
1806 1881
 
1807 1882
 	echo '
@@ -1824,10 +1899,11 @@  discard block
 block discarded – undo
1824 1899
 	$isFirst = true;
1825 1900
 	foreach ($context['rule']['actions'] as $k => $action)
1826 1901
 	{
1827
-		if (!$isFirst && $action['t'] == '')
1828
-			echo '<div id="removeonjs2">';
1829
-		elseif (!$isFirst)
1830
-			echo '<br>';
1902
+		if (!$isFirst && $action['t'] == '') {
1903
+					echo '<div id="removeonjs2">';
1904
+		} elseif (!$isFirst) {
1905
+					echo '<br>';
1906
+		}
1831 1907
 
1832 1908
 		echo '
1833 1909
 				<select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
@@ -1838,20 +1914,22 @@  discard block
 block discarded – undo
1838 1914
 				<span id="labdiv', $k, '">
1839 1915
 					<select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
1840 1916
 						<option value="">', $txt['pm_rule_sel_label'], '</option>';
1841
-		foreach ($context['labels'] as $label)
1842
-			if ($label['id'] != -1)
1917
+		foreach ($context['labels'] as $label) {
1918
+					if ($label['id'] != -1)
1843 1919
 				echo '
1844 1920
 						<option value="', ($label['id']), '"', $action['t'] == 'lab' && $action['v'] == $label['id'] ? ' selected' : '', '>', $label['name'], '</option>';
1921
+		}
1845 1922
 
1846 1923
 		echo '
1847 1924
 					</select>
1848 1925
 				</span>';
1849 1926
 
1850
-		if ($isFirst)
1851
-			$isFirst = false;
1852
-		elseif ($action['t'] == '')
1853
-			echo '
1927
+		if ($isFirst) {
1928
+					$isFirst = false;
1929
+		} elseif ($action['t'] == '') {
1930
+					echo '
1854 1931
 			</div>';
1932
+		}
1855 1933
 	}
1856 1934
 
1857 1935
 	echo '
@@ -1875,22 +1953,25 @@  discard block
 block discarded – undo
1875 1953
 		echo '
1876 1954
 	<script>';
1877 1955
 
1878
-	foreach ($context['rule']['criteria'] as $k => $c)
1879
-		echo '
1956
+	foreach ($context['rule']['criteria'] as $k => $c) {
1957
+			echo '
1880 1958
 			updateRuleDef(', $k, ');';
1959
+	}
1881 1960
 
1882
-	foreach ($context['rule']['actions'] as $k => $c)
1883
-		echo '
1961
+	foreach ($context['rule']['actions'] as $k => $c) {
1962
+			echo '
1884 1963
 			updateActionDef(', $k, ');';
1964
+	}
1885 1965
 
1886 1966
 	echo '
1887 1967
 			rebuildRuleDesc();';
1888 1968
 
1889 1969
 	// If this isn't a new rule and we have JS enabled remove the JS compatibility stuff.
1890
-	if ($context['rid'])
1891
-		echo '
1970
+	if ($context['rid']) {
1971
+			echo '
1892 1972
 			document.getElementById("removeonjs1").style.display = "none";
1893 1973
 			document.getElementById("removeonjs2").style.display = "none";';
1974
+	}
1894 1975
 
1895 1976
 	echo '
1896 1977
 			document.getElementById("addonjs1").style.display = "";
@@ -1918,12 +1999,12 @@  discard block
 block discarded – undo
1918 1999
 		</div>';
1919 2000
 
1920 2001
 	// No drafts? Just show an informative message.
1921
-	if (empty($context['drafts']))
1922
-		echo '
2002
+	if (empty($context['drafts'])) {
2003
+			echo '
1923 2004
 		<div class="windowbg2 centertext">
1924 2005
 			', $txt['draft_none'], '
1925 2006
 		</div>';
1926
-	else
2007
+	} else
1927 2008
 	{
1928 2009
 		// For every draft to be displayed, give it its own div, and show the important details of the draft.
1929 2010
 		foreach ($context['drafts'] as $draft)
Please login to merge, or discard this patch.
Themes/default/ManageScheduledTasks.template.php 1 patch
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@
 block discarded – undo
20 20
 	// We completed some tasks?
21 21
 	if (!empty($context['tasks_were_run']))
22 22
 	{
23
-		if (empty($context['scheduled_errors']))
24
-			echo '
23
+		if (empty($context['scheduled_errors'])) {
24
+					echo '
25 25
 	<div class="infobox">
26 26
 		', $txt['scheduled_tasks_were_run'], '
27 27
 	</div>';
28
-		else
28
+		} else
29 29
 		{
30 30
 			echo '
31 31
 	<div class="errorbox" id="errors">
Please login to merge, or discard this patch.
Themes/default/Xml.template.php 1 patch
Braces   +50 added lines, -37 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 		<subject is_first="', $context['message']['first_in_topic'] ? '1' : '0', '"><![CDATA[', cleanXml($context['message']['subject']), ']]></subject>
75 75
 		<body><![CDATA[', $context['message']['body'], ']]></body>
76 76
 		<success><![CDATA[', $txt['quick_modify_message'], ']]></success>';
77
-	}
78
-	else
79
-		echo '
77
+	} else {
78
+			echo '
80 79
 		<error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '" in_body="', cleanXml($context['message']['error_in_body']) ? '1' : '0', '"><![CDATA[', implode('<br />', $context['message']['errors']), ']]></error>';
80
+	}
81 81
 	echo '
82 82
 	</message>
83 83
 </smf>';
@@ -101,13 +101,14 @@  discard block
 block discarded – undo
101 101
 
102 102
 		echo '
103 103
 		<modified><![CDATA[', empty($modified) ? '' : cleanXml('&#171; <em>' . $modified . '</em>&#187;'), ']]></modified>';
104
-		if (!empty($context['message']['subject']))
105
-			echo '
104
+		if (!empty($context['message']['subject'])) {
105
+					echo '
106 106
 		<subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject>';
107
-	}
108
-	else
109
-		echo '
107
+		}
108
+	} else {
109
+			echo '
110 110
 		<error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '"><![CDATA[', cleanXml(implode('<br />', $context['message']['errors'])), ']]></error>';
111
+	}
111 112
 	echo '
112 113
 	</message>
113 114
 </smf>';
@@ -127,10 +128,11 @@  discard block
 block discarded – undo
127 128
 		<body><![CDATA[', $context['preview_message'], ']]></body>
128 129
 	</preview>
129 130
 	<errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '" topic_locked="', $context['locked'] ? '1' : '0', '">';
130
-	if (!empty($context['post_error']))
131
-		foreach ($context['post_error'] as $message)
131
+	if (!empty($context['post_error'])) {
132
+			foreach ($context['post_error'] as $message)
132 133
 			echo '
133 134
 		<error><![CDATA[', cleanXml($message), ']]></error>';
135
+	}
134 136
 	echo '
135 137
 		<caption name="guestname" class="', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? 'error' : '', '" />
136 138
 		<caption name="email" class="', isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? 'error' : '', '" />
@@ -145,14 +147,15 @@  discard block
 block discarded – undo
145 147
 	{
146 148
 		echo '
147 149
 	<new_posts>';
148
-		foreach ($context['previous_posts'] as $post)
149
-			echo '
150
+		foreach ($context['previous_posts'] as $post) {
151
+					echo '
150 152
 		<post id="', $post['id'], '">
151 153
 			<time><![CDATA[', $post['time'], ']]></time>
152 154
 			<poster><![CDATA[', cleanXml($post['poster']), ']]></poster>
153 155
 			<message><![CDATA[', cleanXml($post['message']), ']]></message>
154 156
 			<is_ignored>', $post['is_ignored'] ? '1' : '0', '</is_ignored>
155 157
 		</post>';
158
+		}
156 159
 		echo '
157 160
 	</new_posts>';
158 161
 	}
@@ -176,10 +179,11 @@  discard block
 block discarded – undo
176 179
 		<body><![CDATA[', $context['preview_message'], ']]></body>
177 180
 	</preview>
178 181
 	<errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">';
179
-	if (!empty($context['post_error']['messages']))
180
-		foreach ($context['post_error']['messages'] as $message)
182
+	if (!empty($context['post_error']['messages'])) {
183
+			foreach ($context['post_error']['messages'] as $message)
181 184
 			echo '
182 185
 		<error><![CDATA[', cleanXml($message), ']]></error>';
186
+	}
183 187
 
184 188
 	echo '
185 189
 		<caption name="to" class="', isset($context['post_error']['no_to']) ? 'error' : '', '" />
@@ -208,10 +212,11 @@  discard block
 block discarded – undo
208 212
 		<body><![CDATA[', $context['preview_message'], ']]></body>
209 213
 	</preview>
210 214
 	<errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">';
211
-	if (!empty($context['post_error']['messages']))
212
-		foreach ($context['post_error']['messages'] as $message)
215
+	if (!empty($context['post_error']['messages'])) {
216
+			foreach ($context['post_error']['messages'] as $message)
213 217
 			echo '
214 218
 		<error><![CDATA[', cleanXml($message), ']]></error>';
219
+	}
215 220
 
216 221
 	echo '
217 222
 	</errors>';
@@ -227,19 +232,22 @@  discard block
 block discarded – undo
227 232
 {
228 233
 	global $context, $modSettings;
229 234
 
230
-	if (empty($context['yearly']))
231
-		return;
235
+	if (empty($context['yearly'])) {
236
+			return;
237
+	}
232 238
 
233 239
 	echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>
234 240
 <smf>';
235
-	foreach ($context['yearly'] as $year)
236
-		foreach ($year['months'] as $month)
241
+	foreach ($context['yearly'] as $year) {
242
+			foreach ($year['months'] as $month)
237 243
 		{
238 244
 			echo '
239 245
 	<month id="', $month['date']['year'], $month['date']['month'], '">';
240
-			foreach ($month['days'] as $day)
241
-				echo '
246
+	}
247
+			foreach ($month['days'] as $day) {
248
+							echo '
242 249
 		<day date="', $day['year'], '-', $day['month'], '-', $day['day'], '" new_topics="', $day['new_topics'], '" new_posts="', $day['new_posts'], '" new_members="', $day['new_members'], '" most_members_online="', $day['most_members_online'], '"', empty($modSettings['hitStats']) ? '' : ' hits="' . $day['hits'] . '"', ' />';
250
+			}
243 251
 			echo '
244 252
 	</month>';
245 253
 		}
@@ -260,17 +268,18 @@  discard block
 block discarded – undo
260 268
 	<pageIndex section="selected" startFrom="', $context['selected']['start'], '"><![CDATA[', $context['selected']['page_index'], ']]></pageIndex>';
261 269
 	foreach ($context['changes'] as $change)
262 270
 	{
263
-		if ($change['type'] == 'remove')
264
-			echo '
271
+		if ($change['type'] == 'remove') {
272
+					echo '
265 273
 	<change id="', $change['id'], '" curAction="remove" section="', $change['section'], '" />';
266
-		else
267
-			echo '
274
+		} else {
275
+					echo '
268 276
 	<change id="', $change['id'], '" curAction="insert" section="', $change['section'], '">
269 277
 		<subject><![CDATA[', cleanXml($change['insert_value']['subject']), ']]></subject>
270 278
 		<time><![CDATA[', cleanXml($change['insert_value']['time']), ']]></time>
271 279
 		<body><![CDATA[', cleanXml($change['insert_value']['body']), ']]></body>
272 280
 		<poster><![CDATA[', cleanXml($change['insert_value']['poster']), ']]></poster>
273 281
 	</change>';
282
+		}
274 283
 	}
275 284
 	echo '
276 285
 </smf>';
@@ -301,10 +310,10 @@  discard block
 block discarded – undo
301 310
 	echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>
302 311
 <smf>';
303 312
 
304
-	if (empty($context['topics']))
305
-		echo '
313
+	if (empty($context['topics'])) {
314
+			echo '
306 315
 		<noresults>', $txt['search_no_results'], '</noresults>';
307
-	else
316
+	} else
308 317
 	{
309 318
 		echo '
310 319
 		<results>';
@@ -370,9 +379,10 @@  discard block
 block discarded – undo
370 379
 	{
371 380
 		echo '
372 381
 	<item type="category" id="', $category['id'], '"><![CDATA[', cleanXml($category['name']), ']]></item>';
373
-		foreach ($category['boards'] as $board)
374
-			echo '
382
+		foreach ($category['boards'] as $board) {
383
+					echo '
375 384
 	<item type="board" id="', $board['id'], '" childlevel="', $board['child_level'], '"><![CDATA[', cleanXml($board['name']), ']]></item>';
385
+		}
376 386
 	}
377 387
 	echo '
378 388
 </smf>';
@@ -387,9 +397,10 @@  discard block
 block discarded – undo
387 397
 
388 398
 	echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>
389 399
 <smf>';
390
-	foreach ($context['icons'] as $icon)
391
-		echo '
400
+	foreach ($context['icons'] as $icon) {
401
+			echo '
392 402
 	<icon value="', $icon['value'], '" url="', $icon['url'], '"><![CDATA[', cleanXml($icon['name']), ']]></icon>';
403
+	}
393 404
 	echo '
394 405
 </smf>';
395 406
 }
@@ -438,16 +449,18 @@  discard block
 block discarded – undo
438 449
 	foreach ($xml_data as $key => $data)
439 450
 	{
440 451
 		// A group?
441
-		if (is_array($data) && isset($data['identifier']))
442
-			template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level);
452
+		if (is_array($data) && isset($data['identifier'])) {
453
+					template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level);
454
+		}
443 455
 		// An item...
444 456
 		elseif (is_array($data) && isset($data['value']))
445 457
 		{
446 458
 			echo "\n", str_repeat("\t", $level), '<', $child_ident;
447 459
 
448
-			if (!empty($data['attributes']))
449
-				foreach ($data['attributes'] as $k => $v)
460
+			if (!empty($data['attributes'])) {
461
+							foreach ($data['attributes'] as $k => $v)
450 462
 					echo ' ' . $k . '="' . $v . '"';
463
+			}
451 464
 			echo '><![CDATA[', cleanXml($data['value']), ']]></', $child_ident, '>';
452 465
 		}
453 466
 
Please login to merge, or discard this patch.