Completed
Pull Request — release-2.1 (#4265)
by Rick
08:35
created
cache/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/SplitTopics.php 1 patch
Braces   +260 added lines, -186 removed lines patch added patch discarded remove patch
@@ -15,8 +15,9 @@  discard block
 block discarded – undo
15 15
  * Original module by Mach8 - We'll never forget you.
16 16
  */
17 17
 
18
-if (!defined('SMF'))
18
+if (!defined('SMF')) {
19 19
 	die('No direct access...');
20
+}
20 21
 
21 22
 /**
22 23
  * splits a topic into two topics.
@@ -30,15 +31,17 @@  discard block
 block discarded – undo
30 31
 	global $topic, $sourcedir;
31 32
 
32 33
 	// And... which topic were you splitting, again?
33
-	if (empty($topic))
34
-		fatal_lang_error('numbers_one_to_nine', false);
34
+	if (empty($topic)) {
35
+			fatal_lang_error('numbers_one_to_nine', false);
36
+	}
35 37
 
36 38
 	// Are you allowed to split topics?
37 39
 	isAllowedTo('split_any');
38 40
 
39 41
 	// Load up the "dependencies" - the template, getMsgMemberID(), and sendNotifications().
40
-	if (!isset($_REQUEST['xml']))
41
-		loadTemplate('SplitTopics');
42
+	if (!isset($_REQUEST['xml'])) {
43
+			loadTemplate('SplitTopics');
44
+	}
42 45
 	require_once($sourcedir . '/Subs-Boards.php');
43 46
 	require_once($sourcedir . '/Subs-Post.php');
44 47
 
@@ -50,12 +53,12 @@  discard block
 block discarded – undo
50 53
 	);
51 54
 
52 55
 	// ?action=splittopics;sa=LETSBREAKIT won't work, sorry.
53
-	if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']]))
54
-		SplitIndex();
55
-
56
-	else
57
-		call_helper($subActions[$_REQUEST['sa']]);
58
-}
56
+	if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) {
57
+			SplitIndex();
58
+	} else {
59
+			call_helper($subActions[$_REQUEST['sa']]);
60
+	}
61
+	}
59 62
 
60 63
 /**
61 64
  * screen shown before the actual split.
@@ -71,8 +74,9 @@  discard block
 block discarded – undo
71 74
 	global $txt, $topic, $context, $smcFunc, $modSettings;
72 75
 
73 76
 	// Validate "at".
74
-	if (empty($_GET['at']))
75
-		fatal_lang_error('numbers_one_to_nine', false);
77
+	if (empty($_GET['at'])) {
78
+			fatal_lang_error('numbers_one_to_nine', false);
79
+	}
76 80
 	$_GET['at'] = (int) $_GET['at'];
77 81
 
78 82
 	// Retrieve the subject and stuff of the specific topic/message.
@@ -89,26 +93,31 @@  discard block
 block discarded – undo
89 93
 			'split_at' => $_GET['at'],
90 94
 		)
91 95
 	);
92
-	if ($smcFunc['db_num_rows']($request) == 0)
93
-		fatal_lang_error('cant_find_messages');
96
+	if ($smcFunc['db_num_rows']($request) == 0) {
97
+			fatal_lang_error('cant_find_messages');
98
+	}
94 99
 	list ($_REQUEST['subname'], $num_replies, $unapproved_posts, $id_first_msg, $approved) = $smcFunc['db_fetch_row']($request);
95 100
 	$smcFunc['db_free_result']($request);
96 101
 
97 102
 	// If not approved validate they can see it.
98
-	if ($modSettings['postmod_active'] && !$approved)
99
-		isAllowedTo('approve_posts');
103
+	if ($modSettings['postmod_active'] && !$approved) {
104
+			isAllowedTo('approve_posts');
105
+	}
100 106
 
101 107
 	// If this topic has unapproved posts, we need to count them too...
102
-	if ($modSettings['postmod_active'] && allowedTo('approve_posts'))
103
-		$num_replies += $unapproved_posts - ($approved ? 0 : 1);
108
+	if ($modSettings['postmod_active'] && allowedTo('approve_posts')) {
109
+			$num_replies += $unapproved_posts - ($approved ? 0 : 1);
110
+	}
104 111
 
105 112
 	// Check if there is more than one message in the topic.  (there should be.)
106
-	if ($num_replies < 1)
107
-		fatal_lang_error('topic_one_post', false);
113
+	if ($num_replies < 1) {
114
+			fatal_lang_error('topic_one_post', false);
115
+	}
108 116
 
109 117
 	// Check if this is the first message in the topic (if so, the first and second option won't be available)
110
-	if ($id_first_msg == $_GET['at'])
111
-		return SplitSelectTopics();
118
+	if ($id_first_msg == $_GET['at']) {
119
+			return SplitSelectTopics();
120
+	}
112 121
 
113 122
 	// Basic template information....
114 123
 	$context['message'] = array(
@@ -137,8 +146,9 @@  discard block
 block discarded – undo
137 146
 	checkSession();
138 147
 
139 148
 	// Clean up the subject.
140
-	if (!isset($_POST['subname']) || $_POST['subname'] == '')
141
-		$_POST['subname'] = $txt['new_topic'];
149
+	if (!isset($_POST['subname']) || $_POST['subname'] == '') {
150
+			$_POST['subname'] = $txt['new_topic'];
151
+	}
142 152
 
143 153
 	// Redirect to the selector if they chose selective.
144 154
 	if ($_POST['step2'] == 'selective')
@@ -163,16 +173,19 @@  discard block
 block discarded – undo
163 173
 				'split_at' => $_POST['at'],
164 174
 			)
165 175
 		);
166
-		while ($row = $smcFunc['db_fetch_assoc']($request))
167
-			$messagesToBeSplit[] = $row['id_msg'];
176
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
177
+					$messagesToBeSplit[] = $row['id_msg'];
178
+		}
168 179
 		$smcFunc['db_free_result']($request);
169 180
 	}
170 181
 	// Only the selected message has to be split. That should be easy.
171
-	elseif ($_POST['step2'] == 'onlythis')
172
-		$messagesToBeSplit[] = $_POST['at'];
182
+	elseif ($_POST['step2'] == 'onlythis') {
183
+			$messagesToBeSplit[] = $_POST['at'];
184
+	}
173 185
 	// There's another action?!
174
-	else
175
-		fatal_lang_error('no_access', false);
186
+	else {
187
+			fatal_lang_error('no_access', false);
188
+	}
176 189
 
177 190
 	$context['old_topic'] = $topic;
178 191
 	$context['new_topic'] = splitTopic($topic, $messagesToBeSplit, $_POST['subname']);
@@ -199,8 +212,9 @@  discard block
 block discarded – undo
199 212
 	$_SESSION['split_selection'][$topic] = empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic];
200 213
 
201 214
 	// This is a special case for split topics from quick-moderation checkboxes
202
-	if (isset($_REQUEST['subname_enc']))
203
-		$_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']);
215
+	if (isset($_REQUEST['subname_enc'])) {
216
+			$_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']);
217
+	}
204 218
 
205 219
 	$context['not_selected'] = array(
206 220
 		'num_messages' => 0,
@@ -252,10 +266,12 @@  discard block
 block discarded – undo
252 266
 			)
253 267
 		);
254 268
 		// You can't split the last message off.
255
-		if (empty($context['not_selected']['start']) && $smcFunc['db_num_rows']($request) <= 1 && $_REQUEST['move'] == 'down')
256
-			$_REQUEST['move'] = '';
257
-		while ($row = $smcFunc['db_fetch_assoc']($request))
258
-			$original_msgs['not_selected'][] = $row['id_msg'];
269
+		if (empty($context['not_selected']['start']) && $smcFunc['db_num_rows']($request) <= 1 && $_REQUEST['move'] == 'down') {
270
+					$_REQUEST['move'] = '';
271
+		}
272
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
273
+					$original_msgs['not_selected'][] = $row['id_msg'];
274
+		}
259 275
 		$smcFunc['db_free_result']($request);
260 276
 		if (!empty($_SESSION['split_selection'][$topic]))
261 277
 		{
@@ -275,8 +291,9 @@  discard block
 block discarded – undo
275 291
 					'messages_per_page' => $context['messages_per_page'],
276 292
 				)
277 293
 			);
278
-			while ($row = $smcFunc['db_fetch_assoc']($request))
279
-				$original_msgs['selected'][] = $row['id_msg'];
294
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
295
+							$original_msgs['selected'][] = $row['id_msg'];
296
+			}
280 297
 			$smcFunc['db_free_result']($request);
281 298
 		}
282 299
 	}
@@ -286,12 +303,13 @@  discard block
 block discarded – undo
286 303
 	{
287 304
 		$_REQUEST['msg'] = (int) $_REQUEST['msg'];
288 305
 
289
-		if ($_REQUEST['move'] == 'reset')
290
-			$_SESSION['split_selection'][$topic] = array();
291
-		elseif ($_REQUEST['move'] == 'up')
292
-			$_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg']));
293
-		else
294
-			$_SESSION['split_selection'][$topic][] = $_REQUEST['msg'];
306
+		if ($_REQUEST['move'] == 'reset') {
307
+					$_SESSION['split_selection'][$topic] = array();
308
+		} elseif ($_REQUEST['move'] == 'up') {
309
+					$_SESSION['split_selection'][$topic] = array_diff($_SESSION['split_selection'][$topic], array($_REQUEST['msg']));
310
+		} else {
311
+					$_SESSION['split_selection'][$topic][] = $_REQUEST['msg'];
312
+		}
295 313
 	}
296 314
 
297 315
 	// Make sure the selection is still accurate.
@@ -310,8 +328,9 @@  discard block
 block discarded – undo
310 328
 			)
311 329
 		);
312 330
 		$_SESSION['split_selection'][$topic] = array();
313
-		while ($row = $smcFunc['db_fetch_assoc']($request))
314
-			$_SESSION['split_selection'][$topic][] = $row['id_msg'];
331
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
332
+					$_SESSION['split_selection'][$topic][] = $row['id_msg'];
333
+		}
315 334
 		$smcFunc['db_free_result']($request);
316 335
 	}
317 336
 
@@ -328,13 +347,15 @@  discard block
 block discarded – undo
328 347
 			'is_approved' => 1,
329 348
 		)
330 349
 	);
331
-	while ($row = $smcFunc['db_fetch_assoc']($request))
332
-		$context[empty($row['is_selected']) || $row['is_selected'] == 'f' ? 'not_selected' : 'selected']['num_messages'] = $row['num_messages'];
350
+	while ($row = $smcFunc['db_fetch_assoc']($request)) {
351
+			$context[empty($row['is_selected']) || $row['is_selected'] == 'f' ? 'not_selected' : 'selected']['num_messages'] = $row['num_messages'];
352
+	}
333 353
 	$smcFunc['db_free_result']($request);
334 354
 
335 355
 	// Fix an oversized starting page (to make sure both pageindexes are properly set).
336
-	if ($context['selected']['start'] >= $context['selected']['num_messages'])
337
-		$context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : ($context['selected']['num_messages'] - (($context['selected']['num_messages'] % $context['messages_per_page']) == 0 ? $context['messages_per_page'] : ($context['selected']['num_messages'] % $context['messages_per_page'])));
356
+	if ($context['selected']['start'] >= $context['selected']['num_messages']) {
357
+			$context['selected']['start'] = $context['selected']['num_messages'] <= $context['messages_per_page'] ? 0 : ($context['selected']['num_messages'] - (($context['selected']['num_messages'] % $context['messages_per_page']) == 0 ? $context['messages_per_page'] : ($context['selected']['num_messages'] % $context['messages_per_page'])));
358
+	}
338 359
 
339 360
 	// Build a page list of the not-selected topics...
340 361
 	$context['not_selected']['page_index'] = constructPageIndex($scripturl . '?action=splittopics;sa=selectTopics;subname=' . strtr(urlencode($_REQUEST['subname']), array('%' => '%%')) . ';topic=' . $topic . '.%1$d;start2=' . $context['selected']['start'], $context['not_selected']['start'], $context['not_selected']['num_messages'], $context['messages_per_page'], true);
@@ -434,11 +455,12 @@  discard block
 block discarded – undo
434 455
 		);
435 456
 
436 457
 		$context['changes'] = array();
437
-		foreach ($changes as $change_type => $change_array)
438
-			foreach ($change_array as $section => $msg_array)
458
+		foreach ($changes as $change_type => $change_array) {
459
+					foreach ($change_array as $section => $msg_array)
439 460
 			{
440 461
 				if (empty($msg_array))
441 462
 					continue;
463
+		}
442 464
 
443 465
 				foreach ($msg_array as $id_msg)
444 466
 				{
@@ -447,8 +469,9 @@  discard block
 block discarded – undo
447 469
 						'type' => $change_type,
448 470
 						'section' => $section,
449 471
 					);
450
-					if ($change_type == 'insert')
451
-						$context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg];
472
+					if ($change_type == 'insert') {
473
+											$context['changes']['insert' . $id_msg]['insert_value'] = $context[$section]['messages'][$id_msg];
474
+					}
452 475
 				}
453 476
 			}
454 477
 	}
@@ -468,12 +491,14 @@  discard block
 block discarded – undo
468 491
 	checkSession();
469 492
 
470 493
 	// Default the subject in case it's blank.
471
-	if (!isset($_POST['subname']) || $_POST['subname'] == '')
472
-		$_POST['subname'] = $txt['new_topic'];
494
+	if (!isset($_POST['subname']) || $_POST['subname'] == '') {
495
+			$_POST['subname'] = $txt['new_topic'];
496
+	}
473 497
 
474 498
 	// You must've selected some messages!  Can't split out none!
475
-	if (empty($_SESSION['split_selection'][$topic]))
476
-		fatal_lang_error('no_posts_selected', false);
499
+	if (empty($_SESSION['split_selection'][$topic])) {
500
+			fatal_lang_error('no_posts_selected', false);
501
+	}
477 502
 
478 503
 	$context['old_topic'] = $topic;
479 504
 	$context['new_topic'] = splitTopic($topic, $_SESSION['split_selection'][$topic], $_POST['subname']);
@@ -499,8 +524,9 @@  discard block
 block discarded – undo
499 524
 	global $smcFunc, $txt, $sourcedir;
500 525
 
501 526
 	// Nothing to split?
502
-	if (empty($splitMessages))
503
-		fatal_lang_error('no_posts_selected', false);
527
+	if (empty($splitMessages)) {
528
+			fatal_lang_error('no_posts_selected', false);
529
+	}
504 530
 
505 531
 	// Get some board info.
506 532
 	$request = $smcFunc['db_query']('', '
@@ -532,8 +558,9 @@  discard block
 block discarded – undo
532 558
 		)
533 559
 	);
534 560
 	// You can't select ALL the messages!
535
-	if ($smcFunc['db_num_rows']($request) == 0)
536
-		fatal_lang_error('selected_all_posts', false);
561
+	if ($smcFunc['db_num_rows']($request) == 0) {
562
+			fatal_lang_error('selected_all_posts', false);
563
+	}
537 564
 
538 565
 	$split1_first_msg = null;
539 566
 	$split1_last_msg = null;
@@ -541,24 +568,27 @@  discard block
 block discarded – undo
541 568
 	while ($row = $smcFunc['db_fetch_assoc']($request))
542 569
 	{
543 570
 		// Get the right first and last message dependant on approved state...
544
-		if (empty($split1_first_msg) || $row['myid_first_msg'] < $split1_first_msg)
545
-			$split1_first_msg = $row['myid_first_msg'];
546
-		if (empty($split1_last_msg) || $row['approved'])
547
-			$split1_last_msg = $row['myid_last_msg'];
571
+		if (empty($split1_first_msg) || $row['myid_first_msg'] < $split1_first_msg) {
572
+					$split1_first_msg = $row['myid_first_msg'];
573
+		}
574
+		if (empty($split1_last_msg) || $row['approved']) {
575
+					$split1_last_msg = $row['myid_last_msg'];
576
+		}
548 577
 
549 578
 		// Get the counts correct...
550 579
 		if ($row['approved'])
551 580
 		{
552 581
 			$split1_replies = $row['message_count'] - 1;
553 582
 			$split1_unapprovedposts = 0;
554
-		}
555
-		else
583
+		} else
556 584
 		{
557
-			if (!isset($split1_replies))
558
-				$split1_replies = 0;
585
+			if (!isset($split1_replies)) {
586
+							$split1_replies = 0;
587
+			}
559 588
 			// If the topic isn't approved then num replies must go up by one... as first post wouldn't be counted.
560
-			elseif (!$split1_approved)
561
-				$split1_replies++;
589
+			elseif (!$split1_approved) {
590
+							$split1_replies++;
591
+			}
562 592
 
563 593
 			$split1_unapprovedposts = $row['message_count'];
564 594
 		}
@@ -584,10 +614,12 @@  discard block
 block discarded – undo
584 614
 	while ($row = $smcFunc['db_fetch_assoc']($request))
585 615
 	{
586 616
 		// As before get the right first and last message dependant on approved state...
587
-		if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg)
588
-			$split2_first_msg = $row['myid_first_msg'];
589
-		if (empty($split2_last_msg) || $row['approved'])
590
-			$split2_last_msg = $row['myid_last_msg'];
617
+		if (empty($split2_first_msg) || $row['myid_first_msg'] < $split2_first_msg) {
618
+					$split2_first_msg = $row['myid_first_msg'];
619
+		}
620
+		if (empty($split2_last_msg) || $row['approved']) {
621
+					$split2_last_msg = $row['myid_last_msg'];
622
+		}
591 623
 
592 624
 		// Then do the counts again...
593 625
 		if ($row['approved'])
@@ -595,18 +627,20 @@  discard block
 block discarded – undo
595 627
 			$split2_approved = true;
596 628
 			$split2_replies = $row['message_count'] - 1;
597 629
 			$split2_unapprovedposts = 0;
598
-		}
599
-		else
630
+		} else
600 631
 		{
601 632
 			// Should this one be approved??
602
-			if ($split2_first_msg == $row['myid_first_msg'])
603
-				$split2_approved = false;
633
+			if ($split2_first_msg == $row['myid_first_msg']) {
634
+							$split2_approved = false;
635
+			}
604 636
 
605
-			if (!isset($split2_replies))
606
-				$split2_replies = 0;
637
+			if (!isset($split2_replies)) {
638
+							$split2_replies = 0;
639
+			}
607 640
 			// As before, fix number of replies.
608
-			elseif (!$split2_approved)
609
-				$split2_replies++;
641
+			elseif (!$split2_approved) {
642
+							$split2_replies++;
643
+			}
610 644
 
611 645
 			$split2_unapprovedposts = $row['message_count'];
612 646
 		}
@@ -616,12 +650,14 @@  discard block
 block discarded – undo
616 650
 	$split2_lastMem = getMsgMemberID($split2_last_msg);
617 651
 
618 652
 	// No database changes yet, so let's double check to see if everything makes at least a little sense.
619
-	if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved))
620
-		fatal_lang_error('cant_find_messages');
653
+	if ($split1_first_msg <= 0 || $split1_last_msg <= 0 || $split2_first_msg <= 0 || $split2_last_msg <= 0 || $split1_replies < 0 || $split2_replies < 0 || $split1_unapprovedposts < 0 || $split2_unapprovedposts < 0 || !isset($split1_approved) || !isset($split2_approved)) {
654
+			fatal_lang_error('cant_find_messages');
655
+	}
621 656
 
622 657
 	// You cannot split off the first message of a topic.
623
-	if ($split1_first_msg > $split2_first_msg)
624
-		fatal_lang_error('split_first_post', false);
658
+	if ($split1_first_msg > $split2_first_msg) {
659
+			fatal_lang_error('split_first_post', false);
660
+	}
625 661
 
626 662
 	// We're off to insert the new topic!  Use 0 for now to avoid UNIQUE errors.
627 663
 	$split2_ID_TOPIC = $smcFunc['db_insert']('',
@@ -644,14 +680,16 @@  discard block
 block discarded – undo
644 680
 			array('id_topic'),
645 681
 			1
646 682
 		);
647
-	if ($split2_ID_TOPIC <= 0)
648
-		fatal_lang_error('cant_insert_topic');
683
+	if ($split2_ID_TOPIC <= 0) {
684
+			fatal_lang_error('cant_insert_topic');
685
+	}
649 686
 
650 687
 	// Move the messages over to the other topic.
651 688
 	$new_subject = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($new_subject)), array("\r" => '', "\n" => '', "\t" => ''));
652 689
 	// Check the subject length.
653
-	if ($smcFunc['strlen']($new_subject) > 100)
654
-		$new_subject = $smcFunc['substr']($new_subject, 0, 100);
690
+	if ($smcFunc['strlen']($new_subject) > 100) {
691
+			$new_subject = $smcFunc['substr']($new_subject, 0, 100);
692
+	}
655 693
 	// Valid subject?
656 694
 	if ($new_subject != '')
657 695
 	{
@@ -722,8 +760,8 @@  discard block
 block discarded – undo
722 760
 	);
723 761
 
724 762
 	// If the new topic isn't approved ensure the first message flags this just in case.
725
-	if (!$split2_approved)
726
-		$smcFunc['db_query']('', '
763
+	if (!$split2_approved) {
764
+			$smcFunc['db_query']('', '
727 765
 			UPDATE {db_prefix}messages
728 766
 			SET approved = {int:approved}
729 767
 			WHERE id_msg = {int:id_msg}
@@ -734,6 +772,7 @@  discard block
 block discarded – undo
734 772
 				'id_topic' => $split2_ID_TOPIC,
735 773
 			)
736 774
 		);
775
+	}
737 776
 
738 777
 	// The board has more topics now (Or more unapproved ones!).
739 778
 	$smcFunc['db_query']('', '
@@ -760,8 +799,9 @@  discard block
 block discarded – undo
760 799
 	if ($smcFunc['db_num_rows']($request) > 0)
761 800
 	{
762 801
 		$replaceEntries = array();
763
-		while ($row = $smcFunc['db_fetch_assoc']($request))
764
-			$replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']);
802
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
803
+					$replaceEntries[] = array($row['id_member'], $split2_ID_TOPIC, $row['id_msg'], $row['unwatched']);
804
+		}
765 805
 
766 806
 		$smcFunc['db_insert']('ignore',
767 807
 			'{db_prefix}log_topics',
@@ -785,8 +825,9 @@  discard block
 block discarded – undo
785 825
 	// If there's a search index that needs updating, update it...
786 826
 	require_once($sourcedir . '/Search.php');
787 827
 	$searchAPI = findSearchAPI();
788
-	if (is_callable(array($searchAPI, 'topicSplit')))
789
-		$searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages);
828
+	if (is_callable(array($searchAPI, 'topicSplit'))) {
829
+			$searchAPI->topicSplit($split2_ID_TOPIC, $splitMessages);
830
+	}
790 831
 
791 832
 	// Maybe we want to let an external CMS know about this split
792 833
 	$split1 = array(
@@ -833,12 +874,12 @@  discard block
 block discarded – undo
833 874
 	);
834 875
 
835 876
 	// ?action=mergetopics;sa=LETSBREAKIT won't work, sorry.
836
-	if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']]))
837
-		MergeIndex();
838
-
839
-	else
840
-		call_helper($subActions[$_REQUEST['sa']]);
841
-}
877
+	if (empty($_REQUEST['sa']) || !isset($subActions[$_REQUEST['sa']])) {
878
+			MergeIndex();
879
+	} else {
880
+			call_helper($subActions[$_REQUEST['sa']]);
881
+	}
882
+	}
842 883
 
843 884
 /**
844 885
  * allows to pick a topic to merge the current topic with.
@@ -852,8 +893,9 @@  discard block
 block discarded – undo
852 893
 	global $txt, $board, $context, $smcFunc, $sourcedir;
853 894
 	global $scripturl, $modSettings;
854 895
 
855
-	if (!isset($_GET['from']))
856
-		fatal_lang_error('no_access', false);
896
+	if (!isset($_GET['from'])) {
897
+			fatal_lang_error('no_access', false);
898
+	}
857 899
 	$_GET['from'] = (int) $_GET['from'];
858 900
 
859 901
 	$_REQUEST['targetboard'] = isset($_REQUEST['targetboard']) ? (int) $_REQUEST['targetboard'] : $board;
@@ -864,9 +906,9 @@  discard block
 block discarded – undo
864 906
 	{
865 907
 		$can_approve_boards = boardsAllowedTo('approve_posts');
866 908
 		$onlyApproved = $can_approve_boards !== array(0) && !in_array($_REQUEST['targetboard'], $can_approve_boards);
909
+	} else {
910
+			$onlyApproved = false;
867 911
 	}
868
-	else
869
-		$onlyApproved = false;
870 912
 
871 913
 	// How many topics are on this board?  (used for paging.)
872 914
 	$request = $smcFunc['db_query']('', '
@@ -900,8 +942,9 @@  discard block
 block discarded – undo
900 942
 			'is_approved' => 1,
901 943
 		)
902 944
 	);
903
-	if ($smcFunc['db_num_rows']($request) == 0)
904
-		fatal_lang_error('no_board');
945
+	if ($smcFunc['db_num_rows']($request) == 0) {
946
+			fatal_lang_error('no_board');
947
+	}
905 948
 	list ($subject) = $smcFunc['db_fetch_row']($request);
906 949
 	$smcFunc['db_free_result']($request);
907 950
 
@@ -914,8 +957,9 @@  discard block
 block discarded – undo
914 957
 	// Check which boards you have merge permissions on.
915 958
 	$merge_boards = boardsAllowedTo('merge_any');
916 959
 
917
-	if (empty($merge_boards))
918
-		fatal_lang_error('cannot_merge_any', 'user');
960
+	if (empty($merge_boards)) {
961
+			fatal_lang_error('cannot_merge_any', 'user');
962
+	}
919 963
 
920 964
 	// No sense in loading this if you can only merge on this board
921 965
 	if (count($merge_boards) > 1 || in_array(0, $merge_boards))
@@ -929,8 +973,9 @@  discard block
 block discarded – undo
929 973
 		);
930 974
 
931 975
 		// Only include these boards in the list (0 means you're an admin')
932
-		if (!in_array(0, $merge_boards))
933
-			$options['included_boards'] = $merge_boards;
976
+		if (!in_array(0, $merge_boards)) {
977
+					$options['included_boards'] = $merge_boards;
978
+		}
934 979
 
935 980
 		$context['merge_categories'] = getBoardList($options);
936 981
 	}
@@ -976,8 +1021,9 @@  discard block
 block discarded – undo
976 1021
 	}
977 1022
 	$smcFunc['db_free_result']($request);
978 1023
 
979
-	if (empty($context['topics']) && count($merge_boards) <= 1 && !in_array(0, $merge_boards))
980
-		fatal_lang_error('merge_need_more_topics');
1024
+	if (empty($context['topics']) && count($merge_boards) <= 1 && !in_array(0, $merge_boards)) {
1025
+			fatal_lang_error('merge_need_more_topics');
1026
+	}
981 1027
 
982 1028
 	$context['sub_template'] = 'merge';
983 1029
 }
@@ -1007,24 +1053,29 @@  discard block
 block discarded – undo
1007 1053
 	checkSession('request');
1008 1054
 
1009 1055
 	// Handle URLs from MergeIndex.
1010
-	if (!empty($_GET['from']) && !empty($_GET['to']))
1011
-		$topics = array((int) $_GET['from'], (int) $_GET['to']);
1056
+	if (!empty($_GET['from']) && !empty($_GET['to'])) {
1057
+			$topics = array((int) $_GET['from'], (int) $_GET['to']);
1058
+	}
1012 1059
 
1013 1060
 	// If we came from a form, the topic IDs came by post.
1014
-	if (!empty($_POST['topics']) && is_array($_POST['topics']))
1015
-		$topics = $_POST['topics'];
1061
+	if (!empty($_POST['topics']) && is_array($_POST['topics'])) {
1062
+			$topics = $_POST['topics'];
1063
+	}
1016 1064
 
1017 1065
 	// There's nothing to merge with just one topic...
1018
-	if (empty($topics) || !is_array($topics) || count($topics) == 1)
1019
-		fatal_lang_error('merge_need_more_topics');
1066
+	if (empty($topics) || !is_array($topics) || count($topics) == 1) {
1067
+			fatal_lang_error('merge_need_more_topics');
1068
+	}
1020 1069
 
1021 1070
 	// Make sure every topic is numeric, or some nasty things could be done with the DB.
1022
-	foreach ($topics as $id => $topic)
1023
-		$topics[$id] = (int) $topic;
1071
+	foreach ($topics as $id => $topic) {
1072
+			$topics[$id] = (int) $topic;
1073
+	}
1024 1074
 
1025 1075
 	// Joy of all joys, make sure they're not messing about with unapproved topics they can't see :P
1026
-	if ($modSettings['postmod_active'])
1027
-		$can_approve_boards = boardsAllowedTo('approve_posts');
1076
+	if ($modSettings['postmod_active']) {
1077
+			$can_approve_boards = boardsAllowedTo('approve_posts');
1078
+	}
1028 1079
 
1029 1080
 	// Get info about the topics and polls that will be merged.
1030 1081
 	$request = $smcFunc['db_query']('', '
@@ -1045,8 +1096,9 @@  discard block
 block discarded – undo
1045 1096
 			'limit' => count($topics),
1046 1097
 		)
1047 1098
 	);
1048
-	if ($smcFunc['db_num_rows']($request) < 2)
1049
-		fatal_lang_error('no_topic_id');
1099
+	if ($smcFunc['db_num_rows']($request) < 2) {
1100
+			fatal_lang_error('no_topic_id');
1101
+	}
1050 1102
 	$num_views = 0;
1051 1103
 	$is_sticky = 0;
1052 1104
 	$boardTotals = array();
@@ -1059,34 +1111,38 @@  discard block
 block discarded – undo
1059 1111
 	while ($row = $smcFunc['db_fetch_assoc']($request))
1060 1112
 	{
1061 1113
 		// Sorry, redirection topics can't be merged
1062
-		if (!empty($row['id_redirect_topic']))
1063
-			fatal_lang_error('cannot_merge_redirect', false);
1114
+		if (!empty($row['id_redirect_topic'])) {
1115
+					fatal_lang_error('cannot_merge_redirect', false);
1116
+		}
1064 1117
 
1065 1118
 		// Make a note for the board counts...
1066
-		if (!isset($boardTotals[$row['id_board']]))
1067
-			$boardTotals[$row['id_board']] = array(
1119
+		if (!isset($boardTotals[$row['id_board']])) {
1120
+					$boardTotals[$row['id_board']] = array(
1068 1121
 				'posts' => 0,
1069 1122
 				'topics' => 0,
1070 1123
 				'unapproved_posts' => 0,
1071 1124
 				'unapproved_topics' => 0
1072 1125
 			);
1126
+		}
1073 1127
 
1074 1128
 		// We can't see unapproved topics here?
1075 1129
 		if ($modSettings['postmod_active'] && !$row['approved'] && $can_approve_boards != array(0) && in_array($row['id_board'], $can_approve_boards))
1076 1130
 		{
1077 1131
 			unset($topics[$row['id_topic']]); // If we can't see it, we should not merge it and not adjust counts! Instead skip it.
1078 1132
 			continue;
1079
-		}elseif (!$row['approved'])
1080
-			$boardTotals[$row['id_board']]['unapproved_topics']++;
1081
-		else
1082
-			$boardTotals[$row['id_board']]['topics']++;
1133
+		} elseif (!$row['approved']) {
1134
+					$boardTotals[$row['id_board']]['unapproved_topics']++;
1135
+		} else {
1136
+					$boardTotals[$row['id_board']]['topics']++;
1137
+		}
1083 1138
 
1084 1139
 		$boardTotals[$row['id_board']]['unapproved_posts'] += $row['unapproved_posts'];
1085 1140
 		$boardTotals[$row['id_board']]['posts'] += $row['num_replies'] + ($row['approved'] ? 1 : 0);
1086 1141
 
1087 1142
 		// In the case of making a redirect, the topic count goes up by one due to the redirect topic.
1088
-		if (isset($_POST['postRedirect']))
1089
-			$boardTotals[$row['id_board']]['topics']--;
1143
+		if (isset($_POST['postRedirect'])) {
1144
+					$boardTotals[$row['id_board']]['topics']--;
1145
+		}
1090 1146
 
1091 1147
 		$topic_data[$row['id_topic']] = array(
1092 1148
 			'id' => $row['id_topic'],
@@ -1112,11 +1168,13 @@  discard block
 block discarded – undo
1112 1168
 		$boards[] = $row['id_board'];
1113 1169
 
1114 1170
 		// If there's no poll, id_poll == 0...
1115
-		if ($row['id_poll'] > 0)
1116
-			$polls[] = $row['id_poll'];
1171
+		if ($row['id_poll'] > 0) {
1172
+					$polls[] = $row['id_poll'];
1173
+		}
1117 1174
 		// Store the id_topic with the lowest id_first_msg.
1118
-		if (empty($firstTopic))
1119
-			$firstTopic = $row['id_topic'];
1175
+		if (empty($firstTopic)) {
1176
+					$firstTopic = $row['id_topic'];
1177
+		}
1120 1178
 
1121 1179
 		// Lowest topic id gets selected as surviving topic id. We need to store this board so we can adjust the topic count (This one will not have a redirect topic)
1122 1180
 		if ($row['id_topic'] < $lowestTopicId || empty($lowestTopicId))
@@ -1130,11 +1188,13 @@  discard block
 block discarded – undo
1130 1188
 	$smcFunc['db_free_result']($request);
1131 1189
 
1132 1190
 	// If we didn't get any topics then they've been messing with unapproved stuff.
1133
-	if (empty($topic_data))
1134
-		fatal_lang_error('no_topic_id');
1191
+	if (empty($topic_data)) {
1192
+			fatal_lang_error('no_topic_id');
1193
+	}
1135 1194
 
1136
-	if (isset($_POST['postRedirect']) && !empty($lowestTopicBoard))
1137
-		$boardTotals[$lowestTopicBoard]['topics']++;
1195
+	if (isset($_POST['postRedirect']) && !empty($lowestTopicBoard)) {
1196
+			$boardTotals[$lowestTopicBoard]['topics']++;
1197
+	}
1138 1198
 
1139 1199
 	// Will this be approved?
1140 1200
 	$context['is_approved'] = $topic_data[$firstTopic]['approved'];
@@ -1150,8 +1210,9 @@  discard block
 block discarded – undo
1150 1210
 
1151 1211
 	// Get the boards a user is allowed to merge in.
1152 1212
 	$merge_boards = boardsAllowedTo('merge_any');
1153
-	if (empty($merge_boards))
1154
-		fatal_lang_error('cannot_merge_any', 'user');
1213
+	if (empty($merge_boards)) {
1214
+			fatal_lang_error('cannot_merge_any', 'user');
1215
+	}
1155 1216
 
1156 1217
 	// Make sure they can see all boards....
1157 1218
 	$request = $smcFunc['db_query']('', '
@@ -1168,8 +1229,9 @@  discard block
 block discarded – undo
1168 1229
 		)
1169 1230
 	);
1170 1231
 	// If the number of boards that's in the output isn't exactly the same as we've put in there, you're in trouble.
1171
-	if ($smcFunc['db_num_rows']($request) != count($boards))
1172
-		fatal_lang_error('no_board');
1232
+	if ($smcFunc['db_num_rows']($request) != count($boards)) {
1233
+			fatal_lang_error('no_board');
1234
+	}
1173 1235
 	$smcFunc['db_free_result']($request);
1174 1236
 
1175 1237
 	if (empty($_REQUEST['sa']) || $_REQUEST['sa'] == 'options')
@@ -1188,8 +1250,8 @@  discard block
 block discarded – undo
1188 1250
 					'limit' => count($polls),
1189 1251
 				)
1190 1252
 			);
1191
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1192
-				$context['polls'][] = array(
1253
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1254
+							$context['polls'][] = array(
1193 1255
 					'id' => $row['id_poll'],
1194 1256
 					'topic' => array(
1195 1257
 						'id' => $row['id_topic'],
@@ -1198,6 +1260,7 @@  discard block
 block discarded – undo
1198 1260
 					'question' => $row['question'],
1199 1261
 					'selected' => $row['id_topic'] == $firstTopic
1200 1262
 				);
1263
+			}
1201 1264
 			$smcFunc['db_free_result']($request);
1202 1265
 		}
1203 1266
 		if (count($boards) > 1)
@@ -1213,18 +1276,20 @@  discard block
 block discarded – undo
1213 1276
 					'limit' => count($boards),
1214 1277
 				)
1215 1278
 			);
1216
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1217
-				$context['boards'][] = array(
1279
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1280
+							$context['boards'][] = array(
1218 1281
 					'id' => $row['id_board'],
1219 1282
 					'name' => $row['name'],
1220 1283
 					'selected' => $row['id_board'] == $topic_data[$firstTopic]['board']
1221 1284
 				);
1285
+			}
1222 1286
 			$smcFunc['db_free_result']($request);
1223 1287
 		}
1224 1288
 
1225 1289
 		$context['topics'] = $topic_data;
1226
-		foreach ($topic_data as $id => $topic)
1227
-			$context['topics'][$id]['selected'] = $topic['id'] == $firstTopic;
1290
+		foreach ($topic_data as $id => $topic) {
1291
+					$context['topics'][$id]['selected'] = $topic['id'] == $firstTopic;
1292
+		}
1228 1293
 
1229 1294
 		$context['page_title'] = $txt['merge'];
1230 1295
 		$context['sub_template'] = 'merge_extra_options';
@@ -1233,13 +1298,15 @@  discard block
 block discarded – undo
1233 1298
 
1234 1299
 	// Determine target board.
1235 1300
 	$target_board = count($boards) > 1 ? (int) $_REQUEST['board'] : $boards[0];
1236
-	if (!in_array($target_board, $boards))
1237
-		fatal_lang_error('no_board');
1301
+	if (!in_array($target_board, $boards)) {
1302
+			fatal_lang_error('no_board');
1303
+	}
1238 1304
 
1239 1305
 	// Determine which poll will survive and which polls won't.
1240 1306
 	$target_poll = count($polls) > 1 ? (int) $_POST['poll'] : (count($polls) == 1 ? $polls[0] : 0);
1241
-	if ($target_poll > 0 && !in_array($target_poll, $polls))
1242
-		fatal_lang_error('no_access', false);
1307
+	if ($target_poll > 0 && !in_array($target_poll, $polls)) {
1308
+			fatal_lang_error('no_access', false);
1309
+	}
1243 1310
 	$deleted_polls = empty($target_poll) ? $polls : array_diff($polls, array($target_poll));
1244 1311
 
1245 1312
 	// Determine the subject of the newly merged topic - was a custom subject specified?
@@ -1247,19 +1314,23 @@  discard block
 block discarded – undo
1247 1314
 	{
1248 1315
 		$target_subject = strtr($smcFunc['htmltrim']($smcFunc['htmlspecialchars']($_POST['custom_subject'])), array("\r" => '', "\n" => '', "\t" => ''));
1249 1316
 		// Keep checking the length.
1250
-		if ($smcFunc['strlen']($target_subject) > 100)
1251
-			$target_subject = $smcFunc['substr']($target_subject, 0, 100);
1317
+		if ($smcFunc['strlen']($target_subject) > 100) {
1318
+					$target_subject = $smcFunc['substr']($target_subject, 0, 100);
1319
+		}
1252 1320
 
1253 1321
 		// Nothing left - odd but pick the first topics subject.
1254
-		if ($target_subject == '')
1255
-			$target_subject = $topic_data[$firstTopic]['subject'];
1322
+		if ($target_subject == '') {
1323
+					$target_subject = $topic_data[$firstTopic]['subject'];
1324
+		}
1256 1325
 	}
1257 1326
 	// A subject was selected from the list.
1258
-	elseif (!empty($topic_data[(int) $_POST['subject']]['subject']))
1259
-		$target_subject = $topic_data[(int) $_POST['subject']]['subject'];
1327
+	elseif (!empty($topic_data[(int) $_POST['subject']]['subject'])) {
1328
+			$target_subject = $topic_data[(int) $_POST['subject']]['subject'];
1329
+	}
1260 1330
 	// Nothing worked? Just take the subject of the first message.
1261
-	else
1262
-		$target_subject = $topic_data[$firstTopic]['subject'];
1331
+	else {
1332
+			$target_subject = $topic_data[$firstTopic]['subject'];
1333
+	}
1263 1334
 
1264 1335
 	// Get the first and last message and the number of messages....
1265 1336
 	$request = $smcFunc['db_query']('', '
@@ -1285,15 +1356,13 @@  discard block
 block discarded – undo
1285 1356
 			{
1286 1357
 				$num_replies = $row['message_count'] - 1;
1287 1358
 				$num_unapproved = 0;
1288
-			}
1289
-			else
1359
+			} else
1290 1360
 			{
1291 1361
 				$topic_approved = 0;
1292 1362
 				$num_replies = 0;
1293 1363
 				$num_unapproved = $row['message_count'];
1294 1364
 			}
1295
-		}
1296
-		else
1365
+		} else
1297 1366
 		{
1298 1367
 			// If this has a lower first_msg then the first post is not approved and hence the number of replies was wrong!
1299 1368
 			if ($first_msg > $row['first_msg'])
@@ -1339,8 +1408,9 @@  discard block
 block discarded – undo
1339 1408
 	list ($member_started) = $smcFunc['db_fetch_row']($request);
1340 1409
 	list ($member_updated) = $smcFunc['db_fetch_row']($request);
1341 1410
 	// First and last message are the same, so only row was returned.
1342
-	if ($member_updated === NULL)
1343
-		$member_updated = $member_started;
1411
+	if ($member_updated === NULL) {
1412
+			$member_updated = $member_started;
1413
+	}
1344 1414
 
1345 1415
 	$smcFunc['db_free_result']($request);
1346 1416
 
@@ -1353,8 +1423,9 @@  discard block
 block discarded – undo
1353 1423
 		array(
1354 1424
 			'topic_list' => $topics,
1355 1425
 	));
1356
-	while ($row = $smcFunc['db_fetch_row']($request))
1357
-		$affected_msgs[] = $row[0];
1426
+	while ($row = $smcFunc['db_fetch_row']($request)) {
1427
+			$affected_msgs[] = $row[0];
1428
+	}
1358 1429
 	$smcFunc['db_free_result']($request);
1359 1430
 
1360 1431
 	// Assign the first topic ID to be the merged topic.
@@ -1432,9 +1503,9 @@  discard block
 block discarded – undo
1432 1503
 	// Grab the response prefix (like 'Re: ') in the default forum language.
1433 1504
 	if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix')))
1434 1505
 	{
1435
-		if ($language === $user_info['language'])
1436
-			$context['response_prefix'] = $txt['response_prefix'];
1437
-		else
1506
+		if ($language === $user_info['language']) {
1507
+					$context['response_prefix'] = $txt['response_prefix'];
1508
+		} else
1438 1509
 		{
1439 1510
 			loadLanguage('index', $language, false);
1440 1511
 			$context['response_prefix'] = $txt['response_prefix'];
@@ -1514,8 +1585,9 @@  discard block
 block discarded – undo
1514 1585
 	if ($smcFunc['db_num_rows']($request) > 0)
1515 1586
 	{
1516 1587
 		$replaceEntries = array();
1517
-		while ($row = $smcFunc['db_fetch_assoc']($request))
1518
-			$replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['unwatched']);
1588
+		while ($row = $smcFunc['db_fetch_assoc']($request)) {
1589
+					$replaceEntries[] = array($row['id_member'], $id_topic, $row['new_id_msg'], $row['unwatched']);
1590
+		}
1519 1591
 
1520 1592
 		$smcFunc['db_insert']('replace',
1521 1593
 			'{db_prefix}log_topics',
@@ -1552,8 +1624,9 @@  discard block
 block discarded – undo
1552 1624
 		if ($smcFunc['db_num_rows']($request) > 0)
1553 1625
 		{
1554 1626
 			$replaceEntries = array();
1555
-			while ($row = $smcFunc['db_fetch_assoc']($request))
1556
-				$replaceEntries[] = array($row['id_member'], $id_topic, 0, $row['sent']);
1627
+			while ($row = $smcFunc['db_fetch_assoc']($request)) {
1628
+							$replaceEntries[] = array($row['id_member'], $id_topic, 0, $row['sent']);
1629
+			}
1557 1630
 
1558 1631
 			$smcFunc['db_insert']('replace',
1559 1632
 					'{db_prefix}log_notify',
@@ -1728,8 +1801,9 @@  discard block
 block discarded – undo
1728 1801
 	// If there's a search index that needs updating, update it...
1729 1802
 	require_once($sourcedir . '/Search.php');
1730 1803
 	$searchAPI = findSearchAPI();
1731
-	if (is_callable(array($searchAPI, 'topicMerge')))
1732
-		$searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject));
1804
+	if (is_callable(array($searchAPI, 'topicMerge'))) {
1805
+			$searchAPI->topicMerge($id_topic, $topics, $affected_msgs, empty($_POST['enforce_subject']) ? null : array($context['response_prefix'], $target_subject));
1806
+	}
1733 1807
 
1734 1808
 	// Merging is the sort of thing an external CMS might want to know about
1735 1809
 	$merged_topic = array(
Please login to merge, or discard this patch.
Sources/RepairBoards.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 					LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
233 233
 				WHERE t.id_topic IS NULL
234 234
 				GROUP BY m.id_topic, m.id_board',
235
-			'fix_processing' => function ($row) use ($smcFunc)
235
+			'fix_processing' => function($row) use ($smcFunc)
236 236
 			{
237 237
 				global $salvageBoardID;
238 238
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 			// Remove all topics that have zero messages in the messages table.
319 319
 			'fix_collect' => array(
320 320
 				'index' => 'id_topic',
321
-				'process' => function ($topics) use ($smcFunc)
321
+				'process' => function($topics) use ($smcFunc)
322 322
 				{
323 323
 					$smcFunc['db_query']('', '
324 324
 						DELETE FROM {db_prefix}topics
@@ -356,21 +356,21 @@  discard block
 block discarded – undo
356 356
 				  AND p.id_poll IS NULL
357 357
 				GROUP BY o.id_poll
358 358
 				  ',
359
-			'fix_processing' => function ($row) use ($smcFunc, $txt)
359
+			'fix_processing' => function($row) use ($smcFunc, $txt)
360 360
 			{
361 361
 				global $salvageBoardID;
362 362
 
363 363
 				$row['poster_name'] = !empty($row['poster_name']) ? $row['poster_name'] : $txt['guest'];
364 364
 				$row['id_poster'] = !empty($row['id_poster']) ? $row['id_poster'] : 0;
365 365
 
366
-				if(empty($row['id_board']))
366
+				if (empty($row['id_board']))
367 367
 				{
368 368
 					// Only if we don't have a reasonable idea of where to put it.
369 369
 					createSalvageArea();
370
-					$row['id_board'] = (int)$salvageBoardID;
370
+					$row['id_board'] = (int) $salvageBoardID;
371 371
 				}
372 372
 
373
-				if(empty($row['id_topic'])) {
373
+				if (empty($row['id_topic'])) {
374 374
 					$newMessageID = $smcFunc['db_insert']('',
375 375
 						'{db_prefix}messages',
376 376
 						array(
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 					LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll)
493 493
 				WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH}
494 494
 					AND t.id_poll IS NULL',
495
-			'fix_processing' => function ($row) use ($smcFunc, $txt)
495
+			'fix_processing' => function($row) use ($smcFunc, $txt)
496 496
 			{
497 497
 				global $salvageBoardID;
498 498
 
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
606 606
 				GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved
607 607
 				ORDER BY t.id_topic',
608
-			'fix_processing' => function ($row) use ($smcFunc)
608
+			'fix_processing' => function($row) use ($smcFunc)
609 609
 			{
610 610
 				$row['firstmsg_approved'] = (int) $row['firstmsg_approved'];
611 611
 				$row['myid_first_msg'] = (int) $row['myid_first_msg'];
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 					)
635 635
 				);
636 636
 			},
637
-			'message_function' => function ($row) use ($txt, &$context)
637
+			'message_function' => function($row) use ($txt, &$context)
638 638
 			{
639 639
 				// A pretend error?
640 640
 				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved'])
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
669 669
 				GROUP BY t.id_topic, t.num_replies, mf.approved
670 670
 				ORDER BY t.id_topic',
671
-			'fix_processing' => function ($row)
671
+			'fix_processing' => function($row)
672 672
 		{
673 673
 
674 674
 				global $smcFunc;
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 				);
690 690
 
691 691
 		},
692
-			'message_function' => function ($row)
692
+			'message_function' => function($row)
693 693
 		{
694 694
 
695 695
 				global $txt, $context;
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 				GROUP BY t.id_topic, t.unapproved_posts
723 723
 				HAVING unapproved_posts != COUNT(mu.id_msg)
724 724
 				ORDER BY t.id_topic',
725
-			'fix_processing' => function ($row)
725
+			'fix_processing' => function($row)
726 726
 		{
727 727
 
728 728
 				global $smcFunc;
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 				WHERE b.id_board IS NULL
765 765
 					AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
766 766
 				GROUP BY t.id_board',
767
-			'fix_processing' => function ($row)
767
+			'fix_processing' => function($row)
768 768
 		{
769 769
 
770 770
 				global $smcFunc, $salvageCatID, $txt;
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 				ORDER BY b.id_cat, b.id_board',
814 814
 			'fix_collect' => array(
815 815
 				'index' => 'id_cat',
816
-				'process' => function ($cats)
816
+				'process' => function($cats)
817 817
 				{
818 818
 					global $smcFunc, $salvageCatID;
819 819
 					createSalvageArea();
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 			// Last step-make sure all non-guest posters still exist.
850 850
 			'fix_collect' => array(
851 851
 				'index' => 'id_msg',
852
-				'process' => function ($msgs)
852
+				'process' => function($msgs)
853 853
 		{
854 854
 
855 855
 					global $smcFunc;
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 				ORDER BY b.id_parent, b.id_board',
879 879
 			'fix_collect' => array(
880 880
 				'index' => 'id_parent',
881
-				'process' => function ($parents)
881
+				'process' => function($parents)
882 882
 				{
883 883
 					global $smcFunc, $salvageBoardID, $salvageCatID;
884 884
 					createSalvageArea();
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 					AND p.id_poll IS NULL',
913 913
 			'fix_collect' => array(
914 914
 				'index' => 'id_poll',
915
-				'process' => function ($polls)
915
+				'process' => function($polls)
916 916
 		{
917 917
 
918 918
 					global $smcFunc;
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 				ORDER BY cal.id_topic',
947 947
 			'fix_collect' => array(
948 948
 				'index' => 'id_topic',
949
-				'process' => function ($events)
949
+				'process' => function($events)
950 950
 		{
951 951
 
952 952
 					global $smcFunc;
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 					AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}',
979 979
 			'fix_collect' => array(
980 980
 				'index' => 'id_topic',
981
-				'process' => function ($topics)
981
+				'process' => function($topics)
982 982
 		{
983 983
 
984 984
 					global $smcFunc;
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 				GROUP BY lt.id_member',
1011 1011
 			'fix_collect' => array(
1012 1012
 				'index' => 'id_member',
1013
-				'process' => function ($members)
1013
+				'process' => function($members)
1014 1014
 		{
1015 1015
 
1016 1016
 					global $smcFunc;
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 				GROUP BY lb.id_board',
1043 1043
 			'fix_collect' => array(
1044 1044
 				'index' => 'id_board',
1045
-				'process' => function ($boards)
1045
+				'process' => function($boards)
1046 1046
 		{
1047 1047
 
1048 1048
 					global $smcFunc;
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 				GROUP BY lb.id_member',
1075 1075
 			'fix_collect' => array(
1076 1076
 				'index' => 'id_member',
1077
-				'process' => function ($members) use ($smcFunc)
1077
+				'process' => function($members) use ($smcFunc)
1078 1078
 				{
1079 1079
 					$smcFunc['db_query']('', '
1080 1080
 						DELETE FROM {db_prefix}log_boards
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 				GROUP BY lmr.id_board',
1104 1104
 			'fix_collect' => array(
1105 1105
 				'index' => 'id_board',
1106
-				'process' => function ($boards) use ($smcFunc)
1106
+				'process' => function($boards) use ($smcFunc)
1107 1107
 				{
1108 1108
 					$smcFunc['db_query']('', '
1109 1109
 						DELETE FROM {db_prefix}log_mark_read
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 				GROUP BY lmr.id_member',
1133 1133
 			'fix_collect' => array(
1134 1134
 				'index' => 'id_member',
1135
-				'process' => function ($members) use ($smcFunc)
1135
+				'process' => function($members) use ($smcFunc)
1136 1136
 				{
1137 1137
 					$smcFunc['db_query']('', '
1138 1138
 						DELETE FROM {db_prefix}log_mark_read
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 				GROUP BY pmr.id_pm',
1162 1162
 			'fix_collect' => array(
1163 1163
 				'index' => 'id_pm',
1164
-				'process' => function ($pms) use ($smcFunc)
1164
+				'process' => function($pms) use ($smcFunc)
1165 1165
 				{
1166 1166
 					$smcFunc['db_query']('', '
1167 1167
 						DELETE FROM {db_prefix}pm_recipients
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 				GROUP BY pmr.id_member',
1192 1192
 			'fix_collect' => array(
1193 1193
 				'index' => 'id_member',
1194
-				'process' => function ($members)
1194
+				'process' => function($members)
1195 1195
 		{
1196 1196
 
1197 1197
 					global $smcFunc;
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 					AND mem.id_member IS NULL',
1224 1224
 			'fix_collect' => array(
1225 1225
 				'index' => 'id_pm',
1226
-				'process' => function ($guestMessages)
1226
+				'process' => function($guestMessages)
1227 1227
 		{
1228 1228
 
1229 1229
 					global $smcFunc;
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 				GROUP BY ln.id_member',
1256 1256
 			'fix_collect' => array(
1257 1257
 				'index' => 'id_member',
1258
-				'process' => function ($members) use ($smcFunc)
1258
+				'process' => function($members) use ($smcFunc)
1259 1259
 				{
1260 1260
 					$smcFunc['db_query']('', '
1261 1261
 						DELETE FROM {db_prefix}log_notify
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
 					LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic)
1283 1283
 				WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH}
1284 1284
 					AND lss.id_topic IS NULL',
1285
-			'fix_full_processing' => function ($result)
1285
+			'fix_full_processing' => function($result)
1286 1286
 		{
1287 1287
 
1288 1288
 				global $smcFunc;
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
 					);
1315 1315
 
1316 1316
 		},
1317
-			'message_function' => function ($row)
1317
+			'message_function' => function($row)
1318 1318
 		{
1319 1319
 
1320 1320
 				global $txt, $context;
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
 					AND t.id_topic IS NULL',
1345 1345
 			'fix_collect' => array(
1346 1346
 				'index' => 'id_topic',
1347
-				'process' => function ($deleteTopics)
1347
+				'process' => function($deleteTopics)
1348 1348
 		{
1349 1349
 
1350 1350
 					global $smcFunc;
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 					AND mem.id_member IS NULL',
1377 1377
 			'fix_collect' => array(
1378 1378
 				'index' => 'id_member',
1379
-				'process' => function ($members)
1379
+				'process' => function($members)
1380 1380
 		{
1381 1381
 
1382 1382
 					global $smcFunc;
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 					AND p.id_poll IS NULL',
1408 1408
 			'fix_collect' => array(
1409 1409
 				'index' => 'id_poll',
1410
-				'process' => function ($polls)
1410
+				'process' => function($polls)
1411 1411
 		{
1412 1412
 
1413 1413
 					global $smcFunc;
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
 					AND lrc.id_report IS NULL',
1439 1439
 			'fix_collect' => array(
1440 1440
 				'index' => 'id_report',
1441
-				'process' => function ($reports)
1441
+				'process' => function($reports)
1442 1442
 		{
1443 1443
 
1444 1444
 					global $smcFunc;
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 					AND lr.id_report IS NULL',
1470 1470
 			'fix_collect' => array(
1471 1471
 				'index' => 'id_report',
1472
-				'process' => function ($reports)
1472
+				'process' => function($reports)
1473 1473
 				{
1474 1474
 					global $smcFunc;
1475 1475
 					$smcFunc['db_query']('', '
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
 				GROUP BY lgr.id_member',
1500 1500
 			'fix_collect' => array(
1501 1501
 				'index' => 'id_member',
1502
-				'process' => function ($members)
1502
+				'process' => function($members)
1503 1503
 				{
1504 1504
 					global $smcFunc;
1505 1505
 					$smcFunc['db_query']('', '
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 				GROUP BY lgr.id_group',
1530 1530
 			'fix_collect' => array(
1531 1531
 				'index' => 'id_group',
1532
-				'process' => function ($groups)
1532
+				'process' => function($groups)
1533 1533
 				{
1534 1534
 					global $smcFunc;
1535 1535
 					$smcFunc['db_query']('', '
Please login to merge, or discard this patch.
Braces   +119 added lines, -85 removed lines patch added patch discarded remove patch
@@ -13,8 +13,9 @@  discard block
 block discarded – undo
13 13
  * @version 2.1 Beta 4
14 14
  */
15 15
 
16
-if (!defined('SMF'))
16
+if (!defined('SMF')) {
17 17
 	die('No direct access...');
18
+}
18 19
 
19 20
 /**
20 21
  * Finds or repairs errors in the database to fix possible problems.
@@ -50,8 +51,9 @@  discard block
 block discarded – undo
50 51
 	);
51 52
 
52 53
 	// Start displaying errors without fixing them.
53
-	if (isset($_GET['fixErrors']))
54
-		checkSession('get');
54
+	if (isset($_GET['fixErrors'])) {
55
+			checkSession('get');
56
+	}
55 57
 
56 58
 	// Will want this.
57 59
 	loadForumTests();
@@ -69,11 +71,11 @@  discard block
 block discarded – undo
69 71
 			$_SESSION['repairboards_to_fix'] = $context['to_fix'];
70 72
 			$_SESSION['repairboards_to_fix2'] = null;
71 73
 
72
-			if (empty($context['repair_errors']))
73
-				$context['repair_errors'][] = '???';
74
+			if (empty($context['repair_errors'])) {
75
+							$context['repair_errors'][] = '???';
76
+			}
74 77
 		}
75
-	}
76
-	else
78
+	} else
77 79
 	{
78 80
 		$context['error_search'] = false;
79 81
 		$context['to_fix'] = isset($_SESSION['repairboards_to_fix']) ? $_SESSION['repairboards_to_fix'] : array();
@@ -120,16 +122,19 @@  discard block
 block discarded – undo
120 122
 
121 123
 	// More time, I need more time!
122 124
 	@set_time_limit(600);
123
-	if (function_exists('apache_reset_timeout'))
124
-		@apache_reset_timeout();
125
+	if (function_exists('apache_reset_timeout')) {
126
+			@apache_reset_timeout();
127
+	}
125 128
 
126 129
 	// Errr, wait.  How much time has this taken already?
127
-	if (!$force && time() - array_sum(explode(' ', $time_start)) < 3)
128
-		return;
130
+	if (!$force && time() - array_sum(explode(' ', $time_start)) < 3) {
131
+			return;
132
+	}
129 133
 
130 134
 	// Restore the query cache if interested.
131
-	if (!empty($db_temp_cache))
132
-		$db_cache = $db_temp_cache;
135
+	if (!empty($db_temp_cache)) {
136
+			$db_cache = $db_temp_cache;
137
+	}
133 138
 
134 139
 	$context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id'];
135 140
 	$context['page_title'] = $txt['not_done_title'];
@@ -138,10 +143,11 @@  discard block
 block discarded – undo
138 143
 	$context['sub_template'] = 'not_done';
139 144
 
140 145
 	// Change these two if more steps are added!
141
-	if (empty($max_substep))
142
-		$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
143
-	else
144
-		$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
146
+	if (empty($max_substep)) {
147
+			$context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']);
148
+	} else {
149
+			$context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']);
150
+	}
145 151
 
146 152
 	// Never more than 100%!
147 153
 	$context['continue_percent'] = min($context['continue_percent'], 100);
@@ -612,8 +618,9 @@  discard block
 block discarded – undo
612 618
 				$row['myid_last_msg'] = (int) $row['myid_last_msg'];
613 619
 
614 620
 				// Not really a problem?
615
-				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved'])
616
-					return false;
621
+				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) {
622
+									return false;
623
+				}
617 624
 
618 625
 				$memberStartedID = (int) getMsgMemberID($row['myid_first_msg']);
619 626
 				$memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']);
@@ -637,15 +644,19 @@  discard block
 block discarded – undo
637 644
 			'message_function' => function ($row) use ($txt, &$context)
638 645
 			{
639 646
 				// A pretend error?
640
-				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved'])
641
-					return false;
647
+				if ($row['myid_first_msg'] == $row['myid_first_msg'] && $row['myid_first_msg'] == $row['myid_first_msg'] && $row['approved'] == $row['firstmsg_approved']) {
648
+									return false;
649
+				}
642 650
 
643
-				if ($row['id_first_msg'] != $row['myid_first_msg'])
644
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
645
-				if ($row['id_last_msg'] != $row['myid_last_msg'])
646
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
647
-				if ($row['approved'] != $row['firstmsg_approved'])
648
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
651
+				if ($row['id_first_msg'] != $row['myid_first_msg']) {
652
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']);
653
+				}
654
+				if ($row['id_last_msg'] != $row['myid_last_msg']) {
655
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']);
656
+				}
657
+				if ($row['approved'] != $row['firstmsg_approved']) {
658
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']);
659
+				}
649 660
 
650 661
 				return true;
651 662
 			},
@@ -675,8 +686,9 @@  discard block
 block discarded – undo
675 686
 				$row['my_num_replies'] = (int) $row['my_num_replies'];
676 687
 
677 688
 				// Not really a problem?
678
-				if ($row['my_num_replies'] == $row['num_replies'])
679
-					return false;
689
+				if ($row['my_num_replies'] == $row['num_replies']) {
690
+									return false;
691
+				}
680 692
 
681 693
 				$smcFunc['db_query']('', '
682 694
 					UPDATE {db_prefix}topics
@@ -695,11 +707,13 @@  discard block
 block discarded – undo
695 707
 				global $txt, $context;
696 708
 
697 709
 				// Just joking?
698
-				if ($row['my_num_replies'] == $row['num_replies'])
699
-					return false;
710
+				if ($row['my_num_replies'] == $row['num_replies']) {
711
+									return false;
712
+				}
700 713
 
701
-				if ($row['num_replies'] != $row['my_num_replies'])
702
-					$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
714
+				if ($row['num_replies'] != $row['my_num_replies']) {
715
+									$context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']);
716
+				}
703 717
 
704 718
 				return true;
705 719
 
@@ -1290,8 +1304,9 @@  discard block
 block discarded – undo
1290 1304
 				$inserts = array();
1291 1305
 				while ($row = $smcFunc['db_fetch_assoc']($result))
1292 1306
 				{
1293
-					foreach (text2words($row['subject']) as $word)
1294
-						$inserts[] = array($word, $row['id_topic']);
1307
+					foreach (text2words($row['subject']) as $word) {
1308
+											$inserts[] = array($word, $row['id_topic']);
1309
+					}
1295 1310
 					if (count($inserts) > 500)
1296 1311
 					{
1297 1312
 						$smcFunc['db_insert']('ignore',
@@ -1305,13 +1320,14 @@  discard block
 block discarded – undo
1305 1320
 
1306 1321
 				}
1307 1322
 
1308
-				if (!empty($inserts))
1309
-					$smcFunc['db_insert']('ignore',
1323
+				if (!empty($inserts)) {
1324
+									$smcFunc['db_insert']('ignore',
1310 1325
 						'{db_prefix}log_search_subjects',
1311 1326
 						array('word' => 'string', 'id_topic' => 'int'),
1312 1327
 						$inserts,
1313 1328
 						array('word', 'id_topic')
1314 1329
 					);
1330
+				}
1315 1331
 
1316 1332
 		},
1317 1333
 			'message_function' => function ($row)
@@ -1581,8 +1597,9 @@  discard block
 block discarded – undo
1581 1597
 		$current_step++;
1582 1598
 
1583 1599
 		// Already done this?
1584
-		if ($_GET['step'] > $current_step)
1585
-			continue;
1600
+		if ($_GET['step'] > $current_step) {
1601
+					continue;
1602
+		}
1586 1603
 
1587 1604
 		// If we're fixing it but it ain't broke why try?
1588 1605
 		if ($do_fix && !in_array($error_type, $to_fix))
@@ -1611,14 +1628,16 @@  discard block
 block discarded – undo
1611 1628
 		while (!$done)
1612 1629
 		{
1613 1630
 			// Make sure there's at least one ID to test.
1614
-			if (isset($test['substeps']) && empty($step_max))
1615
-				break;
1631
+			if (isset($test['substeps']) && empty($step_max)) {
1632
+							break;
1633
+			}
1616 1634
 
1617 1635
 			// What is the testing query (Changes if we are testing or fixing)
1618
-			if (!$do_fix)
1619
-				$test_query = 'check_query';
1620
-			else
1621
-				$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1636
+			if (!$do_fix) {
1637
+							$test_query = 'check_query';
1638
+			} else {
1639
+							$test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query';
1640
+			}
1622 1641
 
1623 1642
 			// Do the test...
1624 1643
 			$request = $smcFunc['db_query']('',
@@ -1628,10 +1647,11 @@  discard block
 block discarded – undo
1628 1647
 			);
1629 1648
 
1630 1649
 			// Does it need a fix?
1631
-			if (!empty($test['check_type']) && $test['check_type'] == 'count')
1632
-				list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1633
-			else
1634
-				$needs_fix = $smcFunc['db_num_rows']($request);
1650
+			if (!empty($test['check_type']) && $test['check_type'] == 'count') {
1651
+							list ($needs_fix) = $smcFunc['db_fetch_row']($request);
1652
+			} else {
1653
+							$needs_fix = $smcFunc['db_num_rows']($request);
1654
+			}
1635 1655
 
1636 1656
 			$total_queries++;
1637 1657
 
@@ -1643,8 +1663,9 @@  discard block
 block discarded – undo
1643 1663
 					// Assume need to fix.
1644 1664
 					$found_errors = true;
1645 1665
 
1646
-					if (isset($test['message']))
1647
-						$context['repair_errors'][] = $txt[$test['message']];
1666
+					if (isset($test['message'])) {
1667
+											$context['repair_errors'][] = $txt[$test['message']];
1668
+					}
1648 1669
 
1649 1670
 					// One per row!
1650 1671
 					elseif (isset($test['messages']))
@@ -1654,10 +1675,11 @@  discard block
 block discarded – undo
1654 1675
 							$variables = $test['messages'];
1655 1676
 							foreach ($variables as $k => $v)
1656 1677
 							{
1657
-								if ($k == 0 && isset($txt[$v]))
1658
-									$variables[$k] = $txt[$v];
1659
-								elseif ($k > 0 && isset($row[$v]))
1660
-									$variables[$k] = $row[$v];
1678
+								if ($k == 0 && isset($txt[$v])) {
1679
+																	$variables[$k] = $txt[$v];
1680
+								} elseif ($k > 0 && isset($row[$v])) {
1681
+																	$variables[$k] = $row[$v];
1682
+								}
1661 1683
 							}
1662 1684
 							$context['repair_errors'][] = call_user_func_array('sprintf', $variables);
1663 1685
 						}
@@ -1668,13 +1690,15 @@  discard block
 block discarded – undo
1668 1690
 					{
1669 1691
 						// Find out if there are actually errors.
1670 1692
 						$found_errors = false;
1671
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1672
-							$found_errors |= $test['message_function']($row);
1693
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1694
+													$found_errors |= $test['message_function']($row);
1695
+						}
1673 1696
 					}
1674 1697
 
1675 1698
 					// Actually have something to fix?
1676
-					if ($found_errors)
1677
-						$to_fix[] = $error_type;
1699
+					if ($found_errors) {
1700
+											$to_fix[] = $error_type;
1701
+					}
1678 1702
 				}
1679 1703
 
1680 1704
 				// We want to fix, we need to fix - so work out what exactly to do!
@@ -1684,8 +1708,9 @@  discard block
 block discarded – undo
1684 1708
 					if (isset($test['fix_collect']))
1685 1709
 					{
1686 1710
 						$ids = array();
1687
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1688
-							$ids[] = $row[$test['fix_collect']['index']];
1711
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1712
+													$ids[] = $row[$test['fix_collect']['index']];
1713
+						}
1689 1714
 						if (!empty($ids))
1690 1715
 						{
1691 1716
 							// Fix it!
@@ -1694,30 +1719,34 @@  discard block
 block discarded – undo
1694 1719
 					}
1695 1720
 
1696 1721
 					// Simply executing a fix it query?
1697
-					elseif (isset($test['fix_it_query']))
1698
-						$smcFunc['db_query']('',
1722
+					elseif (isset($test['fix_it_query'])) {
1723
+											$smcFunc['db_query']('',
1699 1724
 							$test['fix_it_query'],
1700 1725
 							array(
1701 1726
 							)
1702 1727
 						);
1728
+					}
1703 1729
 
1704 1730
 					// Do we have some processing to do?
1705 1731
 					elseif (isset($test['fix_processing']))
1706 1732
 					{
1707
-						while ($row = $smcFunc['db_fetch_assoc']($request))
1708
-							$test['fix_processing']($row);
1733
+						while ($row = $smcFunc['db_fetch_assoc']($request)) {
1734
+													$test['fix_processing']($row);
1735
+						}
1709 1736
 					}
1710 1737
 
1711 1738
 					// What about the full set of processing?
1712
-					elseif (isset($test['fix_full_processing']))
1713
-						$test['fix_full_processing']($request);
1739
+					elseif (isset($test['fix_full_processing'])) {
1740
+											$test['fix_full_processing']($request);
1741
+					}
1714 1742
 
1715 1743
 					// Do we have other things we need to fix as a result?
1716 1744
 					if (!empty($test['force_fix']))
1717 1745
 					{
1718
-						foreach ($test['force_fix'] as $item)
1719
-							if (!in_array($item, $to_fix))
1746
+						foreach ($test['force_fix'] as $item) {
1747
+													if (!in_array($item, $to_fix))
1720 1748
 								$to_fix[] = $item;
1749
+						}
1721 1750
 					}
1722 1751
 				}
1723 1752
 			}
@@ -1735,16 +1764,17 @@  discard block
 block discarded – undo
1735 1764
 				if ($_GET['substep'] <= $step_max)
1736 1765
 				{
1737 1766
 					pauseRepairProcess($to_fix, $error_type, $step_max);
1767
+				} else {
1768
+									$done = true;
1738 1769
 				}
1739
-				else
1740
-					$done = true;
1770
+			} else {
1771
+							$done = true;
1741 1772
 			}
1742
-			else
1743
-				$done = true;
1744 1773
 
1745 1774
 			// Don't allow more than 1000 queries at a time.
1746
-			if ($total_queries >= 1000)
1747
-				pauseRepairProcess($to_fix, $error_type, $step_max, true);
1775
+			if ($total_queries >= 1000) {
1776
+							pauseRepairProcess($to_fix, $error_type, $step_max, true);
1777
+			}
1748 1778
 		}
1749 1779
 
1750 1780
 		// Keep going.
@@ -1757,8 +1787,9 @@  discard block
 block discarded – undo
1757 1787
 		if ($do_fix)
1758 1788
 		{
1759 1789
 			$key = array_search($error_type, $to_fix);
1760
-			if ($key !== false && isset($to_fix[$key]))
1761
-				unset($to_fix[$key]);
1790
+			if ($key !== false && isset($to_fix[$key])) {
1791
+							unset($to_fix[$key]);
1792
+			}
1762 1793
 		}
1763 1794
 
1764 1795
 		// Are we done?
@@ -1781,10 +1812,11 @@  discard block
 block discarded – undo
1781 1812
 	static $createOnce = false;
1782 1813
 
1783 1814
 	// Have we already created it?
1784
-	if ($createOnce)
1785
-		return;
1786
-	else
1787
-		$createOnce = true;
1815
+	if ($createOnce) {
1816
+			return;
1817
+	} else {
1818
+			$createOnce = true;
1819
+	}
1788 1820
 
1789 1821
 	// Back to the forum's default language.
1790 1822
 	loadLanguage('Admin', $language);
@@ -1799,8 +1831,9 @@  discard block
 block discarded – undo
1799 1831
 			'cat_name' => $txt['salvaged_category_name'],
1800 1832
 		)
1801 1833
 	);
1802
-	if ($smcFunc['db_num_rows']($result) != 0)
1803
-		list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1834
+	if ($smcFunc['db_num_rows']($result) != 0) {
1835
+			list ($salvageCatID) = $smcFunc['db_fetch_row']($result);
1836
+	}
1804 1837
 	$smcFunc['db_free_result']($result);
1805 1838
 
1806 1839
 	if (empty($salvageCatID))
@@ -1832,8 +1865,9 @@  discard block
 block discarded – undo
1832 1865
 			'board_name' => $txt['salvaged_board_name'],
1833 1866
 		)
1834 1867
 	);
1835
-	if ($smcFunc['db_num_rows']($result) != 0)
1836
-		list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1868
+	if ($smcFunc['db_num_rows']($result) != 0) {
1869
+			list ($salvageBoardID) = $smcFunc['db_fetch_row']($result);
1870
+	}
1837 1871
 	$smcFunc['db_free_result']($result);
1838 1872
 
1839 1873
 	if (empty($salvageBoardID))
Please login to merge, or discard this patch.
Sources/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Sources/tasks/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
avatars/Oxygen/index.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Try to handle it with the upper level index.php. (it should know what to do.)
4
-if (file_exists(dirname(dirname(__FILE__)) . '/index.php'))
4
+if (file_exists(dirname(dirname(__FILE__)) . '/index.php')) {
5 5
 	include (dirname(dirname(__FILE__)) . '/index.php');
6
-else
6
+} else {
7 7
 	exit;
8
+}
8 9
 
9 10
 ?>
10 11
\ No newline at end of file
Please login to merge, or discard this patch.
avatars/index.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 	header('Location: ' . $boardurl);
13 13
 }
14 14
 // Can't find it... just forget it.
15
-else
15
+else {
16 16
 	exit;
17
+}
17 18
 
18 19
 ?>
19 20
\ No newline at end of file
Please login to merge, or discard this patch.
Themes/default/Themes.template.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -645,12 +645,12 @@
 block discarded – undo
645 645
 					</dd>';
646 646
 		}
647 647
 		// A Textarea?
648
-        	elseif ($setting['type'] == 'textarea')
648
+			elseif ($setting['type'] == 'textarea')
649 649
 		{
650 650
 			echo '
651 651
 					<dd>
652 652
 						<textarea rows="4" style="width: 95%;" cols="40" name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">', $setting['value'], '</textarea>';
653
-                echo '
653
+				echo '
654 654
                 			</dd>';
655 655
 		}
656 656
 		// A regular input box, then?
Please login to merge, or discard this patch.
Braces   +103 added lines, -80 removed lines patch added patch discarded remove patch
@@ -54,9 +54,10 @@  discard block
 block discarded – undo
54 54
 					<dd>
55 55
 						<div id="known_themes_list">';
56 56
 
57
-	foreach ($context['themes'] as $theme)
58
-		echo '
57
+	foreach ($context['themes'] as $theme) {
58
+			echo '
59 59
 							<label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked' : '', '> ', $theme['name'], '</label><br>';
60
+	}
60 61
 
61 62
 		echo '
62 63
 						</div>
@@ -73,9 +74,10 @@  discard block
 block discarded – undo
73 74
 						<select name="options[theme_guests]" id="theme_guests">';
74 75
 
75 76
 	// Put an option for each theme in the select box.
76
-	foreach ($context['themes'] as $theme)
77
-		echo '
77
+	foreach ($context['themes'] as $theme) {
78
+			echo '
78 79
 							<option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected' : '', '>', $theme['name'], '</option>';
80
+	}
79 81
 
80 82
 	echo '
81 83
 						</select>
@@ -90,9 +92,10 @@  discard block
 block discarded – undo
90 92
 							<option value="0">', $txt['theme_forum_default'], '</option>';
91 93
 
92 94
 	// Same thing, this time for changing the theme of everyone.
93
-	foreach ($context['themes'] as $theme)
94
-		echo '
95
+	foreach ($context['themes'] as $theme) {
96
+			echo '
95 97
 							<option value="', $theme['id'], '">', $theme['name'], '</option>';
98
+	}
96 99
 
97 100
 	echo '
98 101
 						</select>
@@ -189,11 +192,12 @@  discard block
 block discarded – undo
189 192
 	global $context, $scripturl, $txt;
190 193
 
191 194
 	// Show a nice confirmation message.
192
-	if (isset($_GET['done']))
193
-		echo '
195
+	if (isset($_GET['done'])) {
196
+			echo '
194 197
 	<div class="infobox">
195 198
 		', $txt['theme_confirmed_' . $_GET['done']], '
196 199
 	</div>';
200
+	}
197 201
 
198 202
 	echo '
199 203
 	<div id="admincenter">';
@@ -357,11 +361,12 @@  discard block
 block discarded – undo
357 361
 		if (empty($setting) || !is_array($setting))
358 362
 		{
359 363
 			// Insert a separator (unless this is the first item in the list)
360
-			if ($i !== $first_option_key)
361
-				echo '
364
+			if ($i !== $first_option_key) {
365
+							echo '
362 366
 				</dl>
363 367
 				<hr>
364 368
 				<dl class="settings">';
369
+			}
365 370
 
366 371
 			// Should we give a name to this section?
367 372
 			if (is_string($setting) && !empty($setting))
@@ -369,9 +374,9 @@  discard block
 block discarded – undo
369 374
 				$titled_section = true;
370 375
 				echo '
371 376
 					<dt><strong>' . $setting . '</strong></dt><dd></dd>';
377
+			} else {
378
+							$titled_section = false;
372 379
 			}
373
-			else
374
-				$titled_section = false;
375 380
 
376 381
 			continue;
377 382
 		}
@@ -380,19 +385,21 @@  discard block
 block discarded – undo
380 385
 					<dt ', $context['theme_options_reset'] ? 'style="width:50%"' : '', '>';
381 386
 
382 387
 		// Show the change option box ?
383
-		if ($context['theme_options_reset'])
384
-			echo '
388
+		if ($context['theme_options_reset']) {
389
+					echo '
385 390
 						<span class="floatleft"><select name="', !empty($setting['default']) ? 'default_' : '', 'options_master[', $setting['id'], ']" onchange="this.form.options_', $setting['id'], '.disabled = this.selectedIndex != 1;">
386 391
 							<option value="0" selected>', $txt['themeadmin_reset_options_none'], '</option>
387 392
 							<option value="1">', $txt['themeadmin_reset_options_change'], '</option>
388 393
 							<option value="2">', $txt['themeadmin_reset_options_default'], '</option>
389 394
 						</select>&nbsp;</span>';
395
+		}
390 396
 
391 397
 		echo '
392 398
 						<label for="options_', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>';
393
-		if (isset($setting['description']))
394
-			echo '
399
+		if (isset($setting['description'])) {
400
+					echo '
395 401
 						<br><span class="smalltext">', $setting['description'], '</span>';
402
+		}
396 403
 		echo '
397 404
 					</dt>';
398 405
 
@@ -434,13 +441,11 @@  discard block
 block discarded – undo
434 441
 
435 442
 				echo '
436 443
 						<input type="number"', $min . $max . $step;
437
-			}
438
-			else if (isset($setting['type']) && $setting['type'] == 'url')
444
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
439 445
 			{
440 446
 				echo'
441 447
 						<input type="url"';
442
-			}
443
-			else
448
+			} else
444 449
 			{
445 450
 				echo '
446 451
 						<input type="text"';
@@ -484,8 +489,8 @@  discard block
 block discarded – undo
484 489
 			<br>';
485 490
 
486 491
 	// @todo Why can't I edit the default theme popup.
487
-	if ($context['theme_settings']['theme_id'] != 1)
488
-		echo '
492
+	if ($context['theme_settings']['theme_id'] != 1) {
493
+			echo '
489 494
 			<div class="cat_bar">
490 495
 				<h3 class="catbg config_hd">
491 496
 					', $txt['theme_edit'], '
@@ -501,6 +506,7 @@  discard block
 block discarded – undo
501 506
 					</li>
502 507
 				</ul>
503 508
 			</div>';
509
+	}
504 510
 
505 511
 	echo '
506 512
 			<div class="cat_bar">
@@ -554,9 +560,10 @@  discard block
 block discarded – undo
554 560
 					<dd>
555 561
 						<select id="variant" name="options[default_variant]" onchange="changeVariant(this.value)">';
556 562
 
557
-		foreach ($context['theme_variants'] as $key => $variant)
558
-			echo '
563
+		foreach ($context['theme_variants'] as $key => $variant) {
564
+					echo '
559 565
 							<option value="', $key, '"', $context['default_variant'] == $key ? ' selected' : '', '>', $variant['label'], '</option>';
566
+		}
560 567
 
561 568
 		echo '
562 569
 						</select>
@@ -592,11 +599,12 @@  discard block
 block discarded – undo
592 599
 		if (empty($setting) || !is_array($setting))
593 600
 		{
594 601
 			// We don't need a separator before the first list element
595
-			if ($i !== $first_setting_key)
596
-				echo '
602
+			if ($i !== $first_setting_key) {
603
+							echo '
597 604
 				</dl>
598 605
 				<hr>
599 606
 				<dl class="settings">';
607
+			}
600 608
 
601 609
 			// Add a fake heading?
602 610
 			if (is_string($setting) && !empty($setting))
@@ -604,9 +612,9 @@  discard block
 block discarded – undo
604 612
 				$titled_section = true;
605 613
 				echo '
606 614
 					<dt><strong>' . $setting . '</strong></dt><dd></dd>';
615
+			} else {
616
+							$titled_section = false;
607 617
 			}
608
-			else
609
-				$titled_section = false;
610 618
 
611 619
 			continue;
612 620
 		}
@@ -615,9 +623,10 @@  discard block
 block discarded – undo
615 623
 					<dt>
616 624
 						<label for="', $setting['id'], '">', !$titled_section ? '<strong>' : '', $setting['label'], !$titled_section ? '</strong>' : '', '</label>:';
617 625
 
618
-		if (isset($setting['description']))
619
-			echo '<br>
626
+		if (isset($setting['description'])) {
627
+					echo '<br>
620 628
 						<span class="smalltext">', $setting['description'], '</span>';
629
+		}
621 630
 
622 631
 		echo '
623 632
 					</dt>';
@@ -638,9 +647,10 @@  discard block
 block discarded – undo
638 647
 					<dd>
639 648
 						<select name="', !empty($setting['default']) ? 'default_' : '', 'options[', $setting['id'], ']" id="', $setting['id'], '">';
640 649
 
641
-			foreach ($setting['options'] as $value => $label)
642
-				echo '
650
+			foreach ($setting['options'] as $value => $label) {
651
+							echo '
643 652
 							<option value="', $value, '"', $value == $setting['value'] ? ' selected' : '', '>', $label, '</option>';
653
+			}
644 654
 
645 655
 			echo '
646 656
 						</select>
@@ -669,13 +679,11 @@  discard block
 block discarded – undo
669 679
 
670 680
 				echo '
671 681
 						<input type="number"', $min . $max . $step;
672
-			}
673
-			else if (isset($setting['type']) && $setting['type'] == 'url')
682
+			} else if (isset($setting['type']) && $setting['type'] == 'url')
674 683
 			{
675 684
 				echo'
676 685
 						<input type="url"';
677
-			}
678
-			else
686
+			} else
679 687
 			{
680 688
 				echo '
681 689
 						<input type="text"';
@@ -828,21 +836,23 @@  discard block
 block discarded – undo
828 836
 		<div class="windowbg">';
829 837
 
830 838
 	// Oops! there was an error :(
831
-	if (!empty($context['error_message']))
832
-		echo '
839
+	if (!empty($context['error_message'])) {
840
+			echo '
833 841
 			<p>
834 842
 				', $context['error_message'], '
835 843
 			</p>';
844
+	}
836 845
 
837 846
 	// Not much to show except a link back...
838
-	else
839
-		echo '
847
+	else {
848
+			echo '
840 849
 			<p>
841 850
 				<a href="', $scripturl, '?action=admin;area=theme;sa=list;th=', $context['installed_theme']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['installed_theme']['name'], '</a> ', $txt['theme_' . (isset($context['installed_theme']['updated']) ? 'updated' : 'installed') . '_message'], '
842 851
 			</p>
843 852
 			<p>
844 853
 				<a href="', $scripturl, '?action=admin;area=theme;sa=admin;', $context['session_var'], '=', $context['session_id'], '">', $txt['back'], '</a>
845 854
 			</p>';
855
+	}
846 856
 
847 857
 	echo '
848 858
 		</div>
@@ -909,10 +919,11 @@  discard block
 block discarded – undo
909 919
 					<span class="floatleft">', $template['filename'], $template['already_exists'] ? ' <span class="error">(' . $txt['themeadmin_edit_exists'] . ')</span>' : '', '</span>
910 920
 					<span class="floatright">';
911 921
 
912
-		if ($template['can_copy'])
913
-			echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
914
-		else
915
-			echo $txt['themeadmin_edit_no_copy'];
922
+		if ($template['can_copy']) {
923
+					echo '<a href="', $scripturl, '?action=admin;area=theme;th=', $context['theme_id'], ';', $context['session_var'], '=', $context['session_id'], ';sa=copy;template=', $template['value'], '" data-confirm="', $template['already_exists'] ? $txt['themeadmin_edit_overwrite_confirm'] : $txt['themeadmin_edit_copy_confirm'], '" class="you_sure">', $txt['themeadmin_edit_do_copy'], '</a>';
924
+		} else {
925
+					echo $txt['themeadmin_edit_no_copy'];
926
+		}
916 927
 
917 928
 		echo '
918 929
 					</span>
@@ -935,11 +946,12 @@  discard block
 block discarded – undo
935 946
 	echo '
936 947
 	<div id="admincenter">';
937 948
 
938
-	if (!empty($context['browse_title']))
939
-		echo '
949
+	if (!empty($context['browse_title'])) {
950
+			echo '
940 951
 		<div class="cat_bar">
941 952
 			<h3 class="catbg">', $context['browse_title'], '</h3>
942 953
 		</div>';
954
+	}
943 955
 
944 956
 	echo '
945 957
 		<table class="table_grid tborder">
@@ -959,14 +971,13 @@  discard block
 block discarded – undo
959 971
 			<tr class="windowbg">
960 972
 				<td>';
961 973
 
962
-		if ($file['is_editable'])
963
-			echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
964
-
965
-		elseif ($file['is_directory'])
966
-			echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>';
967
-
968
-		else
969
-			echo $file['filename'];
974
+		if ($file['is_editable']) {
975
+					echo '<a href="', $file['href'], '"', $file['is_template'] ? ' style="font-weight: bold;"' : '', '>', $file['filename'], '</a>';
976
+		} elseif ($file['is_directory']) {
977
+					echo '<a href="', $file['href'], '" class="is_directory"><span class="generic_icons folder"></span>', $file['filename'], '</a>';
978
+		} else {
979
+					echo $file['filename'];
980
+		}
970 981
 
971 982
 		echo '
972 983
 				</td>
@@ -988,11 +999,12 @@  discard block
 block discarded – undo
988 999
 {
989 1000
 	global $context, $settings, $scripturl, $txt;
990 1001
 
991
-	if ($context['session_error'])
992
-		echo '
1002
+	if ($context['session_error']) {
1003
+			echo '
993 1004
 	<div class="errorbox">
994 1005
 		', $txt['error_session_timeout'], '
995 1006
 	</div>';
1007
+	}
996 1008
 
997 1009
 	// From now on no one can complain that editing css is difficult. If you disagree, go to www.w3schools.com.
998 1010
 	echo '
@@ -1055,17 +1067,18 @@  discard block
 block discarded – undo
1055 1067
 					try
1056 1068
 					{
1057 1069
 					';
1058
-	if (isBrowser('is_ie'))
1059
-		echo '
1070
+	if (isBrowser('is_ie')) {
1071
+			echo '
1060 1072
 						var sheets = frames["css_preview_box"].document.styleSheets;
1061 1073
 						for (var j = 0; j < sheets.length; j++)
1062 1074
 						{
1063 1075
 							if (sheets[j].id == "css_preview_box")
1064 1076
 								sheets[j].cssText = document.forms.stylesheetForm.entire_file.value;
1065 1077
 						}';
1066
-	else
1067
-		echo '
1078
+	} else {
1079
+			echo '
1068 1080
 						setInnerHTML(frames["css_preview_box"].document.getElementById("css_preview_sheet"), document.forms.stylesheetForm.entire_file.value);';
1081
+	}
1069 1082
 	echo '
1070 1083
 					}
1071 1084
 					catch (e)
@@ -1117,9 +1130,10 @@  discard block
 block discarded – undo
1117 1130
 			</div>
1118 1131
 			<div class="windowbg">';
1119 1132
 
1120
-	if (!$context['allow_save'])
1121
-		echo '
1133
+	if (!$context['allow_save']) {
1134
+			echo '
1122 1135
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1136
+	}
1123 1137
 
1124 1138
 	echo '
1125 1139
 				<textarea name="entire_file" cols="80" rows="20" style="width: 96%; font-family: monospace; margin-top: 1ex; white-space: pre;" onkeyup="setPreviewTimeout();" onchange="refreshPreview(true);">', $context['entire_file'], '</textarea><br>
@@ -1132,9 +1146,10 @@  discard block
 block discarded – undo
1132 1146
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1133 1147
 
1134 1148
 	// Hopefully it exists.
1135
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1136
-		echo '
1149
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1150
+			echo '
1137 1151
 			<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1152
+	}
1138 1153
 
1139 1154
 	echo '
1140 1155
 		</form>
@@ -1148,18 +1163,20 @@  discard block
 block discarded – undo
1148 1163
 {
1149 1164
 	global $context, $scripturl, $txt;
1150 1165
 
1151
-	if ($context['session_error'])
1152
-		echo '
1166
+	if ($context['session_error']) {
1167
+			echo '
1153 1168
 	<div class="errorbox">
1154 1169
 		', $txt['error_session_timeout'], '
1155 1170
 	</div>';
1171
+	}
1156 1172
 
1157
-	if (isset($context['parse_error']))
1158
-		echo '
1173
+	if (isset($context['parse_error'])) {
1174
+			echo '
1159 1175
 	<div class="errorbox">
1160 1176
 		', $txt['themeadmin_edit_error'], '
1161 1177
 			<div><pre>', $context['parse_error'], '</pre></div>
1162 1178
 	</div>';
1179
+	}
1163 1180
 
1164 1181
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1165 1182
 	echo '
@@ -1170,16 +1187,18 @@  discard block
 block discarded – undo
1170 1187
 			</div>
1171 1188
 			<div class="windowbg">';
1172 1189
 
1173
-	if (!$context['allow_save'])
1174
-		echo '
1190
+	if (!$context['allow_save']) {
1191
+			echo '
1175 1192
 				', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '<br>';
1193
+	}
1176 1194
 
1177
-	foreach ($context['file_parts'] as $part)
1178
-		echo '
1195
+	foreach ($context['file_parts'] as $part) {
1196
+			echo '
1179 1197
 				<label for="on_line', $part['line'], '">', $txt['themeadmin_edit_on_line'], ' ', $part['line'], '</label>:<br>
1180 1198
 				<div class="centertext">
1181 1199
 					<textarea id="on_line', $part['line'], '" name="entire_file[]" cols="80" rows="', $part['lines'] > 14 ? '14' : $part['lines'], '" class="edit_file">', $part['data'], '</textarea>
1182 1200
 				</div>';
1201
+	}
1183 1202
 
1184 1203
 	echo '
1185 1204
 				<div class="padding righttext">
@@ -1188,9 +1207,10 @@  discard block
 block discarded – undo
1188 1207
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1189 1208
 
1190 1209
 	// Hopefully it exists.
1191
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1192
-		echo '
1210
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1211
+			echo '
1193 1212
 					<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1213
+	}
1194 1214
 
1195 1215
 	echo '
1196 1216
 				</div>
@@ -1206,18 +1226,20 @@  discard block
 block discarded – undo
1206 1226
 {
1207 1227
 	global $context, $scripturl, $txt;
1208 1228
 
1209
-	if ($context['session_error'])
1210
-		echo '
1229
+	if ($context['session_error']) {
1230
+			echo '
1211 1231
 	<div class="errorbox">
1212 1232
 		', $txt['error_session_timeout'], '
1213 1233
 	</div>';
1234
+	}
1214 1235
 
1215 1236
 	//Is this file writeable?
1216
-	if (!$context['allow_save'])
1217
-		echo '
1237
+	if (!$context['allow_save']) {
1238
+			echo '
1218 1239
 	<div class="errorbox">
1219 1240
 		', $txt['theme_edit_no_save'], ': ', $context['allow_save_filename'], '
1220 1241
 	</div>';
1242
+	}
1221 1243
 
1222 1244
 	// Just show a big box.... gray out the Save button if it's not saveable... (ie. not 777.)
1223 1245
 	echo '
@@ -1233,9 +1255,10 @@  discard block
 block discarded – undo
1233 1255
 				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">';
1234 1256
 
1235 1257
 	// Hopefully it exists.
1236
-	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token']))
1237
-		echo '
1258
+	if (isset($context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'])) {
1259
+			echo '
1238 1260
 				<input type="hidden" name="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token_var'], '" value="', $context['admin-te-' . md5($context['theme_id'] . '-' . $context['edit_filename']) . '_token'], '">';
1261
+	}
1239 1262
 
1240 1263
 	echo '
1241 1264
 			</div>
Please login to merge, or discard this patch.
Sources/tasks/CreatePost-Notify.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 class CreatePost_Notify_Background extends SMF_BackgroundTask
19 19
 {
20 20
 	/**
21
-     * This handles notifications when a new post is created - new topic, reply, quotes and mentions.
21
+	 * This handles notifications when a new post is created - new topic, reply, quotes and mentions.
22 22
 	 * @return bool Always returns true
23 23
 	 */
24 24
 	public function execute()
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 
107 107
 			// Don't send a notification if the watching member ignored the member who made the action.
108 108
 			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
109
-			    continue;
109
+				continue;
110 110
 			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started'])
111 111
 				continue;
112 112
 			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
Please login to merge, or discard this patch.
Braces   +62 added lines, -46 removed lines patch added patch discarded remove patch
@@ -73,8 +73,9 @@  discard block
 block discarded – undo
73 73
 		while ($row = $smcFunc['db_fetch_assoc']($request))
74 74
 		{
75 75
 			$groups = array_merge(array($row['id_group'], $row['id_post_group']), (empty($row['additional_groups']) ? array() : explode(',', $row['additional_groups'])));
76
-			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0)
77
-				continue;
76
+			if (!in_array(1, $groups) && count(array_intersect($groups, explode(',', $row['member_groups']))) == 0) {
77
+							continue;
78
+			}
78 79
 
79 80
 			$members[] = $row['id_member'];
80 81
 			$watched[$row['id_member']] = $row;
@@ -82,8 +83,9 @@  discard block
 block discarded – undo
82 83
 
83 84
 		$smcFunc['db_free_result']($request);
84 85
 
85
-		if (empty($members))
86
-			return true;
86
+		if (empty($members)) {
87
+					return true;
88
+		}
87 89
 
88 90
 		$members = array_unique($members);
89 91
 		$prefs = getNotifyPrefs($members, '', true);
@@ -105,20 +107,23 @@  discard block
 block discarded – undo
105 107
 			$notify_types = !empty($prefs[$member]['msg_notify_type']) ? $prefs[$member]['msg_notify_type'] : 1;
106 108
 
107 109
 			// Don't send a notification if the watching member ignored the member who made the action.
108
-			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list'])))
109
-			    continue;
110
-			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started'])
111
-				continue;
112
-			elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id'])
113
-				continue;
114
-			elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3)
115
-				continue;
116
-			elseif ($notify_types == 4)
117
-				continue;
110
+			if (!empty($data['pm_ignore_list']) && in_array($data['id_member_updated'], explode(',', $data['pm_ignore_list']))) {
111
+						    continue;
112
+			}
113
+			if (!in_array($type, array('reply', 'topic')) && $notify_types == 2 && $member != $data['id_member_started']) {
114
+							continue;
115
+			} elseif (in_array($type, array('reply', 'topic')) && $member == $posterOptions['id']) {
116
+							continue;
117
+			} elseif (!in_array($type, array('reply', 'topic')) && $notify_types == 3) {
118
+							continue;
119
+			} elseif ($notify_types == 4) {
120
+							continue;
121
+			}
118 122
 
