@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * The central part of the board - topic display. |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | global $messages_request, $language, $smcFunc; |
35 | 36 | |
36 | 37 | // What are you gonna display if these are empty?! |
37 | - if (empty($topic)) |
|
38 | - fatal_lang_error('no_board', false); |
|
38 | + if (empty($topic)) { |
|
39 | + fatal_lang_error('no_board', false); |
|
40 | + } |
|
39 | 41 | |
40 | 42 | // Load the proper template. |
41 | 43 | loadTemplate('Display'); |
@@ -52,15 +54,17 @@ discard block |
||
52 | 54 | $context['messages_per_page'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
53 | 55 | |
54 | 56 | // Let's do some work on what to search index. |
55 | - if (count($_GET) > 2) |
|
56 | - foreach ($_GET as $k => $v) |
|
57 | + if (count($_GET) > 2) { |
|
58 | + foreach ($_GET as $k => $v) |
|
57 | 59 | { |
58 | 60 | if (!in_array($k, array('topic', 'board', 'start', session_name()))) |
59 | 61 | $context['robot_no_index'] = true; |
62 | + } |
|
60 | 63 | } |
61 | 64 | |
62 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
63 | - $context['robot_no_index'] = true; |
|
65 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
66 | + $context['robot_no_index'] = true; |
|
67 | + } |
|
64 | 68 | |
65 | 69 | // Find the previous or next topic. Make a fuss if there are no more. |
66 | 70 | if (isset($_REQUEST['prev_next']) && ($_REQUEST['prev_next'] == 'prev' || $_REQUEST['prev_next'] == 'next')) |
@@ -172,8 +176,9 @@ discard block |
||
172 | 176 | $topic_parameters |
173 | 177 | ); |
174 | 178 | |
175 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
176 | - fatal_lang_error('not_a_topic', false, 404); |
|
179 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
180 | + fatal_lang_error('not_a_topic', false, 404); |
|
181 | + } |
|
177 | 182 | $context['topicinfo'] = $smcFunc['db_fetch_assoc']($request); |
178 | 183 | $smcFunc['db_free_result']($request); |
179 | 184 | |
@@ -210,8 +215,9 @@ discard block |
||
210 | 215 | $context['topic_unwatched'] = isset($context['topicinfo']['unwatched']) ? $context['topicinfo']['unwatched'] : 0; |
211 | 216 | |
212 | 217 | // Add up unapproved replies to get real number of replies... |
213 | - if ($modSettings['postmod_active'] && $approve_posts) |
|
214 | - $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
218 | + if ($modSettings['postmod_active'] && $approve_posts) { |
|
219 | + $context['real_num_replies'] += $context['topicinfo']['unapproved_posts'] - ($context['topicinfo']['approved'] ? 0 : 1); |
|
220 | + } |
|
215 | 221 | |
216 | 222 | // If this topic has unapproved posts, we need to work out how many posts the user can see, for page indexing. |
217 | 223 | if ($modSettings['postmod_active'] && $context['topicinfo']['unapproved_posts'] && !$user_info['is_guest'] && !$approve_posts) |
@@ -231,11 +237,11 @@ discard block |
||
231 | 237 | $smcFunc['db_free_result']($request); |
232 | 238 | |
233 | 239 | $context['total_visible_posts'] = $context['num_replies'] + $myUnapprovedPosts + ($context['topicinfo']['approved'] ? 1 : 0); |
240 | + } elseif ($user_info['is_guest']) { |
|
241 | + $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
242 | + } else { |
|
243 | + $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
234 | 244 | } |
235 | - elseif ($user_info['is_guest']) |
|
236 | - $context['total_visible_posts'] = $context['num_replies'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
237 | - else |
|
238 | - $context['total_visible_posts'] = $context['num_replies'] + $context['topicinfo']['unapproved_posts'] + ($context['topicinfo']['approved'] ? 1 : 0); |
|
239 | 245 | |
240 | 246 | // The start isn't a number; it's information about what to do, where to go. |
241 | 247 | if (!is_numeric($_REQUEST['start'])) |
@@ -248,8 +254,7 @@ discard block |
||
248 | 254 | { |
249 | 255 | $context['start_from'] = $context['total_visible_posts'] - 1; |
250 | 256 | $_REQUEST['start'] = empty($options['view_newest_first']) ? $context['start_from'] : 0; |
251 | - } |
|
252 | - else |
|
257 | + } else |
|
253 | 258 | { |
254 | 259 | // Find the earliest unread message in the topic. (the use of topics here is just for both tables.) |
255 | 260 | $request = $smcFunc['db_query']('', ' |
@@ -277,9 +282,9 @@ discard block |
||
277 | 282 | if (substr($_REQUEST['start'], 0, 4) == 'from') |
278 | 283 | { |
279 | 284 | $timestamp = (int) substr($_REQUEST['start'], 4); |
280 | - if ($timestamp === 0) |
|
281 | - $_REQUEST['start'] = 0; |
|
282 | - else |
|
285 | + if ($timestamp === 0) { |
|
286 | + $_REQUEST['start'] = 0; |
|
287 | + } else |
|
283 | 288 | { |
284 | 289 | // Find the number of messages posted before said time... |
285 | 290 | $request = $smcFunc['db_query']('', ' |
@@ -307,11 +312,11 @@ discard block |
||
307 | 312 | elseif (substr($_REQUEST['start'], 0, 3) == 'msg') |
308 | 313 | { |
309 | 314 | $virtual_msg = (int) substr($_REQUEST['start'], 3); |
310 | - if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) |
|
311 | - $context['start_from'] = $context['total_visible_posts'] - 1; |
|
312 | - elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) |
|
313 | - $context['start_from'] = 0; |
|
314 | - else |
|
315 | + if (!$context['topicinfo']['unapproved_posts'] && $virtual_msg >= $context['topicinfo']['id_last_msg']) { |
|
316 | + $context['start_from'] = $context['total_visible_posts'] - 1; |
|
317 | + } elseif (!$context['topicinfo']['unapproved_posts'] && $virtual_msg <= $context['topicinfo']['id_first_msg']) { |
|
318 | + $context['start_from'] = 0; |
|
319 | + } else |
|
315 | 320 | { |
316 | 321 | // Find the start value for that message...... |
317 | 322 | $request = $smcFunc['db_query']('', ' |
@@ -365,9 +370,10 @@ discard block |
||
365 | 370 | list ($sig_limits, $sig_bbc) = explode(':', $modSettings['signature_settings']); |
366 | 371 | $sig_limits = explode(',', $sig_limits); |
367 | 372 | |
368 | - if (!empty($sig_limits[5]) || !empty($sig_limits[6])) |
|
369 | - addInlineCss(' |
|
373 | + if (!empty($sig_limits[5]) || !empty($sig_limits[6])) { |
|
374 | + addInlineCss(' |
|
370 | 375 | .signature img { ' . (!empty($sig_limits[5]) ? 'max-width: ' . (int) $sig_limits[5] . 'px; ' : '') . (!empty($sig_limits[6]) ? 'max-height: ' . (int) $sig_limits[6] . 'px; ' : '') . '}'); |
376 | + } |
|
371 | 377 | } |
372 | 378 | |
373 | 379 | // Censor the title... |
@@ -405,21 +411,25 @@ discard block |
||
405 | 411 | ); |
406 | 412 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
407 | 413 | { |
408 | - if (empty($row['id_member'])) |
|
409 | - continue; |
|
414 | + if (empty($row['id_member'])) { |
|
415 | + continue; |
|
416 | + } |
|
410 | 417 | |
411 | - if (!empty($row['online_color'])) |
|
412 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
413 | - else |
|
414 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
418 | + if (!empty($row['online_color'])) { |
|
419 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
420 | + } else { |
|
421 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
422 | + } |
|
415 | 423 | |
416 | 424 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
417 | - if ($is_buddy) |
|
418 | - $link = '<strong>' . $link . '</strong>'; |
|
425 | + if ($is_buddy) { |
|
426 | + $link = '<strong>' . $link . '</strong>'; |
|
427 | + } |
|
419 | 428 | |
420 | 429 | // Add them both to the list and to the more detailed list. |
421 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
422 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
430 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
431 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
432 | + } |
|
423 | 433 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
424 | 434 | 'id' => $row['id_member'], |
425 | 435 | 'username' => $row['member_name'], |
@@ -431,8 +441,9 @@ discard block |
||
431 | 441 | 'hidden' => empty($row['show_online']), |
432 | 442 | ); |
433 | 443 | |
434 | - if (empty($row['show_online'])) |
|
435 | - $context['view_num_hidden']++; |
|
444 | + if (empty($row['show_online'])) { |
|
445 | + $context['view_num_hidden']++; |
|
446 | + } |
|
436 | 447 | } |
437 | 448 | |
438 | 449 | // The number of guests is equal to the rows minus the ones we actually used ;). |
@@ -446,11 +457,13 @@ discard block |
||
446 | 457 | |
447 | 458 | // If all is set, but not allowed... just unset it. |
448 | 459 | $can_show_all = !empty($modSettings['enableAllMessages']) && $context['total_visible_posts'] > $context['messages_per_page'] && $context['total_visible_posts'] < $modSettings['enableAllMessages']; |
449 | - if (isset($_REQUEST['all']) && !$can_show_all) |
|
450 | - unset($_REQUEST['all']); |
|
460 | + if (isset($_REQUEST['all']) && !$can_show_all) { |
|
461 | + unset($_REQUEST['all']); |
|
462 | + } |
|
451 | 463 | // Otherwise, it must be allowed... so pretend start was -1. |
452 | - elseif (isset($_REQUEST['all'])) |
|
453 | - $_REQUEST['start'] = -1; |
|
464 | + elseif (isset($_REQUEST['all'])) { |
|
465 | + $_REQUEST['start'] = -1; |
|
466 | + } |
|
454 | 467 | |
455 | 468 | // Construct the page index, allowing for the .START method... |
456 | 469 | $context['page_index'] = constructPageIndex($scripturl . '?topic=' . $topic . '.%1$d', $_REQUEST['start'], $context['total_visible_posts'], $context['messages_per_page'], true); |
@@ -487,8 +500,9 @@ discard block |
||
487 | 500 | $_REQUEST['start'] = 0; |
488 | 501 | } |
489 | 502 | // They aren't using it, but the *option* is there, at least. |
490 | - else |
|
491 | - $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
503 | + else { |
|
504 | + $context['page_index'] .= ' <a href="' . $scripturl . '?topic=' . $topic . '.0;all">' . $txt['all'] . '</a> '; |
|
505 | + } |
|
492 | 506 | } |
493 | 507 | |
494 | 508 | // Build the link tree. |
@@ -504,14 +518,16 @@ discard block |
||
504 | 518 | if (!empty($board_info['moderators'])) |
505 | 519 | { |
506 | 520 | // Add a link for each moderator... |
507 | - foreach ($board_info['moderators'] as $mod) |
|
508 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
521 | + foreach ($board_info['moderators'] as $mod) { |
|
522 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
523 | + } |
|
509 | 524 | } |
510 | 525 | if (!empty($board_info['moderator_groups'])) |
511 | 526 | { |
512 | 527 | // Add a link for each moderator group as well... |
513 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
514 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
528 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
529 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=viewmemberes;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
530 | + } |
|
515 | 531 | } |
516 | 532 | |
517 | 533 | if (!empty($context['link_moderators'])) |
@@ -542,9 +558,9 @@ discard block |
||
542 | 558 | // For quick reply we need a response prefix in the default forum language. |
543 | 559 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix', 600))) |
544 | 560 | { |
545 | - if ($language === $user_info['language']) |
|
546 | - $context['response_prefix'] = $txt['response_prefix']; |
|
547 | - else |
|
561 | + if ($language === $user_info['language']) { |
|
562 | + $context['response_prefix'] = $txt['response_prefix']; |
|
563 | + } else |
|
548 | 564 | { |
549 | 565 | loadLanguage('index', $language, false); |
550 | 566 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -576,8 +592,9 @@ discard block |
||
576 | 592 | list($start, $end, $allday, $span, $tz, $tz_abbrev) = buildEventDatetimes($row); |
577 | 593 | |
578 | 594 | // Sanity check |
579 | - if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) |
|
580 | - continue; |
|
595 | + if (!empty($start['error_count']) || !empty($start['warning_count']) || !empty($end['error_count']) || !empty($end['warning_count'])) { |
|
596 | + continue; |
|
597 | + } |
|
581 | 598 | |
582 | 599 | $linked_calendar_event = array( |
583 | 600 | 'id' => $row['id_event'], |
@@ -626,8 +643,9 @@ discard block |
||
626 | 643 | } |
627 | 644 | $smcFunc['db_free_result']($request); |
628 | 645 | |
629 | - if (!empty($context['linked_calendar_events'])) |
|
630 | - $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
646 | + if (!empty($context['linked_calendar_events'])) { |
|
647 | + $context['linked_calendar_events'][count($context['linked_calendar_events']) - 1]['is_last'] = true; |
|
648 | + } |
|
631 | 649 | } |
632 | 650 | |
633 | 651 | // Create the poll info if it exists. |
@@ -651,9 +669,9 @@ discard block |
||
651 | 669 | } |
652 | 670 | |
653 | 671 | // Create the poll info if it exists and is valid. |
654 | - if ($context['is_poll'] && empty($pollinfo)) |
|
655 | - $context['is_poll'] = false; |
|
656 | - elseif ($context['is_poll']) |
|
672 | + if ($context['is_poll'] && empty($pollinfo)) { |
|
673 | + $context['is_poll'] = false; |
|
674 | + } elseif ($context['is_poll']) |
|
657 | 675 | { |
658 | 676 | $request = $smcFunc['db_query']('', ' |
659 | 677 | SELECT COUNT(DISTINCT id_member) AS total |
@@ -696,8 +714,9 @@ discard block |
||
696 | 714 | $smcFunc['db_free_result']($request); |
697 | 715 | |
698 | 716 | // Got we multi choice? |
699 | - if ($pollinfo['max_votes'] > 1) |
|
700 | - $realtotal = $pollinfo['total']; |
|
717 | + if ($pollinfo['max_votes'] > 1) { |
|
718 | + $realtotal = $pollinfo['total']; |
|
719 | + } |
|
701 | 720 | |
702 | 721 | // If this is a guest we need to do our best to work out if they have voted, and what they voted for. |
703 | 722 | if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote')) |
@@ -710,20 +729,21 @@ discard block |
||
710 | 729 | foreach ($guestinfo as $i => $guestvoted) |
711 | 730 | { |
712 | 731 | $guestvoted = explode(',', $guestvoted); |
713 | - if ($guestvoted[0] == $context['topicinfo']['id_poll']) |
|
714 | - break; |
|
732 | + if ($guestvoted[0] == $context['topicinfo']['id_poll']) { |
|
733 | + break; |
|
734 | + } |
|
715 | 735 | } |
716 | 736 | // Has the poll been reset since guest voted? |
717 | 737 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
718 | 738 | { |
719 | 739 | // Remove the poll info from the cookie to allow guest to vote again |
720 | 740 | unset($guestinfo[$i]); |
721 | - if (!empty($guestinfo)) |
|
722 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
723 | - else |
|
724 | - unset($_COOKIE['guest_poll_vote']); |
|
725 | - } |
|
726 | - else |
|
741 | + if (!empty($guestinfo)) { |
|
742 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
743 | + } else { |
|
744 | + unset($_COOKIE['guest_poll_vote']); |
|
745 | + } |
|
746 | + } else |
|
727 | 747 | { |
728 | 748 | // What did they vote for? |
729 | 749 | unset($guestvoted[0], $guestvoted[1]); |
@@ -837,23 +857,29 @@ discard block |
||
837 | 857 | // Build the poll moderation button array. |
838 | 858 | $context['poll_buttons'] = array(); |
839 | 859 | |
840 | - if ($context['allow_return_vote']) |
|
841 | - $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
860 | + if ($context['allow_return_vote']) { |
|
861 | + $context['poll_buttons']['vote'] = array('text' => 'poll_return_vote', 'image' => 'poll_options.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']); |
|
862 | + } |
|
842 | 863 | |
843 | - if ($context['show_view_results_button']) |
|
844 | - $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
864 | + if ($context['show_view_results_button']) { |
|
865 | + $context['poll_buttons']['results'] = array('text' => 'poll_results', 'image' => 'poll_results.png', 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'); |
|
866 | + } |
|
845 | 867 | |
846 | - if ($context['allow_change_vote']) |
|
847 | - $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
868 | + if ($context['allow_change_vote']) { |
|
869 | + $context['poll_buttons']['change_vote'] = array('text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
870 | + } |
|
848 | 871 | |
849 | - if ($context['allow_lock_poll']) |
|
850 | - $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
872 | + if ($context['allow_lock_poll']) { |
|
873 | + $context['poll_buttons']['lock'] = array('text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
874 | + } |
|
851 | 875 | |
852 | - if ($context['allow_edit_poll']) |
|
853 | - $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
876 | + if ($context['allow_edit_poll']) { |
|
877 | + $context['poll_buttons']['edit'] = array('text' => 'poll_edit', 'image' => 'poll_edit.png', 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
878 | + } |
|
854 | 879 | |
855 | - if ($context['can_remove_poll']) |
|
856 | - $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
880 | + if ($context['can_remove_poll']) { |
|
881 | + $context['poll_buttons']['remove_poll'] = array('text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'custom' => 'data-confirm="' . $txt['poll_remove_warn'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
882 | + } |
|
857 | 883 | |
858 | 884 | // Allow mods to add additional buttons here |
859 | 885 | call_integration_hook('integrate_poll_buttons'); |
@@ -889,9 +915,9 @@ discard block |
||
889 | 915 | { |
890 | 916 | $start_char = 'C'; |
891 | 917 | $page_id = $ascending ? $context['topicinfo']['id_first_msg'] : $context['topicinfo']['id_last_msg']; |
918 | + } else { |
|
919 | + $start_char = null; |
|
892 | 920 | } |
893 | - else |
|
894 | - $start_char = null; |
|
895 | 921 | |
896 | 922 | $limit = $context['messages_per_page']; |
897 | 923 | |
@@ -905,17 +931,17 @@ discard block |
||
905 | 931 | { |
906 | 932 | $ascending_seek = true; |
907 | 933 | $page_operator = $ascending ? '>=' : '<='; |
908 | - } |
|
909 | - else |
|
934 | + } else |
|
910 | 935 | { |
911 | 936 | $ascending_seek = false; |
912 | 937 | $page_operator = $ascending ? '<=' : '>='; |
913 | 938 | } |
914 | 939 | |
915 | - if ($start_char === 'C') |
|
916 | - $limit_seek = $limit; |
|
917 | - else |
|
918 | - $limit_seek = $limit + 1; |
|
940 | + if ($start_char === 'C') { |
|
941 | + $limit_seek = $limit; |
|
942 | + } else { |
|
943 | + $limit_seek = $limit + 1; |
|
944 | + } |
|
919 | 945 | |
920 | 946 | $request = $smcFunc['db_query']('', ' |
921 | 947 | SELECT id_msg, id_member, approved |
@@ -938,21 +964,23 @@ discard block |
||
938 | 964 | $found_msg = false; |
939 | 965 | |
940 | 966 | // Fallback |
941 | - if ($smcFunc['db_num_rows']($request) < 1) |
|
942 | - unset($start_char); |
|
943 | - else |
|
967 | + if ($smcFunc['db_num_rows']($request) < 1) { |
|
968 | + unset($start_char); |
|
969 | + } else |
|
944 | 970 | { |
945 | 971 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
946 | 972 | { |
947 | 973 | // Check if the start msg is in our result |
948 | - if ($row['id_msg'] == $page_id) |
|
949 | - $found_msg = true; |
|
974 | + if ($row['id_msg'] == $page_id) { |
|
975 | + $found_msg = true; |
|
976 | + } |
|
950 | 977 | |
951 | 978 | // Skip the the start msg if we not in mode C |
952 | 979 | if ($start_char === 'C' || $row['id_msg'] != $page_id) |
953 | 980 | { |
954 | - if (!empty($row['id_member'])) |
|
955 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
981 | + if (!empty($row['id_member'])) { |
|
982 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
983 | + } |
|
956 | 984 | |
957 | 985 | $messages[] = $row['id_msg']; |
958 | 986 | } |
@@ -968,8 +996,9 @@ discard block |
||
968 | 996 | } |
969 | 997 | |
970 | 998 | // Before Page bring in the right order |
971 | - if (!empty($start_char) && $start_char === 'L') |
|
972 | - krsort($messages); |
|
999 | + if (!empty($start_char) && $start_char === 'L') { |
|
1000 | + krsort($messages); |
|
1001 | + } |
|
973 | 1002 | } |
974 | 1003 | |
975 | 1004 | // Jump to page |
@@ -1004,14 +1033,16 @@ discard block |
||
1004 | 1033 | |
1005 | 1034 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1006 | 1035 | { |
1007 | - if (!empty($row['id_member'])) |
|
1008 | - $all_posters[$row['id_msg']] = $row['id_member']; |
|
1036 | + if (!empty($row['id_member'])) { |
|
1037 | + $all_posters[$row['id_msg']] = $row['id_member']; |
|
1038 | + } |
|
1009 | 1039 | $messages[] = $row['id_msg']; |
1010 | 1040 | } |
1011 | 1041 | |
1012 | 1042 | // Sort the messages into the correct display order |
1013 | - if (!$ascending) |
|
1014 | - sort($messages); |
|
1043 | + if (!$ascending) { |
|
1044 | + sort($messages); |
|
1045 | + } |
|
1015 | 1046 | } |
1016 | 1047 | |
1017 | 1048 | // Remember the paging data for next time |
@@ -1031,8 +1062,9 @@ discard block |
||
1031 | 1062 | if (!$user_info['is_guest'] && !empty($messages)) |
1032 | 1063 | { |
1033 | 1064 | $mark_at_msg = max($messages); |
1034 | - if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) |
|
1035 | - $mark_at_msg = $modSettings['maxMsgID']; |
|
1065 | + if ($mark_at_msg >= $context['topicinfo']['id_last_msg']) { |
|
1066 | + $mark_at_msg = $modSettings['maxMsgID']; |
|
1067 | + } |
|
1036 | 1068 | if ($mark_at_msg >= $context['topicinfo']['new_from']) |
1037 | 1069 | { |
1038 | 1070 | $smcFunc['db_insert']($context['topicinfo']['new_from'] == 0 ? 'ignore' : 'replace', |
@@ -1064,8 +1096,9 @@ discard block |
||
1064 | 1096 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1065 | 1097 | { |
1066 | 1098 | // Find if this topic is marked for notification... |
1067 | - if (!empty($row['id_topic'])) |
|
1068 | - $context['is_marked_notify'] = true; |
|
1099 | + if (!empty($row['id_topic'])) { |
|
1100 | + $context['is_marked_notify'] = true; |
|
1101 | + } |
|
1069 | 1102 | |
1070 | 1103 | // Only do this once, but mark the notifications as "not sent yet" for next time. |
1071 | 1104 | if (!empty($row['sent']) && $do_once) |
@@ -1087,8 +1120,9 @@ discard block |
||
1087 | 1120 | } |
1088 | 1121 | |
1089 | 1122 | // Have we recently cached the number of new topics in this board, and it's still a lot? |
1090 | - if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) |
|
1091 | - $_SESSION['topicseen_cache'][$board]--; |
|
1123 | + if (isset($_REQUEST['topicseen']) && isset($_SESSION['topicseen_cache'][$board]) && $_SESSION['topicseen_cache'][$board] > 5) { |
|
1124 | + $_SESSION['topicseen_cache'][$board]--; |
|
1125 | + } |
|
1092 | 1126 | // Mark board as seen if this is the only new topic. |
1093 | 1127 | elseif (isset($_REQUEST['topicseen'])) |
1094 | 1128 | { |
@@ -1112,14 +1146,16 @@ discard block |
||
1112 | 1146 | $smcFunc['db_free_result']($request); |
1113 | 1147 | |
1114 | 1148 | // If there're no real new topics in this board, mark the board as seen. |
1115 | - if (empty($numNewTopics)) |
|
1116 | - $_REQUEST['boardseen'] = true; |
|
1117 | - else |
|
1118 | - $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1149 | + if (empty($numNewTopics)) { |
|
1150 | + $_REQUEST['boardseen'] = true; |
|
1151 | + } else { |
|
1152 | + $_SESSION['topicseen_cache'][$board] = $numNewTopics; |
|
1153 | + } |
|
1119 | 1154 | } |
1120 | 1155 | // Probably one less topic - maybe not, but even if we decrease this too fast it will only make us look more often. |
1121 | - elseif (isset($_SESSION['topicseen_cache'][$board])) |
|
1122 | - $_SESSION['topicseen_cache'][$board]--; |
|
1156 | + elseif (isset($_SESSION['topicseen_cache'][$board])) { |
|
1157 | + $_SESSION['topicseen_cache'][$board]--; |
|
1158 | + } |
|
1123 | 1159 | |
1124 | 1160 | // Mark board as seen if we came using last post link from BoardIndex. (or other places...) |
1125 | 1161 | if (isset($_REQUEST['boardseen'])) |
@@ -1176,23 +1212,26 @@ discard block |
||
1176 | 1212 | $temp = array(); |
1177 | 1213 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1178 | 1214 | { |
1179 | - if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) |
|
1180 | - continue; |
|
1215 | + if (!$row['approved'] && $modSettings['postmod_active'] && !allowedTo('approve_posts') && (!isset($all_posters[$row['id_msg']]) || $all_posters[$row['id_msg']] != $user_info['id'])) { |
|
1216 | + continue; |
|
1217 | + } |
|
1181 | 1218 | |
1182 | 1219 | $temp[$row['id_attach']] = $row; |
1183 | 1220 | $temp[$row['id_attach']]['topic'] = $topic; |
1184 | 1221 | $temp[$row['id_attach']]['board'] = $board; |
1185 | 1222 | |
1186 | - if (!isset($context['loaded_attachments'][$row['id_msg']])) |
|
1187 | - $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1223 | + if (!isset($context['loaded_attachments'][$row['id_msg']])) { |
|
1224 | + $context['loaded_attachments'][$row['id_msg']] = array(); |
|
1225 | + } |
|
1188 | 1226 | } |
1189 | 1227 | $smcFunc['db_free_result']($request); |
1190 | 1228 | |
1191 | 1229 | // This is better than sorting it with the query... |
1192 | 1230 | ksort($temp); |
1193 | 1231 | |
1194 | - foreach ($temp as $row) |
|
1195 | - $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1232 | + foreach ($temp as $row) { |
|
1233 | + $context['loaded_attachments'][$row['id_msg']][] = $row; |
|
1234 | + } |
|
1196 | 1235 | } |
1197 | 1236 | |
1198 | 1237 | $msg_parameters = array( |
@@ -1219,21 +1258,23 @@ discard block |
||
1219 | 1258 | ); |
1220 | 1259 | |
1221 | 1260 | // And the likes |
1222 | - if (!empty($modSettings['enable_likes'])) |
|
1223 | - $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1261 | + if (!empty($modSettings['enable_likes'])) { |
|
1262 | + $context['my_likes'] = $context['user']['is_guest'] ? array() : prepareLikesContext($topic); |
|
1263 | + } |
|
1224 | 1264 | |
1225 | 1265 | // Go to the last message if the given time is beyond the time of the last message. |
1226 | - if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) |
|
1227 | - $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1266 | + if (isset($context['start_from']) && $context['start_from'] >= $context['topicinfo']['num_replies']) { |
|
1267 | + $context['start_from'] = $context['topicinfo']['num_replies']; |
|
1268 | + } |
|
1228 | 1269 | |
1229 | 1270 | // Since the anchor information is needed on the top of the page we load these variables beforehand. |
1230 | 1271 | $context['first_message'] = isset($messages[$firstIndex]) ? $messages[$firstIndex] : $messages[0]; |
1231 | - if (empty($options['view_newest_first'])) |
|
1232 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1233 | - else |
|
1234 | - $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1235 | - } |
|
1236 | - else |
|
1272 | + if (empty($options['view_newest_first'])) { |
|
1273 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['start_from']; |
|
1274 | + } else { |
|
1275 | + $context['first_new_message'] = isset($context['start_from']) && $_REQUEST['start'] == $context['topicinfo']['num_replies'] - $context['start_from']; |
|
1276 | + } |
|
1277 | + } else |
|
1237 | 1278 | { |
1238 | 1279 | $messages_request = false; |
1239 | 1280 | $context['first_message'] = 0; |
@@ -1268,8 +1309,9 @@ discard block |
||
1268 | 1309 | 'can_restore_msg' => 'move_any', |
1269 | 1310 | 'can_like' => 'likes_like', |
1270 | 1311 | ); |
1271 | - foreach ($common_permissions as $contextual => $perm) |
|
1272 | - $context[$contextual] = allowedTo($perm); |
|
1312 | + foreach ($common_permissions as $contextual => $perm) { |
|
1313 | + $context[$contextual] = allowedTo($perm); |
|
1314 | + } |
|
1273 | 1315 | |
1274 | 1316 | // Permissions with _any/_own versions. $context[YYY] => ZZZ_any/_own. |
1275 | 1317 | $anyown_permissions = array( |
@@ -1282,8 +1324,9 @@ discard block |
||
1282 | 1324 | 'can_reply_unapproved' => 'post_unapproved_replies', |
1283 | 1325 | 'can_view_warning' => 'profile_warning', |
1284 | 1326 | ); |
1285 | - foreach ($anyown_permissions as $contextual => $perm) |
|
1286 | - $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1327 | + foreach ($anyown_permissions as $contextual => $perm) { |
|
1328 | + $context[$contextual] = allowedTo($perm . '_any') || ($context['user']['started'] && allowedTo($perm . '_own')); |
|
1329 | + } |
|
1287 | 1330 | |
1288 | 1331 | if (!$user_info['is_admin'] && $context['can_move'] && !$modSettings['topic_move_any']) |
1289 | 1332 | { |
@@ -1329,8 +1372,9 @@ discard block |
||
1329 | 1372 | // Check if the draft functions are enabled and that they have permission to use them (for quick reply.) |
1330 | 1373 | $context['drafts_save'] = !empty($modSettings['drafts_post_enabled']) && allowedTo('post_draft') && $context['can_reply']; |
1331 | 1374 | $context['drafts_autosave'] = !empty($context['drafts_save']) && !empty($modSettings['drafts_autosave_enabled']); |
1332 | - if (!empty($context['drafts_save'])) |
|
1333 | - loadLanguage('Drafts'); |
|
1375 | + if (!empty($context['drafts_save'])) { |
|
1376 | + loadLanguage('Drafts'); |
|
1377 | + } |
|
1334 | 1378 | |
1335 | 1379 | // When was the last time this topic was replied to? Should we warn them about it? |
1336 | 1380 | if (!empty($modSettings['oldTopicDays']) && ($context['can_reply'] || $context['can_reply_unapproved']) && empty($context['topicinfo']['is_sticky'])) |
@@ -1391,26 +1435,31 @@ discard block |
||
1391 | 1435 | // Message icons - customized icons are off? |
1392 | 1436 | $context['icons'] = getMessageIcons($board); |
1393 | 1437 | |
1394 | - if (!empty($context['icons'])) |
|
1395 | - $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1438 | + if (!empty($context['icons'])) { |
|
1439 | + $context['icons'][count($context['icons']) - 1]['is_last'] = true; |
|
1440 | + } |
|
1396 | 1441 | |
1397 | 1442 | // Build the normal button array. |
1398 | 1443 | $context['normal_buttons'] = array(); |
1399 | 1444 | |
1400 | - if ($context['can_reply']) |
|
1401 | - $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1445 | + if ($context['can_reply']) { |
|
1446 | + $context['normal_buttons']['reply'] = array('text' => 'reply', 'image' => 'reply.png', 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true); |
|
1447 | + } |
|
1402 | 1448 | |
1403 | - if ($context['can_add_poll']) |
|
1404 | - $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1449 | + if ($context['can_add_poll']) { |
|
1450 | + $context['normal_buttons']['add_poll'] = array('text' => 'add_poll', 'image' => 'add_poll.png', 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']); |
|
1451 | + } |
|
1405 | 1452 | |
1406 | - if ($context['can_mark_unread']) |
|
1407 | - $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1453 | + if ($context['can_mark_unread']) { |
|
1454 | + $context['normal_buttons']['mark_unread'] = array('text' => 'mark_unread', 'image' => 'markunread.png', 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1455 | + } |
|
1408 | 1456 | |
1409 | - if ($context['can_print']) |
|
1410 | - $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1457 | + if ($context['can_print']) { |
|
1458 | + $context['normal_buttons']['print'] = array('text' => 'print', 'image' => 'print.png', 'custom' => 'rel="nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'); |
|
1459 | + } |
|
1411 | 1460 | |
1412 | - if ($context['can_set_notify']) |
|
1413 | - $context['normal_buttons']['notify'] = array( |
|
1461 | + if ($context['can_set_notify']) { |
|
1462 | + $context['normal_buttons']['notify'] = array( |
|
1414 | 1463 | 'text' => 'notify_topic_' . $context['topic_notification_mode'], |
1415 | 1464 | 'sub_buttons' => array( |
1416 | 1465 | array( |
@@ -1432,38 +1481,47 @@ discard block |
||
1432 | 1481 | ), |
1433 | 1482 | ), |
1434 | 1483 | ); |
1484 | + } |
|
1435 | 1485 | |
1436 | 1486 | // Build the mod button array |
1437 | 1487 | $context['mod_buttons'] = array(); |
1438 | 1488 | |
1439 | - if ($context['can_move']) |
|
1440 | - $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1489 | + if ($context['can_move']) { |
|
1490 | + $context['mod_buttons']['move'] = array('text' => 'move_topic', 'image' => 'admin_move.png', 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1491 | + } |
|
1441 | 1492 | |
1442 | - if ($context['can_delete']) |
|
1443 | - $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1493 | + if ($context['can_delete']) { |
|
1494 | + $context['mod_buttons']['delete'] = array('text' => 'remove_topic', 'image' => 'admin_rem.png', 'custom' => 'data-confirm="' . $txt['are_sure_remove_topic'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
1495 | + } |
|
1444 | 1496 | |
1445 | - if ($context['can_lock']) |
|
1446 | - $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1497 | + if ($context['can_lock']) { |
|
1498 | + $context['mod_buttons']['lock'] = array('text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1499 | + } |
|
1447 | 1500 | |
1448 | - if ($context['can_sticky']) |
|
1449 | - $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1501 | + if ($context['can_sticky']) { |
|
1502 | + $context['mod_buttons']['sticky'] = array('text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1503 | + } |
|
1450 | 1504 | |
1451 | - if ($context['can_merge']) |
|
1452 | - $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1505 | + if ($context['can_merge']) { |
|
1506 | + $context['mod_buttons']['merge'] = array('text' => 'merge', 'image' => 'merge.png', 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']); |
|
1507 | + } |
|
1453 | 1508 | |
1454 | - if ($context['calendar_post']) |
|
1455 | - $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1509 | + if ($context['calendar_post']) { |
|
1510 | + $context['mod_buttons']['calendar'] = array('text' => 'calendar_link', 'image' => 'linktocal.png', 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'); |
|
1511 | + } |
|
1456 | 1512 | |
1457 | 1513 | // Restore topic. eh? No monkey business. |
1458 | - if ($context['can_restore_topic']) |
|
1459 | - $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1514 | + if ($context['can_restore_topic']) { |
|
1515 | + $context['mod_buttons']['restore_topic'] = array('text' => 'restore_topic', 'image' => '', 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1516 | + } |
|
1460 | 1517 | |
1461 | 1518 | // Show a message in case a recently posted message became unapproved. |
1462 | 1519 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
1463 | 1520 | |
1464 | 1521 | // Don't want to show this forever... |
1465 | - if ($context['becomesUnapproved']) |
|
1466 | - unset($_SESSION['becomesUnapproved']); |
|
1522 | + if ($context['becomesUnapproved']) { |
|
1523 | + unset($_SESSION['becomesUnapproved']); |
|
1524 | + } |
|
1467 | 1525 | |
1468 | 1526 | // Allow adding new mod buttons easily. |
1469 | 1527 | // Note: $context['normal_buttons'] and $context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used |
@@ -1472,12 +1530,14 @@ discard block |
||
1472 | 1530 | call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons'])); |
1473 | 1531 | |
1474 | 1532 | // Load the drafts js file |
1475 | - if ($context['drafts_autosave']) |
|
1476 | - loadJavaScriptFile('drafts.js', array('defer' => false, 'minimize' => true), 'smf_drafts'); |
|
1533 | + if ($context['drafts_autosave']) { |
|
1534 | + loadJavaScriptFile('drafts.js', array('defer' => false, 'minimize' => true), 'smf_drafts'); |
|
1535 | + } |
|
1477 | 1536 | |
1478 | 1537 | // Spellcheck |
1479 | - if ($context['show_spellchecking']) |
|
1480 | - loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); |
|
1538 | + if ($context['show_spellchecking']) { |
|
1539 | + loadJavaScriptFile('spellcheck.js', array('defer' => false, 'minimize' => true), 'smf_spellcheck'); |
|
1540 | + } |
|
1481 | 1541 | |
1482 | 1542 | // topic.js |
1483 | 1543 | loadJavaScriptFile('topic.js', array('defer' => false, 'minimize' => true), 'smf_topic'); |
@@ -1511,16 +1571,19 @@ discard block |
||
1511 | 1571 | static $counter = null; |
1512 | 1572 | |
1513 | 1573 | // If the query returned false, bail. |
1514 | - if ($messages_request == false) |
|
1515 | - return false; |
|
1574 | + if ($messages_request == false) { |
|
1575 | + return false; |
|
1576 | + } |
|
1516 | 1577 | |
1517 | 1578 | // Remember which message this is. (ie. reply #83) |
1518 | - if ($counter === null || $reset) |
|
1519 | - $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1579 | + if ($counter === null || $reset) { |
|
1580 | + $counter = empty($options['view_newest_first']) ? $context['start'] : $context['total_visible_posts'] - $context['start']; |
|
1581 | + } |
|
1520 | 1582 | |
1521 | 1583 | // Start from the beginning... |
1522 | - if ($reset) |
|
1523 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1584 | + if ($reset) { |
|
1585 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1586 | + } |
|
1524 | 1587 | |
1525 | 1588 | // Attempt to get the next message. |
1526 | 1589 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
@@ -1534,19 +1597,21 @@ discard block |
||
1534 | 1597 | if (empty($context['icon_sources'])) |
1535 | 1598 | { |
1536 | 1599 | $context['icon_sources'] = array(); |
1537 | - foreach ($context['stable_icons'] as $icon) |
|
1538 | - $context['icon_sources'][$icon] = 'images_url'; |
|
1600 | + foreach ($context['stable_icons'] as $icon) { |
|
1601 | + $context['icon_sources'][$icon] = 'images_url'; |
|
1602 | + } |
|
1539 | 1603 | } |
1540 | 1604 | |
1541 | 1605 | // Message Icon Management... check the images exist. |
1542 | 1606 | if (empty($modSettings['messageIconChecks_disable'])) |
1543 | 1607 | { |
1544 | 1608 | // If the current icon isn't known, then we need to do something... |
1545 | - if (!isset($context['icon_sources'][$message['icon']])) |
|
1546 | - $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1609 | + if (!isset($context['icon_sources'][$message['icon']])) { |
|
1610 | + $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
1611 | + } |
|
1612 | + } elseif (!isset($context['icon_sources'][$message['icon']])) { |
|
1613 | + $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1547 | 1614 | } |
1548 | - elseif (!isset($context['icon_sources'][$message['icon']])) |
|
1549 | - $context['icon_sources'][$message['icon']] = 'images_url'; |
|
1550 | 1615 | |
1551 | 1616 | // If you're a lazy bum, you probably didn't give a subject... |
1552 | 1617 | $message['subject'] = $message['subject'] != '' ? $message['subject'] : $txt['no_subject']; |
@@ -1571,8 +1636,7 @@ discard block |
||
1571 | 1636 | $memberContext[$message['id_member']]['email'] = $message['poster_email']; |
1572 | 1637 | $memberContext[$message['id_member']]['show_email'] = allowedTo('moderate_forum'); |
1573 | 1638 | $memberContext[$message['id_member']]['is_guest'] = true; |
1574 | - } |
|
1575 | - else |
|
1639 | + } else |
|
1576 | 1640 | { |
1577 | 1641 | // Define this here to make things a bit more readable |
1578 | 1642 | $can_view_warning = $context['user']['can_mod'] || allowedTo('view_warning_any') || ($message['id_member'] == $user_info['id'] && allowedTo('view_warning_own')); |
@@ -1595,8 +1659,9 @@ discard block |
||
1595 | 1659 | $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']); |
1596 | 1660 | |
1597 | 1661 | // If it's in the recycle bin we need to override whatever icon we did have. |
1598 | - if (!empty($board_info['recycle'])) |
|
1599 | - $message['icon'] = 'recycled'; |
|
1662 | + if (!empty($board_info['recycle'])) { |
|
1663 | + $message['icon'] = 'recycled'; |
|
1664 | + } |
|
1600 | 1665 | |
1601 | 1666 | require_once($sourcedir . '/Subs-Attachments.php'); |
1602 | 1667 | |
@@ -1640,32 +1705,36 @@ discard block |
||
1640 | 1705 | } |
1641 | 1706 | |
1642 | 1707 | // Are likes enable? |
1643 | - if (!empty($modSettings['enable_likes'])) |
|
1644 | - $output['likes'] = array( |
|
1708 | + if (!empty($modSettings['enable_likes'])) { |
|
1709 | + $output['likes'] = array( |
|
1645 | 1710 | 'count' => $message['likes'], |
1646 | 1711 | 'you' => in_array($message['id_msg'], $context['my_likes']), |
1647 | 1712 | 'can_like' => !$context['user']['is_guest'] && $message['id_member'] != $context['user']['id'] && !empty($context['can_like']), |
1648 | 1713 | ); |
1714 | + } |
|
1649 | 1715 | |
1650 | 1716 | // Is this user the message author? |
1651 | 1717 | $output['is_message_author'] = $message['id_member'] == $user_info['id']; |
1652 | - if (!empty($output['modified']['name'])) |
|
1653 | - $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1718 | + if (!empty($output['modified']['name'])) { |
|
1719 | + $output['modified']['last_edit_text'] = sprintf($txt['last_edit_by'], $output['modified']['time'], $output['modified']['name']); |
|
1720 | + } |
|
1654 | 1721 | |
1655 | 1722 | // Did they give a reason for editing? |
1656 | - if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) |
|
1657 | - $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1723 | + if (!empty($output['modified']['name']) && !empty($output['modified']['reason'])) { |
|
1724 | + $output['modified']['last_edit_text'] .= ' ' . sprintf($txt['last_edit_reason'], $output['modified']['reason']); |
|
1725 | + } |
|
1658 | 1726 | |
1659 | 1727 | // Any custom profile fields? |
1660 | - if (!empty($memberContext[$message['id_member']]['custom_fields'])) |
|
1661 | - foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1728 | + if (!empty($memberContext[$message['id_member']]['custom_fields'])) { |
|
1729 | + foreach ($memberContext[$message['id_member']]['custom_fields'] as $custom) |
|
1662 | 1730 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1731 | + } |
|
1663 | 1732 | |
1664 | - if (empty($options['view_newest_first'])) |
|
1665 | - $counter++; |
|
1666 | - |
|
1667 | - else |
|
1668 | - $counter--; |
|
1733 | + if (empty($options['view_newest_first'])) { |
|
1734 | + $counter++; |
|
1735 | + } else { |
|
1736 | + $counter--; |
|
1737 | + } |
|
1669 | 1738 | |
1670 | 1739 | call_integration_hook('integrate_prepare_display_context', array(&$output, &$message, $counter)); |
1671 | 1740 | |
@@ -1691,8 +1760,9 @@ discard block |
||
1691 | 1760 | */ |
1692 | 1761 | function approved_attach_sort($a, $b) |
1693 | 1762 | { |
1694 | - if ($a['is_approved'] == $b['is_approved']) |
|
1695 | - return 0; |
|
1763 | + if ($a['is_approved'] == $b['is_approved']) { |
|
1764 | + return 0; |
|
1765 | + } |
|
1696 | 1766 | |
1697 | 1767 | return $a['is_approved'] > $b['is_approved'] ? -1 : 1; |
1698 | 1768 | } |
@@ -1709,16 +1779,19 @@ discard block |
||
1709 | 1779 | |
1710 | 1780 | require_once($sourcedir . '/RemoveTopic.php'); |
1711 | 1781 | |
1712 | - if (empty($_REQUEST['msgs'])) |
|
1713 | - redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1782 | + if (empty($_REQUEST['msgs'])) { |
|
1783 | + redirectexit('topic=' . $topic . '.' . $_REQUEST['start']); |
|
1784 | + } |
|
1714 | 1785 | |
1715 | 1786 | $messages = array(); |
1716 | - foreach ($_REQUEST['msgs'] as $dummy) |
|
1717 | - $messages[] = (int) $dummy; |
|
1787 | + foreach ($_REQUEST['msgs'] as $dummy) { |
|
1788 | + $messages[] = (int) $dummy; |
|
1789 | + } |
|
1718 | 1790 | |
1719 | 1791 | // We are restoring messages. We handle this in another place. |
1720 | - if (isset($_REQUEST['restore_selected'])) |
|
1721 | - redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1792 | + if (isset($_REQUEST['restore_selected'])) { |
|
1793 | + redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
1794 | + } |
|
1722 | 1795 | if (isset($_REQUEST['split_selection'])) |
1723 | 1796 | { |
1724 | 1797 | $request = $smcFunc['db_query']('', ' |
@@ -1737,8 +1810,9 @@ discard block |
||
1737 | 1810 | } |
1738 | 1811 | |
1739 | 1812 | // Allowed to delete any message? |
1740 | - if (allowedTo('delete_any')) |
|
1741 | - $allowed_all = true; |
|
1813 | + if (allowedTo('delete_any')) { |
|
1814 | + $allowed_all = true; |
|
1815 | + } |
|
1742 | 1816 | // Allowed to delete replies to their messages? |
1743 | 1817 | elseif (allowedTo('delete_replies')) |
1744 | 1818 | { |
@@ -1755,13 +1829,14 @@ discard block |
||
1755 | 1829 | $smcFunc['db_free_result']($request); |
1756 | 1830 | |
1757 | 1831 | $allowed_all = $starter == $user_info['id']; |
1832 | + } else { |
|
1833 | + $allowed_all = false; |
|
1758 | 1834 | } |
1759 | - else |
|
1760 | - $allowed_all = false; |
|
1761 | 1835 | |
1762 | 1836 | // Make sure they're allowed to delete their own messages, if not any. |
1763 | - if (!$allowed_all) |
|
1764 | - isAllowedTo('delete_own'); |
|
1837 | + if (!$allowed_all) { |
|
1838 | + isAllowedTo('delete_own'); |
|
1839 | + } |
|
1765 | 1840 | |
1766 | 1841 | // Allowed to remove which messages? |
1767 | 1842 | $request = $smcFunc['db_query']('', ' |
@@ -1781,8 +1856,9 @@ discard block |
||
1781 | 1856 | $messages = array(); |
1782 | 1857 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1783 | 1858 | { |
1784 | - if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) |
|
1785 | - continue; |
|
1859 | + if (!$allowed_all && !empty($modSettings['edit_disable_time']) && $row['poster_time'] + $modSettings['edit_disable_time'] * 60 < time()) { |
|
1860 | + continue; |
|
1861 | + } |
|
1786 | 1862 | |
1787 | 1863 | $messages[$row['id_msg']] = array($row['subject'], $row['id_member']); |
1788 | 1864 | } |
@@ -1805,17 +1881,20 @@ discard block |
||
1805 | 1881 | foreach ($messages as $message => $info) |
1806 | 1882 | { |
1807 | 1883 | // Just skip the first message - if it's not the last. |
1808 | - if ($message == $first_message && $message != $last_message) |
|
1809 | - continue; |
|
1884 | + if ($message == $first_message && $message != $last_message) { |
|
1885 | + continue; |
|
1886 | + } |
|
1810 | 1887 | // If the first message is going then don't bother going back to the topic as we're effectively deleting it. |
1811 | - elseif ($message == $first_message) |
|
1812 | - $topicGone = true; |
|
1888 | + elseif ($message == $first_message) { |
|
1889 | + $topicGone = true; |
|
1890 | + } |
|
1813 | 1891 | |
1814 | 1892 | removeMessage($message); |
1815 | 1893 | |
1816 | 1894 | // Log this moderation action ;). |
1817 | - if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) |
|
1818 | - logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1895 | + if (allowedTo('delete_any') && (!allowedTo('delete_own') || $info[1] != $user_info['id'])) { |
|
1896 | + logAction('delete', array('topic' => $topic, 'subject' => $info[0], 'member' => $info[1], 'board' => $board)); |
|
1897 | + } |
|
1819 | 1898 | } |
1820 | 1899 | |
1821 | 1900 | redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | LEFT JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic) |
247 | 247 | WHERE t.id_topic IS NULL |
248 | 248 | GROUP BY m.id_topic, m.id_board', |
249 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
249 | + 'fix_processing' => function($row) use ($smcFunc) |
|
250 | 250 | { |
251 | 251 | global $salvageBoardID; |
252 | 252 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | // Remove all topics that have zero messages in the messages table. |
333 | 333 | 'fix_collect' => array( |
334 | 334 | 'index' => 'id_topic', |
335 | - 'process' => function ($topics) use ($smcFunc) |
|
335 | + 'process' => function($topics) use ($smcFunc) |
|
336 | 336 | { |
337 | 337 | $smcFunc['db_query']('', ' |
338 | 338 | DELETE FROM {db_prefix}topics |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | AND p.id_poll IS NULL |
370 | 370 | GROUP BY o.id_poll, t.id_topic, t.id_board, t.id_member_started, m.member_name |
371 | 371 | ', |
372 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
372 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
373 | 373 | { |
374 | 374 | global $salvageBoardID; |
375 | 375 | |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | LEFT JOIN {db_prefix}topics AS t ON (t.id_poll = p.id_poll) |
507 | 507 | WHERE p.id_poll BETWEEN {STEP_LOW} AND {STEP_HIGH} |
508 | 508 | AND t.id_poll IS NULL', |
509 | - 'fix_processing' => function ($row) use ($smcFunc, $txt) |
|
509 | + 'fix_processing' => function($row) use ($smcFunc, $txt) |
|
510 | 510 | { |
511 | 511 | global $salvageBoardID; |
512 | 512 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
618 | 618 | GROUP BY t.id_topic, t.id_first_msg, t.id_last_msg, t.approved, mf.approved |
619 | 619 | ORDER BY t.id_topic', |
620 | - 'fix_processing' => function ($row) use ($smcFunc) |
|
620 | + 'fix_processing' => function($row) use ($smcFunc) |
|
621 | 621 | { |
622 | 622 | $row['firstmsg_approved'] = (int) $row['firstmsg_approved']; |
623 | 623 | $row['myid_first_msg'] = (int) $row['myid_first_msg']; |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | ) |
647 | 647 | ); |
648 | 648 | }, |
649 | - 'message_function' => function ($row) use ($txt, &$context) |
|
649 | + 'message_function' => function($row) use ($txt, &$context) |
|
650 | 650 | { |
651 | 651 | // A pretend error? |
652 | 652 | if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
681 | 681 | GROUP BY t.id_topic, t.num_replies, mf.approved |
682 | 682 | ORDER BY t.id_topic', |
683 | - 'fix_processing' => function ($row) |
|
683 | + 'fix_processing' => function($row) |
|
684 | 684 | { |
685 | 685 | global $smcFunc; |
686 | 686 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | ) |
700 | 700 | ); |
701 | 701 | }, |
702 | - 'message_function' => function ($row) |
|
702 | + 'message_function' => function($row) |
|
703 | 703 | { |
704 | 704 | global $txt, $context; |
705 | 705 | |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | GROUP BY t.id_topic, t.unapproved_posts |
731 | 731 | HAVING unapproved_posts != COUNT(mu.id_msg) |
732 | 732 | ORDER BY t.id_topic', |
733 | - 'fix_processing' => function ($row) |
|
733 | + 'fix_processing' => function($row) |
|
734 | 734 | { |
735 | 735 | global $smcFunc; |
736 | 736 | $row['my_unapproved_posts'] = (int) $row['my_unapproved_posts']; |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | WHERE b.id_board IS NULL |
771 | 771 | AND t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
772 | 772 | GROUP BY t.id_board', |
773 | - 'fix_processing' => function ($row) |
|
773 | + 'fix_processing' => function($row) |
|
774 | 774 | { |
775 | 775 | global $smcFunc, $salvageCatID, $txt; |
776 | 776 | createSalvageArea(); |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | ORDER BY b.id_cat, b.id_board', |
818 | 818 | 'fix_collect' => array( |
819 | 819 | 'index' => 'id_cat', |
820 | - 'process' => function ($cats) |
|
820 | + 'process' => function($cats) |
|
821 | 821 | { |
822 | 822 | global $smcFunc, $salvageCatID; |
823 | 823 | createSalvageArea(); |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | // Last step-make sure all non-guest posters still exist. |
854 | 854 | 'fix_collect' => array( |
855 | 855 | 'index' => 'id_msg', |
856 | - 'process' => function ($msgs) |
|
856 | + 'process' => function($msgs) |
|
857 | 857 | { |
858 | 858 | global $smcFunc; |
859 | 859 | $smcFunc['db_query']('', ' |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | ORDER BY b.id_parent, b.id_board', |
881 | 881 | 'fix_collect' => array( |
882 | 882 | 'index' => 'id_parent', |
883 | - 'process' => function ($parents) |
|
883 | + 'process' => function($parents) |
|
884 | 884 | { |
885 | 885 | global $smcFunc, $salvageBoardID, $salvageCatID; |
886 | 886 | |
@@ -917,7 +917,7 @@ discard block |
||
917 | 917 | AND p.id_poll IS NULL', |
918 | 918 | 'fix_collect' => array( |
919 | 919 | 'index' => 'id_poll', |
920 | - 'process' => function ($polls) |
|
920 | + 'process' => function($polls) |
|
921 | 921 | { |
922 | 922 | global $smcFunc; |
923 | 923 | $smcFunc['db_query']('', ' |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | ORDER BY cal.id_topic', |
950 | 950 | 'fix_collect' => array( |
951 | 951 | 'index' => 'id_topic', |
952 | - 'process' => function ($events) |
|
952 | + 'process' => function($events) |
|
953 | 953 | { |
954 | 954 | global $smcFunc; |
955 | 955 | $smcFunc['db_query']('', ' |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | AND lt.id_member BETWEEN {STEP_LOW} AND {STEP_HIGH}', |
980 | 980 | 'fix_collect' => array( |
981 | 981 | 'index' => 'id_topic', |
982 | - 'process' => function ($topics) |
|
982 | + 'process' => function($topics) |
|
983 | 983 | { |
984 | 984 | global $smcFunc; |
985 | 985 | $smcFunc['db_query']('', ' |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | GROUP BY lt.id_member', |
1010 | 1010 | 'fix_collect' => array( |
1011 | 1011 | 'index' => 'id_member', |
1012 | - 'process' => function ($members) |
|
1012 | + 'process' => function($members) |
|
1013 | 1013 | { |
1014 | 1014 | global $smcFunc; |
1015 | 1015 | $smcFunc['db_query']('', ' |
@@ -1039,7 +1039,7 @@ discard block |
||
1039 | 1039 | GROUP BY lb.id_board', |
1040 | 1040 | 'fix_collect' => array( |
1041 | 1041 | 'index' => 'id_board', |
1042 | - 'process' => function ($boards) |
|
1042 | + 'process' => function($boards) |
|
1043 | 1043 | { |
1044 | 1044 | global $smcFunc; |
1045 | 1045 | $smcFunc['db_query']('', ' |
@@ -1069,7 +1069,7 @@ discard block |
||
1069 | 1069 | GROUP BY lb.id_member', |
1070 | 1070 | 'fix_collect' => array( |
1071 | 1071 | 'index' => 'id_member', |
1072 | - 'process' => function ($members) use ($smcFunc) |
|
1072 | + 'process' => function($members) use ($smcFunc) |
|
1073 | 1073 | { |
1074 | 1074 | $smcFunc['db_query']('', ' |
1075 | 1075 | DELETE FROM {db_prefix}log_boards |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | GROUP BY lmr.id_board', |
1099 | 1099 | 'fix_collect' => array( |
1100 | 1100 | 'index' => 'id_board', |
1101 | - 'process' => function ($boards) use ($smcFunc) |
|
1101 | + 'process' => function($boards) use ($smcFunc) |
|
1102 | 1102 | { |
1103 | 1103 | $smcFunc['db_query']('', ' |
1104 | 1104 | DELETE FROM {db_prefix}log_mark_read |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | GROUP BY lmr.id_member', |
1128 | 1128 | 'fix_collect' => array( |
1129 | 1129 | 'index' => 'id_member', |
1130 | - 'process' => function ($members) use ($smcFunc) |
|
1130 | + 'process' => function($members) use ($smcFunc) |
|
1131 | 1131 | { |
1132 | 1132 | $smcFunc['db_query']('', ' |
1133 | 1133 | DELETE FROM {db_prefix}log_mark_read |
@@ -1156,7 +1156,7 @@ discard block |
||
1156 | 1156 | GROUP BY pmr.id_pm', |
1157 | 1157 | 'fix_collect' => array( |
1158 | 1158 | 'index' => 'id_pm', |
1159 | - 'process' => function ($pms) use ($smcFunc) |
|
1159 | + 'process' => function($pms) use ($smcFunc) |
|
1160 | 1160 | { |
1161 | 1161 | $smcFunc['db_query']('', ' |
1162 | 1162 | DELETE FROM {db_prefix}pm_recipients |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | GROUP BY pmr.id_member', |
1187 | 1187 | 'fix_collect' => array( |
1188 | 1188 | 'index' => 'id_member', |
1189 | - 'process' => function ($members) |
|
1189 | + 'process' => function($members) |
|
1190 | 1190 | { |
1191 | 1191 | global $smcFunc; |
1192 | 1192 | $smcFunc['db_query']('', ' |
@@ -1216,7 +1216,7 @@ discard block |
||
1216 | 1216 | AND mem.id_member IS NULL', |
1217 | 1217 | 'fix_collect' => array( |
1218 | 1218 | 'index' => 'id_pm', |
1219 | - 'process' => function ($guestMessages) |
|
1219 | + 'process' => function($guestMessages) |
|
1220 | 1220 | { |
1221 | 1221 | global $smcFunc; |
1222 | 1222 | $smcFunc['db_query']('', ' |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | GROUP BY ln.id_member', |
1247 | 1247 | 'fix_collect' => array( |
1248 | 1248 | 'index' => 'id_member', |
1249 | - 'process' => function ($members) use ($smcFunc) |
|
1249 | + 'process' => function($members) use ($smcFunc) |
|
1250 | 1250 | { |
1251 | 1251 | $smcFunc['db_query']('', ' |
1252 | 1252 | DELETE FROM {db_prefix}log_notify |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | LEFT JOIN {db_prefix}log_search_subjects AS lss ON (lss.id_topic = t.id_topic) |
1274 | 1274 | WHERE t.id_topic BETWEEN {STEP_LOW} AND {STEP_HIGH} |
1275 | 1275 | AND lss.id_topic IS NULL', |
1276 | - 'fix_full_processing' => function ($result) |
|
1276 | + 'fix_full_processing' => function($result) |
|
1277 | 1277 | { |
1278 | 1278 | global $smcFunc; |
1279 | 1279 | |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | array('word', 'id_topic') |
1303 | 1303 | ); |
1304 | 1304 | }, |
1305 | - 'message_function' => function ($row) |
|
1305 | + 'message_function' => function($row) |
|
1306 | 1306 | { |
1307 | 1307 | global $txt, $context; |
1308 | 1308 | |
@@ -1330,7 +1330,7 @@ discard block |
||
1330 | 1330 | AND t.id_topic IS NULL', |
1331 | 1331 | 'fix_collect' => array( |
1332 | 1332 | 'index' => 'id_topic', |
1333 | - 'process' => function ($deleteTopics) |
|
1333 | + 'process' => function($deleteTopics) |
|
1334 | 1334 | { |
1335 | 1335 | global $smcFunc; |
1336 | 1336 | $smcFunc['db_query']('', ' |
@@ -1360,7 +1360,7 @@ discard block |
||
1360 | 1360 | AND mem.id_member IS NULL', |
1361 | 1361 | 'fix_collect' => array( |
1362 | 1362 | 'index' => 'id_member', |
1363 | - 'process' => function ($members) |
|
1363 | + 'process' => function($members) |
|
1364 | 1364 | { |
1365 | 1365 | global $smcFunc; |
1366 | 1366 | $smcFunc['db_query']('', ' |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | AND p.id_poll IS NULL', |
1390 | 1390 | 'fix_collect' => array( |
1391 | 1391 | 'index' => 'id_poll', |
1392 | - 'process' => function ($polls) |
|
1392 | + 'process' => function($polls) |
|
1393 | 1393 | { |
1394 | 1394 | global $smcFunc; |
1395 | 1395 | $smcFunc['db_query']('', ' |
@@ -1418,7 +1418,7 @@ discard block |
||
1418 | 1418 | AND lrc.id_report IS NULL', |
1419 | 1419 | 'fix_collect' => array( |
1420 | 1420 | 'index' => 'id_report', |
1421 | - 'process' => function ($reports) |
|
1421 | + 'process' => function($reports) |
|
1422 | 1422 | { |
1423 | 1423 | global $smcFunc; |
1424 | 1424 | $smcFunc['db_query']('', ' |
@@ -1447,7 +1447,7 @@ discard block |
||
1447 | 1447 | AND lr.id_report IS NULL', |
1448 | 1448 | 'fix_collect' => array( |
1449 | 1449 | 'index' => 'id_report', |
1450 | - 'process' => function ($reports) |
|
1450 | + 'process' => function($reports) |
|
1451 | 1451 | { |
1452 | 1452 | global $smcFunc; |
1453 | 1453 | $smcFunc['db_query']('', ' |
@@ -1477,7 +1477,7 @@ discard block |
||
1477 | 1477 | GROUP BY lgr.id_member', |
1478 | 1478 | 'fix_collect' => array( |
1479 | 1479 | 'index' => 'id_member', |
1480 | - 'process' => function ($members) |
|
1480 | + 'process' => function($members) |
|
1481 | 1481 | { |
1482 | 1482 | global $smcFunc; |
1483 | 1483 | $smcFunc['db_query']('', ' |
@@ -1507,7 +1507,7 @@ discard block |
||
1507 | 1507 | GROUP BY lgr.id_group', |
1508 | 1508 | 'fix_collect' => array( |
1509 | 1509 | 'index' => 'id_group', |
1510 | - 'process' => function ($groups) |
|
1510 | + 'process' => function($groups) |
|
1511 | 1511 | { |
1512 | 1512 | global $smcFunc; |
1513 | 1513 | $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,14 +71,14 @@ 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 | 78 | |
76 | 79 | // Need a token here. |
77 | 80 | createToken('admin-repairboards', 'request'); |
78 | - } |
|
79 | - else |
|
81 | + } else |
|
80 | 82 | { |
81 | 83 | // Validate the token, create a new one and tell the not done template. |
82 | 84 | validateToken('admin-repairboards', 'request'); |
@@ -134,16 +136,19 @@ discard block |
||
134 | 136 | |
135 | 137 | // More time, I need more time! |
136 | 138 | @set_time_limit(600); |
137 | - if (function_exists('apache_reset_timeout')) |
|
138 | - @apache_reset_timeout(); |
|
139 | + if (function_exists('apache_reset_timeout')) { |
|
140 | + @apache_reset_timeout(); |
|
141 | + } |
|
139 | 142 | |
140 | 143 | // Errr, wait. How much time has this taken already? |
141 | - if (!$force && (time() - $time_start) < 3) |
|
142 | - return; |
|
144 | + if (!$force && (time() - $time_start) < 3) { |
|
145 | + return; |
|
146 | + } |
|
143 | 147 | |
144 | 148 | // Restore the query cache if interested. |
145 | - if (!empty($db_temp_cache)) |
|
146 | - $db_cache = $db_temp_cache; |
|
149 | + if (!empty($db_temp_cache)) { |
|
150 | + $db_cache = $db_temp_cache; |
|
151 | + } |
|
147 | 152 | |
148 | 153 | $context['continue_get_data'] = '?action=admin;area=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'] . ';' . $context['session_var'] . '=' . $context['session_id']; |
149 | 154 | $context['page_title'] = $txt['not_done_title']; |
@@ -152,10 +157,11 @@ discard block |
||
152 | 157 | $context['sub_template'] = 'not_done'; |
153 | 158 | |
154 | 159 | // Change these two if more steps are added! |
155 | - if (empty($max_substep)) |
|
156 | - $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
157 | - else |
|
158 | - $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
160 | + if (empty($max_substep)) { |
|
161 | + $context['continue_percent'] = round(($_GET['step'] * 100) / $context['total_steps']); |
|
162 | + } else { |
|
163 | + $context['continue_percent'] = round((($_GET['step'] + ($_GET['substep'] / $max_substep)) * 100) / $context['total_steps']); |
|
164 | + } |
|
159 | 165 | |
160 | 166 | // Never more than 100%! |
161 | 167 | $context['continue_percent'] = min($context['continue_percent'], 100); |
@@ -624,8 +630,9 @@ discard block |
||
624 | 630 | $row['myid_last_msg'] = (int) $row['myid_last_msg']; |
625 | 631 | |
626 | 632 | // Not really a problem? |
627 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
628 | - return false; |
|
633 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
634 | + return false; |
|
635 | + } |
|
629 | 636 | |
630 | 637 | $memberStartedID = (int) getMsgMemberID($row['myid_first_msg']); |
631 | 638 | $memberUpdatedID = (int) getMsgMemberID($row['myid_last_msg']); |
@@ -649,15 +656,19 @@ discard block |
||
649 | 656 | 'message_function' => function ($row) use ($txt, &$context) |
650 | 657 | { |
651 | 658 | // A pretend error? |
652 | - if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) |
|
653 | - return false; |
|
659 | + if ($row['id_first_msg'] == $row['myid_first_msg'] && $row['id_last_msg'] == $row['myid_last_msg'] && $row['approved'] == $row['firstmsg_approved']) { |
|
660 | + return false; |
|
661 | + } |
|
654 | 662 | |
655 | - if ($row['id_first_msg'] != $row['myid_first_msg']) |
|
656 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
657 | - if ($row['id_last_msg'] != $row['myid_last_msg']) |
|
658 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
659 | - if ($row['approved'] != $row['firstmsg_approved']) |
|
660 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
663 | + if ($row['id_first_msg'] != $row['myid_first_msg']) { |
|
664 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_1'], $row['id_topic'], $row['id_first_msg']); |
|
665 | + } |
|
666 | + if ($row['id_last_msg'] != $row['myid_last_msg']) { |
|
667 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_2'], $row['id_topic'], $row['id_last_msg']); |
|
668 | + } |
|
669 | + if ($row['approved'] != $row['firstmsg_approved']) { |
|
670 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_5'], $row['id_topic']); |
|
671 | + } |
|
661 | 672 | |
662 | 673 | return true; |
663 | 674 | }, |
@@ -686,8 +697,9 @@ discard block |
||
686 | 697 | $row['my_num_replies'] = (int) $row['my_num_replies']; |
687 | 698 | |
688 | 699 | // Not really a problem? |
689 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
690 | - return false; |
|
700 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
701 | + return false; |
|
702 | + } |
|
691 | 703 | |
692 | 704 | $smcFunc['db_query']('', ' |
693 | 705 | UPDATE {db_prefix}topics |
@@ -704,11 +716,13 @@ discard block |
||
704 | 716 | global $txt, $context; |
705 | 717 | |
706 | 718 | // Just joking? |
707 | - if ($row['my_num_replies'] == $row['num_replies']) |
|
708 | - return false; |
|
719 | + if ($row['my_num_replies'] == $row['num_replies']) { |
|
720 | + return false; |
|
721 | + } |
|
709 | 722 | |
710 | - if ($row['num_replies'] != $row['my_num_replies']) |
|
711 | - $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
723 | + if ($row['num_replies'] != $row['my_num_replies']) { |
|
724 | + $context['repair_errors'][] = sprintf($txt['repair_stats_topics_3'], $row['id_topic'], $row['num_replies']); |
|
725 | + } |
|
712 | 726 | |
713 | 727 | return true; |
714 | 728 | }, |
@@ -1280,8 +1294,9 @@ discard block |
||
1280 | 1294 | $inserts = array(); |
1281 | 1295 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
1282 | 1296 | { |
1283 | - foreach (text2words($row['subject']) as $word) |
|
1284 | - $inserts[] = array($word, $row['id_topic']); |
|
1297 | + foreach (text2words($row['subject']) as $word) { |
|
1298 | + $inserts[] = array($word, $row['id_topic']); |
|
1299 | + } |
|
1285 | 1300 | if (count($inserts) > 500) |
1286 | 1301 | { |
1287 | 1302 | $smcFunc['db_insert']('ignore', |
@@ -1294,13 +1309,14 @@ discard block |
||
1294 | 1309 | } |
1295 | 1310 | } |
1296 | 1311 | |
1297 | - if (!empty($inserts)) |
|
1298 | - $smcFunc['db_insert']('ignore', |
|
1312 | + if (!empty($inserts)) { |
|
1313 | + $smcFunc['db_insert']('ignore', |
|
1299 | 1314 | '{db_prefix}log_search_subjects', |
1300 | 1315 | array('word' => 'string', 'id_topic' => 'int'), |
1301 | 1316 | $inserts, |
1302 | 1317 | array('word', 'id_topic') |
1303 | 1318 | ); |
1319 | + } |
|
1304 | 1320 | }, |
1305 | 1321 | 'message_function' => function ($row) |
1306 | 1322 | { |
@@ -1559,8 +1575,9 @@ discard block |
||
1559 | 1575 | $current_step++; |
1560 | 1576 | |
1561 | 1577 | // Already done this? |
1562 | - if ($_GET['step'] > $current_step) |
|
1563 | - continue; |
|
1578 | + if ($_GET['step'] > $current_step) { |
|
1579 | + continue; |
|
1580 | + } |
|
1564 | 1581 | |
1565 | 1582 | // If we're fixing it but it ain't broke why try? |
1566 | 1583 | if ($do_fix && !in_array($error_type, $to_fix)) |
@@ -1589,14 +1606,16 @@ discard block |
||
1589 | 1606 | while (!$done) |
1590 | 1607 | { |
1591 | 1608 | // Make sure there's at least one ID to test. |
1592 | - if (isset($test['substeps']) && empty($step_max)) |
|
1593 | - break; |
|
1609 | + if (isset($test['substeps']) && empty($step_max)) { |
|
1610 | + break; |
|
1611 | + } |
|
1594 | 1612 | |
1595 | 1613 | // What is the testing query (Changes if we are testing or fixing) |
1596 | - if (!$do_fix) |
|
1597 | - $test_query = 'check_query'; |
|
1598 | - else |
|
1599 | - $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
1614 | + if (!$do_fix) { |
|
1615 | + $test_query = 'check_query'; |
|
1616 | + } else { |
|
1617 | + $test_query = isset($test['fix_query']) ? 'fix_query' : 'check_query'; |
|
1618 | + } |
|
1600 | 1619 | |
1601 | 1620 | // Do the test... |
1602 | 1621 | $request = $smcFunc['db_query']('', |
@@ -1606,10 +1625,11 @@ discard block |
||
1606 | 1625 | ); |
1607 | 1626 | |
1608 | 1627 | // Does it need a fix? |
1609 | - if (!empty($test['check_type']) && $test['check_type'] == 'count') |
|
1610 | - list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
1611 | - else |
|
1612 | - $needs_fix = $smcFunc['db_num_rows']($request); |
|
1628 | + if (!empty($test['check_type']) && $test['check_type'] == 'count') { |
|
1629 | + list ($needs_fix) = $smcFunc['db_fetch_row']($request); |
|
1630 | + } else { |
|
1631 | + $needs_fix = $smcFunc['db_num_rows']($request); |
|
1632 | + } |
|
1613 | 1633 | |
1614 | 1634 | $total_queries++; |
1615 | 1635 | |
@@ -1621,8 +1641,9 @@ discard block |
||
1621 | 1641 | // Assume need to fix. |
1622 | 1642 | $found_errors = true; |
1623 | 1643 | |
1624 | - if (isset($test['message'])) |
|
1625 | - $context['repair_errors'][] = $txt[$test['message']]; |
|
1644 | + if (isset($test['message'])) { |
|
1645 | + $context['repair_errors'][] = $txt[$test['message']]; |
|
1646 | + } |
|
1626 | 1647 | |
1627 | 1648 | // One per row! |
1628 | 1649 | elseif (isset($test['messages'])) |
@@ -1632,10 +1653,11 @@ discard block |
||
1632 | 1653 | $variables = $test['messages']; |
1633 | 1654 | foreach ($variables as $k => $v) |
1634 | 1655 | { |
1635 | - if ($k == 0 && isset($txt[$v])) |
|
1636 | - $variables[$k] = $txt[$v]; |
|
1637 | - elseif ($k > 0 && isset($row[$v])) |
|
1638 | - $variables[$k] = $row[$v]; |
|
1656 | + if ($k == 0 && isset($txt[$v])) { |
|
1657 | + $variables[$k] = $txt[$v]; |
|
1658 | + } elseif ($k > 0 && isset($row[$v])) { |
|
1659 | + $variables[$k] = $row[$v]; |
|
1660 | + } |
|
1639 | 1661 | } |
1640 | 1662 | $context['repair_errors'][] = call_user_func_array('sprintf', $variables); |
1641 | 1663 | } |
@@ -1646,13 +1668,15 @@ discard block |
||
1646 | 1668 | { |
1647 | 1669 | // Find out if there are actually errors. |
1648 | 1670 | $found_errors = false; |
1649 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1650 | - $found_errors |= $test['message_function']($row); |
|
1671 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1672 | + $found_errors |= $test['message_function']($row); |
|
1673 | + } |
|
1651 | 1674 | } |
1652 | 1675 | |
1653 | 1676 | // Actually have something to fix? |
1654 | - if ($found_errors) |
|
1655 | - $to_fix[] = $error_type; |
|
1677 | + if ($found_errors) { |
|
1678 | + $to_fix[] = $error_type; |
|
1679 | + } |
|
1656 | 1680 | } |
1657 | 1681 | |
1658 | 1682 | // We want to fix, we need to fix - so work out what exactly to do! |
@@ -1662,8 +1686,9 @@ discard block |
||
1662 | 1686 | if (isset($test['fix_collect'])) |
1663 | 1687 | { |
1664 | 1688 | $ids = array(); |
1665 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1666 | - $ids[] = $row[$test['fix_collect']['index']]; |
|
1689 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1690 | + $ids[] = $row[$test['fix_collect']['index']]; |
|
1691 | + } |
|
1667 | 1692 | if (!empty($ids)) |
1668 | 1693 | { |
1669 | 1694 | // Fix it! |
@@ -1672,30 +1697,34 @@ discard block |
||
1672 | 1697 | } |
1673 | 1698 | |
1674 | 1699 | // Simply executing a fix it query? |
1675 | - elseif (isset($test['fix_it_query'])) |
|
1676 | - $smcFunc['db_query']('', |
|
1700 | + elseif (isset($test['fix_it_query'])) { |
|
1701 | + $smcFunc['db_query']('', |
|
1677 | 1702 | $test['fix_it_query'], |
1678 | 1703 | array( |
1679 | 1704 | ) |
1680 | 1705 | ); |
1706 | + } |
|
1681 | 1707 | |
1682 | 1708 | // Do we have some processing to do? |
1683 | 1709 | elseif (isset($test['fix_processing'])) |
1684 | 1710 | { |
1685 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1686 | - $test['fix_processing']($row); |
|
1711 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1712 | + $test['fix_processing']($row); |
|
1713 | + } |
|
1687 | 1714 | } |
1688 | 1715 | |
1689 | 1716 | // What about the full set of processing? |
1690 | - elseif (isset($test['fix_full_processing'])) |
|
1691 | - $test['fix_full_processing']($request); |
|
1717 | + elseif (isset($test['fix_full_processing'])) { |
|
1718 | + $test['fix_full_processing']($request); |
|
1719 | + } |
|
1692 | 1720 | |
1693 | 1721 | // Do we have other things we need to fix as a result? |
1694 | 1722 | if (!empty($test['force_fix'])) |
1695 | 1723 | { |
1696 | - foreach ($test['force_fix'] as $item) |
|
1697 | - if (!in_array($item, $to_fix)) |
|
1724 | + foreach ($test['force_fix'] as $item) { |
|
1725 | + if (!in_array($item, $to_fix)) |
|
1698 | 1726 | $to_fix[] = $item; |
1727 | + } |
|
1699 | 1728 | } |
1700 | 1729 | } |
1701 | 1730 | } |
@@ -1713,16 +1742,17 @@ discard block |
||
1713 | 1742 | if ($_GET['substep'] <= $step_max) |
1714 | 1743 | { |
1715 | 1744 | pauseRepairProcess($to_fix, $error_type, $step_max); |
1745 | + } else { |
|
1746 | + $done = true; |
|
1716 | 1747 | } |
1717 | - else |
|
1718 | - $done = true; |
|
1748 | + } else { |
|
1749 | + $done = true; |
|
1719 | 1750 | } |
1720 | - else |
|
1721 | - $done = true; |
|
1722 | 1751 | |
1723 | 1752 | // Don't allow more than 1000 queries at a time. |
1724 | - if ($total_queries >= 1000) |
|
1725 | - pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
1753 | + if ($total_queries >= 1000) { |
|
1754 | + pauseRepairProcess($to_fix, $error_type, $step_max, true); |
|
1755 | + } |
|
1726 | 1756 | } |
1727 | 1757 | |
1728 | 1758 | // Keep going. |
@@ -1735,8 +1765,9 @@ discard block |
||
1735 | 1765 | if ($do_fix) |
1736 | 1766 | { |
1737 | 1767 | $key = array_search($error_type, $to_fix); |
1738 | - if ($key !== false && isset($to_fix[$key])) |
|
1739 | - unset($to_fix[$key]); |
|
1768 | + if ($key !== false && isset($to_fix[$key])) { |
|
1769 | + unset($to_fix[$key]); |
|
1770 | + } |
|
1740 | 1771 | } |
1741 | 1772 | |
1742 | 1773 | // Are we done? |
@@ -1759,10 +1790,11 @@ discard block |
||
1759 | 1790 | static $createOnce = false; |
1760 | 1791 | |
1761 | 1792 | // Have we already created it? |
1762 | - if ($createOnce) |
|
1763 | - return; |
|
1764 | - else |
|
1765 | - $createOnce = true; |
|
1793 | + if ($createOnce) { |
|
1794 | + return; |
|
1795 | + } else { |
|
1796 | + $createOnce = true; |
|
1797 | + } |
|
1766 | 1798 | |
1767 | 1799 | // Back to the forum's default language. |
1768 | 1800 | loadLanguage('Admin', $language); |
@@ -1777,8 +1809,9 @@ discard block |
||
1777 | 1809 | 'cat_name' => $txt['salvaged_category_name'], |
1778 | 1810 | ) |
1779 | 1811 | ); |
1780 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1781 | - list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
1812 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1813 | + list ($salvageCatID) = $smcFunc['db_fetch_row']($result); |
|
1814 | + } |
|
1782 | 1815 | $smcFunc['db_free_result']($result); |
1783 | 1816 | |
1784 | 1817 | if (empty($salvageCatID)) |
@@ -1810,8 +1843,9 @@ discard block |
||
1810 | 1843 | 'board_name' => $txt['salvaged_board_name'], |
1811 | 1844 | ) |
1812 | 1845 | ); |
1813 | - if ($smcFunc['db_num_rows']($result) != 0) |
|
1814 | - list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
1846 | + if ($smcFunc['db_num_rows']($result) != 0) { |
|
1847 | + list ($salvageBoardID) = $smcFunc['db_fetch_row']($result); |
|
1848 | + } |
|
1815 | 1849 | $smcFunc['db_free_result']($result); |
1816 | 1850 | |
1817 | 1851 | if (empty($salvageBoardID)) |
@@ -61,9 +61,10 @@ discard block |
||
61 | 61 | ', implode(', ', $context['administrators']); |
62 | 62 | |
63 | 63 | // If we have lots of admins... don't show them all. |
64 | - if (!empty($context['more_admins_link'])) |
|
65 | - echo ' |
|
64 | + if (!empty($context['more_admins_link'])) { |
|
65 | + echo ' |
|
66 | 66 | (', $context['more_admins_link'], ')'; |
67 | + } |
|
67 | 68 | |
68 | 69 | echo ' |
69 | 70 | </div><!-- #version_details --> |
@@ -80,17 +81,19 @@ discard block |
||
80 | 81 | foreach ($area['areas'] as $item_id => $item) |
81 | 82 | { |
82 | 83 | // No point showing the 'home' page here, we're already on it! |
83 | - if ($area_id == 'forum' && $item_id == 'index') |
|
84 | - continue; |
|
84 | + if ($area_id == 'forum' && $item_id == 'index') { |
|
85 | + continue; |
|
86 | + } |
|
85 | 87 | |
86 | 88 | $url = isset($item['url']) ? $item['url'] : $scripturl . '?action=admin;area=' . $item_id . (!empty($context[$context['admin_menu_name']]['extra_parameters']) ? $context[$context['admin_menu_name']]['extra_parameters'] : ''); |
87 | 89 | |
88 | - if (!empty($item['icon_file'])) |
|
89 | - echo ' |
|
90 | + if (!empty($item['icon_file'])) { |
|
91 | + echo ' |
|
90 | 92 | <a href="', $url, '" class="admin_group', !empty($item['inactive']) ? ' inactive' : '', '"><img class="large_admin_menu_icon_file" src="', $item['icon_file'], '" alt="">', $item['label'], '</a>'; |
91 | - else |
|
92 | - echo ' |
|
93 | + } else { |
|
94 | + echo ' |
|
93 | 95 | <a href="', $url, '"><span class="large_', $item['icon_class'], !empty($item['inactive']) ? ' inactive' : '', '"></span>', $item['label'], '</a>'; |
96 | + } |
|
94 | 97 | } |
95 | 98 | |
96 | 99 | echo ' |
@@ -98,10 +101,11 @@ discard block |
||
98 | 101 | } |
99 | 102 | |
100 | 103 | // The below functions include all the scripts needed from the simplemachines.org site. The language and format are passed for internationalization. |
101 | - if (empty($modSettings['disable_smf_js'])) |
|
102 | - echo ' |
|
104 | + if (empty($modSettings['disable_smf_js'])) { |
|
105 | + echo ' |
|
103 | 106 | <script src="', $scripturl, '?action=viewsmfile;filename=current-version.js"></script> |
104 | 107 | <script src="', $scripturl, '?action=viewsmfile;filename=latest-news.js"></script>'; |
108 | + } |
|
105 | 109 | |
106 | 110 | // This sets the announcements and current versions themselves ;). |
107 | 111 | echo ' |
@@ -178,9 +182,10 @@ discard block |
||
178 | 182 | <em>', $version['version'], '</em>'; |
179 | 183 | |
180 | 184 | // more details for this item, show them a link |
181 | - if ($context['can_admin'] && isset($version['more'])) |
|
182 | - echo |
|
185 | + if ($context['can_admin'] && isset($version['more'])) { |
|
186 | + echo |
|
183 | 187 | ' <a href="', $scripturl, $version['more'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['version_check_more'], '</a>'; |
188 | + } |
|
184 | 189 | echo ' |
185 | 190 | <br>'; |
186 | 191 | } |
@@ -211,21 +216,23 @@ discard block |
||
211 | 216 | |
212 | 217 | foreach ($context['credits'] as $section) |
213 | 218 | { |
214 | - if (isset($section['pretext'])) |
|
215 | - echo ' |
|
219 | + if (isset($section['pretext'])) { |
|
220 | + echo ' |
|
216 | 221 | <p>', $section['pretext'], '</p> |
217 | 222 | <hr>'; |
223 | + } |
|
218 | 224 | |
219 | 225 | echo ' |
220 | 226 | <dl>'; |
221 | 227 | |
222 | 228 | foreach ($section['groups'] as $group) |
223 | 229 | { |
224 | - if (isset($group['title'])) |
|
225 | - echo ' |
|
230 | + if (isset($group['title'])) { |
|
231 | + echo ' |
|
226 | 232 | <dt> |
227 | 233 | <strong>', $group['title'], ':</strong> |
228 | 234 | </dt>'; |
235 | + } |
|
229 | 236 | |
230 | 237 | echo ' |
231 | 238 | <dd>', implode(', ', $group['members']), '</dd>'; |
@@ -234,10 +241,11 @@ discard block |
||
234 | 241 | echo ' |
235 | 242 | </dl>'; |
236 | 243 | |
237 | - if (isset($section['posttext'])) |
|
238 | - echo ' |
|
244 | + if (isset($section['posttext'])) { |
|
245 | + echo ' |
|
239 | 246 | <hr> |
240 | 247 | <p>', $section['posttext'], '</p>'; |
248 | + } |
|
241 | 249 | } |
242 | 250 | |
243 | 251 | echo ' |
@@ -252,9 +260,10 @@ discard block |
||
252 | 260 | smfSupportVersions.forum = "', $context['forum_version'], '";'; |
253 | 261 | |
254 | 262 | // Don't worry, none of this is logged, it's just used to give information that might be of use. |
255 | - foreach ($context['current_versions'] as $variable => $version) |
|
256 | - echo ' |
|
263 | + foreach ($context['current_versions'] as $variable => $version) { |
|
264 | + echo ' |
|
257 | 265 | smfSupportVersions.', $variable, ' = "', $version['version'], '";'; |
266 | + } |
|
258 | 267 | |
259 | 268 | // Now we just have to include the script and wait ;). |
260 | 269 | echo ' |
@@ -350,8 +359,8 @@ discard block |
||
350 | 359 | <tbody>'; |
351 | 360 | |
352 | 361 | // Loop through every source file displaying its version - using javascript. |
353 | - foreach ($context['file_versions'] as $filename => $version) |
|
354 | - echo ' |
|
362 | + foreach ($context['file_versions'] as $filename => $version) { |
|
363 | + echo ' |
|
355 | 364 | <tr class="windowbg"> |
356 | 365 | <td class="half_table"> |
357 | 366 | ', $filename, ' |
@@ -363,6 +372,7 @@ discard block |
||
363 | 372 | <em id="currentSources', $filename, '">??</em> |
364 | 373 | </td> |
365 | 374 | </tr>'; |
375 | + } |
|
366 | 376 | |
367 | 377 | // Default template files. |
368 | 378 | echo ' |
@@ -388,8 +398,8 @@ discard block |
||
388 | 398 | <table id="Default" class="table_grid"> |
389 | 399 | <tbody>'; |
390 | 400 | |
391 | - foreach ($context['default_template_versions'] as $filename => $version) |
|
392 | - echo ' |
|
401 | + foreach ($context['default_template_versions'] as $filename => $version) { |
|
402 | + echo ' |
|
393 | 403 | <tr class="windowbg"> |
394 | 404 | <td class="half_table"> |
395 | 405 | ', $filename, ' |
@@ -401,6 +411,7 @@ discard block |
||
401 | 411 | <em id="currentDefault', $filename, '">??</em> |
402 | 412 | </td> |
403 | 413 | </tr>'; |
414 | + } |
|
404 | 415 | |
405 | 416 | // Now the language files... |
406 | 417 | echo ' |
@@ -428,8 +439,8 @@ discard block |
||
428 | 439 | |
429 | 440 | foreach ($context['default_language_versions'] as $language => $files) |
430 | 441 | { |
431 | - foreach ($files as $filename => $version) |
|
432 | - echo ' |
|
442 | + foreach ($files as $filename => $version) { |
|
443 | + echo ' |
|
433 | 444 | <tr class="windowbg"> |
434 | 445 | <td class="half_table"> |
435 | 446 | ', $filename, '.<em>', $language, '</em>.php |
@@ -441,6 +452,7 @@ discard block |
||
441 | 452 | <em id="current', $filename, '.', $language, '">??</em> |
442 | 453 | </td> |
443 | 454 | </tr>'; |
455 | + } |
|
444 | 456 | } |
445 | 457 | |
446 | 458 | echo ' |
@@ -470,8 +482,8 @@ discard block |
||
470 | 482 | <table id="Templates" class="table_grid"> |
471 | 483 | <tbody>'; |
472 | 484 | |
473 | - foreach ($context['template_versions'] as $filename => $version) |
|
474 | - echo ' |
|
485 | + foreach ($context['template_versions'] as $filename => $version) { |
|
486 | + echo ' |
|
475 | 487 | <tr class="windowbg"> |
476 | 488 | <td class="half_table"> |
477 | 489 | ', $filename, ' |
@@ -483,6 +495,7 @@ discard block |
||
483 | 495 | <em id="currentTemplates', $filename, '">??</em> |
484 | 496 | </td> |
485 | 497 | </tr>'; |
498 | + } |
|
486 | 499 | |
487 | 500 | echo ' |
488 | 501 | </tbody> |
@@ -512,8 +525,8 @@ discard block |
||
512 | 525 | <table id="Tasks" class="table_grid"> |
513 | 526 | <tbody>'; |
514 | 527 | |
515 | - foreach ($context['tasks_versions'] as $filename => $version) |
|
516 | - echo ' |
|
528 | + foreach ($context['tasks_versions'] as $filename => $version) { |
|
529 | + echo ' |
|
517 | 530 | <tr class="windowbg"> |
518 | 531 | <td class="half_table"> |
519 | 532 | ', $filename, ' |
@@ -525,6 +538,7 @@ discard block |
||
525 | 538 | <em id="currentTasks', $filename, '">??</em> |
526 | 539 | </td> |
527 | 540 | </tr>'; |
541 | + } |
|
528 | 542 | |
529 | 543 | echo ' |
530 | 544 | </tbody> |
@@ -565,9 +579,10 @@ discard block |
||
565 | 579 | { |
566 | 580 | global $context, $scripturl, $txt, $modSettings; |
567 | 581 | |
568 | - if (!empty($context['saved_successful'])) |
|
569 | - echo ' |
|
582 | + if (!empty($context['saved_successful'])) { |
|
583 | + echo ' |
|
570 | 584 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
585 | + } |
|
571 | 586 | |
572 | 587 | // First section is for adding/removing words from the censored list. |
573 | 588 | echo ' |
@@ -581,11 +596,12 @@ discard block |
||
581 | 596 | <p>', $txt['admin_censored_where'], '</p>'; |
582 | 597 | |
583 | 598 | // Show text boxes for censoring [bad ] => [good ]. |
584 | - foreach ($context['censored_words'] as $vulgar => $proper) |
|
585 | - echo ' |
|
599 | + foreach ($context['censored_words'] as $vulgar => $proper) { |
|
600 | + echo ' |
|
586 | 601 | <div class="block"> |
587 | 602 | <input type="text" name="censor_vulgar[]" value="', $vulgar, '" size="30"> => <input type="text" name="censor_proper[]" value="', $proper, '" size="30"> |
588 | 603 | </div>'; |
604 | + } |
|
589 | 605 | |
590 | 606 | // Now provide a way to censor more words. |
591 | 607 | echo ' |
@@ -658,27 +674,30 @@ discard block |
||
658 | 674 | <div class="windowbg"> |
659 | 675 | ', $txt['not_done_reason']; |
660 | 676 | |
661 | - if (!empty($context['continue_percent'])) |
|
662 | - echo ' |
|
677 | + if (!empty($context['continue_percent'])) { |
|
678 | + echo ' |
|
663 | 679 | <div class="progress_bar"> |
664 | 680 | <span>', $context['continue_percent'], '%</span> |
665 | 681 | <div class="bar" style="width: ', $context['continue_percent'], '%;"></div> |
666 | 682 | </div>'; |
683 | + } |
|
667 | 684 | |
668 | - if (!empty($context['substep_enabled'])) |
|
669 | - echo ' |
|
685 | + if (!empty($context['substep_enabled'])) { |
|
686 | + echo ' |
|
670 | 687 | <div class="progress_bar progress_blue"> |
671 | 688 | <span>', $context['substep_title'], ' (', $context['substep_continue_percent'], '%)</span> |
672 | 689 | <div class="bar" style="width: ', $context['substep_continue_percent'], '%;"></div> |
673 | 690 | </div>'; |
691 | + } |
|
674 | 692 | |
675 | 693 | echo ' |
676 | 694 | <form action="', $scripturl, $context['continue_get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">'; |
677 | 695 | |
678 | 696 | // Do we have a token? |
679 | - if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var'])) |
|
680 | - echo ' |
|
697 | + if (isset($context['not_done_token']) && isset($context[$context['not_done_token'] . '_token'], $context[$context['not_done_token'] . '_token_var'])) { |
|
698 | + echo ' |
|
681 | 699 | <input type="hidden" name="', $context[$context['not_done_token'] . '_token_var'], '" value="', $context[$context['not_done_token'] . '_token'], '">'; |
700 | + } |
|
682 | 701 | |
683 | 702 | echo ' |
684 | 703 | <input type="submit" name="cont" value="', $txt['not_done_continue'], '" class="button"> |
@@ -711,34 +730,39 @@ discard block |
||
711 | 730 | { |
712 | 731 | global $context, $txt, $scripturl; |
713 | 732 | |
714 | - if (!empty($context['saved_successful'])) |
|
715 | - echo ' |
|
733 | + if (!empty($context['saved_successful'])) { |
|
734 | + echo ' |
|
716 | 735 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
717 | - elseif (!empty($context['saved_failed'])) |
|
718 | - echo ' |
|
736 | + } elseif (!empty($context['saved_failed'])) { |
|
737 | + echo ' |
|
719 | 738 | <div class="errorbox">', sprintf($txt['settings_not_saved'], $context['saved_failed']), '</div>'; |
739 | + } |
|
720 | 740 | |
721 | - if (!empty($context['settings_pre_javascript'])) |
|
722 | - echo ' |
|
741 | + if (!empty($context['settings_pre_javascript'])) { |
|
742 | + echo ' |
|
723 | 743 | <script>', $context['settings_pre_javascript'], '</script>'; |
744 | + } |
|
724 | 745 | |
725 | - if (!empty($context['settings_insert_above'])) |
|
726 | - echo $context['settings_insert_above']; |
|
746 | + if (!empty($context['settings_insert_above'])) { |
|
747 | + echo $context['settings_insert_above']; |
|
748 | + } |
|
727 | 749 | |
728 | 750 | echo ' |
729 | 751 | <form id="admin_form_wrapper" action="', $context['post_url'], '" method="post" accept-charset="', $context['character_set'], '"', !empty($context['force_form_onsubmit']) ? ' onsubmit="' . $context['force_form_onsubmit'] . '"' : '', '>'; |
730 | 752 | |
731 | 753 | // Is there a custom title? |
732 | - if (isset($context['settings_title'])) |
|
733 | - echo ' |
|
754 | + if (isset($context['settings_title'])) { |
|
755 | + echo ' |
|
734 | 756 | <div class="cat_bar"> |
735 | 757 | <h3 class="catbg">', $context['settings_title'], '</h3> |
736 | 758 | </div>'; |
759 | + } |
|
737 | 760 | |
738 | 761 | // Have we got a message to display? |
739 | - if (!empty($context['settings_message'])) |
|
740 | - echo ' |
|
762 | + if (!empty($context['settings_message'])) { |
|
763 | + echo ' |
|
741 | 764 | <div class="information">', $context['settings_message'], '</div>'; |
765 | + } |
|
742 | 766 | |
743 | 767 | // Now actually loop through all the variables. |
744 | 768 | $is_open = false; |
@@ -791,8 +815,9 @@ discard block |
||
791 | 815 | // Hang about? Are you pulling my leg - a callback?! |
792 | 816 | if (is_array($config_var) && $config_var['type'] == 'callback') |
793 | 817 | { |
794 | - if (function_exists('template_callback_' . $config_var['name'])) |
|
795 | - call_user_func('template_callback_' . $config_var['name']); |
|
818 | + if (function_exists('template_callback_' . $config_var['name'])) { |
|
819 | + call_user_func('template_callback_' . $config_var['name']); |
|
820 | + } |
|
796 | 821 | |
797 | 822 | continue; |
798 | 823 | } |
@@ -822,9 +847,10 @@ discard block |
||
822 | 847 | $text_types = array('color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'); |
823 | 848 | |
824 | 849 | // Show the [?] button. |
825 | - if ($config_var['help']) |
|
826 | - echo ' |
|
850 | + if ($config_var['help']) { |
|
851 | + echo ' |
|
827 | 852 | <a id="setting_', $config_var['name'], '_help" href="', $scripturl, '?action=helpadmin;help=', $config_var['help'], '" onclick="return reqOverlayDiv(this.href);"><span class="generic_icons help" title="', $txt['help'], '"></span></a> '; |
853 | + } |
|
828 | 854 | |
829 | 855 | echo ' |
830 | 856 | <a id="setting_', $config_var['name'], '"></a> <span', ($config_var['disabled'] ? ' style="color: #777777;"' : ($config_var['invalid'] ? ' class="error"' : '')), '><label for="', $config_var['name'], '">', $config_var['label'], '</label>', $subtext, ($config_var['type'] == 'password' ? '<br><em>' . $txt['admin_confirm_password'] . '</em>' : ''), '</span> |
@@ -833,23 +859,26 @@ discard block |
||
833 | 859 | $config_var['preinput']; |
834 | 860 | |
835 | 861 | // Show a check box. |
836 | - if ($config_var['type'] == 'check') |
|
837 | - echo ' |
|
862 | + if ($config_var['type'] == 'check') { |
|
863 | + echo ' |
|
838 | 864 | <input type="checkbox"', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '"', ($config_var['value'] ? ' checked' : ''), ' value="1">'; |
865 | + } |
|
839 | 866 | // Escape (via htmlspecialchars.) the text box. |
840 | - elseif ($config_var['type'] == 'password') |
|
841 | - echo ' |
|
867 | + elseif ($config_var['type'] == 'password') { |
|
868 | + echo ' |
|
842 | 869 | <input type="password"', $disabled, $javascript, ' name="', $config_var['name'], '[0]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), ' value="*#fakepass#*" onfocus="this.value = \'\'; this.form.', $config_var['name'], '.disabled = false;"><br> |
843 | 870 | <input type="password" disabled id="', $config_var['name'], '" name="', $config_var['name'], '[1]"', ($config_var['size'] ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
871 | + } |
|
844 | 872 | // Show a selection box. |
845 | 873 | elseif ($config_var['type'] == 'select') |
846 | 874 | { |
847 | 875 | echo ' |
848 | 876 | <select name="', $config_var['name'], '" id="', $config_var['name'], '" ', $javascript, $disabled, (!empty($config_var['multiple']) ? ' multiple="multiple"' : ''), (!empty($config_var['multiple']) && !empty($config_var['size']) ? ' size="' . $config_var['size'] . '"' : ''), '>'; |
849 | 877 | |
850 | - foreach ($config_var['data'] as $option) |
|
851 | - echo ' |
|
878 | + foreach ($config_var['data'] as $option) { |
|
879 | + echo ' |
|
852 | 880 | <option value="', $option[0], '"', (!empty($config_var['value']) && ($option[0] == $config_var['value'] || (!empty($config_var['multiple']) && in_array($option[0], $config_var['value']))) ? ' selected' : ''), '>', $option[1], '</option>'; |
881 | + } |
|
853 | 882 | echo ' |
854 | 883 | </select>'; |
855 | 884 | } |
@@ -866,16 +895,18 @@ discard block |
||
866 | 895 | |
867 | 896 | foreach ($context['board_list'] as $id_cat => $cat) |
868 | 897 | { |
869 | - if (!$first) |
|
870 | - echo ' |
|
898 | + if (!$first) { |
|
899 | + echo ' |
|
871 | 900 | <hr>'; |
901 | + } |
|
872 | 902 | echo ' |
873 | 903 | <strong>', $cat['name'], '</strong> |
874 | 904 | <ul>'; |
875 | 905 | |
876 | - foreach ($cat['boards'] as $id_board => $brd) |
|
877 | - echo ' |
|
906 | + foreach ($cat['boards'] as $id_board => $brd) { |
|
907 | + echo ' |
|
878 | 908 | <li><label><input type="checkbox" name="', $config_var['name'], '[', $brd['id'], ']" value="1"', in_array($brd['id'], $config_var['value']) ? ' checked' : '', '> ', $brd['child_level'] > 0 ? str_repeat(' ', $brd['child_level']) : '', $brd['name'], '</label></li>'; |
909 | + } |
|
879 | 910 | |
880 | 911 | echo ' |
881 | 912 | </ul>'; |
@@ -885,12 +916,14 @@ discard block |
||
885 | 916 | </fieldset>'; |
886 | 917 | } |
887 | 918 | // Text area? |
888 | - elseif ($config_var['type'] == 'large_text') |
|
889 | - echo ' |
|
919 | + elseif ($config_var['type'] == 'large_text') { |
|
920 | + echo ' |
|
890 | 921 | <textarea rows="', (!empty($config_var['size']) ? $config_var['size'] : (!empty($config_var['rows']) ? $config_var['rows'] : 4)), '" cols="', (!empty($config_var['cols']) ? $config_var['cols'] : 30), '" ', $javascript, $disabled, ' name="', $config_var['name'], '" id="', $config_var['name'], '">', $config_var['value'], '</textarea>'; |
922 | + } |
|
891 | 923 | // Permission group? |
892 | - elseif ($config_var['type'] == 'permissions') |
|
893 | - theme_inline_permissions($config_var['name']); |
|
924 | + elseif ($config_var['type'] == 'permissions') { |
|
925 | + theme_inline_permissions($config_var['name']); |
|
926 | + } |
|
894 | 927 | |
895 | 928 | // BBC selection? |
896 | 929 | elseif ($config_var['type'] == 'bbc') |
@@ -902,22 +935,24 @@ discard block |
||
902 | 935 | |
903 | 936 | foreach ($context['bbc_columns'] as $bbcColumn) |
904 | 937 | { |
905 | - foreach ($bbcColumn as $bbcTag) |
|
906 | - echo ' |
|
938 | + foreach ($bbcColumn as $bbcTag) { |
|
939 | + echo ' |
|
907 | 940 | <li class="list_bbc floatleft"> |
908 | 941 | <input type="checkbox" name="', $config_var['name'], '_enabledTags[]" id="tag_', $config_var['name'], '_', $bbcTag['tag'], '" value="', $bbcTag['tag'], '"', !in_array($bbcTag['tag'], $context['bbc_sections'][$config_var['name']]['disabled']) ? ' checked' : '', '> <label for="tag_', $config_var['name'], '_', $bbcTag['tag'], '">', $bbcTag['tag'], '</label>', $bbcTag['show_help'] ? ' (<a href="' . $scripturl . '?action=helpadmin;help=tag_' . $bbcTag['tag'] . '" onclick="return reqOverlayDiv(this.href);">?</a>)' : '', ' |
909 | 942 | </li>'; |
943 | + } |
|
910 | 944 | } |
911 | 945 | echo ' </ul> |
912 | 946 | <input type="checkbox" id="bbc_', $config_var['name'], '_select_all" onclick="invertAll(this, this.form, \'', $config_var['name'], '_enabledTags\');"', $context['bbc_sections'][$config_var['name']]['all_selected'] ? ' checked' : '', '> <label for="bbc_', $config_var['name'], '_select_all"><em>', $txt['bbcTagsToUse_select_all'], '</em></label> |
913 | 947 | </fieldset>'; |
914 | 948 | } |
915 | 949 | // A simple message? |
916 | - elseif ($config_var['type'] == 'var_message') |
|
917 | - echo ' |
|
950 | + elseif ($config_var['type'] == 'var_message') { |
|
951 | + echo ' |
|
918 | 952 | <div', !empty($config_var['name']) ? ' id="' . $config_var['name'] . '"' : '', '> |
919 | 953 | ', $config_var['var_message'], ' |
920 | 954 | </div>'; |
955 | + } |
|
921 | 956 | // Assume it must be a text box |
922 | 957 | else |
923 | 958 | { |
@@ -942,61 +977,69 @@ discard block |
||
942 | 977 | ' . $config_var['postinput'] : '',' |
943 | 978 | </dd>'; |
944 | 979 | } |
945 | - } |
|
946 | - else |
|
980 | + } else |
|
947 | 981 | { |
948 | 982 | // Just show a separator. |
949 | - if ($config_var == '') |
|
950 | - echo ' |
|
983 | + if ($config_var == '') { |
|
984 | + echo ' |
|
951 | 985 | </dl> |
952 | 986 | <hr> |
953 | 987 | <dl class="settings">'; |
954 | - else |
|
955 | - echo ' |
|
988 | + } else { |
|
989 | + echo ' |
|
956 | 990 | <dd> |
957 | 991 | <strong>' . $config_var . '</strong> |
958 | 992 | </dd>'; |
993 | + } |
|
959 | 994 | } |
960 | 995 | } |
961 | 996 | |
962 | - if ($is_open) |
|
963 | - echo ' |
|
997 | + if ($is_open) { |
|
998 | + echo ' |
|
964 | 999 | </dl>'; |
1000 | + } |
|
965 | 1001 | |
966 | - if (empty($context['settings_save_dont_show'])) |
|
967 | - echo ' |
|
1002 | + if (empty($context['settings_save_dont_show'])) { |
|
1003 | + echo ' |
|
968 | 1004 | <input type="submit" value="', $txt['save'], '"', (!empty($context['save_disabled']) ? ' disabled' : ''), (!empty($context['settings_save_onclick']) ? ' onclick="' . $context['settings_save_onclick'] . '"' : ''), ' class="button">'; |
1005 | + } |
|
969 | 1006 | |
970 | - if ($is_open) |
|
971 | - echo ' |
|
1007 | + if ($is_open) { |
|
1008 | + echo ' |
|
972 | 1009 | </div><!-- .windowbg -->'; |
1010 | + } |
|
973 | 1011 | |
974 | 1012 | |
975 | 1013 | // At least one token has to be used! |
976 | - if (isset($context['admin-ssc_token'])) |
|
977 | - echo ' |
|
1014 | + if (isset($context['admin-ssc_token'])) { |
|
1015 | + echo ' |
|
978 | 1016 | <input type="hidden" name="', $context['admin-ssc_token_var'], '" value="', $context['admin-ssc_token'], '">'; |
1017 | + } |
|
979 | 1018 | |
980 | - if (isset($context['admin-dbsc_token'])) |
|
981 | - echo ' |
|
1019 | + if (isset($context['admin-dbsc_token'])) { |
|
1020 | + echo ' |
|
982 | 1021 | <input type="hidden" name="', $context['admin-dbsc_token_var'], '" value="', $context['admin-dbsc_token'], '">'; |
1022 | + } |
|
983 | 1023 | |
984 | - if (isset($context['admin-mp_token'])) |
|
985 | - echo ' |
|
1024 | + if (isset($context['admin-mp_token'])) { |
|
1025 | + echo ' |
|
986 | 1026 | <input type="hidden" name="', $context['admin-mp_token_var'], '" value="', $context['admin-mp_token'], '">'; |
1027 | + } |
|
987 | 1028 | |
988 | 1029 | echo ' |
989 | 1030 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
990 | 1031 | </form>'; |
991 | 1032 | |
992 | - if (!empty($context['settings_post_javascript'])) |
|
993 | - echo ' |
|
1033 | + if (!empty($context['settings_post_javascript'])) { |
|
1034 | + echo ' |
|
994 | 1035 | <script> |
995 | 1036 | ', $context['settings_post_javascript'], ' |
996 | 1037 | </script>'; |
1038 | + } |
|
997 | 1039 | |
998 | - if (!empty($context['settings_insert_below'])) |
|
999 | - echo $context['settings_insert_below']; |
|
1040 | + if (!empty($context['settings_insert_below'])) { |
|
1041 | + echo $context['settings_insert_below']; |
|
1042 | + } |
|
1000 | 1043 | |
1001 | 1044 | // We may have added a board listing. If we did, we need to make it work. |
1002 | 1045 | addInlineJavascript(' |
@@ -1019,9 +1062,10 @@ discard block |
||
1019 | 1062 | { |
1020 | 1063 | global $context, $txt; |
1021 | 1064 | |
1022 | - if (!empty($context['saved_successful'])) |
|
1023 | - echo ' |
|
1065 | + if (!empty($context['saved_successful'])) { |
|
1066 | + echo ' |
|
1024 | 1067 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
1068 | + } |
|
1025 | 1069 | |
1026 | 1070 | // Standard fields. |
1027 | 1071 | template_show_list('standard_profile_fields'); |
@@ -1055,11 +1099,12 @@ discard block |
||
1055 | 1099 | { |
1056 | 1100 | loadLanguage('Errors'); |
1057 | 1101 | |
1058 | - if (isset($txt['custom_option_' . $_GET['msg']])) |
|
1059 | - echo ' |
|
1102 | + if (isset($txt['custom_option_' . $_GET['msg']])) { |
|
1103 | + echo ' |
|
1060 | 1104 | <div class="errorbox">', |
1061 | 1105 | $txt['custom_option_' . $_GET['msg']], ' |
1062 | 1106 | </div>'; |
1107 | + } |
|
1063 | 1108 | } |
1064 | 1109 | |
1065 | 1110 | echo ' |
@@ -1125,9 +1170,10 @@ discard block |
||
1125 | 1170 | <dd> |
1126 | 1171 | <select name="placement" id="placement">'; |
1127 | 1172 | |
1128 | - foreach ($context['cust_profile_fields_placement'] as $order => $name) |
|
1129 | - echo ' |
|
1173 | + foreach ($context['cust_profile_fields_placement'] as $order => $name) { |
|
1174 | + echo ' |
|
1130 | 1175 | <option value="', $order, '"', $context['field']['placement'] == $order ? ' selected' : '', '>', $txt['custom_profile_placement_' . $name], '</option>'; |
1176 | + } |
|
1131 | 1177 | |
1132 | 1178 | echo ' |
1133 | 1179 | </select> |
@@ -1151,9 +1197,10 @@ discard block |
||
1151 | 1197 | <dd> |
1152 | 1198 | <select name="field_type" id="field_type" onchange="updateInputBoxes();">'; |
1153 | 1199 | |
1154 | - foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) |
|
1155 | - echo ' |
|
1200 | + foreach (array('text', 'textarea', 'select', 'radio', 'check') as $field_type) { |
|
1201 | + echo ' |
|
1156 | 1202 | <option value="', $field_type, '"', $context['field']['type'] == $field_type ? ' selected' : '', '>', $txt['custom_profile_type_' . $field_type], '</option>'; |
1203 | + } |
|
1157 | 1204 | |
1158 | 1205 | echo ' |
1159 | 1206 | </select> |
@@ -1185,9 +1232,10 @@ discard block |
||
1185 | 1232 | </dt> |
1186 | 1233 | <dd id="options_dd">'; |
1187 | 1234 | |
1188 | - foreach ($context['field']['options'] as $k => $option) |
|
1189 | - echo ' |
|
1235 | + foreach ($context['field']['options'] as $k => $option) { |
|
1236 | + echo ' |
|
1190 | 1237 | ', $k == 0 ? '' : '<br>', '<input type="radio" name="default_select" value="', $k, '"', $context['field']['default_select'] == $option ? ' checked' : '', '><input type="text" name="select_option[', $k, ']" value="', $option, '">'; |
1238 | + } |
|
1191 | 1239 | |
1192 | 1240 | echo ' |
1193 | 1241 | <span id="addopt"></span> |
@@ -1251,9 +1299,10 @@ discard block |
||
1251 | 1299 | </fieldset> |
1252 | 1300 | <input type="submit" name="save" value="', $txt['save'], '" class="button">'; |
1253 | 1301 | |
1254 | - if ($context['fid']) |
|
1255 | - echo ' |
|
1302 | + if ($context['fid']) { |
|
1303 | + echo ' |
|
1256 | 1304 | <input type="submit" name="delete" value="', $txt['delete'], '" data-confirm="', $txt['custom_edit_delete_sure'], '" class="button you_sure">'; |
1305 | + } |
|
1257 | 1306 | |
1258 | 1307 | echo ' |
1259 | 1308 | </div><!-- .windowbg --> |
@@ -1299,8 +1348,7 @@ discard block |
||
1299 | 1348 | <p class="centertext"> |
1300 | 1349 | <strong>', $txt['admin_search_results_none'], '</strong> |
1301 | 1350 | </p>'; |
1302 | - } |
|
1303 | - else |
|
1351 | + } else |
|
1304 | 1352 | { |
1305 | 1353 | echo ' |
1306 | 1354 | <ol class="search_results">'; |
@@ -1327,9 +1375,10 @@ discard block |
||
1327 | 1375 | <li> |
1328 | 1376 | <a href="', $result['url'], '"><strong>', $result['name'], '</strong></a> [', isset($txt['admin_search_section_' . $result['type']]) ? $txt['admin_search_section_' . $result['type']] : $result['type'], ']'; |
1329 | 1377 | |
1330 | - if ($result['help']) |
|
1331 | - echo ' |
|
1378 | + if ($result['help']) { |
|
1379 | + echo ' |
|
1332 | 1380 | <p class="double_height">', $result['help'], '</p>'; |
1381 | + } |
|
1333 | 1382 | |
1334 | 1383 | echo ' |
1335 | 1384 | </li>'; |
@@ -1369,10 +1418,11 @@ discard block |
||
1369 | 1418 | <strong>', $txt['setup_verification_answer'], '</strong> |
1370 | 1419 | </dd>'; |
1371 | 1420 | |
1372 | - if (!empty($context['qa_by_lang'][$lang_id])) |
|
1373 | - foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1421 | + if (!empty($context['qa_by_lang'][$lang_id])) { |
|
1422 | + foreach ($context['qa_by_lang'][$lang_id] as $q_id) |
|
1374 | 1423 | { |
1375 | 1424 | $question = $context['question_answers'][$q_id]; |
1425 | + } |
|
1376 | 1426 | |
1377 | 1427 | echo ' |
1378 | 1428 | <dt> |
@@ -1380,9 +1430,10 @@ discard block |
||
1380 | 1430 | </dt> |
1381 | 1431 | <dd>'; |
1382 | 1432 | |
1383 | - foreach ($question['answers'] as $answer) |
|
1384 | - echo ' |
|
1433 | + foreach ($question['answers'] as $answer) { |
|
1434 | + echo ' |
|
1385 | 1435 | <input type="text" name="answer[', $lang_id, '][', $q_id, '][]" value="', $answer, '" size="50" class="verification_answer">'; |
1436 | + } |
|
1386 | 1437 | |
1387 | 1438 | echo ' |
1388 | 1439 | <div class="qa_add_answer"><a href="javascript:void(0);">[ ', $txt['setup_verification_add_answer'], ' ]</a></div> |
@@ -1420,11 +1471,12 @@ discard block |
||
1420 | 1471 | ', $txt['errors_found'], ': |
1421 | 1472 | <ul>'; |
1422 | 1473 | |
1423 | - foreach ($context['repair_errors'] as $error) |
|
1424 | - echo ' |
|
1474 | + foreach ($context['repair_errors'] as $error) { |
|
1475 | + echo ' |
|
1425 | 1476 | <li> |
1426 | 1477 | ', $error, ' |
1427 | 1478 | </li>'; |
1479 | + } |
|
1428 | 1480 | |
1429 | 1481 | echo ' |
1430 | 1482 | </ul> |
@@ -1434,15 +1486,14 @@ discard block |
||
1434 | 1486 | <p class="padding"> |
1435 | 1487 | <strong><a href="', $scripturl, '?action=admin;area=repairboards;fixErrors;', $context['session_var'], '=', $context['session_id'], ';', $context['admin-repairboards_token_var'], '=', $context['admin-repairboards_token'], '">', $txt['yes'], '</a> - <a href="', $scripturl, '?action=admin;area=maintain">', $txt['no'], '</a></strong> |
1436 | 1488 | </p>'; |
1437 | - } |
|
1438 | - else |
|
1439 | - echo ' |
|
1489 | + } else { |
|
1490 | + echo ' |
|
1440 | 1491 | <p>', $txt['maintain_no_errors'], '</p> |
1441 | 1492 | <p class="padding"> |
1442 | 1493 | <a href="', $scripturl, '?action=admin;area=maintain;sa=routine">', $txt['maintain_return'], '</a> |
1443 | 1494 | </p>'; |
1444 | - } |
|
1445 | - else |
|
1495 | + } |
|
1496 | + } else |
|
1446 | 1497 | { |
1447 | 1498 | if (!empty($context['redirect_to_recount'])) |
1448 | 1499 | { |
@@ -1455,8 +1506,7 @@ discard block |
||
1455 | 1506 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
1456 | 1507 | <input type="submit" name="recount" id="recount_now" value="', $txt['errors_recount_now'], '"> |
1457 | 1508 | </form>'; |
1458 | - } |
|
1459 | - else |
|
1509 | + } else |
|
1460 | 1510 | { |
1461 | 1511 | echo ' |
1462 | 1512 | <p>', $txt['errors_fixed'], '</p> |
@@ -1546,9 +1596,10 @@ discard block |
||
1546 | 1596 | <tr class="windowbg"> |
1547 | 1597 | <td class="equal_table">', $key, '</td>'; |
1548 | 1598 | |
1549 | - foreach ($setting as $key_lm => $value) |
|
1550 | - echo ' |
|
1599 | + foreach ($setting as $key_lm => $value) { |
|
1600 | + echo ' |
|
1551 | 1601 | <td class="equal_table">', $value, '</td>'; |
1602 | + } |
|
1552 | 1603 | |
1553 | 1604 | echo ' |
1554 | 1605 | </tr>'; |
@@ -1608,8 +1659,8 @@ discard block |
||
1608 | 1659 | { |
1609 | 1660 | global $context, $txt; |
1610 | 1661 | |
1611 | - if ($context['user']['is_admin']) |
|
1612 | - echo ' |
|
1662 | + if ($context['user']['is_admin']) { |
|
1663 | + echo ' |
|
1613 | 1664 | <span class="floatright admin_search"> |
1614 | 1665 | <span class="generic_icons filter centericon"></span> |
1615 | 1666 | <input type="search" name="search_term" placeholder="', $txt['admin_search'], '"> |
@@ -1620,6 +1671,7 @@ discard block |
||
1620 | 1671 | </select> |
1621 | 1672 | <input type="submit" name="search_go" id="search_go" value="', $txt['admin_search_go'], '" class="button"> |
1622 | 1673 | </span>'; |
1623 | -} |
|
1674 | + } |
|
1675 | + } |
|
1624 | 1676 | |
1625 | 1677 | ?> |
1626 | 1678 | \ No newline at end of file |