@@ -12,7 +12,8 @@ |
||
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 |
@@ -15,8 +15,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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( |
@@ -232,7 +232,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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']('', ' |
@@ -13,8 +13,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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)) |
@@ -1,9 +1,10 @@ |
||
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 |
@@ -1,9 +1,10 @@ |
||
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 |
@@ -1,9 +1,10 @@ |
||
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 |
@@ -1,9 +1,10 @@ |
||
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 |
@@ -1,9 +1,10 @@ |
||
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 |
@@ -1,9 +1,10 @@ |
||
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 |