119 123
 			if ($frequency > 2 || (!empty($frequency) && $data['sent']) || in_array($member, $done_members)
120
-				|| (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only'])))
121
-				continue;
124
+				|| (!empty($this->_details['members_only']) && !in_array($member, $this->_details['members_only']))) {
125
+							continue;
126
+			}
122 127
 
123 128
 			// Watched topic?
124 129
 			if (!empty($data['id_topic']) && $type != 'topic' && !empty($prefs[$member]))
@@ -128,10 +133,12 @@  discard block
 block discarded – undo
128 133
 
129 134
 				if ($type == 'reply')
130 135
 				{
131
-					if (!empty($prefs[$member]['msg_receive_body']))
132
-						$message_type .= '_body';
133
-					if (!empty($frequency))
134
-						$message_type .= '_once';
136
+					if (!empty($prefs[$member]['msg_receive_body'])) {
137
+											$message_type .= '_body';
138
+					}
139
+					if (!empty($frequency)) {
140
+											$message_type .= '_once';
141
+					}
135 142
 				}
136 143
 
137 144
 				$content_type = 'topic';
@@ -144,12 +151,14 @@  discard block
 block discarded – undo
144 151
 				$content_type = 'board';
145 152
 
146 153
 				$message_type = !empty($frequency) ? 'notify_boards_once' : 'notify_boards';
147
-				if (!empty($prefs[$member]['msg_receive_body']))
148
-					$message_type .= '_body';
154
+				if (!empty($prefs[$member]['msg_receive_body'])) {
155
+									$message_type .= '_body';
156
+				}
149 157
 			}
150 158
 			// If neither of the above, this might be a redundent row due to the OR clause in our SQL query, skip
151
-			else
152
-				continue;
159
+			else {
160
+							continue;
161
+			}
153 162
 
154 163
 			if ($pref & 0x02)
155 164
 			{
@@ -212,14 +221,15 @@  discard block
 block discarded – undo
212 221
 		);
213 222
 
214 223
 		// Insert the alerts if any
215
-		if (!empty($alert_rows))
216
-			$smcFunc['db_insert']('',
224
+		if (!empty($alert_rows)) {
225
+					$smcFunc['db_insert']('',
217 226
 				'{db_prefix}user_alerts',
218 227
 				array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string',
219 228
 					'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'),
220 229
 				$alert_rows,
221 230
 				array()
222 231
 			);
232
+		}
223 233
 
224 234
 		return true;
225 235
 	}
@@ -230,8 +240,9 @@  discard block
 block discarded – undo
230 240
 
231 241
 		foreach ($quotedMembers as $id => $member)
232 242
 		{
233
-			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote']))
234
-				continue;
243
+			if (!isset($prefs[$id]) || $id == $posterOptions['id'] || empty($prefs[$id]['msg_quote'])) {
244
+							continue;
245
+			}
235 246
 
236 247
 			$done_members[] = $id;
237 248
 
@@ -283,32 +294,35 @@  discard block
 block discarded – undo
283 294
 		{
284 295
 			if (preg_match('/\[quote(.*)?\]/i', $block, $matches))
285 296
 			{
286
-				if ($quote_level == 0)
287
-					$message .= '[quote' . $matches[1] . ']';
297
+				if ($quote_level == 0) {
298
+									$message .= '[quote' . $matches[1] . ']';
299
+				}
288 300
 				$quote_level++;
289
-			}
290
-			elseif (preg_match('/\[\/quote\]/i', $block))
301
+			} elseif (preg_match('/\[\/quote\]/i', $block))
291 302
 			{
292
-				if ($quote_level <= 1)
293
-					$message .= '[/quote]';
303
+				if ($quote_level <= 1) {
304
+									$message .= '[/quote]';
305
+				}
294 306
 				if ($quote_level >= 1)
295 307
 				{
296 308
 					$quote_level--;
297 309
 					$message .= "\n";
298 310
 				}
311
+			} elseif ($quote_level <= 1) {
312
+							$message .= $block;
299 313
 			}
300
-			elseif ($quote_level <= 1)
301
-				$message .= $block;
302 314
 		}
303 315
 
304 316
 		preg_match_all('/\[quote.*?link=msg=([0-9]+).*?\]/i', $message, $matches);
305 317
 
306 318
 		$id_msgs = $matches[1];
307
-		foreach ($id_msgs as $k => $id_msg)
308
-			$id_msgs[$k] = (int) $id_msg;
319
+		foreach ($id_msgs as $k => $id_msg) {
320
+					$id_msgs[$k] = (int) $id_msg;
321
+		}
309 322
 
310
-		if (empty($id_msgs))
311
-			return array();
323
+		if (empty($id_msgs)) {
324
+					return array();
325
+		}
312 326
 
313 327
 		// Get the messages
314 328
 		$request = $smcFunc['db_query']('', '
@@ -326,8 +340,9 @@  discard block
 block discarded – undo
326 340
 		$members = array();
327 341
 		while ($row = $smcFunc['db_fetch_assoc']($request))
328 342
 		{
329
-			if ($posterOptions['id'] == $row['id_member'])
330
-				continue;
343
+			if ($posterOptions['id'] == $row['id_member']) {
344
+							continue;
345
+			}
331 346
 
332 347
 			$members[$row['id_member']] = $row;
333 348
 		}
@@ -341,10 +356,11 @@  discard block
 block discarded – undo
341 356
 
342 357
 		foreach ($members as $id => $member)
343 358
 		{
344
-			if (!empty($prefs[$id]['msg_mention']))
345
-				$done_members[] = $id;
346
-			else
347
-				continue;
359
+			if (!empty($prefs[$id]['msg_mention'])) {
360
+							$done_members[] = $id;
361
+			} else {
362
+							continue;
363
+			}
348 364
 
349 365
 			// Alerts' emails are always instant
350 366
 			if ($prefs[$id]['msg_mention'] & 0x02)
Please login to merge, or discard this patch.