@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | * @version 2.1 Beta 4 |
16 | 16 | */ |
17 | 17 | |
18 | -if (!defined('SMF')) |
|
18 | +if (!defined('SMF')) { |
|
19 | 19 | die('No direct access...'); |
20 | +} |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * This helps organize things... |
@@ -37,13 +38,14 @@ discard block |
||
37 | 38 | |
38 | 39 | loadLanguage('PersonalMessage+Drafts'); |
39 | 40 | |
40 | - if (!isset($_REQUEST['xml'])) |
|
41 | - loadTemplate('PersonalMessage'); |
|
41 | + if (!isset($_REQUEST['xml'])) { |
|
42 | + loadTemplate('PersonalMessage'); |
|
43 | + } |
|
42 | 44 | |
43 | 45 | // Load up the members maximum message capacity. |
44 | - if ($user_info['is_admin']) |
|
45 | - $context['message_limit'] = 0; |
|
46 | - elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
46 | + if ($user_info['is_admin']) { |
|
47 | + $context['message_limit'] = 0; |
|
48 | + } elseif (($context['message_limit'] = cache_get_data('msgLimit:' . $user_info['id'], 360)) === null) |
|
47 | 49 | { |
48 | 50 | // @todo Why do we do this? It seems like if they have any limit we should use it. |
49 | 51 | $request = $smcFunc['db_query']('', ' |
@@ -78,8 +80,9 @@ discard block |
||
78 | 80 | } |
79 | 81 | |
80 | 82 | // a previous message was sent successfully? show a small indication. |
81 | - if (isset($_GET['done']) && ($_GET['done'] == 'sent')) |
|
82 | - $context['pm_sent'] = true; |
|
83 | + if (isset($_GET['done']) && ($_GET['done'] == 'sent')) { |
|
84 | + $context['pm_sent'] = true; |
|
85 | + } |
|
83 | 86 | |
84 | 87 | $context['labels'] = array(); |
85 | 88 | |
@@ -210,11 +213,11 @@ discard block |
||
210 | 213 | { |
211 | 214 | $_REQUEST['sa'] = ''; |
212 | 215 | MessageFolder(); |
213 | - } |
|
214 | - else |
|
216 | + } else |
|
215 | 217 | { |
216 | - if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') |
|
217 | - messageIndexBar($_REQUEST['sa']); |
|
218 | + if (!isset($_REQUEST['xml']) && $_REQUEST['sa'] != 'popup') { |
|
219 | + messageIndexBar($_REQUEST['sa']); |
|
220 | + } |
|
218 | 221 | |
219 | 222 | call_helper($subActions[$_REQUEST['sa']]); |
220 | 223 | } |
@@ -291,16 +294,17 @@ discard block |
||
291 | 294 | ); |
292 | 295 | |
293 | 296 | // Handle labels. |
294 | - if (empty($context['currently_using_labels'])) |
|
295 | - unset($pm_areas['labels']); |
|
296 | - else |
|
297 | + if (empty($context['currently_using_labels'])) { |
|
298 | + unset($pm_areas['labels']); |
|
299 | + } else |
|
297 | 300 | { |
298 | 301 | // Note we send labels by id as it will have less problems in the querystring. |
299 | 302 | $unread_in_labels = 0; |
300 | 303 | foreach ($context['labels'] as $label) |
301 | 304 | { |
302 | - if ($label['id'] == -1) |
|
303 | - continue; |
|
305 | + if ($label['id'] == -1) { |
|
306 | + continue; |
|
307 | + } |
|
304 | 308 | |
305 | 309 | // Count the amount of unread items in labels. |
306 | 310 | $unread_in_labels += $label['unread_messages']; |
@@ -314,8 +318,9 @@ discard block |
||
314 | 318 | ); |
315 | 319 | } |
316 | 320 | |
317 | - if (!empty($unread_in_labels)) |
|
318 | - $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
321 | + if (!empty($unread_in_labels)) { |
|
322 | + $pm_areas['labels']['title'] .= ' <span class="amt">' . $unread_in_labels . '</span>'; |
|
323 | + } |
|
319 | 324 | } |
320 | 325 | |
321 | 326 | $pm_areas['folders']['areas']['inbox']['unread_messages'] = &$context['labels'][-1]['unread_messages']; |
@@ -353,8 +358,9 @@ discard block |
||
353 | 358 | unset($pm_areas); |
354 | 359 | |
355 | 360 | // No menu means no access. |
356 | - if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) |
|
357 | - fatal_lang_error('no_access', false); |
|
361 | + if (!$pm_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
362 | + fatal_lang_error('no_access', false); |
|
363 | + } |
|
358 | 364 | |
359 | 365 | // Make a note of the Unique ID for this menu. |
360 | 366 | $context['pm_menu_id'] = $context['max_menu_id']; |
@@ -365,9 +371,10 @@ discard block |
||
365 | 371 | $context['menu_item_selected'] = $current_area; |
366 | 372 | |
367 | 373 | // Set the template for this area and add the profile layer. |
368 | - if (!isset($_REQUEST['xml'])) |
|
369 | - $context['template_layers'][] = 'pm'; |
|
370 | -} |
|
374 | + if (!isset($_REQUEST['xml'])) { |
|
375 | + $context['template_layers'][] = 'pm'; |
|
376 | + } |
|
377 | + } |
|
371 | 378 | |
372 | 379 | /** |
373 | 380 | * The popup for when we ask for the popup from the user. |
@@ -399,8 +406,9 @@ discard block |
||
399 | 406 | ) |
400 | 407 | ); |
401 | 408 | $pms = array(); |
402 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
403 | - $pms[] = $row[0]; |
|
409 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
410 | + $pms[] = $row[0]; |
|
411 | + } |
|
404 | 412 | $smcFunc['db_free_result']($request); |
405 | 413 | |
406 | 414 | if (!empty($pms)) |
@@ -428,8 +436,9 @@ discard block |
||
428 | 436 | ); |
429 | 437 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
430 | 438 | { |
431 | - if (!empty($row['id_member_from'])) |
|
432 | - $senders[] = $row['id_member_from']; |
|
439 | + if (!empty($row['id_member_from'])) { |
|
440 | + $senders[] = $row['id_member_from']; |
|
441 | + } |
|
433 | 442 | |
434 | 443 | $row['replied_to_you'] = $row['id_pm'] != $row['id_pm_head']; |
435 | 444 | $row['time'] = timeformat($row['timestamp']); |
@@ -439,13 +448,15 @@ discard block |
||
439 | 448 | $smcFunc['db_free_result']($request); |
440 | 449 | |
441 | 450 | $senders = loadMemberData($senders); |
442 | - foreach ($senders as $member) |
|
443 | - loadMemberContext($member); |
|
451 | + foreach ($senders as $member) { |
|
452 | + loadMemberContext($member); |
|
453 | + } |
|
444 | 454 | |
445 | 455 | // Having loaded everyone, attach them to the PMs. |
446 | - foreach ($context['unread_pms'] as $id_pm => $details) |
|
447 | - if (!empty($memberContext[$details['id_member_from']])) |
|
456 | + foreach ($context['unread_pms'] as $id_pm => $details) { |
|
457 | + if (!empty($memberContext[$details['id_member_from']])) |
|
448 | 458 | $context['unread_pms'][$id_pm]['member'] = &$memberContext[$details['id_member_from']]; |
459 | + } |
|
449 | 460 | } |
450 | 461 | } |
451 | 462 | |
@@ -465,12 +476,13 @@ discard block |
||
465 | 476 | } |
466 | 477 | |
467 | 478 | // Make sure the starting location is valid. |
468 | - if (isset($_GET['start']) && $_GET['start'] != 'new') |
|
469 | - $_GET['start'] = (int) $_GET['start']; |
|
470 | - elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) |
|
471 | - $_GET['start'] = 0; |
|
472 | - else |
|
473 | - $_GET['start'] = 'new'; |
|
479 | + if (isset($_GET['start']) && $_GET['start'] != 'new') { |
|
480 | + $_GET['start'] = (int) $_GET['start']; |
|
481 | + } elseif (!isset($_GET['start']) && !empty($options['view_newest_pm_first'])) { |
|
482 | + $_GET['start'] = 0; |
|
483 | + } else { |
|
484 | + $_GET['start'] = 'new'; |
|
485 | + } |
|
474 | 486 | |
475 | 487 | // Set up some basic theme stuff. |
476 | 488 | $context['from_or_to'] = $context['folder'] != 'sent' ? 'from' : 'to'; |
@@ -487,8 +499,7 @@ discard block |
||
487 | 499 | { |
488 | 500 | $labelQuery = ' |
489 | 501 | AND pmr.in_inbox = 1'; |
490 | - } |
|
491 | - elseif ($context['folder'] != 'sent') |
|
502 | + } elseif ($context['folder'] != 'sent') |
|
492 | 503 | { |
493 | 504 | $labelJoin = ' |
494 | 505 | INNER JOIN {db_prefix}pm_labeled_messages AS pl ON (pl.id_pm = pmr.id_pm)'; |
@@ -530,22 +541,24 @@ discard block |
||
530 | 541 | $txt['delete_all'] = str_replace('PMBOX', $pmbox, $txt['delete_all']); |
531 | 542 | |
532 | 543 | // Now, build the link tree! |
533 | - if ($context['current_label_id'] == -1) |
|
534 | - $context['linktree'][] = array( |
|
544 | + if ($context['current_label_id'] == -1) { |
|
545 | + $context['linktree'][] = array( |
|
535 | 546 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'], |
536 | 547 | 'name' => $pmbox |
537 | 548 | ); |
549 | + } |
|
538 | 550 | |
539 | 551 | // Build it further for a label. |
540 | - if ($context['current_label_id'] != -1) |
|
541 | - $context['linktree'][] = array( |
|
552 | + if ($context['current_label_id'] != -1) { |
|
553 | + $context['linktree'][] = array( |
|
542 | 554 | 'url' => $scripturl . '?action=pm;f=' . $context['folder'] . ';l=' . $context['current_label_id'], |
543 | 555 | 'name' => $txt['pm_current_label'] . ': ' . $context['current_label'] |
544 | 556 | ); |
557 | + } |
|
545 | 558 | |
546 | 559 | // Figure out how many messages there are. |
547 | - if ($context['folder'] == 'sent') |
|
548 | - $request = $smcFunc['db_query']('', ' |
|
560 | + if ($context['folder'] == 'sent') { |
|
561 | + $request = $smcFunc['db_query']('', ' |
|
549 | 562 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
550 | 563 | FROM {db_prefix}personal_messages AS pm |
551 | 564 | WHERE pm.id_member_from = {int:current_member} |
@@ -555,8 +568,8 @@ discard block |
||
555 | 568 | 'not_deleted' => 0, |
556 | 569 | ) |
557 | 570 | ); |
558 | - else |
|
559 | - $request = $smcFunc['db_query']('', ' |
|
571 | + } else { |
|
572 | + $request = $smcFunc['db_query']('', ' |
|
560 | 573 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
561 | 574 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
562 | 575 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -567,6 +580,7 @@ discard block |
||
567 | 580 | 'not_deleted' => 0, |
568 | 581 | ) |
569 | 582 | ); |
583 | + } |
|
570 | 584 | list ($max_messages) = $smcFunc['db_fetch_row']($request); |
571 | 585 | $smcFunc['db_free_result']($request); |
572 | 586 | |
@@ -575,10 +589,11 @@ discard block |
||
575 | 589 | $maxPerPage = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages']; |
576 | 590 | |
577 | 591 | // Start on the last page. |
578 | - if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) |
|
579 | - $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
580 | - elseif ($_GET['start'] < 0) |
|
581 | - $_GET['start'] = 0; |
|
592 | + if (!is_numeric($_GET['start']) || $_GET['start'] >= $max_messages) { |
|
593 | + $_GET['start'] = ($max_messages - 1) - (($max_messages - 1) % $maxPerPage); |
|
594 | + } elseif ($_GET['start'] < 0) { |
|
595 | + $_GET['start'] = 0; |
|
596 | + } |
|
582 | 597 | |
583 | 598 | // ... but wait - what if we want to start from a specific message? |
584 | 599 | if (isset($_GET['pmid'])) |
@@ -586,19 +601,21 @@ discard block |
||
586 | 601 | $pmID = (int) $_GET['pmid']; |
587 | 602 | |
588 | 603 | // Make sure you have access to this PM. |
589 | - if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
590 | - fatal_lang_error('no_access', false); |
|
604 | + if (!isAccessiblePM($pmID, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
605 | + fatal_lang_error('no_access', false); |
|
606 | + } |
|
591 | 607 | |
592 | 608 | $context['current_pm'] = $pmID; |
593 | 609 | |
594 | 610 | // With only one page of PM's we're gonna want page 1. |
595 | - if ($max_messages <= $maxPerPage) |
|
596 | - $_GET['start'] = 0; |
|
611 | + if ($max_messages <= $maxPerPage) { |
|
612 | + $_GET['start'] = 0; |
|
613 | + } |
|
597 | 614 | // If we pass kstart we assume we're in the right place. |
598 | 615 | elseif (!isset($_GET['kstart'])) |
599 | 616 | { |
600 | - if ($context['folder'] == 'sent') |
|
601 | - $request = $smcFunc['db_query']('', ' |
|
617 | + if ($context['folder'] == 'sent') { |
|
618 | + $request = $smcFunc['db_query']('', ' |
|
602 | 619 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
603 | 620 | FROM {db_prefix}personal_messages |
604 | 621 | WHERE id_member_from = {int:current_member} |
@@ -610,8 +627,8 @@ discard block |
||
610 | 627 | 'id_pm' => $pmID, |
611 | 628 | ) |
612 | 629 | ); |
613 | - else |
|
614 | - $request = $smcFunc['db_query']('', ' |
|
630 | + } else { |
|
631 | + $request = $smcFunc['db_query']('', ' |
|
615 | 632 | SELECT COUNT(' . ($context['display_mode'] == 2 ? 'DISTINCT pm.id_pm_head' : '*') . ') |
616 | 633 | FROM {db_prefix}pm_recipients AS pmr' . ($context['display_mode'] == 2 ? ' |
617 | 634 | INNER JOIN {db_prefix}personal_messages AS pm ON (pm.id_pm = pmr.id_pm)' : '') . $labelJoin . ' |
@@ -624,6 +641,7 @@ discard block |
||
624 | 641 | 'id_pm' => $pmID, |
625 | 642 | ) |
626 | 643 | ); |
644 | + } |
|
627 | 645 | |
628 | 646 | list ($_GET['start']) = $smcFunc['db_fetch_row']($request); |
629 | 647 | $smcFunc['db_free_result']($request); |
@@ -638,8 +656,9 @@ discard block |
||
638 | 656 | { |
639 | 657 | $pmsg = (int) $_GET['pmsg']; |
640 | 658 | |
641 | - if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) |
|
642 | - fatal_lang_error('no_access', false); |
|
659 | + if (!isAccessiblePM($pmsg, $context['folder'] == 'sent' ? 'outbox' : 'inbox')) { |
|
660 | + fatal_lang_error('no_access', false); |
|
661 | + } |
|
643 | 662 | } |
644 | 663 | |
645 | 664 | // Set up the page index. |
@@ -734,8 +753,9 @@ discard block |
||
734 | 753 | { |
735 | 754 | if (!isset($recipients[$row['id_pm']])) |
736 | 755 | { |
737 | - if (isset($row['id_member_from'])) |
|
738 | - $posters[$row['id_pm']] = $row['id_member_from']; |
|
756 | + if (isset($row['id_member_from'])) { |
|
757 | + $posters[$row['id_pm']] = $row['id_member_from']; |
|
758 | + } |
|
739 | 759 | $pms[$row['id_pm']] = $row['id_pm']; |
740 | 760 | $recipients[$row['id_pm']] = array( |
741 | 761 | 'to' => array(), |
@@ -744,29 +764,33 @@ discard block |
||
744 | 764 | } |
745 | 765 | |
746 | 766 | // Keep track of the last message so we know what the head is without another query! |
747 | - if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) |
|
748 | - $lastData = array( |
|
767 | + if ((empty($pmID) && (empty($options['view_newest_pm_first']) || !isset($lastData))) || empty($lastData) || (!empty($pmID) && $pmID == $row['id_pm'])) { |
|
768 | + $lastData = array( |
|
749 | 769 | 'id' => $row['id_pm'], |
750 | 770 | 'head' => $row['id_pm_head'], |
751 | 771 | ); |
772 | + } |
|
752 | 773 | } |
753 | 774 | $smcFunc['db_free_result']($request); |
754 | 775 | |
755 | 776 | // Make sure that we have been given a correct head pm id! |
756 | - if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) |
|
757 | - fatal_lang_error('no_access', false); |
|
777 | + if ($context['display_mode'] == 2 && !empty($pmID) && $pmID != $lastData['id']) { |
|
778 | + fatal_lang_error('no_access', false); |
|
779 | + } |
|
758 | 780 | |
759 | 781 | if (!empty($pms)) |
760 | 782 | { |
761 | 783 | // Select the correct current message. |
762 | - if (empty($pmID)) |
|
763 | - $context['current_pm'] = $lastData['id']; |
|
784 | + if (empty($pmID)) { |
|
785 | + $context['current_pm'] = $lastData['id']; |
|
786 | + } |
|
764 | 787 | |
765 | 788 | // This is a list of the pm's that are used for "full" display. |
766 | - if ($context['display_mode'] == 0) |
|
767 | - $display_pms = $pms; |
|
768 | - else |
|
769 | - $display_pms = array($context['current_pm']); |
|
789 | + if ($context['display_mode'] == 0) { |
|
790 | + $display_pms = $pms; |
|
791 | + } else { |
|
792 | + $display_pms = array($context['current_pm']); |
|
793 | + } |
|
770 | 794 | |
771 | 795 | // At this point we know the main id_pm's. But - if we are looking at conversations we need the others! |
772 | 796 | if ($context['display_mode'] == 2) |
@@ -788,16 +812,18 @@ discard block |
||
788 | 812 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
789 | 813 | { |
790 | 814 | // This is, frankly, a joke. We will put in a workaround for people sending to themselves - yawn! |
791 | - if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) |
|
792 | - continue; |
|
793 | - elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) |
|
794 | - continue; |
|
815 | + if ($context['folder'] == 'sent' && $row['id_member_from'] == $user_info['id'] && $row['deleted_by_sender'] == 1) { |
|
816 | + continue; |
|
817 | + } elseif ($row['id_member'] == $user_info['id'] & $row['deleted'] == 1) { |
|
818 | + continue; |
|
819 | + } |
|
795 | 820 | |
796 | - if (!isset($recipients[$row['id_pm']])) |
|
797 | - $recipients[$row['id_pm']] = array( |
|
821 | + if (!isset($recipients[$row['id_pm']])) { |
|
822 | + $recipients[$row['id_pm']] = array( |
|
798 | 823 | 'to' => array(), |
799 | 824 | 'bcc' => array() |
800 | 825 | ); |
826 | + } |
|
801 | 827 | $display_pms[] = $row['id_pm']; |
802 | 828 | $posters[$row['id_pm']] = $row['id_member_from']; |
803 | 829 | } |
@@ -848,8 +874,9 @@ discard block |
||
848 | 874 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
849 | 875 | { |
850 | 876 | $l_id = $row2['id_label']; |
851 | - if (isset($context['labels'][$l_id])) |
|
852 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
877 | + if (isset($context['labels'][$l_id])) { |
|
878 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
879 | + } |
|
853 | 880 | } |
854 | 881 | |
855 | 882 | $smcFunc['db_free_result']($request2); |
@@ -866,9 +893,10 @@ discard block |
||
866 | 893 | // Make sure we don't load unnecessary data. |
867 | 894 | if ($context['display_mode'] == 1) |
868 | 895 | { |
869 | - foreach ($posters as $k => $v) |
|
870 | - if (!in_array($k, $display_pms)) |
|
896 | + foreach ($posters as $k => $v) { |
|
897 | + if (!in_array($k, $display_pms)) |
|
871 | 898 | unset($posters[$k]); |
899 | + } |
|
872 | 900 | } |
873 | 901 | |
874 | 902 | // Load any users.... |
@@ -879,8 +907,9 @@ discard block |
||
879 | 907 | { |
880 | 908 | // Get the order right. |
881 | 909 | $orderBy = array(); |
882 | - foreach (array_reverse($pms) as $pm) |
|
883 | - $orderBy[] = 'pm.id_pm = ' . $pm; |
|
910 | + foreach (array_reverse($pms) as $pm) { |
|
911 | + $orderBy[] = 'pm.id_pm = ' . $pm; |
|
912 | + } |
|
884 | 913 | |
885 | 914 | // Seperate query for these bits! |
886 | 915 | $subjects_request = $smcFunc['db_query']('', ' |
@@ -926,9 +955,9 @@ discard block |
||
926 | 955 | // Allow mods to add additional buttons here |
927 | 956 | call_integration_hook('integrate_conversation_buttons'); |
928 | 957 | } |
958 | + } else { |
|
959 | + $messages_request = false; |
|
929 | 960 | } |
930 | - else |
|
931 | - $messages_request = false; |
|
932 | 961 | |
933 | 962 | $context['can_send_pm'] = allowedTo('pm_send'); |
934 | 963 | $context['can_send_email'] = allowedTo('moderate_forum'); |
@@ -939,11 +968,13 @@ discard block |
||
939 | 968 | if ($context['folder'] != 'sent' && !empty($context['labels'][(int) $context['current_label_id']]['unread_messages'])) |
940 | 969 | { |
941 | 970 | // If the display mode is "old sk00l" do them all... |
942 | - if ($context['display_mode'] == 0) |
|
943 | - markMessages(null, $context['current_label_id']); |
|
971 | + if ($context['display_mode'] == 0) { |
|
972 | + markMessages(null, $context['current_label_id']); |
|
973 | + } |
|
944 | 974 | // Otherwise do just the current one! |
945 | - elseif (!empty($context['current_pm'])) |
|
946 | - markMessages($display_pms, $context['current_label_id']); |
|
975 | + elseif (!empty($context['current_pm'])) { |
|
976 | + markMessages($display_pms, $context['current_label_id']); |
|
977 | + } |
|
947 | 978 | } |
948 | 979 | } |
949 | 980 | |
@@ -961,8 +992,9 @@ discard block |
||
961 | 992 | |
962 | 993 | // Count the current message number.... |
963 | 994 | static $counter = null; |
964 | - if ($counter === null || $reset) |
|
965 | - $counter = $context['start']; |
|
995 | + if ($counter === null || $reset) { |
|
996 | + $counter = $context['start']; |
|
997 | + } |
|
966 | 998 | |
967 | 999 | static $temp_pm_selected = null; |
968 | 1000 | if ($temp_pm_selected === null) |
@@ -1007,19 +1039,22 @@ discard block |
||
1007 | 1039 | } |
1008 | 1040 | |
1009 | 1041 | // Bail if it's false, ie. no messages. |
1010 | - if ($messages_request == false) |
|
1011 | - return false; |
|
1042 | + if ($messages_request == false) { |
|
1043 | + return false; |
|
1044 | + } |
|
1012 | 1045 | |
1013 | 1046 | // Reset the data? |
1014 | - if ($reset == true) |
|
1015 | - return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1047 | + if ($reset == true) { |
|
1048 | + return @$smcFunc['db_data_seek']($messages_request, 0); |
|
1049 | + } |
|
1016 | 1050 | |
1017 | 1051 | // Get the next one... bail if anything goes wrong. |
1018 | 1052 | $message = $smcFunc['db_fetch_assoc']($messages_request); |
1019 | 1053 | if (!$message) |
1020 | 1054 | { |
1021 | - if ($type != 'subject') |
|
1022 | - $smcFunc['db_free_result']($messages_request); |
|
1055 | + if ($type != 'subject') { |
|
1056 | + $smcFunc['db_free_result']($messages_request); |
|
1057 | + } |
|
1023 | 1058 | |
1024 | 1059 | return false; |
1025 | 1060 | } |
@@ -1039,8 +1074,7 @@ discard block |
||
1039 | 1074 | $memberContext[$message['id_member_from']]['email'] = ''; |
1040 | 1075 | $memberContext[$message['id_member_from']]['show_email'] = false; |
1041 | 1076 | $memberContext[$message['id_member_from']]['is_guest'] = true; |
1042 | - } |
|
1043 | - else |
|
1077 | + } else |
|
1044 | 1078 | { |
1045 | 1079 | $memberContext[$message['id_member_from']]['can_view_profile'] = allowedTo('profile_view') || ($message['id_member_from'] == $user_info['id'] && !$user_info['is_guest']); |
1046 | 1080 | $memberContext[$message['id_member_from']]['can_see_warning'] = !isset($context['disabled_fields']['warning_status']) && $memberContext[$message['id_member_from']]['warning_status'] && ($context['user']['can_mod'] || (!empty($modSettings['warning_show']) && ($modSettings['warning_show'] > 1 || $message['id_member_from'] == $user_info['id']))); |
@@ -1081,9 +1115,10 @@ discard block |
||
1081 | 1115 | $counter++; |
1082 | 1116 | |
1083 | 1117 | // Any custom profile fields? |
1084 | - if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) |
|
1085 | - foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
1118 | + if (!empty($memberContext[$message['id_member_from']]['custom_fields'])) { |
|
1119 | + foreach ($memberContext[$message['id_member_from']]['custom_fields'] as $custom) |
|
1086 | 1120 | $output['custom_fields'][$context['cust_profile_fields_placement'][$custom['placement']]][] = $custom; |
1121 | + } |
|
1087 | 1122 | |
1088 | 1123 | call_integration_hook('integrate_prepare_pm_context', array(&$output, &$message, $counter)); |
1089 | 1124 | |
@@ -1107,22 +1142,28 @@ discard block |
||
1107 | 1142 | $context['search_params'][$k] = $v; |
1108 | 1143 | } |
1109 | 1144 | } |
1110 | - if (isset($_REQUEST['search'])) |
|
1111 | - $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
1145 | + if (isset($_REQUEST['search'])) { |
|
1146 | + $context['search_params']['search'] = un_htmlspecialchars($_REQUEST['search']); |
|
1147 | + } |
|
1112 | 1148 | |
1113 | - if (isset($context['search_params']['search'])) |
|
1114 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1115 | - if (isset($context['search_params']['userspec'])) |
|
1116 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1149 | + if (isset($context['search_params']['search'])) { |
|
1150 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1151 | + } |
|
1152 | + if (isset($context['search_params']['userspec'])) { |
|
1153 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1154 | + } |
|
1117 | 1155 | |
1118 | - if (!empty($context['search_params']['searchtype'])) |
|
1119 | - $context['search_params']['searchtype'] = 2; |
|
1156 | + if (!empty($context['search_params']['searchtype'])) { |
|
1157 | + $context['search_params']['searchtype'] = 2; |
|
1158 | + } |
|
1120 | 1159 | |
1121 | - if (!empty($context['search_params']['minage'])) |
|
1122 | - $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
1160 | + if (!empty($context['search_params']['minage'])) { |
|
1161 | + $context['search_params']['minage'] = (int) $context['search_params']['minage']; |
|
1162 | + } |
|
1123 | 1163 | |
1124 | - if (!empty($context['search_params']['maxage'])) |
|
1125 | - $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
1164 | + if (!empty($context['search_params']['maxage'])) { |
|
1165 | + $context['search_params']['maxage'] = (int) $context['search_params']['maxage']; |
|
1166 | + } |
|
1126 | 1167 | |
1127 | 1168 | $context['search_params']['subject_only'] = !empty($context['search_params']['subject_only']); |
1128 | 1169 | $context['search_params']['show_complete'] = !empty($context['search_params']['show_complete']); |
@@ -1149,8 +1190,9 @@ discard block |
||
1149 | 1190 | $context['search_errors']['messages'] = array(); |
1150 | 1191 | foreach ($context['search_errors'] as $search_error => $dummy) |
1151 | 1192 | { |
1152 | - if ($search_error == 'messages') |
|
1153 | - continue; |
|
1193 | + if ($search_error == 'messages') { |
|
1194 | + continue; |
|
1195 | + } |
|
1154 | 1196 | |
1155 | 1197 | $context['search_errors']['messages'][] = $txt['error_' . $search_error]; |
1156 | 1198 | } |
@@ -1172,8 +1214,9 @@ discard block |
||
1172 | 1214 | global $scripturl, $modSettings, $user_info, $context, $txt; |
1173 | 1215 | global $memberContext, $smcFunc; |
1174 | 1216 | |
1175 | - if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) |
|
1176 | - fatal_lang_error('loadavg_search_disabled', false); |
|
1217 | + if (!empty($context['load_average']) && !empty($modSettings['loadavg_search']) && $context['load_average'] >= $modSettings['loadavg_search']) { |
|
1218 | + fatal_lang_error('loadavg_search_disabled', false); |
|
1219 | + } |
|
1177 | 1220 | |
1178 | 1221 | /** |
1179 | 1222 | * @todo For the moment force the folder to the inbox. |
@@ -1202,35 +1245,40 @@ discard block |
||
1202 | 1245 | $context['start'] = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
1203 | 1246 | |
1204 | 1247 | // Store whether simple search was used (needed if the user wants to do another query). |
1205 | - if (!isset($search_params['advanced'])) |
|
1206 | - $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
1248 | + if (!isset($search_params['advanced'])) { |
|
1249 | + $search_params['advanced'] = empty($_REQUEST['advanced']) ? 0 : 1; |
|
1250 | + } |
|
1207 | 1251 | |
1208 | 1252 | // 1 => 'allwords' (default, don't set as param) / 2 => 'anywords'. |
1209 | - if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) |
|
1210 | - $search_params['searchtype'] = 2; |
|
1253 | + if (!empty($search_params['searchtype']) || (!empty($_REQUEST['searchtype']) && $_REQUEST['searchtype'] == 2)) { |
|
1254 | + $search_params['searchtype'] = 2; |
|
1255 | + } |
|
1211 | 1256 | |
1212 | 1257 | // Minimum age of messages. Default to zero (don't set param in that case). |
1213 | - if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) |
|
1214 | - $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
1258 | + if (!empty($search_params['minage']) || (!empty($_REQUEST['minage']) && $_REQUEST['minage'] > 0)) { |
|
1259 | + $search_params['minage'] = !empty($search_params['minage']) ? (int) $search_params['minage'] : (int) $_REQUEST['minage']; |
|
1260 | + } |
|
1215 | 1261 | |
1216 | 1262 | // Maximum age of messages. Default to infinite (9999 days: param not set). |
1217 | - if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) |
|
1218 | - $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
1263 | + if (!empty($search_params['maxage']) || (!empty($_REQUEST['maxage']) && $_REQUEST['maxage'] != 9999)) { |
|
1264 | + $search_params['maxage'] = !empty($search_params['maxage']) ? (int) $search_params['maxage'] : (int) $_REQUEST['maxage']; |
|
1265 | + } |
|
1219 | 1266 | |
1220 | 1267 | $search_params['subject_only'] = !empty($search_params['subject_only']) || !empty($_REQUEST['subject_only']); |
1221 | 1268 | $search_params['show_complete'] = !empty($search_params['show_complete']) || !empty($_REQUEST['show_complete']); |
1222 | 1269 | |
1223 | 1270 | // Default the user name to a wildcard matching every user (*). |
1224 | - if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) |
|
1225 | - $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
1271 | + if (!empty($search_params['user_spec']) || (!empty($_REQUEST['userspec']) && $_REQUEST['userspec'] != '*')) { |
|
1272 | + $search_params['userspec'] = isset($search_params['userspec']) ? $search_params['userspec'] : $_REQUEST['userspec']; |
|
1273 | + } |
|
1226 | 1274 | |
1227 | 1275 | // This will be full of all kinds of parameters! |
1228 | 1276 | $searchq_parameters = array(); |
1229 | 1277 | |
1230 | 1278 | // If there's no specific user, then don't mention it in the main query. |
1231 | - if (empty($search_params['userspec'])) |
|
1232 | - $userQuery = ''; |
|
1233 | - else |
|
1279 | + if (empty($search_params['userspec'])) { |
|
1280 | + $userQuery = ''; |
|
1281 | + } else |
|
1234 | 1282 | { |
1235 | 1283 | $userString = strtr($smcFunc['htmlspecialchars']($search_params['userspec'], ENT_QUOTES), array('"' => '"')); |
1236 | 1284 | $userString = strtr($userString, array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_')); |
@@ -1242,8 +1290,9 @@ discard block |
||
1242 | 1290 | { |
1243 | 1291 | $possible_users[$k] = trim($possible_users[$k]); |
1244 | 1292 | |
1245 | - if (strlen($possible_users[$k]) == 0) |
|
1246 | - unset($possible_users[$k]); |
|
1293 | + if (strlen($possible_users[$k]) == 0) { |
|
1294 | + unset($possible_users[$k]); |
|
1295 | + } |
|
1247 | 1296 | } |
1248 | 1297 | |
1249 | 1298 | if (!empty($possible_users)) |
@@ -1255,8 +1304,9 @@ discard block |
||
1255 | 1304 | { |
1256 | 1305 | $where_params['name_' . $k] = $v; |
1257 | 1306 | $where_clause[] = '{raw:real_name} LIKE {string:name_' . $k . '}'; |
1258 | - if (!isset($where_params['real_name'])) |
|
1259 | - $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
1307 | + if (!isset($where_params['real_name'])) { |
|
1308 | + $where_params['real_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(real_name)' : 'real_name'; |
|
1309 | + } |
|
1260 | 1310 | } |
1261 | 1311 | |
1262 | 1312 | // Who matches those criteria? |
@@ -1269,28 +1319,28 @@ discard block |
||
1269 | 1319 | ); |
1270 | 1320 | |
1271 | 1321 | // Simply do nothing if there're too many members matching the criteria. |
1272 | - if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) |
|
1273 | - $userQuery = ''; |
|
1274 | - elseif ($smcFunc['db_num_rows']($request) == 0) |
|
1322 | + if ($smcFunc['db_num_rows']($request) > $maxMembersToSearch) { |
|
1323 | + $userQuery = ''; |
|
1324 | + } elseif ($smcFunc['db_num_rows']($request) == 0) |
|
1275 | 1325 | { |
1276 | 1326 | $userQuery = 'AND pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})'; |
1277 | 1327 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
1278 | 1328 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
1279 | - } |
|
1280 | - else |
|
1329 | + } else |
|
1281 | 1330 | { |
1282 | 1331 | $memberlist = array(); |
1283 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1284 | - $memberlist[] = $row['id_member']; |
|
1332 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1333 | + $memberlist[] = $row['id_member']; |
|
1334 | + } |
|
1285 | 1335 | $userQuery = 'AND (pm.id_member_from IN ({array_int:member_list}) OR (pm.id_member_from = 0 AND ({raw:pm_from_name} LIKE {raw:guest_user_name_implode})))'; |
1286 | 1336 | $searchq_parameters['guest_user_name_implode'] = '\'' . implode('\' OR ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name') . ' LIKE \'', $possible_users) . '\''; |
1287 | 1337 | $searchq_parameters['member_list'] = $memberlist; |
1288 | 1338 | $searchq_parameters['pm_from_name'] = $smcFunc['db_case_sensitive'] ? 'LOWER(pm.from_name)' : 'pm.from_name'; |
1289 | 1339 | } |
1290 | 1340 | $smcFunc['db_free_result']($request); |
1341 | + } else { |
|
1342 | + $userQuery = ''; |
|
1291 | 1343 | } |
1292 | - else |
|
1293 | - $userQuery = ''; |
|
1294 | 1344 | } |
1295 | 1345 | |
1296 | 1346 | // Setup the sorting variables... |
@@ -1298,8 +1348,9 @@ discard block |
||
1298 | 1348 | $sort_columns = array( |
1299 | 1349 | 'pm.id_pm', |
1300 | 1350 | ); |
1301 | - if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) |
|
1302 | - list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
1351 | + if (empty($search_params['sort']) && !empty($_REQUEST['sort'])) { |
|
1352 | + list ($search_params['sort'], $search_params['sort_dir']) = array_pad(explode('|', $_REQUEST['sort']), 2, ''); |
|
1353 | + } |
|
1303 | 1354 | $search_params['sort'] = !empty($search_params['sort']) && in_array($search_params['sort'], $sort_columns) ? $search_params['sort'] : 'pm.id_pm'; |
1304 | 1355 | $search_params['sort_dir'] = !empty($search_params['sort_dir']) && $search_params['sort_dir'] == 'asc' ? 'asc' : 'desc'; |
1305 | 1356 | |
@@ -1309,24 +1360,27 @@ discard block |
||
1309 | 1360 | if ($context['folder'] == 'inbox' && !empty($search_params['advanced']) && $context['currently_using_labels']) |
1310 | 1361 | { |
1311 | 1362 | // Came here from pagination? Put them back into $_REQUEST for sanitization. |
1312 | - if (isset($search_params['labels'])) |
|
1313 | - $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
1363 | + if (isset($search_params['labels'])) { |
|
1364 | + $_REQUEST['searchlabel'] = explode(',', $search_params['labels']); |
|
1365 | + } |
|
1314 | 1366 | |
1315 | 1367 | // Assuming we have some labels - make them all integers. |
1316 | 1368 | if (!empty($_REQUEST['searchlabel']) && is_array($_REQUEST['searchlabel'])) |
1317 | 1369 | { |
1318 | - foreach ($_REQUEST['searchlabel'] as $key => $id) |
|
1319 | - $_REQUEST['searchlabel'][$key] = (int) $id; |
|
1370 | + foreach ($_REQUEST['searchlabel'] as $key => $id) { |
|
1371 | + $_REQUEST['searchlabel'][$key] = (int) $id; |
|
1372 | + } |
|
1373 | + } else { |
|
1374 | + $_REQUEST['searchlabel'] = array(); |
|
1320 | 1375 | } |
1321 | - else |
|
1322 | - $_REQUEST['searchlabel'] = array(); |
|
1323 | 1376 | |
1324 | 1377 | // Now that everything is cleaned up a bit, make the labels a param. |
1325 | 1378 | $search_params['labels'] = implode(',', $_REQUEST['searchlabel']); |
1326 | 1379 | |
1327 | 1380 | // No labels selected? That must be an error! |
1328 | - if (empty($_REQUEST['searchlabel'])) |
|
1329 | - $context['search_errors']['no_labels_selected'] = true; |
|
1381 | + if (empty($_REQUEST['searchlabel'])) { |
|
1382 | + $context['search_errors']['no_labels_selected'] = true; |
|
1383 | + } |
|
1330 | 1384 | // Otherwise prepare the query! |
1331 | 1385 | elseif (count($_REQUEST['searchlabel']) != count($context['labels'])) |
1332 | 1386 | { |
@@ -1349,8 +1403,7 @@ discard block |
||
1349 | 1403 | // Not searching the inbox - PM must be labeled |
1350 | 1404 | $labelQuery = ' AND pml.id_label IN ({array_int:labels})'; |
1351 | 1405 | $labelJoin = ' INNER JOIN {db_prefix}pm_labeled_messages AS pml ON (pml.id_pm = pmr.id_pm)'; |
1352 | - } |
|
1353 | - else |
|
1406 | + } else |
|
1354 | 1407 | { |
1355 | 1408 | // Searching the inbox - PM doesn't have to be labeled |
1356 | 1409 | $labelQuery = ' AND (' . substr($labelQuery, 5) . ' OR pml.id_label IN ({array_int:labels}))'; |
@@ -1365,8 +1418,9 @@ discard block |
||
1365 | 1418 | // What are we actually searching for? |
1366 | 1419 | $search_params['search'] = !empty($search_params['search']) ? $search_params['search'] : (isset($_REQUEST['search']) ? $_REQUEST['search'] : ''); |
1367 | 1420 | // If we ain't got nothing - we should error! |
1368 | - if (!isset($search_params['search']) || $search_params['search'] == '') |
|
1369 | - $context['search_errors']['invalid_search_string'] = true; |
|
1421 | + if (!isset($search_params['search']) || $search_params['search'] == '') { |
|
1422 | + $context['search_errors']['invalid_search_string'] = true; |
|
1423 | + } |
|
1370 | 1424 | |
1371 | 1425 | // Extract phrase parts first (e.g. some words "this is a phrase" some more words.) |
1372 | 1426 | preg_match_all('~(?:^|\s)([-]?)"([^"]+)"(?:$|\s)~' . ($context['utf8'] ? 'u' : ''), $search_params['search'], $matches, PREG_PATTERN_ORDER); |
@@ -1379,12 +1433,14 @@ discard block |
||
1379 | 1433 | $excludedWords = array(); |
1380 | 1434 | |
1381 | 1435 | // .. first, we check for things like -"some words", but not "-some words". |
1382 | - foreach ($matches[1] as $index => $word) |
|
1383 | - if ($word == '-') |
|
1436 | + foreach ($matches[1] as $index => $word) { |
|
1437 | + if ($word == '-') |
|
1384 | 1438 | { |
1385 | 1439 | $word = $smcFunc['strtolower'](trim($searchArray[$index])); |
1386 | - if (strlen($word) > 0) |
|
1387 | - $excludedWords[] = $word; |
|
1440 | + } |
|
1441 | + if (strlen($word) > 0) { |
|
1442 | + $excludedWords[] = $word; |
|
1443 | + } |
|
1388 | 1444 | unset($searchArray[$index]); |
1389 | 1445 | } |
1390 | 1446 | |
@@ -1394,8 +1450,9 @@ discard block |
||
1394 | 1450 | if (strpos(trim($word), '-') === 0) |
1395 | 1451 | { |
1396 | 1452 | $word = substr($smcFunc['strtolower']($word), 1); |
1397 | - if (strlen($word) > 0) |
|
1398 | - $excludedWords[] = $word; |
|
1453 | + if (strlen($word) > 0) { |
|
1454 | + $excludedWords[] = $word; |
|
1455 | + } |
|
1399 | 1456 | unset($tempSearch[$index]); |
1400 | 1457 | } |
1401 | 1458 | } |
@@ -1406,9 +1463,9 @@ discard block |
||
1406 | 1463 | foreach ($searchArray as $index => $value) |
1407 | 1464 | { |
1408 | 1465 | $searchArray[$index] = $smcFunc['strtolower'](trim($value)); |
1409 | - if ($searchArray[$index] == '') |
|
1410 | - unset($searchArray[$index]); |
|
1411 | - else |
|
1466 | + if ($searchArray[$index] == '') { |
|
1467 | + unset($searchArray[$index]); |
|
1468 | + } else |
|
1412 | 1469 | { |
1413 | 1470 | // Sort out entities first. |
1414 | 1471 | $searchArray[$index] = $smcFunc['htmlspecialchars']($searchArray[$index]); |
@@ -1418,27 +1475,32 @@ discard block |
||
1418 | 1475 | |
1419 | 1476 | // Create an array of replacements for highlighting. |
1420 | 1477 | $context['mark'] = array(); |
1421 | - foreach ($searchArray as $word) |
|
1422 | - $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
1478 | + foreach ($searchArray as $word) { |
|
1479 | + $context['mark'][$word] = '<strong class="highlight">' . $word . '</strong>'; |
|
1480 | + } |
|
1423 | 1481 | |
1424 | 1482 | // This contains *everything* |
1425 | 1483 | $searchWords = array_merge($searchArray, $excludedWords); |
1426 | 1484 | |
1427 | 1485 | // Make sure at least one word is being searched for. |
1428 | - if (empty($searchArray)) |
|
1429 | - $context['search_errors']['invalid_search_string'] = true; |
|
1486 | + if (empty($searchArray)) { |
|
1487 | + $context['search_errors']['invalid_search_string'] = true; |
|
1488 | + } |
|
1430 | 1489 | |
1431 | 1490 | // Sort out the search query so the user can edit it - if they want. |
1432 | 1491 | $context['search_params'] = $search_params; |
1433 | - if (isset($context['search_params']['search'])) |
|
1434 | - $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1435 | - if (isset($context['search_params']['userspec'])) |
|
1436 | - $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1492 | + if (isset($context['search_params']['search'])) { |
|
1493 | + $context['search_params']['search'] = $smcFunc['htmlspecialchars']($context['search_params']['search']); |
|
1494 | + } |
|
1495 | + if (isset($context['search_params']['userspec'])) { |
|
1496 | + $context['search_params']['userspec'] = $smcFunc['htmlspecialchars']($context['search_params']['userspec']); |
|
1497 | + } |
|
1437 | 1498 | |
1438 | 1499 | // Now we have all the parameters, combine them together for pagination and the like... |
1439 | 1500 | $context['params'] = array(); |
1440 | - foreach ($search_params as $k => $v) |
|
1441 | - $context['params'][] = $k . '|\'|' . $v; |
|
1501 | + foreach ($search_params as $k => $v) { |
|
1502 | + $context['params'][] = $k . '|\'|' . $v; |
|
1503 | + } |
|
1442 | 1504 | $context['params'] = base64_encode(implode('|"|', $context['params'])); |
1443 | 1505 | |
1444 | 1506 | // Compile the subject query part. |
@@ -1446,26 +1508,31 @@ discard block |
||
1446 | 1508 | |
1447 | 1509 | foreach ($searchWords as $index => $word) |
1448 | 1510 | { |
1449 | - if ($word == '') |
|
1450 | - continue; |
|
1511 | + if ($word == '') { |
|
1512 | + continue; |
|
1513 | + } |
|
1451 | 1514 | |
1452 | - if ($search_params['subject_only']) |
|
1453 | - $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
1454 | - else |
|
1455 | - $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
1515 | + if ($search_params['subject_only']) { |
|
1516 | + $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}'; |
|
1517 | + } else { |
|
1518 | + $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})'; |
|
1519 | + } |
|
1456 | 1520 | $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%'; |
1457 | 1521 | } |
1458 | 1522 | |
1459 | 1523 | $searchQuery = ' 1=1'; |
1460 | - if (!empty($andQueryParts)) |
|
1461 | - $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
1524 | + if (!empty($andQueryParts)) { |
|
1525 | + $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts); |
|
1526 | + } |
|
1462 | 1527 | |
1463 | 1528 | // Age limits? |
1464 | 1529 | $timeQuery = ''; |
1465 | - if (!empty($search_params['minage'])) |
|
1466 | - $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
1467 | - if (!empty($search_params['maxage'])) |
|
1468 | - $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
1530 | + if (!empty($search_params['minage'])) { |
|
1531 | + $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400); |
|
1532 | + } |
|
1533 | + if (!empty($search_params['maxage'])) { |
|
1534 | + $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400); |
|
1535 | + } |
|
1469 | 1536 | |
1470 | 1537 | // If we have errors - return back to the first screen... |
1471 | 1538 | if (!empty($context['search_errors'])) |
@@ -1551,8 +1618,9 @@ discard block |
||
1551 | 1618 | ) |
1552 | 1619 | ); |
1553 | 1620 | $real_pm_ids = array(); |
1554 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1555 | - $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
1621 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1622 | + $real_pm_ids[$row['id_pm_head']] = $row['id_pm']; |
|
1623 | + } |
|
1556 | 1624 | $smcFunc['db_free_result']($request); |
1557 | 1625 | } |
1558 | 1626 | |
@@ -1582,8 +1650,9 @@ discard block |
||
1582 | 1650 | ); |
1583 | 1651 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1584 | 1652 | { |
1585 | - if ($context['folder'] == 'sent' || empty($row['bcc'])) |
|
1586 | - $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
1653 | + if ($context['folder'] == 'sent' || empty($row['bcc'])) { |
|
1654 | + $recipients[$row['id_pm']][empty($row['bcc']) ? 'to' : 'bcc'][] = empty($row['id_member_to']) ? $txt['guest_title'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . '">' . $row['to_name'] . '</a>'; |
|
1655 | + } |
|
1587 | 1656 | |
1588 | 1657 | if ($row['id_member_to'] == $user_info['id'] && $context['folder'] != 'sent') |
1589 | 1658 | { |
@@ -1604,12 +1673,14 @@ discard block |
||
1604 | 1673 | while ($row2 = $smcFunc['db_fetch_assoc']($request2)) |
1605 | 1674 | { |
1606 | 1675 | $l_id = $row2['id_label']; |
1607 | - if (isset($context['labels'][$l_id])) |
|
1608 | - $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
1676 | + if (isset($context['labels'][$l_id])) { |
|
1677 | + $context['message_labels'][$row['id_pm']][$l_id] = array('id' => $l_id, 'name' => $context['labels'][$l_id]['name']); |
|
1678 | + } |
|
1609 | 1679 | |
1610 | 1680 | // Here we find the first label on a message - for linking to posts in results |
1611 | - if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) |
|
1612 | - $context['first_label'][$row['id_pm']] = $l_id; |
|
1681 | + if (!isset($context['first_label'][$row['id_pm']]) && $row['in_inbox'] != 1) { |
|
1682 | + $context['first_label'][$row['id_pm']] = $l_id; |
|
1683 | + } |
|
1613 | 1684 | } |
1614 | 1685 | |
1615 | 1686 | $smcFunc['db_free_result']($request2); |
@@ -1736,8 +1807,9 @@ discard block |
||
1736 | 1807 | list ($postCount) = $smcFunc['db_fetch_row']($request); |
1737 | 1808 | $smcFunc['db_free_result']($request); |
1738 | 1809 | |
1739 | - if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
|
1740 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
1810 | + if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) { |
|
1811 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
1812 | + } |
|
1741 | 1813 | } |
1742 | 1814 | |
1743 | 1815 | // Quoting/Replying to a message? |
@@ -1746,8 +1818,9 @@ discard block |
||
1746 | 1818 | $pmsg = (int) $_REQUEST['pmsg']; |
1747 | 1819 | |
1748 | 1820 | // Make sure this is yours. |
1749 | - if (!isAccessiblePM($pmsg)) |
|
1750 | - fatal_lang_error('no_access', false); |
|
1821 | + if (!isAccessiblePM($pmsg)) { |
|
1822 | + fatal_lang_error('no_access', false); |
|
1823 | + } |
|
1751 | 1824 | |
1752 | 1825 | // Work out whether this is one you've received? |
1753 | 1826 | $request = $smcFunc['db_query']('', ' |
@@ -1784,8 +1857,9 @@ discard block |
||
1784 | 1857 | 'id_pm' => $pmsg, |
1785 | 1858 | ) |
1786 | 1859 | ); |
1787 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1788 | - fatal_lang_error('pm_not_yours', false); |
|
1860 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1861 | + fatal_lang_error('pm_not_yours', false); |
|
1862 | + } |
|
1789 | 1863 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
1790 | 1864 | $smcFunc['db_free_result']($request); |
1791 | 1865 | |
@@ -1796,9 +1870,9 @@ discard block |
||
1796 | 1870 | // Add 'Re: ' to it.... |
1797 | 1871 | if (!isset($context['response_prefix']) && !($context['response_prefix'] = cache_get_data('response_prefix'))) |
1798 | 1872 | { |
1799 | - if ($language === $user_info['language']) |
|
1800 | - $context['response_prefix'] = $txt['response_prefix']; |
|
1801 | - else |
|
1873 | + if ($language === $user_info['language']) { |
|
1874 | + $context['response_prefix'] = $txt['response_prefix']; |
|
1875 | + } else |
|
1802 | 1876 | { |
1803 | 1877 | loadLanguage('index', $language, false); |
1804 | 1878 | $context['response_prefix'] = $txt['response_prefix']; |
@@ -1807,22 +1881,25 @@ discard block |
||
1807 | 1881 | cache_put_data('response_prefix', $context['response_prefix'], 600); |
1808 | 1882 | } |
1809 | 1883 | $form_subject = $row_quoted['subject']; |
1810 | - if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) |
|
1811 | - $form_subject = $context['response_prefix'] . $form_subject; |
|
1884 | + if ($context['reply'] && trim($context['response_prefix']) != '' && $smcFunc['strpos']($form_subject, trim($context['response_prefix'])) !== 0) { |
|
1885 | + $form_subject = $context['response_prefix'] . $form_subject; |
|
1886 | + } |
|
1812 | 1887 | |
1813 | 1888 | if (isset($_REQUEST['quote'])) |
1814 | 1889 | { |
1815 | 1890 | // Remove any nested quotes and <br>... |
1816 | 1891 | $form_message = preg_replace('~<br ?/?' . '>~i', "\n", $row_quoted['body']); |
1817 | - if (!empty($modSettings['removeNestedQuotes'])) |
|
1818 | - $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
1819 | - if (empty($row_quoted['id_member'])) |
|
1820 | - $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1821 | - else |
|
1822 | - $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1892 | + if (!empty($modSettings['removeNestedQuotes'])) { |
|
1893 | + $form_message = preg_replace(array('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '~^\n~', '~\[/quote\]~'), '', $form_message); |
|
1894 | + } |
|
1895 | + if (empty($row_quoted['id_member'])) { |
|
1896 | + $form_message = '[quote author="' . $row_quoted['real_name'] . '"]' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1897 | + } else { |
|
1898 | + $form_message = '[quote author=' . $row_quoted['real_name'] . ' link=action=profile;u=' . $row_quoted['id_member'] . ' date=' . $row_quoted['msgtime'] . ']' . "\n" . $form_message . "\n" . '[/quote]'; |
|
1899 | + } |
|
1900 | + } else { |
|
1901 | + $form_message = ''; |
|
1823 | 1902 | } |
1824 | - else |
|
1825 | - $form_message = ''; |
|
1826 | 1903 | |
1827 | 1904 | // Do the BBC thang on the message. |
1828 | 1905 | $row_quoted['body'] = parse_bbc($row_quoted['body'], true, 'pm' . $row_quoted['id_pm']); |
@@ -1843,8 +1920,7 @@ discard block |
||
1843 | 1920 | 'timestamp' => forum_time(true, $row_quoted['msgtime']), |
1844 | 1921 | 'body' => $row_quoted['body'] |
1845 | 1922 | ); |
1846 | - } |
|
1847 | - else |
|
1923 | + } else |
|
1848 | 1924 | { |
1849 | 1925 | $context['quoted_message'] = false; |
1850 | 1926 | $form_subject = ''; |
@@ -1863,11 +1939,12 @@ discard block |
||
1863 | 1939 | if ($_REQUEST['u'] == 'all' && isset($row_quoted)) |
1864 | 1940 | { |
1865 | 1941 | // Firstly, to reply to all we clearly already have $row_quoted - so have the original member from. |
1866 | - if ($row_quoted['id_member'] != $user_info['id']) |
|
1867 | - $context['recipients']['to'][] = array( |
|
1942 | + if ($row_quoted['id_member'] != $user_info['id']) { |
|
1943 | + $context['recipients']['to'][] = array( |
|
1868 | 1944 | 'id' => $row_quoted['id_member'], |
1869 | 1945 | 'name' => $smcFunc['htmlspecialchars']($row_quoted['real_name']), |
1870 | 1946 | ); |
1947 | + } |
|
1871 | 1948 | |
1872 | 1949 | // Now to get the others. |
1873 | 1950 | $request = $smcFunc['db_query']('', ' |
@@ -1883,18 +1960,19 @@ discard block |
||
1883 | 1960 | 'not_bcc' => 0, |
1884 | 1961 | ) |
1885 | 1962 | ); |
1886 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1887 | - $context['recipients']['to'][] = array( |
|
1963 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1964 | + $context['recipients']['to'][] = array( |
|
1888 | 1965 | 'id' => $row['id_member'], |
1889 | 1966 | 'name' => $row['real_name'], |
1890 | 1967 | ); |
1968 | + } |
|
1891 | 1969 | $smcFunc['db_free_result']($request); |
1892 | - } |
|
1893 | - else |
|
1970 | + } else |
|
1894 | 1971 | { |
1895 | 1972 | $_REQUEST['u'] = explode(',', $_REQUEST['u']); |
1896 | - foreach ($_REQUEST['u'] as $key => $uID) |
|
1897 | - $_REQUEST['u'][$key] = (int) $uID; |
|
1973 | + foreach ($_REQUEST['u'] as $key => $uID) { |
|
1974 | + $_REQUEST['u'][$key] = (int) $uID; |
|
1975 | + } |
|
1898 | 1976 | |
1899 | 1977 | $_REQUEST['u'] = array_unique($_REQUEST['u']); |
1900 | 1978 | |
@@ -1908,22 +1986,24 @@ discard block |
||
1908 | 1986 | 'limit' => count($_REQUEST['u']), |
1909 | 1987 | ) |
1910 | 1988 | ); |
1911 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1912 | - $context['recipients']['to'][] = array( |
|
1989 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1990 | + $context['recipients']['to'][] = array( |
|
1913 | 1991 | 'id' => $row['id_member'], |
1914 | 1992 | 'name' => $row['real_name'], |
1915 | 1993 | ); |
1994 | + } |
|
1916 | 1995 | $smcFunc['db_free_result']($request); |
1917 | 1996 | } |
1918 | 1997 | |
1919 | 1998 | // Get a literal name list in case the user has JavaScript disabled. |
1920 | 1999 | $names = array(); |
1921 | - foreach ($context['recipients']['to'] as $to) |
|
1922 | - $names[] = $to['name']; |
|
2000 | + foreach ($context['recipients']['to'] as $to) { |
|
2001 | + $names[] = $to['name']; |
|
2002 | + } |
|
1923 | 2003 | $context['to_value'] = empty($names) ? '' : '"' . implode('", "', $names) . '"'; |
2004 | + } else { |
|
2005 | + $context['to_value'] = ''; |
|
1924 | 2006 | } |
1925 | - else |
|
1926 | - $context['to_value'] = ''; |
|
1927 | 2007 | |
1928 | 2008 | // Set the defaults... |
1929 | 2009 | $context['subject'] = $form_subject; |
@@ -1993,8 +2073,9 @@ discard block |
||
1993 | 2073 | |
1994 | 2074 | // validate with loadMemberData() |
1995 | 2075 | $memberResult = loadMemberData($user_info['id'], false); |
1996 | - if (!$memberResult) |
|
1997 | - fatal_lang_error('not_a_user', false); |
|
2076 | + if (!$memberResult) { |
|
2077 | + fatal_lang_error('not_a_user', false); |
|
2078 | + } |
|
1998 | 2079 | list ($memID) = $memberResult; |
1999 | 2080 | |
2000 | 2081 | // drafts is where the functions reside |
@@ -2020,9 +2101,9 @@ discard block |
||
2020 | 2101 | $context['sub_template'] = 'send'; |
2021 | 2102 | loadJavaScriptFile('PersonalMessage.js', array('defer' => false), 'smf_pms'); |
2022 | 2103 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
2104 | + } else { |
|
2105 | + $context['sub_template'] = 'pm'; |
|
2023 | 2106 | } |
2024 | - else |
|
2025 | - $context['sub_template'] = 'pm'; |
|
2026 | 2107 | |
2027 | 2108 | $context['page_title'] = $txt['send_message']; |
2028 | 2109 | |
@@ -2083,10 +2164,11 @@ discard block |
||
2083 | 2164 | ); |
2084 | 2165 | if ($smcFunc['db_num_rows']($request) == 0) |
2085 | 2166 | { |
2086 | - if (!isset($_REQUEST['xml'])) |
|
2087 | - fatal_lang_error('pm_not_yours', false); |
|
2088 | - else |
|
2089 | - $error_types[] = 'pm_not_yours'; |
|
2167 | + if (!isset($_REQUEST['xml'])) { |
|
2168 | + fatal_lang_error('pm_not_yours', false); |
|
2169 | + } else { |
|
2170 | + $error_types[] = 'pm_not_yours'; |
|
2171 | + } |
|
2090 | 2172 | } |
2091 | 2173 | $row_quoted = $smcFunc['db_fetch_assoc']($request); |
2092 | 2174 | $smcFunc['db_free_result']($request); |
@@ -2133,14 +2215,16 @@ discard block |
||
2133 | 2215 | $context['post_error'][$error_type] = true; |
2134 | 2216 | if (isset($txt['error_' . $error_type])) |
2135 | 2217 | { |
2136 | - if ($error_type == 'long_message') |
|
2137 | - $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
2218 | + if ($error_type == 'long_message') { |
|
2219 | + $txt['error_' . $error_type] = sprintf($txt['error_' . $error_type], $modSettings['max_messageLength']); |
|
2220 | + } |
|
2138 | 2221 | $context['post_error']['messages'][] = $txt['error_' . $error_type]; |
2139 | 2222 | } |
2140 | 2223 | |
2141 | 2224 | // If it's not a minor error flag it as such. |
2142 | - if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) |
|
2143 | - $context['error_type'] = 'serious'; |
|
2225 | + if (!in_array($error_type, array('new_reply', 'not_approved', 'new_replies', 'old_topic', 'need_qr_verification', 'no_subject'))) { |
|
2226 | + $context['error_type'] = 'serious'; |
|
2227 | + } |
|
2144 | 2228 | } |
2145 | 2229 | |
2146 | 2230 | // We need to load the editor once more. |
@@ -2198,8 +2282,9 @@ discard block |
||
2198 | 2282 | require_once($sourcedir . '/Subs-Auth.php'); |
2199 | 2283 | |
2200 | 2284 | // PM Drafts enabled and needed? |
2201 | - if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) |
|
2202 | - require_once($sourcedir . '/Drafts.php'); |
|
2285 | + if ($context['drafts_pm_save'] && (isset($_POST['save_draft']) || isset($_POST['id_pm_draft']))) { |
|
2286 | + require_once($sourcedir . '/Drafts.php'); |
|
2287 | + } |
|
2203 | 2288 | |
2204 | 2289 | loadLanguage('PersonalMessage', '', false); |
2205 | 2290 | |
@@ -2229,24 +2314,27 @@ discard block |
||
2229 | 2314 | |
2230 | 2315 | if (!empty($postCount) && $postCount >= $modSettings['pm_posts_per_hour']) |
2231 | 2316 | { |
2232 | - if (!isset($_REQUEST['xml'])) |
|
2233 | - fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
2234 | - else |
|
2235 | - $post_errors[] = 'pm_too_many_per_hour'; |
|
2317 | + if (!isset($_REQUEST['xml'])) { |
|
2318 | + fatal_lang_error('pm_too_many_per_hour', true, array($modSettings['pm_posts_per_hour'])); |
|
2319 | + } else { |
|
2320 | + $post_errors[] = 'pm_too_many_per_hour'; |
|
2321 | + } |
|
2236 | 2322 | } |
2237 | 2323 | } |
2238 | 2324 | |
2239 | 2325 | // If your session timed out, show an error, but do allow to re-submit. |
2240 | - if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') |
|
2241 | - $post_errors[] = 'session_timeout'; |
|
2326 | + if (!isset($_REQUEST['xml']) && checkSession('post', '', false) != '') { |
|
2327 | + $post_errors[] = 'session_timeout'; |
|
2328 | + } |
|
2242 | 2329 | |
2243 | 2330 | $_REQUEST['subject'] = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; |
2244 | 2331 | $_REQUEST['to'] = empty($_POST['to']) ? (empty($_GET['to']) ? '' : $_GET['to']) : $_POST['to']; |
2245 | 2332 | $_REQUEST['bcc'] = empty($_POST['bcc']) ? (empty($_GET['bcc']) ? '' : $_GET['bcc']) : $_POST['bcc']; |
2246 | 2333 | |
2247 | 2334 | // Route the input from the 'u' parameter to the 'to'-list. |
2248 | - if (!empty($_POST['u'])) |
|
2249 | - $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
2335 | + if (!empty($_POST['u'])) { |
|
2336 | + $_POST['recipient_to'] = explode(',', $_POST['u']); |
|
2337 | + } |
|
2250 | 2338 | |
2251 | 2339 | // Construct the list of recipients. |
2252 | 2340 | $recipientList = array(); |
@@ -2258,8 +2346,9 @@ discard block |
||
2258 | 2346 | $recipientList[$recipientType] = array(); |
2259 | 2347 | if (!empty($_POST['recipient_' . $recipientType]) && is_array($_POST['recipient_' . $recipientType])) |
2260 | 2348 | { |
2261 | - foreach ($_POST['recipient_' . $recipientType] as $recipient) |
|
2262 | - $recipientList[$recipientType][] = (int) $recipient; |
|
2349 | + foreach ($_POST['recipient_' . $recipientType] as $recipient) { |
|
2350 | + $recipientList[$recipientType][] = (int) $recipient; |
|
2351 | + } |
|
2263 | 2352 | } |
2264 | 2353 | |
2265 | 2354 | // Are there also literal names set? |
@@ -2273,10 +2362,11 @@ discard block |
||
2273 | 2362 | |
2274 | 2363 | foreach ($namedRecipientList[$recipientType] as $index => $recipient) |
2275 | 2364 | { |
2276 | - if (strlen(trim($recipient)) > 0) |
|
2277 | - $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
2278 | - else |
|
2279 | - unset($namedRecipientList[$recipientType][$index]); |
|
2365 | + if (strlen(trim($recipient)) > 0) { |
|
2366 | + $namedRecipientList[$recipientType][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($recipient))); |
|
2367 | + } else { |
|
2368 | + unset($namedRecipientList[$recipientType][$index]); |
|
2369 | + } |
|
2280 | 2370 | } |
2281 | 2371 | |
2282 | 2372 | if (!empty($namedRecipientList[$recipientType])) |
@@ -2306,8 +2396,9 @@ discard block |
||
2306 | 2396 | } |
2307 | 2397 | |
2308 | 2398 | // Selected a recipient to be deleted? Remove them now. |
2309 | - if (!empty($_POST['delete_recipient'])) |
|
2310 | - $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
2399 | + if (!empty($_POST['delete_recipient'])) { |
|
2400 | + $recipientList[$recipientType] = array_diff($recipientList[$recipientType], array((int) $_POST['delete_recipient'])); |
|
2401 | + } |
|
2311 | 2402 | |
2312 | 2403 | // Make sure we don't include the same name twice |
2313 | 2404 | $recipientList[$recipientType] = array_unique($recipientList[$recipientType]); |
@@ -2317,8 +2408,9 @@ discard block |
||
2317 | 2408 | $is_recipient_change = !empty($_POST['delete_recipient']) || !empty($_POST['to_submit']) || !empty($_POST['bcc_submit']); |
2318 | 2409 | |
2319 | 2410 | // Check if there's at least one recipient. |
2320 | - if (empty($recipientList['to']) && empty($recipientList['bcc'])) |
|
2321 | - $post_errors[] = 'no_to'; |
|
2411 | + if (empty($recipientList['to']) && empty($recipientList['bcc'])) { |
|
2412 | + $post_errors[] = 'no_to'; |
|
2413 | + } |
|
2322 | 2414 | |
2323 | 2415 | // Make sure that we remove the members who did get it from the screen. |
2324 | 2416 | if (!$is_recipient_change) |
@@ -2332,28 +2424,31 @@ discard block |
||
2332 | 2424 | // Since we already have a post error, remove the previous one. |
2333 | 2425 | $post_errors = array_diff($post_errors, array('no_to')); |
2334 | 2426 | |
2335 | - foreach ($namesNotFound[$recipientType] as $name) |
|
2336 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2427 | + foreach ($namesNotFound[$recipientType] as $name) { |
|
2428 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2429 | + } |
|
2337 | 2430 | } |
2338 | 2431 | } |
2339 | 2432 | } |
2340 | 2433 | |
2341 | 2434 | // Did they make any mistakes? |
2342 | - if ($_REQUEST['subject'] == '') |
|
2343 | - $post_errors[] = 'no_subject'; |
|
2344 | - if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') |
|
2345 | - $post_errors[] = 'no_message'; |
|
2346 | - elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) |
|
2347 | - $post_errors[] = 'long_message'; |
|
2348 | - else |
|
2435 | + if ($_REQUEST['subject'] == '') { |
|
2436 | + $post_errors[] = 'no_subject'; |
|
2437 | + } |
|
2438 | + if (!isset($_REQUEST['message']) || $_REQUEST['message'] == '') { |
|
2439 | + $post_errors[] = 'no_message'; |
|
2440 | + } elseif (!empty($modSettings['max_messageLength']) && $smcFunc['strlen']($_REQUEST['message']) > $modSettings['max_messageLength']) { |
|
2441 | + $post_errors[] = 'long_message'; |
|
2442 | + } else |
|
2349 | 2443 | { |
2350 | 2444 | // Preparse the message. |
2351 | 2445 | $message = $_REQUEST['message']; |
2352 | 2446 | preparsecode($message); |
2353 | 2447 | |
2354 | 2448 | // Make sure there's still some content left without the tags. |
2355 | - if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) |
|
2356 | - $post_errors[] = 'no_message'; |
|
2449 | + if ($smcFunc['htmltrim'](strip_tags(parse_bbc($smcFunc['htmlspecialchars']($message, ENT_QUOTES), false), '<img>')) === '' && (!allowedTo('admin_forum') || strpos($message, '[html]') === false)) { |
|
2450 | + $post_errors[] = 'no_message'; |
|
2451 | + } |
|
2357 | 2452 | } |
2358 | 2453 | |
2359 | 2454 | // Wrong verification code? |
@@ -2365,13 +2460,15 @@ discard block |
||
2365 | 2460 | ); |
2366 | 2461 | $context['require_verification'] = create_control_verification($verificationOptions, true); |
2367 | 2462 | |
2368 | - if (is_array($context['require_verification'])) |
|
2369 | - $post_errors = array_merge($post_errors, $context['require_verification']); |
|
2463 | + if (is_array($context['require_verification'])) { |
|
2464 | + $post_errors = array_merge($post_errors, $context['require_verification']); |
|
2465 | + } |
|
2370 | 2466 | } |
2371 | 2467 | |
2372 | 2468 | // If they did, give a chance to make ammends. |
2373 | - if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) |
|
2374 | - return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
2469 | + if (!empty($post_errors) && !$is_recipient_change && !isset($_REQUEST['preview']) && !isset($_REQUEST['xml'])) { |
|
2470 | + return messagePostError($post_errors, $namedRecipientList, $recipientList); |
|
2471 | + } |
|
2375 | 2472 | |
2376 | 2473 | // Want to take a second glance before you send? |
2377 | 2474 | if (isset($_REQUEST['preview'])) |
@@ -2402,8 +2499,9 @@ discard block |
||
2402 | 2499 | foreach ($namesNotFound as $recipientType => $names) |
2403 | 2500 | { |
2404 | 2501 | $post_errors[] = 'bad_' . $recipientType; |
2405 | - foreach ($names as $name) |
|
2406 | - $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2502 | + foreach ($names as $name) { |
|
2503 | + $context['send_log']['failed'][] = sprintf($txt['pm_error_user_not_found'], $name); |
|
2504 | + } |
|
2407 | 2505 | } |
2408 | 2506 | |
2409 | 2507 | return messagePostError(array(), $namedRecipientList, $recipientList); |
@@ -2433,13 +2531,14 @@ discard block |
||
2433 | 2531 | checkSubmitOnce('check'); |
2434 | 2532 | |
2435 | 2533 | // Do the actual sending of the PM. |
2436 | - if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) |
|
2437 | - $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
2438 | - else |
|
2439 | - $context['send_log'] = array( |
|
2534 | + if (!empty($recipientList['to']) || !empty($recipientList['bcc'])) { |
|
2535 | + $context['send_log'] = sendpm($recipientList, $_REQUEST['subject'], $_REQUEST['message'], true, null, !empty($_REQUEST['pm_head']) ? (int) $_REQUEST['pm_head'] : 0); |
|
2536 | + } else { |
|
2537 | + $context['send_log'] = array( |
|
2440 | 2538 | 'sent' => array(), |
2441 | 2539 | 'failed' => array() |
2442 | 2540 | ); |
2541 | + } |
|
2443 | 2542 | |
2444 | 2543 | // Mark the message as "replied to". |
2445 | 2544 | if (!empty($context['send_log']['sent']) && !empty($_REQUEST['replied_to']) && isset($_REQUEST['f']) && $_REQUEST['f'] == 'inbox') |
@@ -2457,11 +2556,12 @@ discard block |
||
2457 | 2556 | } |
2458 | 2557 | |
2459 | 2558 | // If one or more of the recipient were invalid, go back to the post screen with the failed usernames. |
2460 | - if (!empty($context['send_log']['failed'])) |
|
2461 | - return messagePostError($post_errors, $namesNotFound, array( |
|
2559 | + if (!empty($context['send_log']['failed'])) { |
|
2560 | + return messagePostError($post_errors, $namesNotFound, array( |
|
2462 | 2561 | 'to' => array_intersect($recipientList['to'], $context['send_log']['failed']), |
2463 | 2562 | 'bcc' => array_intersect($recipientList['bcc'], $context['send_log']['failed']) |
2464 | 2563 | )); |
2564 | + } |
|
2465 | 2565 | |
2466 | 2566 | // Message sent successfully? |
2467 | 2567 | if (!empty($context['send_log']) && empty($context['send_log']['failed'])) |
@@ -2469,8 +2569,9 @@ discard block |
||
2469 | 2569 | $context['current_label_redirect'] = $context['current_label_redirect'] . ';done=sent'; |
2470 | 2570 | |
2471 | 2571 | // If we had a PM draft for this one, then its time to remove it since it was just sent |
2472 | - if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) |
|
2473 | - DeleteDraft($_POST['id_pm_draft']); |
|
2572 | + if ($context['drafts_pm_save'] && !empty($_POST['id_pm_draft'])) { |
|
2573 | + DeleteDraft($_POST['id_pm_draft']); |
|
2574 | + } |
|
2474 | 2575 | } |
2475 | 2576 | |
2476 | 2577 | // Go back to the where they sent from, if possible... |
@@ -2485,24 +2586,28 @@ discard block |
||
2485 | 2586 | |
2486 | 2587 | checkSession('request'); |
2487 | 2588 | |
2488 | - if (isset($_REQUEST['del_selected'])) |
|
2489 | - $_REQUEST['pm_action'] = 'delete'; |
|
2589 | + if (isset($_REQUEST['del_selected'])) { |
|
2590 | + $_REQUEST['pm_action'] = 'delete'; |
|
2591 | + } |
|
2490 | 2592 | |
2491 | 2593 | if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) |
2492 | 2594 | { |
2493 | - foreach ($_REQUEST['pms'] as $pm) |
|
2494 | - $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
2595 | + foreach ($_REQUEST['pms'] as $pm) { |
|
2596 | + $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action']; |
|
2597 | + } |
|
2495 | 2598 | } |
2496 | 2599 | |
2497 | - if (empty($_REQUEST['pm_actions'])) |
|
2498 | - redirectexit($context['current_label_redirect']); |
|
2600 | + if (empty($_REQUEST['pm_actions'])) { |
|
2601 | + redirectexit($context['current_label_redirect']); |
|
2602 | + } |
|
2499 | 2603 | |
2500 | 2604 | // If we are in conversation, we may need to apply this to every message in the conversation. |
2501 | 2605 | if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) |
2502 | 2606 | { |
2503 | 2607 | $id_pms = array(); |
2504 | - foreach ($_REQUEST['pm_actions'] as $pm => $dummy) |
|
2505 | - $id_pms[] = (int) $pm; |
|
2608 | + foreach ($_REQUEST['pm_actions'] as $pm => $dummy) { |
|
2609 | + $id_pms[] = (int) $pm; |
|
2610 | + } |
|
2506 | 2611 | |
2507 | 2612 | $request = $smcFunc['db_query']('', ' |
2508 | 2613 | SELECT id_pm_head, id_pm |
@@ -2513,8 +2618,9 @@ discard block |
||
2513 | 2618 | ) |
2514 | 2619 | ); |
2515 | 2620 | $pm_heads = array(); |
2516 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2517 | - $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
2621 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2622 | + $pm_heads[$row['id_pm_head']] = $row['id_pm']; |
|
2623 | + } |
|
2518 | 2624 | $smcFunc['db_free_result']($request); |
2519 | 2625 | |
2520 | 2626 | $request = $smcFunc['db_query']('', ' |
@@ -2528,8 +2634,9 @@ discard block |
||
2528 | 2634 | // Copy the action from the single to PM to the others. |
2529 | 2635 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2530 | 2636 | { |
2531 | - if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) |
|
2532 | - $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
2637 | + if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) { |
|
2638 | + $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]]; |
|
2639 | + } |
|
2533 | 2640 | } |
2534 | 2641 | $smcFunc['db_free_result']($request); |
2535 | 2642 | } |
@@ -2540,22 +2647,21 @@ discard block |
||
2540 | 2647 | $labels = array(); |
2541 | 2648 | foreach ($_REQUEST['pm_actions'] as $pm => $action) |
2542 | 2649 | { |
2543 | - if ($action === 'delete') |
|
2544 | - $to_delete[] = (int) $pm; |
|
2545 | - else |
|
2650 | + if ($action === 'delete') { |
|
2651 | + $to_delete[] = (int) $pm; |
|
2652 | + } else |
|
2546 | 2653 | { |
2547 | 2654 | if (substr($action, 0, 4) == 'add_') |
2548 | 2655 | { |
2549 | 2656 | $type = 'add'; |
2550 | 2657 | $action = substr($action, 4); |
2551 | - } |
|
2552 | - elseif (substr($action, 0, 4) == 'rem_') |
|
2658 | + } elseif (substr($action, 0, 4) == 'rem_') |
|
2553 | 2659 | { |
2554 | 2660 | $type = 'rem'; |
2555 | 2661 | $action = substr($action, 4); |
2662 | + } else { |
|
2663 | + $type = 'unk'; |
|
2556 | 2664 | } |
2557 | - else |
|
2558 | - $type = 'unk'; |
|
2559 | 2665 | |
2560 | 2666 | if ($action == '-1' || (int) $action > 0) |
2561 | 2667 | { |
@@ -2566,8 +2672,9 @@ discard block |
||
2566 | 2672 | } |
2567 | 2673 | |
2568 | 2674 | // Deleting, it looks like? |
2569 | - if (!empty($to_delete)) |
|
2570 | - deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
2675 | + if (!empty($to_delete)) { |
|
2676 | + deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']); |
|
2677 | + } |
|
2571 | 2678 | |
2572 | 2679 | // Are we labeling anything? |
2573 | 2680 | if (!empty($to_label) && $context['folder'] == 'inbox') |
@@ -2633,8 +2740,7 @@ discard block |
||
2633 | 2740 | } |
2634 | 2741 | |
2635 | 2742 | $smcFunc['db_free_result']($request2); |
2636 | - } |
|
2637 | - elseif ($type == 'rem') |
|
2743 | + } elseif ($type == 'rem') |
|
2638 | 2744 | { |
2639 | 2745 | // If we're removing from the inbox, see if we have at least one other label. |
2640 | 2746 | // This query is faster than the one above |
@@ -2666,21 +2772,25 @@ discard block |
||
2666 | 2772 | if ($to_label[$row['id_pm']] != '-1') |
2667 | 2773 | { |
2668 | 2774 | // If this label is in the list and we're not adding it, remove it |
2669 | - if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') |
|
2670 | - unset($labels[$to_label[$row['id_pm']]]); |
|
2671 | - else if ($type !== 'rem') |
|
2672 | - $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
2775 | + if (array_key_exists($to_label[$row['id_pm']], $labels) && $type !== 'add') { |
|
2776 | + unset($labels[$to_label[$row['id_pm']]]); |
|
2777 | + } else if ($type !== 'rem') { |
|
2778 | + $labels[$to_label[$row['id_pm']]] = $to_label[$row['id_pm']]; |
|
2779 | + } |
|
2673 | 2780 | } |
2674 | 2781 | |
2675 | 2782 | // Removing all labels or just removing the inbox label |
2676 | - if ($type == 'rem' && empty($labels)) |
|
2677 | - $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
2783 | + if ($type == 'rem' && empty($labels)) { |
|
2784 | + $in_inbox = (empty($context['can_remove_inbox']) ? 1 : 0); |
|
2785 | + } |
|
2678 | 2786 | // Adding new labels, but removing inbox and applying new ones |
2679 | - elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) |
|
2680 | - $in_inbox = 0; |
|
2787 | + elseif ($type == 'add' && !empty($options['pm_remove_inbox_label']) && !empty($labels)) { |
|
2788 | + $in_inbox = 0; |
|
2789 | + } |
|
2681 | 2790 | // Just adding it to the inbox |
2682 | - else |
|
2683 | - $in_inbox = 1; |
|
2791 | + else { |
|
2792 | + $in_inbox = 1; |
|
2793 | + } |
|
2684 | 2794 | |
2685 | 2795 | // Are we adding it to or removing it from the inbox? |
2686 | 2796 | if ($in_inbox != $row['in_inbox']) |
@@ -2722,8 +2832,9 @@ discard block |
||
2722 | 2832 | if (!empty($labels_to_apply)) |
2723 | 2833 | { |
2724 | 2834 | $inserts = array(); |
2725 | - foreach ($labels_to_apply as $label) |
|
2726 | - $inserts[] = array($row['id_pm'], $label); |
|
2835 | + foreach ($labels_to_apply as $label) { |
|
2836 | + $inserts[] = array($row['id_pm'], $label); |
|
2837 | + } |
|
2727 | 2838 | |
2728 | 2839 | $smcFunc['db_insert']('', |
2729 | 2840 | '{db_prefix}pm_labeled_messages', |
@@ -2767,11 +2878,13 @@ discard block |
||
2767 | 2878 | checkSession('get'); |
2768 | 2879 | |
2769 | 2880 | // If all then delete all messages the user has. |
2770 | - if ($_REQUEST['f'] == 'all') |
|
2771 | - deleteMessages(null, null); |
|
2881 | + if ($_REQUEST['f'] == 'all') { |
|
2882 | + deleteMessages(null, null); |
|
2883 | + } |
|
2772 | 2884 | // Otherwise just the selected folder. |
2773 | - else |
|
2774 | - deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
2885 | + else { |
|
2886 | + deleteMessages(null, $_REQUEST['f'] != 'sent' ? 'inbox' : 'sent'); |
|
2887 | + } |
|
2775 | 2888 | |
2776 | 2889 | // Done... all gone. |
2777 | 2890 | redirectexit($context['current_label_redirect']); |
@@ -2808,8 +2921,9 @@ discard block |
||
2808 | 2921 | 'msgtime' => $deleteTime, |
2809 | 2922 | ) |
2810 | 2923 | ); |
2811 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
2812 | - $toDelete[] = $row[0]; |
|
2924 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
2925 | + $toDelete[] = $row[0]; |
|
2926 | + } |
|
2813 | 2927 | $smcFunc['db_free_result']($request); |
2814 | 2928 | |
2815 | 2929 | // Select all messages in their inbox older than $deleteTime. |
@@ -2826,8 +2940,9 @@ discard block |
||
2826 | 2940 | 'msgtime' => $deleteTime, |
2827 | 2941 | ) |
2828 | 2942 | ); |
2829 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2830 | - $toDelete[] = $row['id_pm']; |
|
2943 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
2944 | + $toDelete[] = $row['id_pm']; |
|
2945 | + } |
|
2831 | 2946 | $smcFunc['db_free_result']($request); |
2832 | 2947 | |
2833 | 2948 | // Delete the actual messages. |
@@ -2858,26 +2973,29 @@ discard block |
||
2858 | 2973 | { |
2859 | 2974 | global $user_info, $smcFunc; |
2860 | 2975 | |
2861 | - if ($owner === null) |
|
2862 | - $owner = array($user_info['id']); |
|
2863 | - elseif (empty($owner)) |
|
2864 | - return; |
|
2865 | - elseif (!is_array($owner)) |
|
2866 | - $owner = array($owner); |
|
2976 | + if ($owner === null) { |
|
2977 | + $owner = array($user_info['id']); |
|
2978 | + } elseif (empty($owner)) { |
|
2979 | + return; |
|
2980 | + } elseif (!is_array($owner)) { |
|
2981 | + $owner = array($owner); |
|
2982 | + } |
|
2867 | 2983 | |
2868 | 2984 | if ($personal_messages !== null) |
2869 | 2985 | { |
2870 | - if (empty($personal_messages) || !is_array($personal_messages)) |
|
2871 | - return; |
|
2986 | + if (empty($personal_messages) || !is_array($personal_messages)) { |
|
2987 | + return; |
|
2988 | + } |
|
2872 | 2989 | |
2873 | - foreach ($personal_messages as $index => $delete_id) |
|
2874 | - $personal_messages[$index] = (int) $delete_id; |
|
2990 | + foreach ($personal_messages as $index => $delete_id) { |
|
2991 | + $personal_messages[$index] = (int) $delete_id; |
|
2992 | + } |
|
2875 | 2993 | |
2876 | 2994 | $where = ' |
2877 | 2995 | AND id_pm IN ({array_int:pm_list})'; |
2996 | + } else { |
|
2997 | + $where = ''; |
|
2878 | 2998 | } |
2879 | - else |
|
2880 | - $where = ''; |
|
2881 | 2999 | |
2882 | 3000 | if ($folder == 'sent' || $folder === null) |
2883 | 3001 | { |
@@ -2912,17 +3030,19 @@ discard block |
||
2912 | 3030 | // ...And update the statistics accordingly - now including unread messages!. |
2913 | 3031 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
2914 | 3032 | { |
2915 | - if ($row['is_read']) |
|
2916 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
2917 | - else |
|
2918 | - updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
3033 | + if ($row['is_read']) { |
|
3034 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'])); |
|
3035 | + } else { |
|
3036 | + updateMemberData($row['id_member'], array('instant_messages' => $where == '' ? 0 : 'instant_messages - ' . $row['num_deleted_messages'], 'unread_messages' => $where == '' ? 0 : 'unread_messages - ' . $row['num_deleted_messages'])); |
|
3037 | + } |
|
2919 | 3038 | |
2920 | 3039 | // If this is the current member we need to make their message count correct. |
2921 | 3040 | if ($user_info['id'] == $row['id_member']) |
2922 | 3041 | { |
2923 | 3042 | $user_info['messages'] -= $row['num_deleted_messages']; |
2924 | - if (!($row['is_read'])) |
|
2925 | - $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
3043 | + if (!($row['is_read'])) { |
|
3044 | + $user_info['unread_messages'] -= $row['num_deleted_messages']; |
|
3045 | + } |
|
2926 | 3046 | } |
2927 | 3047 | } |
2928 | 3048 | $smcFunc['db_free_result']($request); |
@@ -2990,8 +3110,9 @@ discard block |
||
2990 | 3110 | ) |
2991 | 3111 | ); |
2992 | 3112 | $remove_pms = array(); |
2993 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
2994 | - $remove_pms[] = $row['sender']; |
|
3113 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3114 | + $remove_pms[] = $row['sender']; |
|
3115 | + } |
|
2995 | 3116 | $smcFunc['db_free_result']($request); |
2996 | 3117 | |
2997 | 3118 | if (!empty($remove_pms)) |
@@ -3036,8 +3157,9 @@ discard block |
||
3036 | 3157 | { |
3037 | 3158 | global $user_info, $context, $smcFunc; |
3038 | 3159 | |
3039 | - if ($owner === null) |
|
3040 | - $owner = $user_info['id']; |
|
3160 | + if ($owner === null) { |
|
3161 | + $owner = $user_info['id']; |
|
3162 | + } |
|
3041 | 3163 | |
3042 | 3164 | $in_inbox = ''; |
3043 | 3165 | |
@@ -3061,8 +3183,7 @@ discard block |
||
3061 | 3183 | } |
3062 | 3184 | |
3063 | 3185 | $smcFunc['db_free_result']($get_messages); |
3064 | - } |
|
3065 | - elseif ($label = '-1') |
|
3186 | + } elseif ($label = '-1') |
|
3066 | 3187 | { |
3067 | 3188 | // Marking all PMs in your inbox read |
3068 | 3189 | $in_inbox = ' |
@@ -3087,8 +3208,9 @@ discard block |
||
3087 | 3208 | { |
3088 | 3209 | if ($owner == $user_info['id']) |
3089 | 3210 | { |
3090 | - foreach ($context['labels'] as $label) |
|
3091 | - $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
3211 | + foreach ($context['labels'] as $label) { |
|
3212 | + $context['labels'][(int) $label['id']]['unread_messages'] = 0; |
|
3213 | + } |
|
3092 | 3214 | } |
3093 | 3215 | |
3094 | 3216 | $result = $smcFunc['db_query']('', ' |
@@ -3108,8 +3230,9 @@ discard block |
||
3108 | 3230 | { |
3109 | 3231 | $total_unread += $row['num']; |
3110 | 3232 | |
3111 | - if ($owner != $user_info['id'] || empty($row['id_pm'])) |
|
3112 | - continue; |
|
3233 | + if ($owner != $user_info['id'] || empty($row['id_pm'])) { |
|
3234 | + continue; |
|
3235 | + } |
|
3113 | 3236 | |
3114 | 3237 | $this_labels = array(); |
3115 | 3238 | |
@@ -3133,11 +3256,13 @@ discard block |
||
3133 | 3256 | |
3134 | 3257 | $smcFunc['db_free_result']($result2); |
3135 | 3258 | |
3136 | - foreach ($this_labels as $this_label) |
|
3137 | - $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
3259 | + foreach ($this_labels as $this_label) { |
|
3260 | + $context['labels'][$this_label]['unread_messages'] += $row['num']; |
|
3261 | + } |
|
3138 | 3262 | |
3139 | - if ($row['in_inbox'] == 1) |
|
3140 | - $context['labels'][-1]['unread_messages'] += $row['num']; |
|
3263 | + if ($row['in_inbox'] == 1) { |
|
3264 | + $context['labels'][-1]['unread_messages'] += $row['num']; |
|
3265 | + } |
|
3141 | 3266 | } |
3142 | 3267 | $smcFunc['db_free_result']($result); |
3143 | 3268 | |
@@ -3146,8 +3271,9 @@ discard block |
||
3146 | 3271 | updateMemberData($owner, array('unread_messages' => $total_unread)); |
3147 | 3272 | |
3148 | 3273 | // If it was for the current member, reflect this in the $user_info array too. |
3149 | - if ($owner == $user_info['id']) |
|
3150 | - $user_info['unread_messages'] = $total_unread; |
|
3274 | + if ($owner == $user_info['id']) { |
|
3275 | + $user_info['unread_messages'] = $total_unread; |
|
3276 | + } |
|
3151 | 3277 | } |
3152 | 3278 | } |
3153 | 3279 | |
@@ -3175,8 +3301,9 @@ discard block |
||
3175 | 3301 | // Add all existing labels to the array to save, slashing them as necessary... |
3176 | 3302 | foreach ($context['labels'] as $label) |
3177 | 3303 | { |
3178 | - if ($label['id'] != -1) |
|
3179 | - $the_labels[$label['id']] = $label['name']; |
|
3304 | + if ($label['id'] != -1) { |
|
3305 | + $the_labels[$label['id']] = $label['name']; |
|
3306 | + } |
|
3180 | 3307 | } |
3181 | 3308 | |
3182 | 3309 | if (isset($_POST[$context['session_var']])) |
@@ -3195,8 +3322,9 @@ discard block |
||
3195 | 3322 | { |
3196 | 3323 | $_POST['label'] = strtr($smcFunc['htmlspecialchars'](trim($_POST['label'])), array(',' => ',')); |
3197 | 3324 | |
3198 | - if ($smcFunc['strlen']($_POST['label']) > 30) |
|
3199 | - $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
3325 | + if ($smcFunc['strlen']($_POST['label']) > 30) { |
|
3326 | + $_POST['label'] = $smcFunc['substr']($_POST['label'], 0, 30); |
|
3327 | + } |
|
3200 | 3328 | if ($_POST['label'] != '') |
3201 | 3329 | { |
3202 | 3330 | $the_labels[] = $_POST['label']; |
@@ -3217,24 +3345,25 @@ discard block |
||
3217 | 3345 | { |
3218 | 3346 | foreach ($the_labels as $id => $name) |
3219 | 3347 | { |
3220 | - if ($id == -1) |
|
3221 | - continue; |
|
3222 | - elseif (isset($_POST['label_name'][$id])) |
|
3348 | + if ($id == -1) { |
|
3349 | + continue; |
|
3350 | + } elseif (isset($_POST['label_name'][$id])) |
|
3223 | 3351 | { |
3224 | 3352 | $_POST['label_name'][$id] = trim(strtr($smcFunc['htmlspecialchars']($_POST['label_name'][$id]), array(',' => ','))); |
3225 | 3353 | |
3226 | - if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) |
|
3227 | - $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
3354 | + if ($smcFunc['strlen']($_POST['label_name'][$id]) > 30) { |
|
3355 | + $_POST['label_name'][$id] = $smcFunc['substr']($_POST['label_name'][$id], 0, 30); |
|
3356 | + } |
|
3228 | 3357 | if ($_POST['label_name'][$id] != '') |
3229 | 3358 | { |
3230 | 3359 | // Changing the name of this label? |
3231 | - if ($the_labels[$id] != $_POST['label_name'][$id]) |
|
3232 | - $label_updates[$id] = $_POST['label_name'][$id]; |
|
3360 | + if ($the_labels[$id] != $_POST['label_name'][$id]) { |
|
3361 | + $label_updates[$id] = $_POST['label_name'][$id]; |
|
3362 | + } |
|
3233 | 3363 | |
3234 | 3364 | $the_labels[(int) $id] = $_POST['label_name'][$id]; |
3235 | 3365 | |
3236 | - } |
|
3237 | - else |
|
3366 | + } else |
|
3238 | 3367 | { |
3239 | 3368 | unset($the_labels[(int) $id]); |
3240 | 3369 | $labels_to_remove[] = $id; |
@@ -3248,8 +3377,9 @@ discard block |
||
3248 | 3377 | if (!empty($labels_to_add)) |
3249 | 3378 | { |
3250 | 3379 | $inserts = array(); |
3251 | - foreach ($labels_to_add AS $label) |
|
3252 | - $inserts[] = array($user_info['id'], $label); |
|
3380 | + foreach ($labels_to_add AS $label) { |
|
3381 | + $inserts[] = array($user_info['id'], $label); |
|
3382 | + } |
|
3253 | 3383 | |
3254 | 3384 | $smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array()); |
3255 | 3385 | } |
@@ -3339,8 +3469,9 @@ discard block |
||
3339 | 3469 | // Each action... |
3340 | 3470 | foreach ($rule['actions'] as $k2 => $action) |
3341 | 3471 | { |
3342 | - if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) |
|
3343 | - continue; |
|
3472 | + if ($action['t'] != 'lab' || !in_array($action['v'], $labels_to_remove)) { |
|
3473 | + continue; |
|
3474 | + } |
|
3344 | 3475 | |
3345 | 3476 | $rule_changes[] = $rule['id']; |
3346 | 3477 | |
@@ -3355,8 +3486,8 @@ discard block |
||
3355 | 3486 | { |
3356 | 3487 | $rule_changes = array_unique($rule_changes); |
3357 | 3488 | // Update/delete as appropriate. |
3358 | - foreach ($rule_changes as $k => $id) |
|
3359 | - if (!empty($context['rules'][$id]['actions'])) |
|
3489 | + foreach ($rule_changes as $k => $id) { |
|
3490 | + if (!empty($context['rules'][$id]['actions'])) |
|
3360 | 3491 | { |
3361 | 3492 | $smcFunc['db_query']('', ' |
3362 | 3493 | UPDATE {db_prefix}pm_rules |
@@ -3369,12 +3500,13 @@ discard block |
||
3369 | 3500 | 'actions' => $smcFunc['json_encode']($context['rules'][$id]['actions']), |
3370 | 3501 | ) |
3371 | 3502 | ); |
3503 | + } |
|
3372 | 3504 | unset($rule_changes[$k]); |
3373 | 3505 | } |
3374 | 3506 | |
3375 | 3507 | // Anything left here means it's lost all actions... |
3376 | - if (!empty($rule_changes)) |
|
3377 | - $smcFunc['db_query']('', ' |
|
3508 | + if (!empty($rule_changes)) { |
|
3509 | + $smcFunc['db_query']('', ' |
|
3378 | 3510 | DELETE FROM {db_prefix}pm_rules |
3379 | 3511 | WHERE id_rule IN ({array_int:rule_list}) |
3380 | 3512 | AND id_member = {int:current_member}', |
@@ -3383,6 +3515,7 @@ discard block |
||
3383 | 3515 | 'rule_list' => $rule_changes, |
3384 | 3516 | ) |
3385 | 3517 | ); |
3518 | + } |
|
3386 | 3519 | } |
3387 | 3520 | |
3388 | 3521 | // Make sure we're not caching this! |
@@ -3452,8 +3585,9 @@ discard block |
||
3452 | 3585 | // Save the fields. |
3453 | 3586 | saveProfileFields(); |
3454 | 3587 | |
3455 | - if (!empty($profile_vars)) |
|
3456 | - updateMemberData($user_info['id'], $profile_vars); |
|
3588 | + if (!empty($profile_vars)) { |
|
3589 | + updateMemberData($user_info['id'], $profile_vars); |
|
3590 | + } |
|
3457 | 3591 | } |
3458 | 3592 | |
3459 | 3593 | setupProfileContext( |
@@ -3478,13 +3612,15 @@ discard block |
||
3478 | 3612 | global $user_info, $language, $modSettings, $smcFunc; |
3479 | 3613 | |
3480 | 3614 | // Check that this feature is even enabled! |
3481 | - if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) |
|
3482 | - fatal_lang_error('no_access', false); |
|
3615 | + if (empty($modSettings['enableReportPM']) || empty($_REQUEST['pmsg'])) { |
|
3616 | + fatal_lang_error('no_access', false); |
|
3617 | + } |
|
3483 | 3618 | |
3484 | 3619 | $pmsg = (int) $_REQUEST['pmsg']; |
3485 | 3620 | |
3486 | - if (!isAccessiblePM($pmsg, 'inbox')) |
|
3487 | - fatal_lang_error('no_access', false); |
|
3621 | + if (!isAccessiblePM($pmsg, 'inbox')) { |
|
3622 | + fatal_lang_error('no_access', false); |
|
3623 | + } |
|
3488 | 3624 | |
3489 | 3625 | $context['pm_id'] = $pmsg; |
3490 | 3626 | $context['page_title'] = $txt['pm_report_title']; |
@@ -3506,8 +3642,9 @@ discard block |
||
3506 | 3642 | ) |
3507 | 3643 | ); |
3508 | 3644 | $context['admins'] = array(); |
3509 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3510 | - $context['admins'][$row['id_member']] = $row['real_name']; |
|
3645 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3646 | + $context['admins'][$row['id_member']] = $row['real_name']; |
|
3647 | + } |
|
3511 | 3648 | $smcFunc['db_free_result']($request); |
3512 | 3649 | |
3513 | 3650 | // How many admins in total? |
@@ -3536,8 +3673,9 @@ discard block |
||
3536 | 3673 | ) |
3537 | 3674 | ); |
3538 | 3675 | // Can only be a hacker here! |
3539 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
3540 | - fatal_lang_error('no_access', false); |
|
3676 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
3677 | + fatal_lang_error('no_access', false); |
|
3678 | + } |
|
3541 | 3679 | list ($subject, $body, $time, $memberFromID, $memberFromName) = $smcFunc['db_fetch_row']($request); |
3542 | 3680 | $smcFunc['db_free_result']($request); |
3543 | 3681 | |
@@ -3561,15 +3699,17 @@ discard block |
||
3561 | 3699 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3562 | 3700 | { |
3563 | 3701 | // If it's hidden still don't reveal their names - privacy after all ;) |
3564 | - if ($row['bcc']) |
|
3565 | - $hidden_recipients++; |
|
3566 | - else |
|
3567 | - $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
3702 | + if ($row['bcc']) { |
|
3703 | + $hidden_recipients++; |
|
3704 | + } else { |
|
3705 | + $recipients[] = '[url=' . $scripturl . '?action=profile;u=' . $row['id_member_to'] . ']' . $row['to_name'] . '[/url]'; |
|
3706 | + } |
|
3568 | 3707 | } |
3569 | 3708 | $smcFunc['db_free_result']($request); |
3570 | 3709 | |
3571 | - if ($hidden_recipients) |
|
3572 | - $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
3710 | + if ($hidden_recipients) { |
|
3711 | + $recipients[] = sprintf($txt['pm_report_pm_hidden'], $hidden_recipients); |
|
3712 | + } |
|
3573 | 3713 | |
3574 | 3714 | // Now let's get out and loop through the admins. |
3575 | 3715 | $request = $smcFunc['db_query']('', ' |
@@ -3585,8 +3725,9 @@ discard block |
||
3585 | 3725 | ); |
3586 | 3726 | |
3587 | 3727 | // Maybe we shouldn't advertise this? |
3588 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
3589 | - fatal_lang_error('no_access', false); |
|
3728 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
3729 | + fatal_lang_error('no_access', false); |
|
3730 | + } |
|
3590 | 3731 | |
3591 | 3732 | $memberFromName = un_htmlspecialchars($memberFromName); |
3592 | 3733 | |
@@ -3605,8 +3746,9 @@ discard block |
||
3605 | 3746 | // Make the body. |
3606 | 3747 | $report_body = str_replace(array('{REPORTER}', '{SENDER}'), array(un_htmlspecialchars($user_info['name']), $memberFromName), $txt['pm_report_pm_user_sent']); |
3607 | 3748 | $report_body .= "\n" . '[b]' . $_POST['reason'] . '[/b]' . "\n\n"; |
3608 | - if (!empty($recipients)) |
|
3609 | - $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
3749 | + if (!empty($recipients)) { |
|
3750 | + $report_body .= $txt['pm_report_pm_other_recipients'] . ' ' . implode(', ', $recipients) . "\n\n"; |
|
3751 | + } |
|
3610 | 3752 | $report_body .= $txt['pm_report_pm_unedited_below'] . "\n" . '[quote author=' . (empty($memberFromID) ? '"' . $memberFromName . '"' : $memberFromName . ' link=action=profile;u=' . $memberFromID . ' date=' . $time) . ']' . "\n" . un_htmlspecialchars($body) . '[/quote]'; |
3611 | 3753 | |
3612 | 3754 | // Plonk it in the array ;) |
@@ -3626,12 +3768,14 @@ discard block |
||
3626 | 3768 | $smcFunc['db_free_result']($request); |
3627 | 3769 | |
3628 | 3770 | // Send a different email for each language. |
3629 | - foreach ($messagesToSend as $lang => $message) |
|
3630 | - sendpm($message['recipients'], $message['subject'], $message['body']); |
|
3771 | + foreach ($messagesToSend as $lang => $message) { |
|
3772 | + sendpm($message['recipients'], $message['subject'], $message['body']); |
|
3773 | + } |
|
3631 | 3774 | |
3632 | 3775 | // Give the user their own language back! |
3633 | - if (!empty($modSettings['userLanguage'])) |
|
3634 | - loadLanguage('PersonalMessage', '', false); |
|
3776 | + if (!empty($modSettings['userLanguage'])) { |
|
3777 | + loadLanguage('PersonalMessage', '', false); |
|
3778 | + } |
|
3635 | 3779 | |
3636 | 3780 | // Leave them with a template. |
3637 | 3781 | $context['sub_template'] = 'report_message_complete'; |
@@ -3677,8 +3821,9 @@ discard block |
||
3677 | 3821 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
3678 | 3822 | { |
3679 | 3823 | // Hide hidden groups! |
3680 | - if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) |
|
3681 | - continue; |
|
3824 | + if ($row['hidden'] && !$row['can_moderate'] && !allowedTo('manage_membergroups')) { |
|
3825 | + continue; |
|
3826 | + } |
|
3682 | 3827 | |
3683 | 3828 | $context['groups'][$row['id_group']] = $row['group_name']; |
3684 | 3829 | } |
@@ -3704,9 +3849,10 @@ discard block |
||
3704 | 3849 | $context['rule'] = $context['rules'][$context['rid']]; |
3705 | 3850 | $members = array(); |
3706 | 3851 | // Need to get member names! |
3707 | - foreach ($context['rule']['criteria'] as $k => $criteria) |
|
3708 | - if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
3852 | + foreach ($context['rule']['criteria'] as $k => $criteria) { |
|
3853 | + if ($criteria['t'] == 'mid' && !empty($criteria['v'])) |
|
3709 | 3854 | $members[(int) $criteria['v']] = $k; |
3855 | + } |
|
3710 | 3856 | |
3711 | 3857 | if (!empty($members)) |
3712 | 3858 | { |
@@ -3718,19 +3864,20 @@ discard block |
||
3718 | 3864 | 'member_list' => array_keys($members), |
3719 | 3865 | ) |
3720 | 3866 | ); |
3721 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
3722 | - $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
3867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
3868 | + $context['rule']['criteria'][$members[$row['id_member']]]['v'] = $row['member_name']; |
|
3869 | + } |
|
3723 | 3870 | $smcFunc['db_free_result']($request); |
3724 | 3871 | } |
3725 | - } |
|
3726 | - else |
|
3727 | - $context['rule'] = array( |
|
3872 | + } else { |
|
3873 | + $context['rule'] = array( |
|
3728 | 3874 | 'id' => '', |
3729 | 3875 | 'name' => '', |
3730 | 3876 | 'criteria' => array(), |
3731 | 3877 | 'actions' => array(), |
3732 | 3878 | 'logic' => 'and', |
3733 | 3879 | ); |
3880 | + } |
|
3734 | 3881 | } |
3735 | 3882 | // Saving? |
3736 | 3883 | elseif (isset($_GET['save'])) |
@@ -3740,22 +3887,25 @@ discard block |
||
3740 | 3887 | |
3741 | 3888 | // Name is easy! |
3742 | 3889 | $ruleName = $smcFunc['htmlspecialchars'](trim($_POST['rule_name'])); |
3743 | - if (empty($ruleName)) |
|
3744 | - fatal_lang_error('pm_rule_no_name', false); |
|
3890 | + if (empty($ruleName)) { |
|
3891 | + fatal_lang_error('pm_rule_no_name', false); |
|
3892 | + } |
|
3745 | 3893 | |
3746 | 3894 | // Sanity check... |
3747 | - if (empty($_POST['ruletype']) || empty($_POST['acttype'])) |
|
3748 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
3895 | + if (empty($_POST['ruletype']) || empty($_POST['acttype'])) { |
|
3896 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
3897 | + } |
|
3749 | 3898 | |
3750 | 3899 | // Let's do the criteria first - it's also hardest! |
3751 | 3900 | $criteria = array(); |
3752 | 3901 | foreach ($_POST['ruletype'] as $ind => $type) |
3753 | 3902 | { |
3754 | 3903 | // Check everything is here... |
3755 | - if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) |
|
3756 | - continue; |
|
3757 | - elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) |
|
3758 | - continue; |
|
3904 | + if ($type == 'gid' && (!isset($_POST['ruledefgroup'][$ind]) || !isset($context['groups'][$_POST['ruledefgroup'][$ind]]))) { |
|
3905 | + continue; |
|
3906 | + } elseif ($type != 'bud' && !isset($_POST['ruledef'][$ind])) { |
|
3907 | + continue; |
|
3908 | + } |
|
3759 | 3909 | |
3760 | 3910 | // Members need to be found. |
3761 | 3911 | if ($type == 'mid') |
@@ -3779,13 +3929,13 @@ discard block |
||
3779 | 3929 | $smcFunc['db_free_result']($request); |
3780 | 3930 | |
3781 | 3931 | $criteria[] = array('t' => 'mid', 'v' => $memID); |
3932 | + } elseif ($type == 'bud') { |
|
3933 | + $criteria[] = array('t' => 'bud', 'v' => 1); |
|
3934 | + } elseif ($type == 'gid') { |
|
3935 | + $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
3936 | + } elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') { |
|
3937 | + $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
3782 | 3938 | } |
3783 | - elseif ($type == 'bud') |
|
3784 | - $criteria[] = array('t' => 'bud', 'v' => 1); |
|
3785 | - elseif ($type == 'gid') |
|
3786 | - $criteria[] = array('t' => 'gid', 'v' => (int) $_POST['ruledefgroup'][$ind]); |
|
3787 | - elseif (in_array($type, array('sub', 'msg')) && trim($_POST['ruledef'][$ind]) != '') |
|
3788 | - $criteria[] = array('t' => $type, 'v' => $smcFunc['htmlspecialchars'](trim($_POST['ruledef'][$ind]))); |
|
3789 | 3939 | } |
3790 | 3940 | |
3791 | 3941 | // Also do the actions! |
@@ -3795,26 +3945,29 @@ discard block |
||
3795 | 3945 | foreach ($_POST['acttype'] as $ind => $type) |
3796 | 3946 | { |
3797 | 3947 | // Picking a valid label? |
3798 | - if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) |
|
3799 | - continue; |
|
3948 | + if ($type == 'lab' && (!isset($_POST['labdef'][$ind]) || !isset($context['labels'][$_POST['labdef'][$ind]]))) { |
|
3949 | + continue; |
|
3950 | + } |
|
3800 | 3951 | |
3801 | 3952 | // Record what we're doing. |
3802 | - if ($type == 'del') |
|
3803 | - $doDelete = 1; |
|
3804 | - elseif ($type == 'lab') |
|
3805 | - $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
3953 | + if ($type == 'del') { |
|
3954 | + $doDelete = 1; |
|
3955 | + } elseif ($type == 'lab') { |
|
3956 | + $actions[] = array('t' => 'lab', 'v' => (int) $_POST['labdef'][$ind]); |
|
3957 | + } |
|
3806 | 3958 | } |
3807 | 3959 | |
3808 | - if (empty($criteria) || (empty($actions) && !$doDelete)) |
|
3809 | - fatal_lang_error('pm_rule_no_criteria', false); |
|
3960 | + if (empty($criteria) || (empty($actions) && !$doDelete)) { |
|
3961 | + fatal_lang_error('pm_rule_no_criteria', false); |
|
3962 | + } |
|
3810 | 3963 | |
3811 | 3964 | // What are we storing? |
3812 | 3965 | $criteria = $smcFunc['json_encode']($criteria); |
3813 | 3966 | $actions = $smcFunc['json_encode']($actions); |
3814 | 3967 | |
3815 | 3968 | // Create the rule? |
3816 | - if (empty($context['rid'])) |
|
3817 | - $smcFunc['db_insert']('', |
|
3969 | + if (empty($context['rid'])) { |
|
3970 | + $smcFunc['db_insert']('', |
|
3818 | 3971 | '{db_prefix}pm_rules', |
3819 | 3972 | array( |
3820 | 3973 | 'id_member' => 'int', 'rule_name' => 'string', 'criteria' => 'string', 'actions' => 'string', |
@@ -3825,8 +3978,8 @@ discard block |
||
3825 | 3978 | ), |
3826 | 3979 | array('id_rule') |
3827 | 3980 | ); |
3828 | - else |
|
3829 | - $smcFunc['db_query']('', ' |
|
3981 | + } else { |
|
3982 | + $smcFunc['db_query']('', ' |
|
3830 | 3983 | UPDATE {db_prefix}pm_rules |
3831 | 3984 | SET rule_name = {string:rule_name}, criteria = {string:criteria}, actions = {string:actions}, |
3832 | 3985 | delete_pm = {int:delete_pm}, is_or = {int:is_or} |
@@ -3842,6 +3995,7 @@ discard block |
||
3842 | 3995 | 'actions' => $actions, |
3843 | 3996 | ) |
3844 | 3997 | ); |
3998 | + } |
|
3845 | 3999 | |
3846 | 4000 | redirectexit('action=pm;sa=manrules'); |
3847 | 4001 | } |
@@ -3850,11 +4004,12 @@ discard block |
||
3850 | 4004 | { |
3851 | 4005 | checkSession(); |
3852 | 4006 | $toDelete = array(); |
3853 | - foreach ($_POST['delrule'] as $k => $v) |
|
3854 | - $toDelete[] = (int) $k; |
|
4007 | + foreach ($_POST['delrule'] as $k => $v) { |
|
4008 | + $toDelete[] = (int) $k; |
|
4009 | + } |
|
3855 | 4010 | |
3856 | - if (!empty($toDelete)) |
|
3857 | - $smcFunc['db_query']('', ' |
|
4011 | + if (!empty($toDelete)) { |
|
4012 | + $smcFunc['db_query']('', ' |
|
3858 | 4013 | DELETE FROM {db_prefix}pm_rules |
3859 | 4014 | WHERE id_rule IN ({array_int:delete_list}) |
3860 | 4015 | AND id_member = {int:current_member}', |
@@ -3863,6 +4018,7 @@ discard block |
||
3863 | 4018 | 'delete_list' => $toDelete, |
3864 | 4019 | ) |
3865 | 4020 | ); |
4021 | + } |
|
3866 | 4022 | |
3867 | 4023 | redirectexit('action=pm;sa=manrules'); |
3868 | 4024 | } |
@@ -3881,8 +4037,9 @@ discard block |
||
3881 | 4037 | loadRules(); |
3882 | 4038 | |
3883 | 4039 | // No rules? |
3884 | - if (empty($context['rules'])) |
|
3885 | - return; |
|
4040 | + if (empty($context['rules'])) { |
|
4041 | + return; |
|
4042 | + } |
|
3886 | 4043 | |
3887 | 4044 | // Just unread ones? |
3888 | 4045 | $ruleQuery = $all_messages ? '' : ' AND pmr.is_new = 1'; |
@@ -3912,8 +4069,9 @@ discard block |
||
3912 | 4069 | // Loop through all the criteria hoping to make a match. |
3913 | 4070 | foreach ($rule['criteria'] as $criterium) |
3914 | 4071 | { |
3915 | - if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) |
|
3916 | - $match = true; |
|
4072 | + if (($criterium['t'] == 'mid' && $criterium['v'] == $row['id_member_from']) || ($criterium['t'] == 'gid' && $criterium['v'] == $row['id_group']) || ($criterium['t'] == 'sub' && strpos($row['subject'], $criterium['v']) !== false) || ($criterium['t'] == 'msg' && strpos($row['body'], $criterium['v']) !== false)) { |
|
4073 | + $match = true; |
|
4074 | + } |
|
3917 | 4075 | // If we're adding and one criteria don't match then we stop! |
3918 | 4076 | elseif ($rule['logic'] == 'and') |
3919 | 4077 | { |
@@ -3925,17 +4083,18 @@ discard block |
||
3925 | 4083 | // If we have a match the rule must be true - act! |
3926 | 4084 | if ($match) |
3927 | 4085 | { |
3928 | - if ($rule['delete']) |
|
3929 | - $actions['deletes'][] = $row['id_pm']; |
|
3930 | - else |
|
4086 | + if ($rule['delete']) { |
|
4087 | + $actions['deletes'][] = $row['id_pm']; |
|
4088 | + } else |
|
3931 | 4089 | { |
3932 | 4090 | foreach ($rule['actions'] as $ruleAction) |
3933 | 4091 | { |
3934 | 4092 | if ($ruleAction['t'] == 'lab') |
3935 | 4093 | { |
3936 | 4094 | // Get a basic pot started! |
3937 | - if (!isset($actions['labels'][$row['id_pm']])) |
|
3938 | - $actions['labels'][$row['id_pm']] = array(); |
|
4095 | + if (!isset($actions['labels'][$row['id_pm']])) { |
|
4096 | + $actions['labels'][$row['id_pm']] = array(); |
|
4097 | + } |
|
3939 | 4098 | $actions['labels'][$row['id_pm']][] = $ruleAction['v']; |
3940 | 4099 | } |
3941 | 4100 | } |
@@ -3946,8 +4105,9 @@ discard block |
||
3946 | 4105 | $smcFunc['db_free_result']($request); |
3947 | 4106 | |
3948 | 4107 | // Deletes are easy! |
3949 | - if (!empty($actions['deletes'])) |
|
3950 | - deleteMessages($actions['deletes']); |
|
4108 | + if (!empty($actions['deletes'])) { |
|
4109 | + deleteMessages($actions['deletes']); |
|
4110 | + } |
|
3951 | 4111 | |
3952 | 4112 | // Relabel? |
3953 | 4113 | if (!empty($actions['labels'])) |
@@ -3974,8 +4134,7 @@ discard block |
||
3974 | 4134 | 'current_member' => $user_info['id'], |
3975 | 4135 | ) |
3976 | 4136 | ); |
3977 | - } |
|
3978 | - else |
|
4137 | + } else |
|
3979 | 4138 | { |
3980 | 4139 | $realLabels[] = $label['id']; |
3981 | 4140 | } |
@@ -3984,8 +4143,9 @@ discard block |
||
3984 | 4143 | |
3985 | 4144 | $inserts = array(); |
3986 | 4145 | // Now we insert the label info |
3987 | - foreach ($realLabels as $a_label) |
|
3988 | - $inserts[] = array($pm, $a_label); |
|
4146 | + foreach ($realLabels as $a_label) { |
|
4147 | + $inserts[] = array($pm, $a_label); |
|
4148 | + } |
|
3989 | 4149 | |
3990 | 4150 | $smcFunc['db_insert']('ignore', |
3991 | 4151 | '{db_prefix}pm_labeled_messages', |
@@ -4006,8 +4166,9 @@ discard block |
||
4006 | 4166 | { |
4007 | 4167 | global $user_info, $context, $smcFunc; |
4008 | 4168 | |
4009 | - if (isset($context['rules']) && !$reload) |
|
4010 | - return; |
|
4169 | + if (isset($context['rules']) && !$reload) { |
|
4170 | + return; |
|
4171 | + } |
|
4011 | 4172 | |
4012 | 4173 | $request = $smcFunc['db_query']('', ' |
4013 | 4174 | SELECT |
@@ -4031,8 +4192,9 @@ discard block |
||
4031 | 4192 | 'logic' => $row['is_or'] ? 'or' : 'and', |
4032 | 4193 | ); |
4033 | 4194 | |
4034 | - if ($row['delete_pm']) |
|
4035 | - $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
4195 | + if ($row['delete_pm']) { |
|
4196 | + $context['rules'][$row['id_rule']]['actions'][] = array('t' => 'del', 'v' => 1); |
|
4197 | + } |
|
4036 | 4198 | } |
4037 | 4199 | $smcFunc['db_free_result']($request); |
4038 | 4200 | } |
@@ -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 | * Fetches a list of boards and (optional) categories including |
@@ -37,11 +38,12 @@ discard block |
||
37 | 38 | require_once($sourcedir . '/Subs-Boards.php'); |
38 | 39 | |
39 | 40 | // For performance, track the latest post while going through the boards. |
40 | - if (!empty($boardIndexOptions['set_latest_post'])) |
|
41 | - $latest_post = array( |
|
41 | + if (!empty($boardIndexOptions['set_latest_post'])) { |
|
42 | + $latest_post = array( |
|
42 | 43 | 'timestamp' => 0, |
43 | 44 | 'ref' => 0, |
44 | 45 | ); |
46 | + } |
|
45 | 47 | |
46 | 48 | // Find all boards and categories, as well as related information. This will be sorted by the natural order of boards and categories, which we control. |
47 | 49 | $result_boards = $smcFunc['db_query']('', ' |
@@ -74,10 +76,11 @@ discard block |
||
74 | 76 | ); |
75 | 77 | |
76 | 78 | // Start with an empty array. |
77 | - if ($boardIndexOptions['include_categories']) |
|
78 | - $categories = array(); |
|
79 | - else |
|
80 | - $this_category = array(); |
|
79 | + if ($boardIndexOptions['include_categories']) { |
|
80 | + $categories = array(); |
|
81 | + } else { |
|
82 | + $this_category = array(); |
|
83 | + } |
|
81 | 84 | $boards = array(); |
82 | 85 | |
83 | 86 | // Run through the categories and boards (or only boards).... |
@@ -88,8 +91,9 @@ discard block |
||
88 | 91 | $row_board['is_read'] = !empty($row_board['is_read']) || $ignoreThisBoard ? '1' : '0'; |
89 | 92 | |
90 | 93 | // Add parent boards to the $boards list later used to fetch moderators |
91 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) |
|
92 | - $boards[] = $row_board['id_board']; |
|
94 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id']) { |
|
95 | + $boards[] = $row_board['id_board']; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | if ($boardIndexOptions['include_categories']) |
95 | 99 | { |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | } |
112 | 116 | |
113 | 117 | // If this board has new posts in it (and isn't the recycle bin!) then the category is new. |
114 | - if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) |
|
115 | - $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
118 | + if (empty($modSettings['recycle_enable']) || $modSettings['recycle_board'] != $row_board['id_board']) { |
|
119 | + $categories[$row_board['id_cat']]['new'] |= empty($row_board['is_read']) && $row_board['poster_name'] != ''; |
|
120 | + } |
|
116 | 121 | |
117 | 122 | // Avoid showing category unread link where it only has redirection boards. |
118 | 123 | $categories[$row_board['id_cat']]['show_unread'] = !empty($categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect']; |
@@ -161,14 +166,12 @@ discard block |
||
161 | 166 | { |
162 | 167 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
163 | 168 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
164 | - } |
|
165 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
169 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
166 | 170 | { |
167 | 171 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
168 | 172 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
169 | 173 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
170 | - } |
|
171 | - else |
|
174 | + } else |
|
172 | 175 | { |
173 | 176 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
174 | 177 | } |
@@ -219,14 +222,16 @@ discard block |
||
219 | 222 | // Child of a child... just add it on... |
220 | 223 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
221 | 224 | { |
222 | - if (!isset($parent_map)) |
|
223 | - $parent_map = array(); |
|
225 | + if (!isset($parent_map)) { |
|
226 | + $parent_map = array(); |
|
227 | + } |
|
224 | 228 | |
225 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
226 | - foreach ($this_category as $id => $board) |
|
229 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
230 | + foreach ($this_category as $id => $board) |
|
227 | 231 | { |
228 | 232 | if (!isset($board['children'][$row_board['id_parent']])) |
229 | 233 | continue; |
234 | + } |
|
230 | 235 | |
231 | 236 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
232 | 237 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -247,8 +252,9 @@ discard block |
||
247 | 252 | continue; |
248 | 253 | } |
249 | 254 | // Found a child of a child - skip. |
250 | - else |
|
251 | - continue; |
|
255 | + else { |
|
256 | + continue; |
|
257 | + } |
|
252 | 258 | |
253 | 259 | // Prepare the subject, and make sure it's not too long. |
254 | 260 | censorText($row_board['subject']); |
@@ -269,12 +275,13 @@ discard block |
||
269 | 275 | 'topic' => $row_board['id_topic'] |
270 | 276 | ); |
271 | 277 | |
272 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
273 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
278 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
279 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
274 | 280 | 'avatar' => $row_board['avatar'], |
275 | 281 | 'email' => $row_board['email_address'], |
276 | 282 | 'filename' => !empty($row_board['member_filename']) ? $row_board['member_filename'] : '', |
277 | 283 | )); |
284 | + } |
|
278 | 285 | |
279 | 286 | // Provide the href and link. |
280 | 287 | if ($row_board['subject'] != '') |
@@ -286,8 +293,7 @@ discard block |
||
286 | 293 | link, href, subject, start (where they should go for the first unread post.), |
287 | 294 | and member. (which has id, name, link, href, username in it.) */ |
288 | 295 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
289 | - } |
|
290 | - else |
|
296 | + } else |
|
291 | 297 | { |
292 | 298 | $this_last_post['href'] = ''; |
293 | 299 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -295,8 +301,9 @@ discard block |
||
295 | 301 | } |
296 | 302 | |
297 | 303 | // Set the last post in the parent board. |
298 | - if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) |
|
299 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
304 | + if ($row_board['id_parent'] == $boardIndexOptions['parent_id'] || ($isChild && !empty($row_board['poster_time']) && $this_category[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time']))) { |
|
305 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
306 | + } |
|
300 | 307 | // Just in the child...? |
301 | 308 | if ($isChild) |
302 | 309 | { |
@@ -306,15 +313,17 @@ discard block |
||
306 | 313 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
307 | 314 | } |
308 | 315 | // No last post for this board? It's not new then, is it..? |
309 | - elseif ($row_board['poster_name'] == '') |
|
310 | - $this_category[$row_board['id_board']]['new'] = false; |
|
316 | + elseif ($row_board['poster_name'] == '') { |
|
317 | + $this_category[$row_board['id_board']]['new'] = false; |
|
318 | + } |
|
311 | 319 | |
312 | 320 | // Determine a global most recent topic. |
313 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
314 | - $latest_post = array( |
|
321 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
322 | + $latest_post = array( |
|
315 | 323 | 'timestamp' => $row_board['poster_time'], |
316 | 324 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
317 | 325 | ); |
326 | + } |
|
318 | 327 | } |
319 | 328 | $smcFunc['db_free_result']($result_boards); |
320 | 329 | |
@@ -331,8 +340,9 @@ discard block |
||
331 | 340 | if (!empty($moderators[$board['id']])) |
332 | 341 | { |
333 | 342 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
334 | - foreach ($moderators[$board['id']] as $moderator) |
|
335 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
343 | + foreach ($moderators[$board['id']] as $moderator) { |
|
344 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
345 | + } |
|
336 | 346 | } |
337 | 347 | if (!empty($groups[$board['id']])) |
338 | 348 | { |
@@ -345,16 +355,16 @@ discard block |
||
345 | 355 | } |
346 | 356 | } |
347 | 357 | } |
348 | - } |
|
349 | - else |
|
358 | + } else |
|
350 | 359 | { |
351 | 360 | foreach ($this_category as $k => $board) |
352 | 361 | { |
353 | 362 | if (!empty($moderators[$board['id']])) |
354 | 363 | { |
355 | 364 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
356 | - foreach ($moderators[$board['id']] as $moderator) |
|
357 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
365 | + foreach ($moderators[$board['id']] as $moderator) { |
|
366 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
367 | + } |
|
358 | 368 | } |
359 | 369 | if (!empty($groups[$board['id']])) |
360 | 370 | { |
@@ -368,20 +378,23 @@ discard block |
||
368 | 378 | } |
369 | 379 | } |
370 | 380 | |
371 | - if ($boardIndexOptions['include_categories']) |
|
372 | - sortCategories($categories); |
|
373 | - else |
|
374 | - sortBoards($this_category); |
|
381 | + if ($boardIndexOptions['include_categories']) { |
|
382 | + sortCategories($categories); |
|
383 | + } else { |
|
384 | + sortBoards($this_category); |
|
385 | + } |
|
375 | 386 | |
376 | 387 | // By now we should know the most recent post...if we wanna know it that is. |
377 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
378 | - $context['latest_post'] = $latest_post['ref']; |
|
388 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
389 | + $context['latest_post'] = $latest_post['ref']; |
|
390 | + } |
|
379 | 391 | |
380 | 392 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
381 | - if ($boardIndexOptions['include_categories']) |
|
382 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
383 | - else |
|
384 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
393 | + if ($boardIndexOptions['include_categories']) { |
|
394 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
395 | + } else { |
|
396 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
397 | + } |
|
385 | 398 | |
386 | 399 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
387 | 400 | } |
@@ -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 | * Main entry point for the admin search settings screen. |
@@ -107,11 +108,13 @@ discard block |
||
107 | 108 | // Perhaps the search method wants to add some settings? |
108 | 109 | require_once($sourcedir . '/Search.php'); |
109 | 110 | $searchAPI = findSearchAPI(); |
110 | - if (is_callable(array($searchAPI, 'searchSettings'))) |
|
111 | - call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
111 | + if (is_callable(array($searchAPI, 'searchSettings'))) { |
|
112 | + call_user_func_array(array($searchAPI, 'searchSettings'), array(&$config_vars)); |
|
113 | + } |
|
112 | 114 | |
113 | - if ($return_config) |
|
114 | - return $config_vars; |
|
115 | + if ($return_config) { |
|
116 | + return $config_vars; |
|
117 | + } |
|
115 | 118 | |
116 | 119 | $context['page_title'] = $txt['search_settings_title']; |
117 | 120 | $context['sub_template'] = 'show_settings'; |
@@ -126,8 +129,9 @@ discard block |
||
126 | 129 | |
127 | 130 | call_integration_hook('integrate_save_search_settings'); |
128 | 131 | |
129 | - if (empty($_POST['search_results_per_page'])) |
|
130 | - $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
132 | + if (empty($_POST['search_results_per_page'])) { |
|
133 | + $_POST['search_results_per_page'] = !empty($modSettings['search_results_per_page']) ? $modSettings['search_results_per_page'] : $modSettings['defaultMaxMessages']; |
|
134 | + } |
|
131 | 135 | saveDBSettings($config_vars); |
132 | 136 | $_SESSION['adm-save'] = true; |
133 | 137 | redirectexit('action=admin;area=managesearch;sa=settings;' . $context['session_var'] . '=' . $context['session_id']); |
@@ -177,17 +181,20 @@ discard block |
||
177 | 181 | call_integration_hook('integrate_save_search_weights'); |
178 | 182 | |
179 | 183 | $changes = array(); |
180 | - foreach ($factors as $factor) |
|
181 | - $changes[$factor] = (int) $_POST[$factor]; |
|
184 | + foreach ($factors as $factor) { |
|
185 | + $changes[$factor] = (int) $_POST[$factor]; |
|
186 | + } |
|
182 | 187 | updateSettings($changes); |
183 | 188 | } |
184 | 189 | |
185 | 190 | $context['relative_weights'] = array('total' => 0); |
186 | - foreach ($factors as $factor) |
|
187 | - $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
191 | + foreach ($factors as $factor) { |
|
192 | + $context['relative_weights']['total'] += isset($modSettings[$factor]) ? $modSettings[$factor] : 0; |
|
193 | + } |
|
188 | 194 | |
189 | - foreach ($factors as $factor) |
|
190 | - $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
195 | + foreach ($factors as $factor) { |
|
196 | + $context['relative_weights'][$factor] = round(100 * (isset($modSettings[$factor]) ? $modSettings[$factor] : 0) / $context['relative_weights']['total'], 1); |
|
197 | + } |
|
191 | 198 | |
192 | 199 | createToken('admin-msw'); |
193 | 200 | } |
@@ -215,8 +222,9 @@ discard block |
||
215 | 222 | $context['search_apis'] = loadSearchAPIs(); |
216 | 223 | |
217 | 224 | // Detect whether a fulltext index is set. |
218 | - if ($context['supports_fulltext']) |
|
219 | - detectFulltextIndex(); |
|
225 | + if ($context['supports_fulltext']) { |
|
226 | + detectFulltextIndex(); |
|
227 | + } |
|
220 | 228 | |
221 | 229 | if (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'createfulltext') |
222 | 230 | { |
@@ -240,8 +248,7 @@ discard block |
||
240 | 248 | 'language' => $language_ftx |
241 | 249 | ) |
242 | 250 | ); |
243 | - } |
|
244 | - else |
|
251 | + } else |
|
245 | 252 | { |
246 | 253 | // Make sure it's gone before creating it. |
247 | 254 | $smcFunc['db_query']('', ' |
@@ -259,8 +266,7 @@ discard block |
||
259 | 266 | ) |
260 | 267 | ); |
261 | 268 | } |
262 | - } |
|
263 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
269 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removefulltext' && !empty($context['fulltext_index'])) |
|
264 | 270 | { |
265 | 271 | checkSession('get'); |
266 | 272 | validateToken('admin-msm', 'get'); |
@@ -277,12 +283,12 @@ discard block |
||
277 | 283 | $context['fulltext_index'] = array(); |
278 | 284 | |
279 | 285 | // Go back to the default search method. |
280 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') |
|
281 | - updateSettings(array( |
|
286 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'fulltext') { |
|
287 | + updateSettings(array( |
|
282 | 288 | 'search_index' => '', |
283 | 289 | )); |
284 | - } |
|
285 | - elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
290 | + } |
|
291 | + } elseif (!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'removecustom') |
|
286 | 292 | { |
287 | 293 | checkSession('get'); |
288 | 294 | validateToken('admin-msm', 'get'); |
@@ -304,12 +310,12 @@ discard block |
||
304 | 310 | )); |
305 | 311 | |
306 | 312 | // Go back to the default search method. |
307 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
308 | - updateSettings(array( |
|
313 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
314 | + updateSettings(array( |
|
309 | 315 | 'search_index' => '', |
310 | 316 | )); |
311 | - } |
|
312 | - elseif (isset($_POST['save'])) |
|
317 | + } |
|
318 | + } elseif (isset($_POST['save'])) |
|
313 | 319 | { |
314 | 320 | checkSession(); |
315 | 321 | validateToken('admin-msmpost'); |
@@ -331,8 +337,8 @@ discard block |
||
331 | 337 | // Get some info about the messages table, to show its size and index size. |
332 | 338 | if ($db_type == 'mysql') |
333 | 339 | { |
334 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
335 | - $request = $smcFunc['db_query']('', ' |
|
340 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
341 | + $request = $smcFunc['db_query']('', ' |
|
336 | 342 | SHOW TABLE STATUS |
337 | 343 | FROM {string:database_name} |
338 | 344 | LIKE {string:table_name}', |
@@ -341,14 +347,15 @@ discard block |
||
341 | 347 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
342 | 348 | ) |
343 | 349 | ); |
344 | - else |
|
345 | - $request = $smcFunc['db_query']('', ' |
|
350 | + } else { |
|
351 | + $request = $smcFunc['db_query']('', ' |
|
346 | 352 | SHOW TABLE STATUS |
347 | 353 | LIKE {string:table_name}', |
348 | 354 | array( |
349 | 355 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
350 | 356 | ) |
351 | 357 | ); |
358 | + } |
|
352 | 359 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
353 | 360 | { |
354 | 361 | // Only do this if the user has permission to execute this query. |
@@ -360,8 +367,8 @@ discard block |
||
360 | 367 | } |
361 | 368 | |
362 | 369 | // Now check the custom index table, if it exists at all. |
363 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
364 | - $request = $smcFunc['db_query']('', ' |
|
370 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
371 | + $request = $smcFunc['db_query']('', ' |
|
365 | 372 | SHOW TABLE STATUS |
366 | 373 | FROM {string:database_name} |
367 | 374 | LIKE {string:table_name}', |
@@ -370,14 +377,15 @@ discard block |
||
370 | 377 | 'table_name' => str_replace('_', '\_', $match[2]) . 'log_search_words', |
371 | 378 | ) |
372 | 379 | ); |
373 | - else |
|
374 | - $request = $smcFunc['db_query']('', ' |
|
380 | + } else { |
|
381 | + $request = $smcFunc['db_query']('', ' |
|
375 | 382 | SHOW TABLE STATUS |
376 | 383 | LIKE {string:table_name}', |
377 | 384 | array( |
378 | 385 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'log_search_words', |
379 | 386 | ) |
380 | 387 | ); |
388 | + } |
|
381 | 389 | if ($request !== false && $smcFunc['db_num_rows']($request) == 1) |
382 | 390 | { |
383 | 391 | // Only do this if the user has permission to execute this query. |
@@ -386,8 +394,7 @@ discard block |
||
386 | 394 | $context['table_info']['custom_index_length'] = $row['Data_length'] + $row['Index_length']; |
387 | 395 | $smcFunc['db_free_result']($request); |
388 | 396 | } |
389 | - } |
|
390 | - elseif ($db_type == 'postgresql') |
|
397 | + } elseif ($db_type == 'postgresql') |
|
391 | 398 | { |
392 | 399 | // In order to report the sizes correctly we need to perform vacuum (optimize) on the tables we will be using. |
393 | 400 | //db_extend(); |
@@ -429,38 +436,38 @@ discard block |
||
429 | 436 | $context['table_info']['data_length'] = (int) $row['table_size']; |
430 | 437 | $context['table_info']['index_length'] = (int) $row['index_size']; |
431 | 438 | $context['table_info']['fulltext_length'] = (int) $row['index_size']; |
432 | - } |
|
433 | - elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
439 | + } elseif ($row['indexname'] == $db_prefix . 'log_search_words') |
|
434 | 440 | { |
435 | 441 | $context['table_info']['index_length'] = (int) $row['index_size']; |
436 | 442 | $context['table_info']['custom_index_length'] = (int) $row['index_size']; |
437 | 443 | } |
438 | 444 | } |
439 | 445 | $smcFunc['db_free_result']($request); |
440 | - } |
|
441 | - else |
|
442 | - // Didn't work for some reason... |
|
446 | + } else { |
|
447 | + // Didn't work for some reason... |
|
443 | 448 | $context['table_info'] = array( |
444 | 449 | 'data_length' => $txt['not_applicable'], |
445 | 450 | 'index_length' => $txt['not_applicable'], |
446 | 451 | 'fulltext_length' => $txt['not_applicable'], |
447 | 452 | 'custom_index_length' => $txt['not_applicable'], |
448 | 453 | ); |
449 | - } |
|
450 | - else |
|
451 | - $context['table_info'] = array( |
|
454 | + } |
|
455 | + } else { |
|
456 | + $context['table_info'] = array( |
|
452 | 457 | 'data_length' => $txt['not_applicable'], |
453 | 458 | 'index_length' => $txt['not_applicable'], |
454 | 459 | 'fulltext_length' => $txt['not_applicable'], |
455 | 460 | 'custom_index_length' => $txt['not_applicable'], |
456 | 461 | ); |
462 | + } |
|
457 | 463 | |
458 | 464 | // Format the data and index length in kilobytes. |
459 | 465 | foreach ($context['table_info'] as $type => $size) |
460 | 466 | { |
461 | 467 | // If it's not numeric then just break. This database engine doesn't support size. |
462 | - if (!is_numeric($size)) |
|
463 | - break; |
|
468 | + if (!is_numeric($size)) { |
|
469 | + break; |
|
470 | + } |
|
464 | 471 | |
465 | 472 | $context['table_info'][$type] = comma_format($context['table_info'][$type] / 1024) . ' ' . $txt['search_method_kilobytes']; |
466 | 473 | } |
@@ -489,8 +496,9 @@ discard block |
||
489 | 496 | |
490 | 497 | // Scotty, we need more time... |
491 | 498 | @set_time_limit(600); |
492 | - if (function_exists('apache_reset_timeout')) |
|
493 | - @apache_reset_timeout(); |
|
499 | + if (function_exists('apache_reset_timeout')) { |
|
500 | + @apache_reset_timeout(); |
|
501 | + } |
|
494 | 502 | |
495 | 503 | $context[$context['admin_menu_name']]['current_subsection'] = 'method'; |
496 | 504 | $context['page_title'] = $txt['search_index_custom']; |
@@ -520,8 +528,7 @@ discard block |
||
520 | 528 | $context['start'] = (int) $context['index_settings']['resume_at']; |
521 | 529 | unset($context['index_settings']['resume_at']); |
522 | 530 | $context['step'] = 1; |
523 | - } |
|
524 | - else |
|
531 | + } else |
|
525 | 532 | { |
526 | 533 | $context['index_settings'] = array( |
527 | 534 | 'bytes_per_word' => isset($_REQUEST['bytes_per_word']) && isset($index_properties[$_REQUEST['bytes_per_word']]) ? (int) $_REQUEST['bytes_per_word'] : 2, |
@@ -530,12 +537,14 @@ discard block |
||
530 | 537 | $context['step'] = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0; |
531 | 538 | |
532 | 539 | // admin timeouts are painful when building these long indexes - but only if we actually have such things enabled |
533 | - if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) |
|
534 | - $_SESSION['admin_time'] = time(); |
|
540 | + if (empty($modSettings['securityDisable']) && $_SESSION['admin_time'] + 3300 < time() && $context['step'] >= 1) { |
|
541 | + $_SESSION['admin_time'] = time(); |
|
542 | + } |
|
535 | 543 | } |
536 | 544 | |
537 | - if ($context['step'] !== 0) |
|
538 | - checkSession('request'); |
|
545 | + if ($context['step'] !== 0) { |
|
546 | + checkSession('request'); |
|
547 | + } |
|
539 | 548 | |
540 | 549 | // Step 0: let the user determine how they like their index. |
541 | 550 | if ($context['step'] === 0) |
@@ -564,12 +573,14 @@ discard block |
||
564 | 573 | $smcFunc['db_create_word_search']($index_properties[$context['index_settings']['bytes_per_word']]['column_definition']); |
565 | 574 | |
566 | 575 | // Temporarily switch back to not using a search index. |
567 | - if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') |
|
568 | - updateSettings(array('search_index' => '')); |
|
576 | + if (!empty($modSettings['search_index']) && $modSettings['search_index'] == 'custom') { |
|
577 | + updateSettings(array('search_index' => '')); |
|
578 | + } |
|
569 | 579 | |
570 | 580 | // Don't let simultanious processes be updating the search index. |
571 | - if (!empty($modSettings['search_custom_index_config'])) |
|
572 | - updateSettings(array('search_custom_index_config' => '')); |
|
581 | + if (!empty($modSettings['search_custom_index_config'])) { |
|
582 | + updateSettings(array('search_custom_index_config' => '')); |
|
583 | + } |
|
573 | 584 | } |
574 | 585 | |
575 | 586 | $num_messages = array( |
@@ -585,16 +596,16 @@ discard block |
||
585 | 596 | 'starting_id' => $context['start'], |
586 | 597 | ) |
587 | 598 | ); |
588 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
589 | - $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
599 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
600 | + $num_messages[empty($row['todo']) ? 'done' : 'todo'] = $row['num_messages']; |
|
601 | + } |
|
590 | 602 | |
591 | 603 | if (empty($num_messages['todo'])) |
592 | 604 | { |
593 | 605 | $context['step'] = 2; |
594 | 606 | $context['percentage'] = 80; |
595 | 607 | $context['start'] = 0; |
596 | - } |
|
597 | - else |
|
608 | + } else |
|
598 | 609 | { |
599 | 610 | // Number of seconds before the next step. |
600 | 611 | $stop = time() + 3; |
@@ -635,21 +646,22 @@ discard block |
||
635 | 646 | |
636 | 647 | $context['start'] += $forced_break ? $number_processed : $messages_per_batch; |
637 | 648 | |
638 | - if (!empty($inserts)) |
|
639 | - $smcFunc['db_insert']('ignore', |
|
649 | + if (!empty($inserts)) { |
|
650 | + $smcFunc['db_insert']('ignore', |
|
640 | 651 | '{db_prefix}log_search_words', |
641 | 652 | array('id_word' => 'int', 'id_msg' => 'int'), |
642 | 653 | $inserts, |
643 | 654 | array('id_word', 'id_msg') |
644 | 655 | ); |
656 | + } |
|
645 | 657 | if ($num_messages['todo'] === 0) |
646 | 658 | { |
647 | 659 | $context['step'] = 2; |
648 | 660 | $context['start'] = 0; |
649 | 661 | break; |
662 | + } else { |
|
663 | + updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
650 | 664 | } |
651 | - else |
|
652 | - updateSettings(array('search_custom_index_resume' => $smcFunc['json_encode'](array_merge($context['index_settings'], array('resume_at' => $context['start']))))); |
|
653 | 665 | } |
654 | 666 | |
655 | 667 | // Since there are still two steps to go, 80% is the maximum here. |
@@ -660,9 +672,9 @@ discard block |
||
660 | 672 | // Step 2: removing the words that occur too often and are of no use. |
661 | 673 | elseif ($context['step'] === 2) |
662 | 674 | { |
663 | - if ($context['index_settings']['bytes_per_word'] < 4) |
|
664 | - $context['step'] = 3; |
|
665 | - else |
|
675 | + if ($context['index_settings']['bytes_per_word'] < 4) { |
|
676 | + $context['step'] = 3; |
|
677 | + } else |
|
666 | 678 | { |
667 | 679 | $stop_words = $context['start'] === 0 || empty($modSettings['search_stopwords']) ? array() : explode(',', $modSettings['search_stopwords']); |
668 | 680 | $stop = time() + 3; |
@@ -683,20 +695,22 @@ discard block |
||
683 | 695 | 'minimum_messages' => $max_messages, |
684 | 696 | ) |
685 | 697 | ); |
686 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
687 | - $stop_words[] = $row['id_word']; |
|
698 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
699 | + $stop_words[] = $row['id_word']; |
|
700 | + } |
|
688 | 701 | $smcFunc['db_free_result']($request); |
689 | 702 | |
690 | 703 | updateSettings(array('search_stopwords' => implode(',', $stop_words))); |
691 | 704 | |
692 | - if (!empty($stop_words)) |
|
693 | - $smcFunc['db_query']('', ' |
|
705 | + if (!empty($stop_words)) { |
|
706 | + $smcFunc['db_query']('', ' |
|
694 | 707 | DELETE FROM {db_prefix}log_search_words |
695 | 708 | WHERE id_word in ({array_int:stop_words})', |
696 | 709 | array( |
697 | 710 | 'stop_words' => $stop_words, |
698 | 711 | ) |
699 | 712 | ); |
713 | + } |
|
700 | 714 | |
701 | 715 | $context['start'] += $index_properties[$context['index_settings']['bytes_per_word']]['step_size']; |
702 | 716 | if ($context['start'] > $index_properties[$context['index_settings']['bytes_per_word']]['max_size']) |
@@ -757,8 +771,9 @@ discard block |
||
757 | 771 | $searchAPI = new $search_class_name(); |
758 | 772 | |
759 | 773 | // No Support? NEXT! |
760 | - if (!$searchAPI->is_supported) |
|
761 | - continue; |
|
774 | + if (!$searchAPI->is_supported) { |
|
775 | + continue; |
|
776 | + } |
|
762 | 777 | |
763 | 778 | $apis[$index_name] = array( |
764 | 779 | 'filename' => $file, |
@@ -805,10 +820,10 @@ discard block |
||
805 | 820 | 'messages_ftx' => $db_prefix . 'messages_ftx', |
806 | 821 | ) |
807 | 822 | ); |
808 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
809 | - $context['fulltext_index'][] = $row['indexname']; |
|
810 | - } |
|
811 | - else |
|
823 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
824 | + $context['fulltext_index'][] = $row['indexname']; |
|
825 | + } |
|
826 | + } else |
|
812 | 827 | { |
813 | 828 | $request = $smcFunc['db_query']('', ' |
814 | 829 | SHOW INDEX |
@@ -819,17 +834,19 @@ discard block |
||
819 | 834 | $context['fulltext_index'] = array(); |
820 | 835 | if ($request !== false || $smcFunc['db_num_rows']($request) != 0) |
821 | 836 | { |
822 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
823 | - if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
837 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
838 | + if ($row['Column_name'] == 'body' && (isset($row['Index_type']) && $row['Index_type'] == 'FULLTEXT' || isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) |
|
824 | 839 | $context['fulltext_index'][] = $row['Key_name']; |
840 | + } |
|
825 | 841 | $smcFunc['db_free_result']($request); |
826 | 842 | |
827 | - if (is_array($context['fulltext_index'])) |
|
828 | - $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
843 | + if (is_array($context['fulltext_index'])) { |
|
844 | + $context['fulltext_index'] = array_unique($context['fulltext_index']); |
|
845 | + } |
|
829 | 846 | } |
830 | 847 | |
831 | - if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) |
|
832 | - $request = $smcFunc['db_query']('', ' |
|
848 | + if (preg_match('~^`(.+?)`\.(.+?)$~', $db_prefix, $match) !== 0) { |
|
849 | + $request = $smcFunc['db_query']('', ' |
|
833 | 850 | SHOW TABLE STATUS |
834 | 851 | FROM {string:database_name} |
835 | 852 | LIKE {string:table_name}', |
@@ -838,20 +855,22 @@ discard block |
||
838 | 855 | 'table_name' => str_replace('_', '\_', $match[2]) . 'messages', |
839 | 856 | ) |
840 | 857 | ); |
841 | - else |
|
842 | - $request = $smcFunc['db_query']('', ' |
|
858 | + } else { |
|
859 | + $request = $smcFunc['db_query']('', ' |
|
843 | 860 | SHOW TABLE STATUS |
844 | 861 | LIKE {string:table_name}', |
845 | 862 | array( |
846 | 863 | 'table_name' => str_replace('_', '\_', $db_prefix) . 'messages', |
847 | 864 | ) |
848 | 865 | ); |
866 | + } |
|
849 | 867 | |
850 | 868 | if ($request !== false) |
851 | 869 | { |
852 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
853 | - if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
870 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
871 | + if (isset($row['Engine']) && strtolower($row['Engine']) != 'myisam' && !(strtolower($row['Engine']) == 'innodb' && version_compare($smcFunc['db_get_version'](), '5.6.4', '>='))) |
|
854 | 872 | $context['cannot_create_fulltext'] = true; |
873 | + } |
|
855 | 874 | $smcFunc['db_free_result']($request); |
856 | 875 | } |
857 | 876 | } |
@@ -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 | * Get a list of versions that are currently installed on the server. |
@@ -45,8 +46,7 @@ discard block |
||
45 | 46 | $temp2 = $temp->getVersion(); |
46 | 47 | $im_version = $temp2['versionString']; |
47 | 48 | $extension_version = 'Imagick ' . phpversion('Imagick'); |
48 | - } |
|
49 | - else |
|
49 | + } else |
|
50 | 50 | { |
51 | 51 | $im_version = MagickGetVersionString(); |
52 | 52 | $extension_version = 'MagickWand ' . phpversion('MagickWand'); |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | if (in_array('db_server', $checkFor)) |
62 | 62 | { |
63 | 63 | db_extend(); |
64 | - if (!isset($db_connection) || $db_connection === false) |
|
65 | - trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
66 | - else |
|
64 | + if (!isset($db_connection) || $db_connection === false) { |
|
65 | + trigger_error('getServerVersions(): you need to be connected to the database in order to get its server version', E_USER_NOTICE); |
|
66 | + } else |
|
67 | 67 | { |
68 | 68 | $versions['db_engine'] = array('title' => sprintf($txt['support_versions_db_engine'], $smcFunc['db_title']), 'version' => ''); |
69 | 69 | $versions['db_engine']['version'] = $smcFunc['db_get_vendor'](); |
@@ -75,24 +75,31 @@ discard block |
||
75 | 75 | |
76 | 76 | // If we're using memcache we need the server info. |
77 | 77 | $memcache_version = '???'; |
78 | - if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) |
|
79 | - $memcache_version = $cacheAPI->getVersion(); |
|
78 | + if (!empty($cache_accelerator) && ($cache_accelerator == 'memcached' || $cache_accelerator == 'memcache') && !empty($cache_memcached) && !empty($cacheAPI)) { |
|
79 | + $memcache_version = $cacheAPI->getVersion(); |
|
80 | + } |
|
80 | 81 | |
81 | 82 | // Check to see if we have any accelerators installed... |
82 | - if (in_array('phpa', $checkFor) && isset($_PHPA)) |
|
83 | - $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
84 | - if (in_array('apc', $checkFor) && extension_loaded('apc')) |
|
85 | - $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
86 | - if (in_array('memcache', $checkFor) && function_exists('memcache_set')) |
|
87 | - $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
88 | - if (in_array('xcache', $checkFor) && function_exists('xcache_set')) |
|
89 | - $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
83 | + if (in_array('phpa', $checkFor) && isset($_PHPA)) { |
|
84 | + $versions['phpa'] = array('title' => 'ionCube PHP-Accelerator', 'version' => $_PHPA['VERSION']); |
|
85 | + } |
|
86 | + if (in_array('apc', $checkFor) && extension_loaded('apc')) { |
|
87 | + $versions['apc'] = array('title' => 'Alternative PHP Cache', 'version' => phpversion('apc')); |
|
88 | + } |
|
89 | + if (in_array('memcache', $checkFor) && function_exists('memcache_set')) { |
|
90 | + $versions['memcache'] = array('title' => 'Memcached', 'version' => $memcache_version); |
|
91 | + } |
|
92 | + if (in_array('xcache', $checkFor) && function_exists('xcache_set')) { |
|
93 | + $versions['xcache'] = array('title' => 'XCache', 'version' => XCACHE_VERSION); |
|
94 | + } |
|
90 | 95 | |
91 | - if (in_array('php', $checkFor)) |
|
92 | - $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
96 | + if (in_array('php', $checkFor)) { |
|
97 | + $versions['php'] = array('title' => 'PHP', 'version' => PHP_VERSION, 'more' => '?action=admin;area=serversettings;sa=phpinfo'); |
|
98 | + } |
|
93 | 99 | |
94 | - if (in_array('server', $checkFor)) |
|
95 | - $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
100 | + if (in_array('server', $checkFor)) { |
|
101 | + $versions['server'] = array('title' => $txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE']); |
|
102 | + } |
|
96 | 103 | |
97 | 104 | return $versions; |
98 | 105 | } |
@@ -132,11 +139,13 @@ discard block |
||
132 | 139 | fclose($fp); |
133 | 140 | |
134 | 141 | // The comment looks rougly like... that. |
135 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
136 | - $version_info['file_versions']['SSI.php'] = $match[1]; |
|
142 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
143 | + $version_info['file_versions']['SSI.php'] = $match[1]; |
|
144 | + } |
|
137 | 145 | // Not found! This is bad. |
138 | - else |
|
139 | - $version_info['file_versions']['SSI.php'] = '??'; |
|
146 | + else { |
|
147 | + $version_info['file_versions']['SSI.php'] = '??'; |
|
148 | + } |
|
140 | 149 | } |
141 | 150 | |
142 | 151 | // Do the paid subscriptions handler? |
@@ -147,11 +156,13 @@ discard block |
||
147 | 156 | fclose($fp); |
148 | 157 | |
149 | 158 | // Found it? |
150 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
151 | - $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
159 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
160 | + $version_info['file_versions']['subscriptions.php'] = $match[1]; |
|
161 | + } |
|
152 | 162 | // If we haven't how do we all get paid? |
153 | - else |
|
154 | - $version_info['file_versions']['subscriptions.php'] = '??'; |
|
163 | + else { |
|
164 | + $version_info['file_versions']['subscriptions.php'] = '??'; |
|
165 | + } |
|
155 | 166 | } |
156 | 167 | |
157 | 168 | // Load all the files in the Sources directory, except this file and the redirect. |
@@ -166,11 +177,13 @@ discard block |
||
166 | 177 | fclose($fp); |
167 | 178 | |
168 | 179 | // Look for the version comment in the file header. |
169 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
170 | - $version_info['file_versions'][$entry] = $match[1]; |
|
180 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
181 | + $version_info['file_versions'][$entry] = $match[1]; |
|
182 | + } |
|
171 | 183 | // It wasn't found, but the file was... show a '??'. |
172 | - else |
|
173 | - $version_info['file_versions'][$entry] = '??'; |
|
184 | + else { |
|
185 | + $version_info['file_versions'][$entry] = '??'; |
|
186 | + } |
|
174 | 187 | } |
175 | 188 | } |
176 | 189 | $sources_dir->close(); |
@@ -189,11 +202,13 @@ discard block |
||
189 | 202 | fclose($fp); |
190 | 203 | |
191 | 204 | // Look for the version comment in the file header. |
192 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
193 | - $version_info['tasks_versions'][$entry] = $match[1]; |
|
205 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
206 | + $version_info['tasks_versions'][$entry] = $match[1]; |
|
207 | + } |
|
194 | 208 | // It wasn't found, but the file was... show a '??'. |
195 | - else |
|
196 | - $version_info['tasks_versions'][$entry] = '??'; |
|
209 | + else { |
|
210 | + $version_info['tasks_versions'][$entry] = '??'; |
|
211 | + } |
|
197 | 212 | } |
198 | 213 | } |
199 | 214 | $tasks_dir->close(); |
@@ -201,8 +216,9 @@ discard block |
||
201 | 216 | |
202 | 217 | // Load all the files in the default template directory - and the current theme if applicable. |
203 | 218 | $directories = array('default_template_versions' => $settings['default_theme_dir']); |
204 | - if ($settings['theme_id'] != 1) |
|
205 | - $directories += array('template_versions' => $settings['theme_dir']); |
|
219 | + if ($settings['theme_id'] != 1) { |
|
220 | + $directories += array('template_versions' => $settings['theme_dir']); |
|
221 | + } |
|
206 | 222 | |
207 | 223 | foreach ($directories as $type => $dirname) |
208 | 224 | { |
@@ -217,11 +233,13 @@ discard block |
||
217 | 233 | fclose($fp); |
218 | 234 | |
219 | 235 | // Look for the version comment in the file header. |
220 | - if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) |
|
221 | - $version_info[$type][$entry] = $match[1]; |
|
236 | + if (preg_match('~\*\s@version\s+(.+)[\s]{2}~i', $header, $match) == 1) { |
|
237 | + $version_info[$type][$entry] = $match[1]; |
|
238 | + } |
|
222 | 239 | // It wasn't found, but the file was... show a '??'. |
223 | - else |
|
224 | - $version_info[$type][$entry] = '??'; |
|
240 | + else { |
|
241 | + $version_info[$type][$entry] = '??'; |
|
242 | + } |
|
225 | 243 | } |
226 | 244 | } |
227 | 245 | $this_dir->close(); |
@@ -242,11 +260,13 @@ discard block |
||
242 | 260 | list ($name, $language) = explode('.', $entry); |
243 | 261 | |
244 | 262 | // Look for the version comment in the file header. |
245 | - if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) |
|
246 | - $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
263 | + if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1) { |
|
264 | + $version_info['default_language_versions'][$language][$name] = $match[1]; |
|
265 | + } |
|
247 | 266 | // It wasn't found, but the file was... show a '??'. |
248 | - else |
|
249 | - $version_info['default_language_versions'][$language][$name] = '??'; |
|
267 | + else { |
|
268 | + $version_info['default_language_versions'][$language][$name] = '??'; |
|
269 | + } |
|
250 | 270 | } |
251 | 271 | } |
252 | 272 | $this_dir->close(); |
@@ -261,8 +281,9 @@ discard block |
||
261 | 281 | ksort($version_info['tasks_versions']); |
262 | 282 | |
263 | 283 | // For languages sort each language too. |
264 | - foreach ($version_info['default_language_versions'] as $language => $dummy) |
|
265 | - ksort($version_info['default_language_versions'][$language]); |
|
284 | + foreach ($version_info['default_language_versions'] as $language => $dummy) { |
|
285 | + ksort($version_info['default_language_versions'][$language]); |
|
286 | + } |
|
266 | 287 | } |
267 | 288 | return $version_info; |
268 | 289 | } |
@@ -304,27 +325,31 @@ discard block |
||
304 | 325 | $settingsArray = trim(file_get_contents($boarddir . '/Settings.php')); |
305 | 326 | |
306 | 327 | // Break it up based on \r or \n, and then clean out extra characters. |
307 | - if (strpos($settingsArray, "\n") !== false) |
|
308 | - $settingsArray = explode("\n", $settingsArray); |
|
309 | - elseif (strpos($settingsArray, "\r") !== false) |
|
310 | - $settingsArray = explode("\r", $settingsArray); |
|
311 | - else |
|
312 | - return; |
|
328 | + if (strpos($settingsArray, "\n") !== false) { |
|
329 | + $settingsArray = explode("\n", $settingsArray); |
|
330 | + } elseif (strpos($settingsArray, "\r") !== false) { |
|
331 | + $settingsArray = explode("\r", $settingsArray); |
|
332 | + } else { |
|
333 | + return; |
|
334 | + } |
|
313 | 335 | |
314 | 336 | // Presumably, the file has to have stuff in it for this function to be called :P. |
315 | - if (count($settingsArray) < 10) |
|
316 | - return; |
|
337 | + if (count($settingsArray) < 10) { |
|
338 | + return; |
|
339 | + } |
|
317 | 340 | |
318 | 341 | // remove any /r's that made there way in here |
319 | - foreach ($settingsArray as $k => $dummy) |
|
320 | - $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
342 | + foreach ($settingsArray as $k => $dummy) { |
|
343 | + $settingsArray[$k] = strtr($dummy, array("\r" => '')) . "\n"; |
|
344 | + } |
|
321 | 345 | |
322 | 346 | // go line by line and see whats changing |
323 | 347 | for ($i = 0, $n = count($settingsArray); $i < $n; $i++) |
324 | 348 | { |
325 | 349 | // Don't trim or bother with it if it's not a variable. |
326 | - if (substr($settingsArray[$i], 0, 1) != '$') |
|
327 | - continue; |
|
350 | + if (substr($settingsArray[$i], 0, 1) != '$') { |
|
351 | + continue; |
|
352 | + } |
|
328 | 353 | |
329 | 354 | $settingsArray[$i] = trim($settingsArray[$i]) . "\n"; |
330 | 355 | |
@@ -336,8 +361,7 @@ discard block |
||
336 | 361 | { |
337 | 362 | updateDbLastError($val); |
338 | 363 | unset($config_vars[$var]); |
339 | - } |
|
340 | - elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
364 | + } elseif (strncasecmp($settingsArray[$i], '$' . $var, 1 + strlen($var)) == 0) |
|
341 | 365 | { |
342 | 366 | $comment = strstr(substr($settingsArray[$i], strpos($settingsArray[$i], ';')), '#'); |
343 | 367 | $settingsArray[$i] = '$' . $var . ' = ' . $val . ';' . ($comment == '' ? '' : "\t\t" . rtrim($comment)) . "\n"; |
@@ -348,34 +372,39 @@ discard block |
||
348 | 372 | } |
349 | 373 | |
350 | 374 | // End of the file ... maybe |
351 | - if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') |
|
352 | - $end = $i; |
|
375 | + if (substr(trim($settingsArray[$i]), 0, 2) == '?' . '>') { |
|
376 | + $end = $i; |
|
377 | + } |
|
353 | 378 | } |
354 | 379 | |
355 | 380 | // This should never happen, but apparently it is happening. |
356 | - if (empty($end) || $end < 10) |
|
357 | - $end = count($settingsArray) - 1; |
|
381 | + if (empty($end) || $end < 10) { |
|
382 | + $end = count($settingsArray) - 1; |
|
383 | + } |
|
358 | 384 | |
359 | 385 | // Still more variables to go? Then lets add them at the end. |
360 | 386 | if (!empty($config_vars)) |
361 | 387 | { |
362 | - if (trim($settingsArray[$end]) == '?' . '>') |
|
363 | - $settingsArray[$end++] = ''; |
|
364 | - else |
|
365 | - $end++; |
|
388 | + if (trim($settingsArray[$end]) == '?' . '>') { |
|
389 | + $settingsArray[$end++] = ''; |
|
390 | + } else { |
|
391 | + $end++; |
|
392 | + } |
|
366 | 393 | |
367 | 394 | // Add in any newly defined vars that were passed |
368 | - foreach ($config_vars as $var => $val) |
|
369 | - $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
395 | + foreach ($config_vars as $var => $val) { |
|
396 | + $settingsArray[$end++] = '$' . $var . ' = ' . $val . ';' . "\n"; |
|
397 | + } |
|
370 | 398 | |
371 | 399 | $settingsArray[$end] = '?' . '>'; |
400 | + } else { |
|
401 | + $settingsArray[$end] = trim($settingsArray[$end]); |
|
372 | 402 | } |
373 | - else |
|
374 | - $settingsArray[$end] = trim($settingsArray[$end]); |
|
375 | 403 | |
376 | 404 | // Sanity error checking: the file needs to be at least 12 lines. |
377 | - if (count($settingsArray) < 12) |
|
378 | - return; |
|
405 | + if (count($settingsArray) < 12) { |
|
406 | + return; |
|
407 | + } |
|
379 | 408 | |
380 | 409 | // Try to avoid a few pitfalls: |
381 | 410 | // - like a possible race condition, |
@@ -383,8 +412,9 @@ discard block |
||
383 | 412 | // |
384 | 413 | // Check before you act: if cache is enabled, we can do a simple write test |
385 | 414 | // to validate that we even write things on this filesystem. |
386 | - if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) |
|
387 | - $cachedir = $boarddir . '/cache'; |
|
415 | + if ((empty($cachedir) || !file_exists($cachedir)) && file_exists($boarddir . '/cache')) { |
|
416 | + $cachedir = $boarddir . '/cache'; |
|
417 | + } |
|
388 | 418 | |
389 | 419 | $test_fp = @fopen($cachedir . '/settings_update.tmp', "w+"); |
390 | 420 | if ($test_fp) |
@@ -419,16 +449,18 @@ discard block |
||
419 | 449 | // Well this is not good at all, lets see if we can save this |
420 | 450 | $context['settings_message'] = 'settings_error'; |
421 | 451 | |
422 | - if (file_exists($boarddir . '/Settings_bak.php')) |
|
423 | - @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
452 | + if (file_exists($boarddir . '/Settings_bak.php')) { |
|
453 | + @copy($boarddir . '/Settings_bak.php', $boarddir . '/Settings.php'); |
|
454 | + } |
|
424 | 455 | } |
425 | 456 | } |
426 | 457 | |
427 | 458 | // Even though on normal installations the filemtime should prevent this being used by the installer incorrectly |
428 | 459 | // it seems that there are times it might not. So let's MAKE it dump the cache. |
429 | - if (function_exists('opcache_invalidate')) |
|
430 | - opcache_invalidate($boarddir . '/Settings.php', true); |
|
431 | -} |
|
460 | + if (function_exists('opcache_invalidate')) { |
|
461 | + opcache_invalidate($boarddir . '/Settings.php', true); |
|
462 | + } |
|
463 | + } |
|
432 | 464 | |
433 | 465 | /** |
434 | 466 | * Saves the time of the last db error for the error log |
@@ -454,8 +486,9 @@ discard block |
||
454 | 486 | global $options, $context, $smcFunc, $settings, $user_info; |
455 | 487 | |
456 | 488 | // This must exist! |
457 | - if (!isset($context['admin_preferences'])) |
|
458 | - return false; |
|
489 | + if (!isset($context['admin_preferences'])) { |
|
490 | + return false; |
|
491 | + } |
|
459 | 492 | |
460 | 493 | // This is what we'll be saving. |
461 | 494 | $options['admin_preferences'] = $smcFunc['json_encode']($context['admin_preferences']); |
@@ -519,8 +552,9 @@ discard block |
||
519 | 552 | $emails_sent = array(); |
520 | 553 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
521 | 554 | { |
522 | - if (empty($prefs[$row['id_member']]['announcements'])) |
|
523 | - continue; |
|
555 | + if (empty($prefs[$row['id_member']]['announcements'])) { |
|
556 | + continue; |
|
557 | + } |
|
524 | 558 | |
525 | 559 | // Stick their particulars in the replacement data. |
526 | 560 | $replacements['IDMEMBER'] = $row['id_member']; |
@@ -539,11 +573,12 @@ discard block |
||
539 | 573 | $smcFunc['db_free_result']($request); |
540 | 574 | |
541 | 575 | // Any additional users we must email this to? |
542 | - if (!empty($additional_recipients)) |
|
543 | - foreach ($additional_recipients as $recipient) |
|
576 | + if (!empty($additional_recipients)) { |
|
577 | + foreach ($additional_recipients as $recipient) |
|
544 | 578 | { |
545 | 579 | if (in_array($recipient['email'], $emails_sent)) |
546 | 580 | continue; |
581 | + } |
|
547 | 582 | |
548 | 583 | $replacements['IDMEMBER'] = $recipient['id']; |
549 | 584 | $replacements['REALNAME'] = $recipient['name']; |
@@ -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 | * Show the list of topics in this board, along with any child boards. |
@@ -56,8 +57,9 @@ discard block |
||
56 | 57 | |
57 | 58 | $context['name'] = $board_info['name']; |
58 | 59 | $context['description'] = $board_info['description']; |
59 | - if (!empty($board_info['description'])) |
|
60 | - $context['meta_description'] = strip_tags($board_info['description']); |
|
60 | + if (!empty($board_info['description'])) { |
|
61 | + $context['meta_description'] = strip_tags($board_info['description']); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | // How many topics do we have in total? |
63 | 65 | $board_info['total_topics'] = allowedTo('approve_posts') ? $board_info['num_topics'] + $board_info['unapproved_topics'] : $board_info['num_topics'] + $board_info['unapproved_user_topics']; |
@@ -73,12 +75,14 @@ discard block |
||
73 | 75 | $session_name = session_name(); |
74 | 76 | foreach ($_GET as $k => $v) |
75 | 77 | { |
76 | - if (!in_array($k, array('board', 'start', $session_name))) |
|
77 | - $context['robot_no_index'] = true; |
|
78 | + if (!in_array($k, array('board', 'start', $session_name))) { |
|
79 | + $context['robot_no_index'] = true; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | - if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) |
|
81 | - $context['robot_no_index'] = true; |
|
83 | + if (!empty($_REQUEST['start']) && (!is_numeric($_REQUEST['start']) || $_REQUEST['start'] % $context['messages_per_page'] != 0)) { |
|
84 | + $context['robot_no_index'] = true; |
|
85 | + } |
|
82 | 86 | |
83 | 87 | // If we can view unapproved messages and there are some build up a list. |
84 | 88 | if (allowedTo('approve_posts') && ($board_info['unapproved_topics'] || $board_info['unapproved_posts'])) |
@@ -89,14 +93,16 @@ discard block |
||
89 | 93 | } |
90 | 94 | |
91 | 95 | // We only know these. |
92 | - if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) |
|
93 | - $_REQUEST['sort'] = 'last_post'; |
|
96 | + if (isset($_REQUEST['sort']) && !in_array($_REQUEST['sort'], array('subject', 'starter', 'last_poster', 'replies', 'views', 'first_post', 'last_post'))) { |
|
97 | + $_REQUEST['sort'] = 'last_post'; |
|
98 | + } |
|
94 | 99 | |
95 | 100 | // Make sure the starting place makes sense and construct the page index. |
96 | - if (isset($_REQUEST['sort'])) |
|
97 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
98 | - else |
|
99 | - $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
101 | + if (isset($_REQUEST['sort'])) { |
|
102 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
103 | + } else { |
|
104 | + $context['page_index'] = constructPageIndex($scripturl . '?board=' . $board . '.%1$d', $_REQUEST['start'], $board_info['total_topics'], $context['maxindex'], true); |
|
105 | + } |
|
100 | 106 | $context['start'] = &$_REQUEST['start']; |
101 | 107 | |
102 | 108 | // Set a canonical URL for this page. |
@@ -132,14 +138,16 @@ discard block |
||
132 | 138 | $context['link_moderators'] = array(); |
133 | 139 | if (!empty($board_info['moderators'])) |
134 | 140 | { |
135 | - foreach ($board_info['moderators'] as $mod) |
|
136 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
141 | + foreach ($board_info['moderators'] as $mod) { |
|
142 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=profile;u=' . $mod['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod['name'] . '</a>'; |
|
143 | + } |
|
137 | 144 | } |
138 | 145 | if (!empty($board_info['moderator_groups'])) |
139 | 146 | { |
140 | 147 | // By default just tack the moderator groups onto the end of the members |
141 | - foreach ($board_info['moderator_groups'] as $mod_group) |
|
142 | - $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
148 | + foreach ($board_info['moderator_groups'] as $mod_group) { |
|
149 | + $context['link_moderators'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $mod_group['id'] . '" title="' . $txt['board_moderator'] . '">' . $mod_group['name'] . '</a>'; |
|
150 | + } |
|
143 | 151 | } |
144 | 152 | |
145 | 153 | // Now we tack the info onto the end of the linktree |
@@ -191,20 +199,24 @@ discard block |
||
191 | 199 | ); |
192 | 200 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
193 | 201 | { |
194 | - if (empty($row['id_member'])) |
|
195 | - continue; |
|
202 | + if (empty($row['id_member'])) { |
|
203 | + continue; |
|
204 | + } |
|
196 | 205 | |
197 | - if (!empty($row['online_color'])) |
|
198 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
199 | - else |
|
200 | - $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
206 | + if (!empty($row['online_color'])) { |
|
207 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>'; |
|
208 | + } else { |
|
209 | + $link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>'; |
|
210 | + } |
|
201 | 211 | |
202 | 212 | $is_buddy = in_array($row['id_member'], $user_info['buddies']); |
203 | - if ($is_buddy) |
|
204 | - $link = '<strong>' . $link . '</strong>'; |
|
213 | + if ($is_buddy) { |
|
214 | + $link = '<strong>' . $link . '</strong>'; |
|
215 | + } |
|
205 | 216 | |
206 | - if (!empty($row['show_online']) || allowedTo('moderate_forum')) |
|
207 | - $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
217 | + if (!empty($row['show_online']) || allowedTo('moderate_forum')) { |
|
218 | + $context['view_members_list'][$row['log_time'] . $row['member_name']] = empty($row['show_online']) ? '<em>' . $link . '</em>' : $link; |
|
219 | + } |
|
208 | 220 | // @todo why are we filling this array of data that are just counted (twice) and discarded? ??? |
209 | 221 | $context['view_members'][$row['log_time'] . $row['member_name']] = array( |
210 | 222 | 'id' => $row['id_member'], |
@@ -217,8 +229,9 @@ discard block |
||
217 | 229 | 'hidden' => empty($row['show_online']), |
218 | 230 | ); |
219 | 231 | |
220 | - if (empty($row['show_online'])) |
|
221 | - $context['view_num_hidden']++; |
|
232 | + if (empty($row['show_online'])) { |
|
233 | + $context['view_num_hidden']++; |
|
234 | + } |
|
222 | 235 | } |
223 | 236 | $context['view_num_guests'] = $smcFunc['db_num_rows']($request) - count($context['view_members']); |
224 | 237 | $smcFunc['db_free_result']($request); |
@@ -260,8 +273,9 @@ discard block |
||
260 | 273 | // Bring in any changes we want to make before the query. |
261 | 274 | call_integration_hook('integrate_pre_messageindex', array(&$sort_methods)); |
262 | 275 | |
263 | - foreach ($sort_methods as $key => $val) |
|
264 | - $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
276 | + foreach ($sort_methods as $key => $val) { |
|
277 | + $context['topics_headers'][$key] = '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : '') . '">' . $txt[$key] . ($context['sort_by'] == $key ? '<span class="sort sort_' . $context['sort_direction'] . '"></span>' : '') . '</a>'; |
|
278 | + } |
|
265 | 279 | |
266 | 280 | // Calculate the fastest way to get the topics. |
267 | 281 | $start = (int) $_REQUEST['start']; |
@@ -271,14 +285,15 @@ discard block |
||
271 | 285 | $fake_ascending = true; |
272 | 286 | $context['maxindex'] = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? $board_info['total_topics'] - $start : $context['maxindex']; |
273 | 287 | $start = $board_info['total_topics'] < $start + $context['maxindex'] + 1 ? 0 : $board_info['total_topics'] - $start - $context['maxindex']; |
288 | + } else { |
|
289 | + $fake_ascending = false; |
|
274 | 290 | } |
275 | - else |
|
276 | - $fake_ascending = false; |
|
277 | 291 | |
278 | 292 | // Setup the default topic icons... |
279 | 293 | $context['icon_sources'] = array(); |
280 | - foreach ($context['stable_icons'] as $icon) |
|
281 | - $context['icon_sources'][$icon] = 'images_url'; |
|
294 | + foreach ($context['stable_icons'] as $icon) { |
|
295 | + $context['icon_sources'][$icon] = 'images_url'; |
|
296 | + } |
|
282 | 297 | |
283 | 298 | $topic_ids = array(); |
284 | 299 | $context['topics'] = array(); |
@@ -316,8 +331,9 @@ discard block |
||
316 | 331 | $message_pre_index_parameters |
317 | 332 | ); |
318 | 333 | $topic_ids = array(); |
319 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
320 | - $topic_ids[] = $row['id_topic']; |
|
334 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
335 | + $topic_ids[] = $row['id_topic']; |
|
336 | + } |
|
321 | 337 | } |
322 | 338 | |
323 | 339 | // Grab the appropriate topic information... |
@@ -340,10 +356,11 @@ discard block |
||
340 | 356 | $message_index_wheres = array(); |
341 | 357 | call_integration_hook('integrate_message_index', array(&$message_index_selects, &$message_index_tables, &$message_index_parameters, &$message_index_wheres, &$topic_ids)); |
342 | 358 | |
343 | - if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) |
|
344 | - $enableParticipation = true; |
|
345 | - else |
|
346 | - $enableParticipation = false; |
|
359 | + if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest']) { |
|
360 | + $enableParticipation = true; |
|
361 | + } else { |
|
362 | + $enableParticipation = false; |
|
363 | + } |
|
347 | 364 | |
348 | 365 | $result = $smcFunc['db_query']('substring', ' |
349 | 366 | SELECT |
@@ -382,11 +399,13 @@ discard block |
||
382 | 399 | // Begin 'printing' the message index for current board. |
383 | 400 | while ($row = $smcFunc['db_fetch_assoc']($result)) |
384 | 401 | { |
385 | - if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') |
|
386 | - continue; |
|
402 | + if ($row['id_poll'] > 0 && $modSettings['pollMode'] == '0') { |
|
403 | + continue; |
|
404 | + } |
|
387 | 405 | |
388 | - if (!$pre_query) |
|
389 | - $topic_ids[] = $row['id_topic']; |
|
406 | + if (!$pre_query) { |
|
407 | + $topic_ids[] = $row['id_topic']; |
|
408 | + } |
|
390 | 409 | |
391 | 410 | // Reference the main color class. |
392 | 411 | $colorClass = 'windowbg'; |
@@ -396,8 +415,9 @@ discard block |
||
396 | 415 | { |
397 | 416 | // Limit them to $modSettings['preview_characters'] characters |
398 | 417 | $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br>' => ' '))); |
399 | - if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) |
|
400 | - $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
418 | + if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters']) { |
|
419 | + $row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...'; |
|
420 | + } |
|
401 | 421 | |
402 | 422 | // Censor the subject and message preview. |
403 | 423 | censorText($row['first_subject']); |
@@ -408,27 +428,27 @@ discard block |
||
408 | 428 | { |
409 | 429 | $row['last_subject'] = $row['first_subject']; |
410 | 430 | $row['last_body'] = $row['first_body']; |
411 | - } |
|
412 | - else |
|
431 | + } else |
|
413 | 432 | { |
414 | 433 | $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br>' => ' '))); |
415 | - if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) |
|
416 | - $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
434 | + if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters']) { |
|
435 | + $row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...'; |
|
436 | + } |
|
417 | 437 | |
418 | 438 | censorText($row['last_subject']); |
419 | 439 | censorText($row['last_body']); |
420 | 440 | } |
421 | - } |
|
422 | - else |
|
441 | + } else |
|
423 | 442 | { |
424 | 443 | $row['first_body'] = ''; |
425 | 444 | $row['last_body'] = ''; |
426 | 445 | censorText($row['first_subject']); |
427 | 446 | |
428 | - if ($row['id_first_msg'] == $row['id_last_msg']) |
|
429 | - $row['last_subject'] = $row['first_subject']; |
|
430 | - else |
|
431 | - censorText($row['last_subject']); |
|
447 | + if ($row['id_first_msg'] == $row['id_last_msg']) { |
|
448 | + $row['last_subject'] = $row['first_subject']; |
|
449 | + } else { |
|
450 | + censorText($row['last_subject']); |
|
451 | + } |
|
432 | 452 | } |
433 | 453 | |
434 | 454 | // Decide how many pages the topic should have. |
@@ -439,42 +459,50 @@ discard block |
||
439 | 459 | $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, false); |
440 | 460 | |
441 | 461 | // If we can use all, show all. |
442 | - if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) |
|
443 | - $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
462 | + if (!empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']) { |
|
463 | + $pages .= ' <a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;all">' . $txt['all'] . '</a>'; |
|
464 | + } |
|
465 | + } else { |
|
466 | + $pages = ''; |
|
444 | 467 | } |
445 | - else |
|
446 | - $pages = ''; |
|
447 | 468 | |
448 | 469 | // We need to check the topic icons exist... |
449 | 470 | if (!empty($modSettings['messageIconChecks_enable'])) |
450 | 471 | { |
451 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
452 | - $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
453 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
454 | - $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
455 | - } |
|
456 | - else |
|
472 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
473 | + $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
474 | + } |
|
475 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
476 | + $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url'; |
|
477 | + } |
|
478 | + } else |
|
457 | 479 | { |
458 | - if (!isset($context['icon_sources'][$row['first_icon']])) |
|
459 | - $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
460 | - if (!isset($context['icon_sources'][$row['last_icon']])) |
|
461 | - $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
480 | + if (!isset($context['icon_sources'][$row['first_icon']])) { |
|
481 | + $context['icon_sources'][$row['first_icon']] = 'images_url'; |
|
482 | + } |
|
483 | + if (!isset($context['icon_sources'][$row['last_icon']])) { |
|
484 | + $context['icon_sources'][$row['last_icon']] = 'images_url'; |
|
485 | + } |
|
462 | 486 | } |
463 | 487 | |
464 | - if (!empty($board_info['recycle'])) |
|
465 | - $row['first_icon'] = 'recycled'; |
|
488 | + if (!empty($board_info['recycle'])) { |
|
489 | + $row['first_icon'] = 'recycled'; |
|
490 | + } |
|
466 | 491 | |
467 | 492 | // Is this topic pending approval, or does it have any posts pending approval? |
468 | - if ($context['can_approve_posts'] && $row['unapproved_posts']) |
|
469 | - $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
493 | + if ($context['can_approve_posts'] && $row['unapproved_posts']) { |
|
494 | + $colorClass .= (!$row['approved'] ? ' approvetopic' : ' approvepost'); |
|
495 | + } |
|
470 | 496 | |
471 | 497 | // Sticky topics should get a different color, too. |
472 | - if ($row['is_sticky']) |
|
473 | - $colorClass .= ' sticky'; |
|
498 | + if ($row['is_sticky']) { |
|
499 | + $colorClass .= ' sticky'; |
|
500 | + } |
|
474 | 501 | |
475 | 502 | // Locked topics get special treatment as well. |
476 | - if ($row['locked']) |
|
477 | - $colorClass .= ' locked'; |
|
503 | + if ($row['locked']) { |
|
504 | + $colorClass .= ' locked'; |
|
505 | + } |
|
478 | 506 | |
479 | 507 | // 'Print' the topic info. |
480 | 508 | $context['topics'][$row['id_topic']] = array_merge($row, array( |
@@ -555,8 +583,9 @@ discard block |
||
555 | 583 | $smcFunc['db_free_result']($result); |
556 | 584 | |
557 | 585 | // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...) |
558 | - if ($fake_ascending) |
|
559 | - $context['topics'] = array_reverse($context['topics'], true); |
|
586 | + if ($fake_ascending) { |
|
587 | + $context['topics'] = array_reverse($context['topics'], true); |
|
588 | + } |
|
560 | 589 | } |
561 | 590 | |
562 | 591 | $context['jump_to'] = array( |
@@ -579,9 +608,9 @@ discard block |
||
579 | 608 | // Can we restore topics? |
580 | 609 | $context['can_restore'] = allowedTo('move_any') && !empty($board_info['recycle']); |
581 | 610 | |
582 | - if ($user_info['is_admin'] || $modSettings['topic_move_any']) |
|
583 | - $context['can_move_any'] = true; |
|
584 | - else |
|
611 | + if ($user_info['is_admin'] || $modSettings['topic_move_any']) { |
|
612 | + $context['can_move_any'] = true; |
|
613 | + } else |
|
585 | 614 | { |
586 | 615 | // We'll use this in a minute |
587 | 616 | $boards_allowed = boardsAllowedTo('post_new'); |
@@ -608,11 +637,13 @@ discard block |
||
608 | 637 | } |
609 | 638 | |
610 | 639 | // Can we use quick moderation checkboxes? |
611 | - if ($options['display_quick_mod'] == 1) |
|
612 | - $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
640 | + if ($options['display_quick_mod'] == 1) { |
|
641 | + $context['can_quick_mod'] = $context['user']['is_logged'] || $context['can_approve'] || $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move'] || $context['can_merge'] || $context['can_restore']; |
|
642 | + } |
|
613 | 643 | // Or the icons? |
614 | - else |
|
615 | - $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
644 | + else { |
|
645 | + $context['can_quick_mod'] = $context['can_remove'] || $context['can_lock'] || $context['can_sticky'] || $context['can_move']; |
|
646 | + } |
|
616 | 647 | } |
617 | 648 | |
618 | 649 | if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1) |
@@ -646,13 +677,15 @@ discard block |
||
646 | 677 | ); |
647 | 678 | |
648 | 679 | // We've seen all these boards now! |
649 | - foreach ($board_info['parent_boards'] as $k => $dummy) |
|
650 | - if (isset($_SESSION['topicseen_cache'][$k])) |
|
680 | + foreach ($board_info['parent_boards'] as $k => $dummy) { |
|
681 | + if (isset($_SESSION['topicseen_cache'][$k])) |
|
651 | 682 | unset($_SESSION['topicseen_cache'][$k]); |
683 | + } |
|
652 | 684 | } |
653 | 685 | |
654 | - if (isset($_SESSION['topicseen_cache'][$board])) |
|
655 | - unset($_SESSION['topicseen_cache'][$board]); |
|
686 | + if (isset($_SESSION['topicseen_cache'][$board])) { |
|
687 | + unset($_SESSION['topicseen_cache'][$board]); |
|
688 | + } |
|
656 | 689 | |
657 | 690 | $request = $smcFunc['db_query']('', ' |
658 | 691 | SELECT id_topic, id_board, sent |
@@ -673,8 +706,9 @@ discard block |
||
673 | 706 | $context['is_marked_notify'] = true; |
674 | 707 | $board_sent = $row['sent']; |
675 | 708 | } |
676 | - if (!empty($row['id_topic'])) |
|
677 | - $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
709 | + if (!empty($row['id_topic'])) { |
|
710 | + $context['topics'][$row['id_topic']]['is_watched'] = true; |
|
711 | + } |
|
678 | 712 | } |
679 | 713 | $smcFunc['db_free_result']($request); |
680 | 714 | |
@@ -698,8 +732,7 @@ discard block |
||
698 | 732 | $pref = !empty($pref[$user_info['id']]) ? $pref[$user_info['id']] : array(); |
699 | 733 | $pref = isset($pref['board_notify_' . $board]) ? $pref['board_notify_' . $board] : (!empty($pref['board_notify']) ? $pref['board_notify'] : 0); |
700 | 734 | $context['board_notification_mode'] = !$context['is_marked_notify'] ? 1 : ($pref & 0x02 ? 3 : ($pref & 0x01 ? 2 : 1)); |
701 | - } |
|
702 | - else |
|
735 | + } else |
|
703 | 736 | { |
704 | 737 | $context['is_marked_notify'] = false; |
705 | 738 | $context['board_notification_mode'] = 1; |
@@ -712,23 +745,27 @@ discard block |
||
712 | 745 | $context['becomesUnapproved'] = !empty($_SESSION['becomesUnapproved']) ? true : false; |
713 | 746 | |
714 | 747 | // Don't want to show this forever... |
715 | - if ($context['becomesUnapproved']) |
|
716 | - unset($_SESSION['becomesUnapproved']); |
|
748 | + if ($context['becomesUnapproved']) { |
|
749 | + unset($_SESSION['becomesUnapproved']); |
|
750 | + } |
|
717 | 751 | |
718 | 752 | // Build the message index button array. |
719 | 753 | $context['normal_buttons'] = array(); |
720 | 754 | |
721 | - if ($context['can_post_new']) |
|
722 | - $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
755 | + if ($context['can_post_new']) { |
|
756 | + $context['normal_buttons']['new_topic'] = array('text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true); |
|
757 | + } |
|
723 | 758 | |
724 | - if ($context['can_post_poll']) |
|
725 | - $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
759 | + if ($context['can_post_poll']) { |
|
760 | + $context['normal_buttons']['post_poll'] = array('text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'); |
|
761 | + } |
|
726 | 762 | |
727 | - if (!$context['user']['is_logged']) |
|
728 | - $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
763 | + if (!$context['user']['is_logged']) { |
|
764 | + $context['normal_buttons']['markread'] = array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'data-confirm="' . $txt['are_sure_mark_read'] . '"', 'class' => 'you_sure', 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']); |
|
765 | + } |
|
729 | 766 | |
730 | - if ($context['can_mark_notify']) |
|
731 | - $context['normal_buttons']['notify'] = array( |
|
767 | + if ($context['can_mark_notify']) { |
|
768 | + $context['normal_buttons']['notify'] = array( |
|
732 | 769 | 'lang' => true, |
733 | 770 | 'text' => 'notify_board_' . $context['board_notification_mode'], |
734 | 771 | 'sub_buttons' => array( |
@@ -746,6 +783,7 @@ discard block |
||
746 | 783 | ), |
747 | 784 | ), |
748 | 785 | ); |
786 | + } |
|
749 | 787 | |
750 | 788 | // Javascript for inline editing. |
751 | 789 | loadJavaScriptFile('topic.js', array('defer' => false), 'smf_topic'); |
@@ -767,18 +805,21 @@ discard block |
||
767 | 805 | checkSession('request'); |
768 | 806 | |
769 | 807 | // Lets go straight to the restore area. |
770 | - if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) |
|
771 | - redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
808 | + if (isset($_REQUEST['qaction']) && $_REQUEST['qaction'] == 'restore' && !empty($_REQUEST['topics'])) { |
|
809 | + redirectexit('action=restoretopic;topics=' . implode(',', $_REQUEST['topics']) . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
810 | + } |
|
772 | 811 | |
773 | - if (isset($_SESSION['topicseen_cache'])) |
|
774 | - $_SESSION['topicseen_cache'] = array(); |
|
812 | + if (isset($_SESSION['topicseen_cache'])) { |
|
813 | + $_SESSION['topicseen_cache'] = array(); |
|
814 | + } |
|
775 | 815 | |
776 | 816 | // This is going to be needed to send off the notifications and for updateLastMessages(). |
777 | 817 | require_once($sourcedir . '/Subs-Post.php'); |
778 | 818 | |
779 | 819 | // Remember the last board they moved things to. |
780 | - if (isset($_REQUEST['move_to'])) |
|
781 | - $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
820 | + if (isset($_REQUEST['move_to'])) { |
|
821 | + $_SESSION['move_to_topic'] = $_REQUEST['move_to']; |
|
822 | + } |
|
782 | 823 | |
783 | 824 | // Only a few possible actions. |
784 | 825 | $possibleActions = array(); |
@@ -798,8 +839,7 @@ discard block |
||
798 | 839 | ); |
799 | 840 | |
800 | 841 | $redirect_url = 'board=' . $board . '.' . $_REQUEST['start']; |
801 | - } |
|
802 | - else |
|
842 | + } else |
|
803 | 843 | { |
804 | 844 | /** |
805 | 845 | * @todo Ugly. There's no getting around this, is there? |
@@ -817,8 +857,7 @@ discard block |
||
817 | 857 | if (!empty($board)) |
818 | 858 | { |
819 | 859 | $boards_can['post_new'] = array_diff(boardsAllowedTo('post_new'), array($board)); |
820 | - } |
|
821 | - else |
|
860 | + } else |
|
822 | 861 | { |
823 | 862 | $boards_can['post_new'] = boardsAllowedTo('post_new'); |
824 | 863 | } |
@@ -829,55 +868,67 @@ discard block |
||
829 | 868 | } |
830 | 869 | } |
831 | 870 | |
832 | - if (!$user_info['is_guest']) |
|
833 | - $possibleActions[] = 'markread'; |
|
834 | - if (!empty($boards_can['make_sticky'])) |
|
835 | - $possibleActions[] = 'sticky'; |
|
836 | - if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) |
|
837 | - $possibleActions[] = 'move'; |
|
838 | - if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) |
|
839 | - $possibleActions[] = 'remove'; |
|
840 | - if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) |
|
841 | - $possibleActions[] = 'lock'; |
|
842 | - if (!empty($boards_can['merge_any'])) |
|
843 | - $possibleActions[] = 'merge'; |
|
844 | - if (!empty($boards_can['approve_posts'])) |
|
845 | - $possibleActions[] = 'approve'; |
|
871 | + if (!$user_info['is_guest']) { |
|
872 | + $possibleActions[] = 'markread'; |
|
873 | + } |
|
874 | + if (!empty($boards_can['make_sticky'])) { |
|
875 | + $possibleActions[] = 'sticky'; |
|
876 | + } |
|
877 | + if (!empty($boards_can['move_any']) || !empty($boards_can['move_own'])) { |
|
878 | + $possibleActions[] = 'move'; |
|
879 | + } |
|
880 | + if (!empty($boards_can['remove_any']) || !empty($boards_can['remove_own'])) { |
|
881 | + $possibleActions[] = 'remove'; |
|
882 | + } |
|
883 | + if (!empty($boards_can['lock_any']) || !empty($boards_can['lock_own'])) { |
|
884 | + $possibleActions[] = 'lock'; |
|
885 | + } |
|
886 | + if (!empty($boards_can['merge_any'])) { |
|
887 | + $possibleActions[] = 'merge'; |
|
888 | + } |
|
889 | + if (!empty($boards_can['approve_posts'])) { |
|
890 | + $possibleActions[] = 'approve'; |
|
891 | + } |
|
846 | 892 | |
847 | 893 | // Two methods: $_REQUEST['actions'] (id_topic => action), and $_REQUEST['topics'] and $_REQUEST['qaction']. |
848 | 894 | // (if action is 'move', $_REQUEST['move_to'] or $_REQUEST['move_tos'][$topic] is used.) |
849 | 895 | if (!empty($_REQUEST['topics'])) |
850 | 896 | { |
851 | 897 | // If the action isn't valid, just quit now. |
852 | - if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) |
|
853 | - redirectexit($redirect_url); |
|
898 | + if (empty($_REQUEST['qaction']) || !in_array($_REQUEST['qaction'], $possibleActions)) { |
|
899 | + redirectexit($redirect_url); |
|
900 | + } |
|
854 | 901 | |
855 | 902 | // Merge requires all topics as one parameter and can be done at once. |
856 | 903 | if ($_REQUEST['qaction'] == 'merge') |
857 | 904 | { |
858 | 905 | // Merge requires at least two topics. |
859 | - if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) |
|
860 | - redirectexit($redirect_url); |
|
906 | + if (empty($_REQUEST['topics']) || count($_REQUEST['topics']) < 2) { |
|
907 | + redirectexit($redirect_url); |
|
908 | + } |
|
861 | 909 | |
862 | 910 | require_once($sourcedir . '/SplitTopics.php'); |
863 | 911 | return MergeExecute($_REQUEST['topics']); |
864 | 912 | } |
865 | 913 | |
866 | 914 | // Just convert to the other method, to make it easier. |
867 | - foreach ($_REQUEST['topics'] as $topic) |
|
868 | - $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
915 | + foreach ($_REQUEST['topics'] as $topic) { |
|
916 | + $_REQUEST['actions'][(int) $topic] = $_REQUEST['qaction']; |
|
917 | + } |
|
869 | 918 | } |
870 | 919 | |
871 | 920 | // Weird... how'd you get here? |
872 | - if (empty($_REQUEST['actions'])) |
|
873 | - redirectexit($redirect_url); |
|
921 | + if (empty($_REQUEST['actions'])) { |
|
922 | + redirectexit($redirect_url); |
|
923 | + } |
|
874 | 924 | |
875 | 925 | // Validate each action. |
876 | 926 | $temp = array(); |
877 | 927 | foreach ($_REQUEST['actions'] as $topic => $action) |
878 | 928 | { |
879 | - if (in_array($action, $possibleActions)) |
|
880 | - $temp[(int) $topic] = $action; |
|
929 | + if (in_array($action, $possibleActions)) { |
|
930 | + $temp[(int) $topic] = $action; |
|
931 | + } |
|
881 | 932 | } |
882 | 933 | $_REQUEST['actions'] = $temp; |
883 | 934 | |
@@ -898,27 +949,31 @@ discard block |
||
898 | 949 | { |
899 | 950 | if (!empty($board)) |
900 | 951 | { |
901 | - if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) |
|
902 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
903 | - } |
|
904 | - else |
|
952 | + if ($row['id_board'] != $board || ($modSettings['postmod_active'] && !$row['approved'] && !allowedTo('approve_posts'))) { |
|
953 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
954 | + } |
|
955 | + } else |
|
905 | 956 | { |
906 | 957 | // Don't allow them to act on unapproved posts they can't see... |
907 | - if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) |
|
908 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
958 | + if ($modSettings['postmod_active'] && !$row['approved'] && !in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])) { |
|
959 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
960 | + } |
|
909 | 961 | // Goodness, this is fun. We need to validate the action. |
910 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) |
|
911 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
912 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) |
|
913 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
914 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) |
|
915 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
962 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'sticky' && !in_array(0, $boards_can['make_sticky']) && !in_array($row['id_board'], $boards_can['make_sticky'])) { |
|
963 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
964 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'move' && !in_array(0, $boards_can['move_any']) && !in_array($row['id_board'], $boards_can['move_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['move_own']) && !in_array($row['id_board'], $boards_can['move_own'])))) { |
|
965 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
966 | + } elseif ($_REQUEST['actions'][$row['id_topic']] == 'remove' && !in_array(0, $boards_can['remove_any']) && !in_array($row['id_board'], $boards_can['remove_any']) && ($row['id_member_started'] != $user_info['id'] || (!in_array(0, $boards_can['remove_own']) && !in_array($row['id_board'], $boards_can['remove_own'])))) { |
|
967 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
968 | + } |
|
916 | 969 | // @todo $locked is not set, what are you trying to do? (taking the change it is supposed to be $row['locked']) |
917 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) |
|
918 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
970 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'lock' && !in_array(0, $boards_can['lock_any']) && !in_array($row['id_board'], $boards_can['lock_any']) && ($row['id_member_started'] != $user_info['id'] || $row['locked'] == 1 || (!in_array(0, $boards_can['lock_own']) && !in_array($row['id_board'], $boards_can['lock_own'])))) { |
|
971 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
972 | + } |
|
919 | 973 | // If the topic is approved then you need permission to approve the posts within. |
920 | - elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) |
|
921 | - unset($_REQUEST['actions'][$row['id_topic']]); |
|
974 | + elseif ($_REQUEST['actions'][$row['id_topic']] == 'approve' && (!$row['unapproved_posts'] || (!in_array(0, $boards_can['approve_posts']) && !in_array($row['id_board'], $boards_can['approve_posts'])))) { |
|
975 | + unset($_REQUEST['actions'][$row['id_topic']]); |
|
976 | + } |
|
922 | 977 | } |
923 | 978 | } |
924 | 979 | $smcFunc['db_free_result']($request); |
@@ -936,11 +991,11 @@ discard block |
||
936 | 991 | { |
937 | 992 | $topic = (int) $topic; |
938 | 993 | |
939 | - if ($action == 'markread') |
|
940 | - $markCache[] = $topic; |
|
941 | - elseif ($action == 'sticky') |
|
942 | - $stickyCache[] = $topic; |
|
943 | - elseif ($action == 'move') |
|
994 | + if ($action == 'markread') { |
|
995 | + $markCache[] = $topic; |
|
996 | + } elseif ($action == 'sticky') { |
|
997 | + $stickyCache[] = $topic; |
|
998 | + } elseif ($action == 'move') |
|
944 | 999 | { |
945 | 1000 | require_once($sourcedir . '/MoveTopic.php'); |
946 | 1001 | moveTopicConcurrence(); |
@@ -948,23 +1003,25 @@ discard block |
||
948 | 1003 | // $moveCache[0] is the topic, $moveCache[1] is the board to move to. |
949 | 1004 | $moveCache[1][$topic] = (int) (isset($_REQUEST['move_tos'][$topic]) ? $_REQUEST['move_tos'][$topic] : $_REQUEST['move_to']); |
950 | 1005 | |
951 | - if (empty($moveCache[1][$topic])) |
|
952 | - continue; |
|
1006 | + if (empty($moveCache[1][$topic])) { |
|
1007 | + continue; |
|
1008 | + } |
|
953 | 1009 | |
954 | 1010 | $moveCache[0][] = $topic; |
1011 | + } elseif ($action == 'remove') { |
|
1012 | + $removeCache[] = $topic; |
|
1013 | + } elseif ($action == 'lock') { |
|
1014 | + $lockCache[] = $topic; |
|
1015 | + } elseif ($action == 'approve') { |
|
1016 | + $approveCache[] = $topic; |
|
955 | 1017 | } |
956 | - elseif ($action == 'remove') |
|
957 | - $removeCache[] = $topic; |
|
958 | - elseif ($action == 'lock') |
|
959 | - $lockCache[] = $topic; |
|
960 | - elseif ($action == 'approve') |
|
961 | - $approveCache[] = $topic; |
|
962 | 1018 | } |
963 | 1019 | |
964 | - if (empty($board)) |
|
965 | - $affectedBoards = array(); |
|
966 | - else |
|
967 | - $affectedBoards = array($board => array(0, 0)); |
|
1020 | + if (empty($board)) { |
|
1021 | + $affectedBoards = array(); |
|
1022 | + } else { |
|
1023 | + $affectedBoards = array($board => array(0, 0)); |
|
1024 | + } |
|
968 | 1025 | |
969 | 1026 | // Do all the stickies... |
970 | 1027 | if (!empty($stickyCache)) |
@@ -1024,14 +1081,16 @@ discard block |
||
1024 | 1081 | { |
1025 | 1082 | $to = $moveCache[1][$row['id_topic']]; |
1026 | 1083 | |
1027 | - if (empty($to)) |
|
1028 | - continue; |
|
1084 | + if (empty($to)) { |
|
1085 | + continue; |
|
1086 | + } |
|
1029 | 1087 | |
1030 | 1088 | // Does this topic's board count the posts or not? |
1031 | 1089 | $countPosts[$row['id_topic']] = empty($row['count_posts']); |
1032 | 1090 | |
1033 | - if (!isset($moveTos[$to])) |
|
1034 | - $moveTos[$to] = array(); |
|
1091 | + if (!isset($moveTos[$to])) { |
|
1092 | + $moveTos[$to] = array(); |
|
1093 | + } |
|
1035 | 1094 | |
1036 | 1095 | $moveTos[$to][] = $row['id_topic']; |
1037 | 1096 | |
@@ -1045,8 +1104,9 @@ discard block |
||
1045 | 1104 | require_once($sourcedir . '/MoveTopic.php'); |
1046 | 1105 | |
1047 | 1106 | // Do the actual moves... |
1048 | - foreach ($moveTos as $to => $topics) |
|
1049 | - moveTopics($topics, $to); |
|
1107 | + foreach ($moveTos as $to => $topics) { |
|
1108 | + moveTopics($topics, $to); |
|
1109 | + } |
|
1050 | 1110 | |
1051 | 1111 | // Does the post counts need to be updated? |
1052 | 1112 | if (!empty($moveTos)) |
@@ -1095,20 +1155,23 @@ discard block |
||
1095 | 1155 | |
1096 | 1156 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1097 | 1157 | { |
1098 | - if (!isset($members[$row['id_member']])) |
|
1099 | - $members[$row['id_member']] = 0; |
|
1158 | + if (!isset($members[$row['id_member']])) { |
|
1159 | + $members[$row['id_member']] = 0; |
|
1160 | + } |
|
1100 | 1161 | |
1101 | - if ($topicRecounts[$row['id_topic']] === '+') |
|
1102 | - $members[$row['id_member']] += 1; |
|
1103 | - else |
|
1104 | - $members[$row['id_member']] -= 1; |
|
1162 | + if ($topicRecounts[$row['id_topic']] === '+') { |
|
1163 | + $members[$row['id_member']] += 1; |
|
1164 | + } else { |
|
1165 | + $members[$row['id_member']] -= 1; |
|
1166 | + } |
|
1105 | 1167 | } |
1106 | 1168 | |
1107 | 1169 | $smcFunc['db_free_result']($request); |
1108 | 1170 | |
1109 | 1171 | // And now update them member's post counts |
1110 | - foreach ($members as $id_member => $post_adj) |
|
1111 | - updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1172 | + foreach ($members as $id_member => $post_adj) { |
|
1173 | + updateMemberData($id_member, array('posts' => 'posts + ' . $post_adj)); |
|
1174 | + } |
|
1112 | 1175 | |
1113 | 1176 | } |
1114 | 1177 | } |
@@ -1188,8 +1251,9 @@ discard block |
||
1188 | 1251 | approveTopics($approveCache); |
1189 | 1252 | |
1190 | 1253 | // Time for some logging! |
1191 | - foreach ($approveCache as $topic) |
|
1192 | - logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1254 | + foreach ($approveCache as $topic) { |
|
1255 | + logAction('approve_topic', array('topic' => $topic, 'member' => $approveCacheMembers[$topic])); |
|
1256 | + } |
|
1193 | 1257 | } |
1194 | 1258 | } |
1195 | 1259 | |
@@ -1224,8 +1288,7 @@ discard block |
||
1224 | 1288 | $lockStatus[$row['id_topic']] = empty($row['locked']); |
1225 | 1289 | } |
1226 | 1290 | $smcFunc['db_free_result']($result); |
1227 | - } |
|
1228 | - else |
|
1291 | + } else |
|
1229 | 1292 | { |
1230 | 1293 | $result = $smcFunc['db_query']('', ' |
1231 | 1294 | SELECT id_topic, locked, id_board |
@@ -1275,13 +1338,15 @@ discard block |
||
1275 | 1338 | ) |
1276 | 1339 | ); |
1277 | 1340 | $logged_topics = array(); |
1278 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1279 | - $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1341 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1342 | + $logged_topics[$row['id_topic']] = $row['unwatched']; |
|
1343 | + } |
|
1280 | 1344 | $smcFunc['db_free_result']($request); |
1281 | 1345 | |
1282 | 1346 | $markArray = array(); |
1283 | - foreach ($markCache as $topic) |
|
1284 | - $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1347 | + foreach ($markCache as $topic) { |
|
1348 | + $markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic, (isset($logged_topics[$topic]) ? $logged_topics[$topic] : 0)); |
|
1349 | + } |
|
1285 | 1350 | |
1286 | 1351 | $smcFunc['db_insert']('replace', |
1287 | 1352 | '{db_prefix}log_topics', |
@@ -1294,8 +1359,9 @@ discard block |
||
1294 | 1359 | foreach ($moveCache as $topic) |
1295 | 1360 | { |
1296 | 1361 | // Didn't actually move anything! |
1297 | - if (!isset($topic[0])) |
|
1298 | - break; |
|
1362 | + if (!isset($topic[0])) { |
|
1363 | + break; |
|
1364 | + } |
|
1299 | 1365 | |
1300 | 1366 | logAction('move', array('topic' => $topic[0], 'board_from' => $topic[1], 'board_to' => $topic[2])); |
1301 | 1367 | sendNotifications($topic[0], 'move'); |
@@ -1317,8 +1383,9 @@ discard block |
||
1317 | 1383 | 'calendar_updated' => time(), |
1318 | 1384 | )); |
1319 | 1385 | |
1320 | - if (!empty($affectedBoards)) |
|
1321 | - updateLastMessages(array_keys($affectedBoards)); |
|
1386 | + if (!empty($affectedBoards)) { |
|
1387 | + updateLastMessages(array_keys($affectedBoards)); |
|
1388 | + } |
|
1322 | 1389 | |
1323 | 1390 | redirectexit($redirect_url); |
1324 | 1391 | } |
@@ -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 | * The news dispatcher; doesn't do anything, just delegates. |
@@ -67,8 +68,9 @@ discard block |
||
67 | 68 | ); |
68 | 69 | |
69 | 70 | // Force the right area... |
70 | - if (substr($_REQUEST['sa'], 0, 7) == 'mailing') |
|
71 | - $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
71 | + if (substr($_REQUEST['sa'], 0, 7) == 'mailing') { |
|
72 | + $context[$context['admin_menu_name']]['current_subsection'] = 'mailingmembers'; |
|
73 | + } |
|
72 | 74 | |
73 | 75 | call_helper($subActions[$_REQUEST['sa']][0]); |
74 | 76 | } |
@@ -99,9 +101,10 @@ discard block |
||
99 | 101 | $temp_news = explode("\n", $modSettings['news']); |
100 | 102 | |
101 | 103 | // Remove the items that were selected. |
102 | - foreach ($temp_news as $i => $news) |
|
103 | - if (in_array($i, $_POST['remove'])) |
|
104 | + foreach ($temp_news as $i => $news) { |
|
105 | + if (in_array($i, $_POST['remove'])) |
|
104 | 106 | unset($temp_news[$i]); |
107 | + } |
|
105 | 108 | |
106 | 109 | // Update the database. |
107 | 110 | updateSettings(array('news' => implode("\n", $temp_news))); |
@@ -117,9 +120,9 @@ discard block |
||
117 | 120 | |
118 | 121 | foreach ($_POST['news'] as $i => $news) |
119 | 122 | { |
120 | - if (trim($news) == '') |
|
121 | - unset($_POST['news'][$i]); |
|
122 | - else |
|
123 | + if (trim($news) == '') { |
|
124 | + unset($_POST['news'][$i]); |
|
125 | + } else |
|
123 | 126 | { |
124 | 127 | $_POST['news'][$i] = $smcFunc['htmlspecialchars']($_POST['news'][$i], ENT_QUOTES); |
125 | 128 | preparsecode($_POST['news'][$i]); |
@@ -155,12 +158,13 @@ discard block |
||
155 | 158 | 'data' => array( |
156 | 159 | 'function' => function($news) |
157 | 160 | { |
158 | - if (is_numeric($news['id'])) |
|
159 | - return ' |
|
161 | + if (is_numeric($news['id'])) { |
|
162 | + return ' |
|
160 | 163 | <textarea id="data_' . $news['id'] . '" rows="3" cols="50" name="news[]" class="padding block">' . $news['unparsed'] . '</textarea> |
161 | 164 | <div class="floatleft" id="preview_' . $news['id'] . '"></div>'; |
162 | - else |
|
163 | - return $news['unparsed']; |
|
165 | + } else { |
|
166 | + return $news['unparsed']; |
|
167 | + } |
|
164 | 168 | }, |
165 | 169 | 'class' => 'half_table', |
166 | 170 | ), |
@@ -186,10 +190,11 @@ discard block |
||
186 | 190 | 'data' => array( |
187 | 191 | 'function' => function($news) |
188 | 192 | { |
189 | - if (is_numeric($news['id'])) |
|
190 | - return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
191 | - else |
|
192 | - return ''; |
|
193 | + if (is_numeric($news['id'])) { |
|
194 | + return '<input type="checkbox" name="remove[]" value="' . $news['id'] . '">'; |
|
195 | + } else { |
|
196 | + return ''; |
|
197 | + } |
|
193 | 198 | }, |
194 | 199 | 'class' => 'centercol icon', |
195 | 200 | ), |
@@ -283,12 +288,13 @@ discard block |
||
283 | 288 | |
284 | 289 | $admin_current_news = array(); |
285 | 290 | // Ready the current news. |
286 | - foreach (explode("\n", $modSettings['news']) as $id => $line) |
|
287 | - $admin_current_news[$id] = array( |
|
291 | + foreach (explode("\n", $modSettings['news']) as $id => $line) { |
|
292 | + $admin_current_news[$id] = array( |
|
288 | 293 | 'id' => $id, |
289 | 294 | 'unparsed' => un_preparsecode($line), |
290 | 295 | 'parsed' => preg_replace('~<([/]?)form[^>]*?[>]*>~i', '<em class="smalltext"><$1form></em>', parse_bbc($line)), |
291 | 296 | ); |
297 | + } |
|
292 | 298 | |
293 | 299 | $admin_current_news['last'] = array( |
294 | 300 | 'id' => 'last', |
@@ -355,10 +361,11 @@ discard block |
||
355 | 361 | 'member_count' => 0, |
356 | 362 | ); |
357 | 363 | |
358 | - if ($row['min_posts'] == -1) |
|
359 | - $normalGroups[$row['id_group']] = $row['id_group']; |
|
360 | - else |
|
361 | - $postGroups[$row['id_group']] = $row['id_group']; |
|
364 | + if ($row['min_posts'] == -1) { |
|
365 | + $normalGroups[$row['id_group']] = $row['id_group']; |
|
366 | + } else { |
|
367 | + $postGroups[$row['id_group']] = $row['id_group']; |
|
368 | + } |
|
362 | 369 | } |
363 | 370 | $smcFunc['db_free_result']($request); |
364 | 371 | |
@@ -374,8 +381,9 @@ discard block |
||
374 | 381 | 'post_group_list' => $postGroups, |
375 | 382 | ) |
376 | 383 | ); |
377 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
378 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
384 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
385 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
386 | + } |
|
379 | 387 | $smcFunc['db_free_result']($query); |
380 | 388 | } |
381 | 389 | |
@@ -391,8 +399,9 @@ discard block |
||
391 | 399 | 'normal_group_list' => $normalGroups, |
392 | 400 | ) |
393 | 401 | ); |
394 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
395 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
402 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
403 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
404 | + } |
|
396 | 405 | $smcFunc['db_free_result']($query); |
397 | 406 | |
398 | 407 | // Also do those who have it as an additional membergroup - this ones more yucky... |
@@ -409,8 +418,9 @@ discard block |
||
409 | 418 | 'blank_string' => '', |
410 | 419 | ) |
411 | 420 | ); |
412 | - while ($row = $smcFunc['db_fetch_assoc']($query)) |
|
413 | - $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
421 | + while ($row = $smcFunc['db_fetch_assoc']($query)) { |
|
422 | + $context['groups'][$row['id_group']]['member_count'] += $row['member_count']; |
|
423 | + } |
|
414 | 424 | $smcFunc['db_free_result']($query); |
415 | 425 | } |
416 | 426 | |
@@ -461,10 +471,11 @@ discard block |
||
461 | 471 | { |
462 | 472 | $context[$key] = !empty($_REQUEST[$post]) ? $_REQUEST[$post] : ''; |
463 | 473 | |
464 | - if (empty($context[$key]) && empty($_REQUEST['xml'])) |
|
465 | - $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
466 | - elseif (!empty($_REQUEST['xml'])) |
|
467 | - continue; |
|
474 | + if (empty($context[$key]) && empty($_REQUEST['xml'])) { |
|
475 | + $context['post_error']['messages'][] = $txt['error_no_' . $post]; |
|
476 | + } elseif (!empty($_REQUEST['xml'])) { |
|
477 | + continue; |
|
478 | + } |
|
468 | 479 | |
469 | 480 | preparsecode($context[$key]); |
470 | 481 | if ($html) |
@@ -543,10 +554,12 @@ discard block |
||
543 | 554 | |
544 | 555 | // Start by finding any members! |
545 | 556 | $toClean = array(); |
546 | - if (!empty($_POST['members'])) |
|
547 | - $toClean[] = 'members'; |
|
548 | - if (!empty($_POST['exclude_members'])) |
|
549 | - $toClean[] = 'exclude_members'; |
|
557 | + if (!empty($_POST['members'])) { |
|
558 | + $toClean[] = 'members'; |
|
559 | + } |
|
560 | + if (!empty($_POST['exclude_members'])) { |
|
561 | + $toClean[] = 'exclude_members'; |
|
562 | + } |
|
550 | 563 | if (!empty($toClean)) |
551 | 564 | { |
552 | 565 | require_once($sourcedir . '/Subs-Auth.php'); |
@@ -558,11 +571,13 @@ discard block |
||
558 | 571 | preg_match_all('~"([^"]+)"~', $_POST[$type], $matches); |
559 | 572 | $_POST[$type] = array_unique(array_merge($matches[1], explode(',', preg_replace('~"[^"]+"~', '', $_POST[$type])))); |
560 | 573 | |
561 | - foreach ($_POST[$type] as $index => $member) |
|
562 | - if (strlen(trim($member)) > 0) |
|
574 | + foreach ($_POST[$type] as $index => $member) { |
|
575 | + if (strlen(trim($member)) > 0) |
|
563 | 576 | $_POST[$type][$index] = $smcFunc['htmlspecialchars']($smcFunc['strtolower'](trim($member))); |
564 | - else |
|
565 | - unset($_POST[$type][$index]); |
|
577 | + } |
|
578 | + else { |
|
579 | + unset($_POST[$type][$index]); |
|
580 | + } |
|
566 | 581 | |
567 | 582 | // Find the members |
568 | 583 | $_POST[$type] = implode(',', array_keys(findMembers($_POST[$type]))); |
@@ -572,16 +587,18 @@ discard block |
||
572 | 587 | if (isset($_POST['member_list']) && is_array($_POST['member_list'])) |
573 | 588 | { |
574 | 589 | $members = array(); |
575 | - foreach ($_POST['member_list'] as $member_id) |
|
576 | - $members[] = (int) $member_id; |
|
590 | + foreach ($_POST['member_list'] as $member_id) { |
|
591 | + $members[] = (int) $member_id; |
|
592 | + } |
|
577 | 593 | $_POST['members'] = implode(',', $members); |
578 | 594 | } |
579 | 595 | |
580 | 596 | if (isset($_POST['exclude_member_list']) && is_array($_POST['exclude_member_list'])) |
581 | 597 | { |
582 | 598 | $members = array(); |
583 | - foreach ($_POST['exclude_member_list'] as $member_id) |
|
584 | - $members[] = (int) $member_id; |
|
599 | + foreach ($_POST['exclude_member_list'] as $member_id) { |
|
600 | + $members[] = (int) $member_id; |
|
601 | + } |
|
585 | 602 | $_POST['exclude_members'] = implode(',', $members); |
586 | 603 | } |
587 | 604 | |
@@ -605,8 +622,9 @@ discard block |
||
605 | 622 | 'current_time' => time(), |
606 | 623 | ) |
607 | 624 | ); |
608 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
609 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
625 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
626 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
627 | + } |
|
610 | 628 | $smcFunc['db_free_result']($request); |
611 | 629 | |
612 | 630 | $request = $smcFunc['db_query']('', ' |
@@ -641,8 +659,9 @@ discard block |
||
641 | 659 | WHERE email_address IN(' . implode(', ', $condition_array) . ')', |
642 | 660 | $condition_array_params |
643 | 661 | ); |
644 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
645 | - $context['recipients']['exclude_members'][] = $row['id_member']; |
|
662 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
663 | + $context['recipients']['exclude_members'][] = $row['id_member']; |
|
664 | + } |
|
646 | 665 | $smcFunc['db_free_result']($request); |
647 | 666 | } |
648 | 667 | |
@@ -660,10 +679,11 @@ discard block |
||
660 | 679 | ); |
661 | 680 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
662 | 681 | { |
663 | - if (in_array(3, $context['recipients'])) |
|
664 | - $context['recipients']['exclude_members'][] = $row['identifier']; |
|
665 | - else |
|
666 | - $context['recipients']['members'][] = $row['identifier']; |
|
682 | + if (in_array(3, $context['recipients'])) { |
|
683 | + $context['recipients']['exclude_members'][] = $row['identifier']; |
|
684 | + } else { |
|
685 | + $context['recipients']['members'][] = $row['identifier']; |
|
686 | + } |
|
667 | 687 | } |
668 | 688 | $smcFunc['db_free_result']($request); |
669 | 689 | } |
@@ -710,8 +730,9 @@ discard block |
||
710 | 730 | $num_at_once = 1000; |
711 | 731 | |
712 | 732 | // If by PM's I suggest we half the above number. |
713 | - if (!empty($_POST['send_pm'])) |
|
714 | - $num_at_once /= 2; |
|
733 | + if (!empty($_POST['send_pm'])) { |
|
734 | + $num_at_once /= 2; |
|
735 | + } |
|
715 | 736 | |
716 | 737 | checkSession(); |
717 | 738 | |
@@ -734,8 +755,7 @@ discard block |
||
734 | 755 | ); |
735 | 756 | list ($context['total_members']) = $smcFunc['db_fetch_row']($request); |
736 | 757 | $smcFunc['db_free_result']($request); |
737 | - } |
|
738 | - else |
|
758 | + } else |
|
739 | 759 | { |
740 | 760 | $context['total_members'] = (int) $_REQUEST['total_members']; |
741 | 761 | } |
@@ -753,32 +773,35 @@ discard block |
||
753 | 773 | if (!empty($_POST['exclude_members'])) |
754 | 774 | { |
755 | 775 | $members = explode(',', $_POST['exclude_members']); |
756 | - foreach ($members as $member) |
|
757 | - if ($member >= $context['start']) |
|
776 | + foreach ($members as $member) { |
|
777 | + if ($member >= $context['start']) |
|
758 | 778 | $context['recipients']['exclude_members'][] = (int) $member; |
779 | + } |
|
759 | 780 | } |
760 | 781 | |
761 | 782 | // What about members we *must* do? |
762 | 783 | if (!empty($_POST['members'])) |
763 | 784 | { |
764 | 785 | $members = explode(',', $_POST['members']); |
765 | - foreach ($members as $member) |
|
766 | - if ($member >= $context['start']) |
|
786 | + foreach ($members as $member) { |
|
787 | + if ($member >= $context['start']) |
|
767 | 788 | $context['recipients']['members'][] = (int) $member; |
789 | + } |
|
768 | 790 | } |
769 | 791 | // Cleaning groups is simple - although deal with both checkbox and commas. |
770 | 792 | if (isset($_POST['groups'])) |
771 | 793 | { |
772 | 794 | if (is_array($_POST['groups'])) |
773 | 795 | { |
774 | - foreach ($_POST['groups'] as $group => $dummy) |
|
775 | - $context['recipients']['groups'][] = (int) $group; |
|
776 | - } |
|
777 | - else |
|
796 | + foreach ($_POST['groups'] as $group => $dummy) { |
|
797 | + $context['recipients']['groups'][] = (int) $group; |
|
798 | + } |
|
799 | + } else |
|
778 | 800 | { |
779 | 801 | $groups = explode(',', $_POST['groups']); |
780 | - foreach ($groups as $group) |
|
781 | - $context['recipients']['groups'][] = (int) $group; |
|
802 | + foreach ($groups as $group) { |
|
803 | + $context['recipients']['groups'][] = (int) $group; |
|
804 | + } |
|
782 | 805 | } |
783 | 806 | } |
784 | 807 | // Same for excluded groups |
@@ -786,15 +809,17 @@ discard block |
||
786 | 809 | { |
787 | 810 | if (is_array($_POST['exclude_groups'])) |
788 | 811 | { |
789 | - foreach ($_POST['exclude_groups'] as $group => $dummy) |
|
790 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
812 | + foreach ($_POST['exclude_groups'] as $group => $dummy) { |
|
813 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
814 | + } |
|
791 | 815 | } |
792 | 816 | // Ignore an empty string - we don't want to exclude "Regular Members" unless it's specifically selected |
793 | 817 | elseif ($_POST['exclude_groups'] != '') |
794 | 818 | { |
795 | 819 | $groups = explode(',', $_POST['exclude_groups']); |
796 | - foreach ($groups as $group) |
|
797 | - $context['recipients']['exclude_groups'][] = (int) $group; |
|
820 | + foreach ($groups as $group) { |
|
821 | + $context['recipients']['exclude_groups'][] = (int) $group; |
|
822 | + } |
|
798 | 823 | } |
799 | 824 | } |
800 | 825 | // Finally - emails! |
@@ -804,14 +829,16 @@ discard block |
||
804 | 829 | foreach ($addressed as $curmem) |
805 | 830 | { |
806 | 831 | $curmem = trim($curmem); |
807 | - if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) |
|
808 | - $context['recipients']['emails'][$curmem] = $curmem; |
|
832 | + if ($curmem != '' && filter_var($curmem, FILTER_VALIDATE_EMAIL)) { |
|
833 | + $context['recipients']['emails'][$curmem] = $curmem; |
|
834 | + } |
|
809 | 835 | } |
810 | 836 | } |
811 | 837 | |
812 | 838 | // If we're only cleaning drop out here. |
813 | - if ($clean_only) |
|
814 | - return; |
|
839 | + if ($clean_only) { |
|
840 | + return; |
|
841 | + } |
|
815 | 842 | |
816 | 843 | require_once($sourcedir . '/Subs-Post.php'); |
817 | 844 | |
@@ -827,16 +854,18 @@ discard block |
||
827 | 854 | if (!$context['send_pm'] && !empty($_POST['send_html'])) |
828 | 855 | { |
829 | 856 | // Prepare the message for HTML. |
830 | - if (!empty($_POST['parse_html'])) |
|
831 | - $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
857 | + if (!empty($_POST['parse_html'])) { |
|
858 | + $_POST['message'] = str_replace(array("\n", ' '), array('<br>' . "\n", ' '), $_POST['message']); |
|
859 | + } |
|
832 | 860 | |
833 | 861 | // This is here to prevent spam filters from tagging this as spam. |
834 | 862 | if (preg_match('~\<html~i', $_POST['message']) == 0) |
835 | 863 | { |
836 | - if (preg_match('~\<body~i', $_POST['message']) == 0) |
|
837 | - $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
838 | - else |
|
839 | - $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
864 | + if (preg_match('~\<body~i', $_POST['message']) == 0) { |
|
865 | + $_POST['message'] = '<html><head><title>' . $_POST['subject'] . '</title></head>' . "\n" . '<body>' . $_POST['message'] . '</body></html>'; |
|
866 | + } else { |
|
867 | + $_POST['message'] = '<html>' . $_POST['message'] . '</html>'; |
|
868 | + } |
|
840 | 869 | } |
841 | 870 | } |
842 | 871 | |
@@ -890,15 +919,17 @@ discard block |
||
890 | 919 | foreach ($context['recipients']['emails'] as $k => $email) |
891 | 920 | { |
892 | 921 | // Done as many as we can? |
893 | - if ($i >= $num_at_once) |
|
894 | - break; |
|
922 | + if ($i >= $num_at_once) { |
|
923 | + break; |
|
924 | + } |
|
895 | 925 | |
896 | 926 | // Don't sent it twice! |
897 | 927 | unset($context['recipients']['emails'][$k]); |
898 | 928 | |
899 | 929 | // Dammit - can't PM emails! |
900 | - if ($context['send_pm']) |
|
901 | - continue; |
|
930 | + if ($context['send_pm']) { |
|
931 | + continue; |
|
932 | + } |
|
902 | 933 | |
903 | 934 | $to_member = array( |
904 | 935 | $email, |
@@ -932,8 +963,9 @@ discard block |
||
932 | 963 | $queryBuild[] = 'mem.id_post_group = {int:group_' . $group . '}'; |
933 | 964 | } |
934 | 965 | } |
935 | - if (!empty($queryBuild)) |
|
936 | - $sendQuery .= implode(' OR ', $queryBuild); |
|
966 | + if (!empty($queryBuild)) { |
|
967 | + $sendQuery .= implode(' OR ', $queryBuild); |
|
968 | + } |
|
937 | 969 | } |
938 | 970 | if (!empty($context['recipients']['members'])) |
939 | 971 | { |
@@ -952,8 +984,9 @@ discard block |
||
952 | 984 | } |
953 | 985 | |
954 | 986 | // Anything to exclude? |
955 | - if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) |
|
956 | - $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
987 | + if (!empty($context['recipients']['exclude_groups']) && in_array(0, $context['recipients']['exclude_groups'])) { |
|
988 | + $sendQuery .= ' AND mem.id_group != {int:regular_group}'; |
|
989 | + } |
|
957 | 990 | if (!empty($context['recipients']['exclude_members'])) |
958 | 991 | { |
959 | 992 | $sendQuery .= ' AND mem.id_member NOT IN ({array_int:exclude_members})'; |
@@ -989,21 +1022,24 @@ discard block |
||
989 | 1022 | foreach ($rows as $row) |
990 | 1023 | { |
991 | 1024 | // Force them to have it? |
992 | - if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) |
|
993 | - continue; |
|
1025 | + if (empty($context['email_force']) && empty($prefs[$row['id_member']]['announcements'])) { |
|
1026 | + continue; |
|
1027 | + } |
|
994 | 1028 | |
995 | 1029 | // What groups are we looking at here? |
996 | - if (empty($row['additional_groups'])) |
|
997 | - $groups = array($row['id_group'], $row['id_post_group']); |
|
998 | - else |
|
999 | - $groups = array_merge( |
|
1030 | + if (empty($row['additional_groups'])) { |
|
1031 | + $groups = array($row['id_group'], $row['id_post_group']); |
|
1032 | + } else { |
|
1033 | + $groups = array_merge( |
|
1000 | 1034 | array($row['id_group'], $row['id_post_group']), |
1001 | 1035 | explode(',', $row['additional_groups']) |
1002 | 1036 | ); |
1037 | + } |
|
1003 | 1038 | |
1004 | 1039 | // Excluded groups? |
1005 | - if (array_intersect($groups, $context['recipients']['exclude_groups'])) |
|
1006 | - continue; |
|
1040 | + if (array_intersect($groups, $context['recipients']['exclude_groups'])) { |
|
1041 | + continue; |
|
1042 | + } |
|
1007 | 1043 | |
1008 | 1044 | // We might need this |
1009 | 1045 | $cleanMemberName = empty($_POST['send_html']) || $context['send_pm'] ? un_htmlspecialchars($row['real_name']) : $row['real_name']; |
@@ -1026,10 +1062,11 @@ discard block |
||
1026 | 1062 | ), $_POST['subject']); |
1027 | 1063 | |
1028 | 1064 | // Send the actual email - or a PM! |
1029 | - if (!$context['send_pm']) |
|
1030 | - sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1031 | - else |
|
1032 | - sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1065 | + if (!$context['send_pm']) { |
|
1066 | + sendmail($row['email_address'], $subject, $message, null, 'news', !empty($_POST['send_html']), 5); |
|
1067 | + } else { |
|
1068 | + sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message); |
|
1069 | + } |
|
1033 | 1070 | } |
1034 | 1071 | } |
1035 | 1072 | |
@@ -1079,8 +1116,9 @@ discard block |
||
1079 | 1116 | |
1080 | 1117 | call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); |
1081 | 1118 | |
1082 | - if ($return_config) |
|
1083 | - return $config_vars; |
|
1119 | + if ($return_config) { |
|
1120 | + return $config_vars; |
|
1121 | + } |
|
1084 | 1122 | |
1085 | 1123 | $context['page_title'] = $txt['admin_edit_news'] . ' - ' . $txt['settings']; |
1086 | 1124 | $context['sub_template'] = 'show_settings'; |
@@ -28,14 +28,15 @@ discard block |
||
28 | 28 | <div id="confirm_buttons">'; |
29 | 29 | |
30 | 30 | // Age restriction in effect? |
31 | - if ($context['show_coppa']) |
|
32 | - echo ' |
|
31 | + if ($context['show_coppa']) { |
|
32 | + echo ' |
|
33 | 33 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
34 | 34 | <br> |
35 | 35 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
36 | - else |
|
37 | - echo ' |
|
36 | + } else { |
|
37 | + echo ' |
|
38 | 38 | <input type="submit" name="accept_agreement" value="', $txt['agreement_agree'], '" class="button">'; |
39 | + } |
|
39 | 40 | |
40 | 41 | echo ' |
41 | 42 | <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '"> |
@@ -78,9 +79,10 @@ discard block |
||
78 | 79 | <ul>'; |
79 | 80 | |
80 | 81 | // Cycle through each error and display an error message. |
81 | - foreach ($context['registration_errors'] as $error) |
|
82 | - echo ' |
|
82 | + foreach ($context['registration_errors'] as $error) { |
|
83 | + echo ' |
|
83 | 84 | <li>', $error, '</li>'; |
85 | + } |
|
84 | 86 | |
85 | 87 | echo ' |
86 | 88 | </ul> |
@@ -149,14 +151,15 @@ discard block |
||
149 | 151 | echo ' |
150 | 152 | <dl class="register_form">'; |
151 | 153 | |
152 | - foreach ($context['custom_fields'] as $field) |
|
153 | - if ($field['show_reg'] > 1) |
|
154 | + foreach ($context['custom_fields'] as $field) { |
|
155 | + if ($field['show_reg'] > 1) |
|
154 | 156 | echo ' |
155 | 157 | <dt> |
156 | 158 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
157 | 159 | <span class="smalltext">', $field['desc'], '</span> |
158 | 160 | </dt> |
159 | 161 | <dd>', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), '</dd>'; |
162 | + } |
|
160 | 163 | |
161 | 164 | echo ' |
162 | 165 | </dl>'; |
@@ -167,14 +170,15 @@ discard block |
||
167 | 170 | </div><!-- .roundframe -->'; |
168 | 171 | |
169 | 172 | // If we have either of these, show the extra group. |
170 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
171 | - echo ' |
|
173 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
174 | + echo ' |
|
172 | 175 | <div class="title_bar title_top"> |
173 | 176 | <h3 class="titlebg">', $txt['additional_information'], '</h3> |
174 | 177 | </div> |
175 | 178 | <div class="roundframe noup"> |
176 | 179 | <fieldset> |
177 | 180 | <dl class="register_form" id="custom_group">'; |
181 | + } |
|
178 | 182 | |
179 | 183 | if (!empty($context['profile_fields'])) |
180 | 184 | { |
@@ -188,41 +192,45 @@ discard block |
||
188 | 192 | $callback_func = 'template_profile_' . $field['callback_func']; |
189 | 193 | $callback_func(); |
190 | 194 | } |
191 | - } |
|
192 | - else |
|
195 | + } else |
|
193 | 196 | { |
194 | 197 | echo ' |
195 | 198 | <dt> |
196 | 199 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['label'], ':</strong>'; |
197 | 200 | |
198 | 201 | // Does it have any subtext to show? |
199 | - if (!empty($field['subtext'])) |
|
200 | - echo ' |
|
202 | + if (!empty($field['subtext'])) { |
|
203 | + echo ' |
|
201 | 204 | <span class="smalltext">', $field['subtext'], '</span>'; |
205 | + } |
|
202 | 206 | |
203 | 207 | echo ' |
204 | 208 | </dt> |
205 | 209 | <dd>'; |
206 | 210 | |
207 | 211 | // Want to put something infront of the box? |
208 | - if (!empty($field['preinput'])) |
|
209 | - echo ' |
|
212 | + if (!empty($field['preinput'])) { |
|
213 | + echo ' |
|
210 | 214 | ', $field['preinput']; |
215 | + } |
|
211 | 216 | |
212 | 217 | // What type of data are we showing? |
213 | - if ($field['type'] == 'label') |
|
214 | - echo ' |
|
218 | + if ($field['type'] == 'label') { |
|
219 | + echo ' |
|
215 | 220 | ', $field['value']; |
221 | + } |
|
216 | 222 | |
217 | 223 | // Maybe it's a text box - very likely! |
218 | - elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) |
|
219 | - echo ' |
|
224 | + elseif (in_array($field['type'], array('int', 'float', 'text', 'password', 'url'))) { |
|
225 | + echo ' |
|
220 | 226 | <input type="', $field['type'] == 'password' ? 'password' : 'text', '" name="', $key, '" id="', $key, '" size="', empty($field['size']) ? 30 : $field['size'], '" value="', $field['value'], '" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
227 | + } |
|
221 | 228 | |
222 | 229 | // You "checking" me out? ;) |
223 | - elseif ($field['type'] == 'check') |
|
224 | - echo ' |
|
230 | + elseif ($field['type'] == 'check') { |
|
231 | + echo ' |
|
225 | 232 | <input type="hidden" name="', $key, '" value="0"><input type="checkbox" name="', $key, '" id="', $key, '"', !empty($field['value']) ? ' checked' : '', ' value="1" tabindex="', $context['tabindex']++, '" ', $field['input_attr'], '>'; |
233 | + } |
|
226 | 234 | |
227 | 235 | // Always fun - select boxes! |
228 | 236 | elseif ($field['type'] == 'select') |
@@ -233,14 +241,16 @@ discard block |
||
233 | 241 | if (isset($field['options'])) |
234 | 242 | { |
235 | 243 | // Is this some code to generate the options? |
236 | - if (!is_array($field['options'])) |
|
237 | - $field['options'] = eval($field['options']); |
|
244 | + if (!is_array($field['options'])) { |
|
245 | + $field['options'] = eval($field['options']); |
|
246 | + } |
|
238 | 247 | |
239 | 248 | // Assuming we now have some! |
240 | - if (is_array($field['options'])) |
|
241 | - foreach ($field['options'] as $value => $name) |
|
249 | + if (is_array($field['options'])) { |
|
250 | + foreach ($field['options'] as $value => $name) |
|
242 | 251 | echo ' |
243 | 252 | <option value="', $value, '"', $value == $field['value'] ? ' selected' : '', '>', $name, '</option>'; |
253 | + } |
|
244 | 254 | } |
245 | 255 | |
246 | 256 | echo ' |
@@ -248,9 +258,10 @@ discard block |
||
248 | 258 | } |
249 | 259 | |
250 | 260 | // Something to end with? |
251 | - if (!empty($field['postinput'])) |
|
252 | - echo ' |
|
261 | + if (!empty($field['postinput'])) { |
|
262 | + echo ' |
|
253 | 263 | ', $field['postinput']; |
264 | + } |
|
254 | 265 | |
255 | 266 | echo ' |
256 | 267 | </dd>'; |
@@ -261,25 +272,27 @@ discard block |
||
261 | 272 | // Are there any custom fields? |
262 | 273 | if (!empty($context['custom_fields'])) |
263 | 274 | { |
264 | - foreach ($context['custom_fields'] as $field) |
|
265 | - if ($field['show_reg'] < 2) |
|
275 | + foreach ($context['custom_fields'] as $field) { |
|
276 | + if ($field['show_reg'] < 2) |
|
266 | 277 | echo ' |
267 | 278 | <dt> |
268 | 279 | <strong', !empty($field['is_error']) ? ' class="red"' : '', '>', $field['name'], ':</strong> |
269 | 280 | <span class="smalltext">', $field['desc'], '</span> |
270 | 281 | </dt> |
271 | 282 | <dd>', $field['input_html'], '</dd>'; |
283 | + } |
|
272 | 284 | } |
273 | 285 | |
274 | 286 | // If we have either of these, close the list like a proper gent. |
275 | - if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) |
|
276 | - echo ' |
|
287 | + if (!empty($context['profile_fields']) || !empty($context['custom_fields'])) { |
|
288 | + echo ' |
|
277 | 289 | </dl> |
278 | 290 | </fieldset> |
279 | 291 | </div><!-- .roundframe -->'; |
292 | + } |
|
280 | 293 | |
281 | - if ($context['visual_verification']) |
|
282 | - echo ' |
|
294 | + if ($context['visual_verification']) { |
|
295 | + echo ' |
|
283 | 296 | <div class="title_bar title_top"> |
284 | 297 | <h3 class="titlebg">', $txt['verification'], '</h3> |
285 | 298 | </div> |
@@ -288,19 +301,21 @@ discard block |
||
288 | 301 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
289 | 302 | </fieldset> |
290 | 303 | </div>'; |
304 | + } |
|
291 | 305 | |
292 | 306 | echo ' |
293 | 307 | <div id="confirm_buttons" class="flow_auto">'; |
294 | 308 | |
295 | 309 | // Age restriction in effect? |
296 | - if (!$context['require_agreement'] && $context['show_coppa']) |
|
297 | - echo ' |
|
310 | + if (!$context['require_agreement'] && $context['show_coppa']) { |
|
311 | + echo ' |
|
298 | 312 | <input type="submit" name="accept_agreement" value="', $context['coppa_agree_above'], '" class="button"><br> |
299 | 313 | <br> |
300 | 314 | <input type="submit" name="accept_agreement_coppa" value="', $context['coppa_agree_below'], '" class="button">'; |
301 | - else |
|
302 | - echo ' |
|
315 | + } else { |
|
316 | + echo ' |
|
303 | 317 | <input type="submit" name="regSubmit" value="', $txt['register'], '" tabindex="', $context['tabindex']++, '" class="button">'; |
318 | + } |
|
304 | 319 | |
305 | 320 | echo ' |
306 | 321 | </div> |
@@ -362,25 +377,28 @@ discard block |
||
362 | 377 | <p>', $context['coppa']['many_options'] ? $txt['coppa_send_to_two_options'] : $txt['coppa_send_to_one_option'], '</p>'; |
363 | 378 | |
364 | 379 | // Can they send by post? |
365 | - if (!empty($context['coppa']['post'])) |
|
366 | - echo ' |
|
380 | + if (!empty($context['coppa']['post'])) { |
|
381 | + echo ' |
|
367 | 382 | <h4>1) ', $txt['coppa_send_by_post'], '</h4> |
368 | 383 | <div class="coppa_contact"> |
369 | 384 | ', $context['coppa']['post'], ' |
370 | 385 | </div>'; |
386 | + } |
|
371 | 387 | |
372 | 388 | // Can they send by fax?? |
373 | - if (!empty($context['coppa']['fax'])) |
|
374 | - echo ' |
|
389 | + if (!empty($context['coppa']['fax'])) { |
|
390 | + echo ' |
|
375 | 391 | <h4>', !empty($context['coppa']['post']) ? '2' : '1', ') ', $txt['coppa_send_by_fax'], '</h4> |
376 | 392 | <div class="coppa_contact"> |
377 | 393 | ', $context['coppa']['fax'], ' |
378 | 394 | </div>'; |
395 | + } |
|
379 | 396 | |
380 | 397 | // Offer an alternative Phone Number? |
381 | - if ($context['coppa']['phone']) |
|
382 | - echo ' |
|
398 | + if ($context['coppa']['phone']) { |
|
399 | + echo ' |
|
383 | 400 | <p>', $context['coppa']['phone'], '</p>'; |
401 | + } |
|
384 | 402 | |
385 | 403 | echo ' |
386 | 404 | </div><!-- #coppa -->'; |
@@ -445,19 +463,20 @@ discard block |
||
445 | 463 | <body style="margin: 1ex;"> |
446 | 464 | <div class="windowbg description" style="text-align: center;">'; |
447 | 465 | |
448 | - if (isBrowser('is_ie') || isBrowser('is_ie11')) |
|
449 | - echo ' |
|
466 | + if (isBrowser('is_ie') || isBrowser('is_ie11')) { |
|
467 | + echo ' |
|
450 | 468 | <object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav"> |
451 | 469 | <param name="AutoStart" value="1"> |
452 | 470 | <param name="FileName" value="', $context['verification_sound_href'], '"> |
453 | 471 | </object>'; |
454 | - else |
|
455 | - echo ' |
|
472 | + } else { |
|
473 | + echo ' |
|
456 | 474 | <audio src="', $context['verification_sound_href'], '" controls> |
457 | 475 | <object type="audio/x-wav" data="', $context['verification_sound_href'], '"> |
458 | 476 | <a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a> |
459 | 477 | </object> |
460 | 478 | </audio>'; |
479 | + } |
|
461 | 480 | |
462 | 481 | echo ' |
463 | 482 | <br> |
@@ -485,11 +504,12 @@ discard block |
||
485 | 504 | </div> |
486 | 505 | <div id="register_screen" class="windowbg2 noup">'; |
487 | 506 | |
488 | - if (!empty($context['registration_done'])) |
|
489 | - echo ' |
|
507 | + if (!empty($context['registration_done'])) { |
|
508 | + echo ' |
|
490 | 509 | <div class="infobox"> |
491 | 510 | ', $context['registration_done'], ' |
492 | 511 | </div>'; |
512 | + } |
|
493 | 513 | |
494 | 514 | echo ' |
495 | 515 | <dl class="register_form" id="admin_register_form"> |
@@ -525,9 +545,10 @@ discard block |
||
525 | 545 | <dd> |
526 | 546 | <select name="group" id="group_select" tabindex="', $context['tabindex']++, '">'; |
527 | 547 | |
528 | - foreach ($context['member_groups'] as $id => $name) |
|
529 | - echo ' |
|
548 | + foreach ($context['member_groups'] as $id => $name) { |
|
549 | + echo ' |
|
530 | 550 | <option value="', $id, '">', $name, '</option>'; |
551 | + } |
|
531 | 552 | |
532 | 553 | echo ' |
533 | 554 | </select> |
@@ -535,8 +556,8 @@ discard block |
||
535 | 556 | } |
536 | 557 | |
537 | 558 | // If there is any field marked as required, show it here! |
538 | - if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) |
|
539 | - foreach ($context['custom_fields'] as $field) |
|
559 | + if (!empty($context['custom_fields_required']) && !empty($context['custom_fields'])) { |
|
560 | + foreach ($context['custom_fields'] as $field) |
|
540 | 561 | if ($field['show_reg'] > 1) |
541 | 562 | echo ' |
542 | 563 | <dt> |
@@ -546,6 +567,7 @@ discard block |
||
546 | 567 | <dd> |
547 | 568 | ', str_replace('name="', 'tabindex="' . $context['tabindex']++ . '" name="', $field['input_html']), ' |
548 | 569 | </dd>'; |
570 | + } |
|
549 | 571 | |
550 | 572 | echo ' |
551 | 573 | <dt> |
@@ -582,13 +604,13 @@ discard block |
||
582 | 604 | { |
583 | 605 | global $context, $scripturl, $txt; |
584 | 606 | |
585 | - if (!empty($context['saved_successful'])) |
|
586 | - echo ' |
|
607 | + if (!empty($context['saved_successful'])) { |
|
608 | + echo ' |
|
587 | 609 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
588 | - |
|
589 | - elseif (!empty($context['could_not_save'])) |
|
590 | - echo ' |
|
610 | + } elseif (!empty($context['could_not_save'])) { |
|
611 | + echo ' |
|
591 | 612 | <div class="errorbox">', $txt['admin_agreement_not_saved'], '</div>'; |
613 | + } |
|
592 | 614 | |
593 | 615 | // Just a big box to edit the text file ;) |
594 | 616 | echo ' |
@@ -598,9 +620,10 @@ discard block |
||
598 | 620 | </div>'; |
599 | 621 | |
600 | 622 | // Warning for if the file isn't writable. |
601 | - if (!empty($context['warning'])) |
|
602 | - echo ' |
|
623 | + if (!empty($context['warning'])) { |
|
624 | + echo ' |
|
603 | 625 | <p class="error">', $context['warning'], '</p>'; |
626 | + } |
|
604 | 627 | |
605 | 628 | echo ' |
606 | 629 | <div class="windowbg2 noup" id="registration_agreement">'; |
@@ -617,9 +640,10 @@ discard block |
||
617 | 640 | <strong>', $txt['admin_agreement_select_language'], ':</strong> |
618 | 641 | <select name="agree_lang" onchange="document.getElementById(\'change_reg\').submit();" tabindex="', $context['tabindex']++, '">'; |
619 | 642 | |
620 | - foreach ($context['editable_agreements'] as $file => $name) |
|
621 | - echo ' |
|
643 | + foreach ($context['editable_agreements'] as $file => $name) { |
|
644 | + echo ' |
|
622 | 645 | <option value="', $file, '"', $context['current_agreement'] == $file ? ' selected' : '', '>', $name, '</option>'; |
646 | + } |
|
623 | 647 | |
624 | 648 | echo ' |
625 | 649 | </select> |
@@ -659,9 +683,10 @@ discard block |
||
659 | 683 | { |
660 | 684 | global $context, $scripturl, $txt; |
661 | 685 | |
662 | - if (!empty($context['saved_successful'])) |
|
663 | - echo ' |
|
686 | + if (!empty($context['saved_successful'])) { |
|
687 | + echo ' |
|
664 | 688 | <div class="infobox">', $txt['settings_saved'], '</div>'; |
689 | + } |
|
665 | 690 | |
666 | 691 | echo ' |
667 | 692 | <form id="admin_form_wrapper" action="', $scripturl, '?action=admin;area=regcenter" method="post" accept-charset="', $context['character_set'], '"> |
@@ -20,17 +20,19 @@ discard block |
||
20 | 20 | echo ' |
21 | 21 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">'; |
22 | 22 | |
23 | - if (!empty($context['search_errors'])) |
|
24 | - echo ' |
|
23 | + if (!empty($context['search_errors'])) { |
|
24 | + echo ' |
|
25 | 25 | <div class="errorbox"> |
26 | 26 | ', implode('<br>', $context['search_errors']['messages']), ' |
27 | 27 | </div>'; |
28 | + } |
|
28 | 29 | |
29 | - if (!empty($context['search_ignored'])) |
|
30 | - echo ' |
|
30 | + if (!empty($context['search_ignored'])) { |
|
31 | + echo ' |
|
31 | 32 | <div class="noticebox"> |
32 | 33 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
33 | 34 | </div>'; |
35 | + } |
|
34 | 36 | |
35 | 37 | echo ' |
36 | 38 | <div class="cat_bar"> |
@@ -48,9 +50,10 @@ discard block |
||
48 | 50 | <dd> |
49 | 51 | <input type="search" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40">'; |
50 | 52 | |
51 | - if (empty($modSettings['search_simple_fulltext'])) |
|
52 | - echo ' |
|
53 | + if (empty($modSettings['search_simple_fulltext'])) { |
|
54 | + echo ' |
|
53 | 55 | <br><em class="smalltext">', $txt['search_example'], '</em>'; |
56 | + } |
|
54 | 57 | |
55 | 58 | echo ' |
56 | 59 | </dd> |
@@ -114,21 +117,23 @@ discard block |
||
114 | 117 | <input type="hidden" name="advanced" value="1">'; |
115 | 118 | |
116 | 119 | // Require an image to be typed to save spamming? |
117 | - if ($context['require_verification']) |
|
118 | - echo ' |
|
120 | + if ($context['require_verification']) { |
|
121 | + echo ' |
|
119 | 122 | <p> |
120 | 123 | <strong>', $txt['verification'], ':</strong> |
121 | 124 | ', template_control_verification($context['visual_verification_id'], 'all'), ' |
122 | 125 | </p>'; |
126 | + } |
|
123 | 127 | |
124 | 128 | // If $context['search_params']['topic'] is set, that means we're searching just one topic. |
125 | - if (!empty($context['search_params']['topic'])) |
|
126 | - echo ' |
|
129 | + if (!empty($context['search_params']['topic'])) { |
|
130 | + echo ' |
|
127 | 131 | <p> |
128 | 132 | ', $txt['search_specific_topic'], ' "', $context['search_topic']['link'], '". |
129 | 133 | </p> |
130 | 134 | <input type="hidden" name="topic" value="', $context['search_topic']['id'], '"> |
131 | 135 | <input type="submit" name="b_search" value="', $txt['search'], '" class="button">'; |
136 | + } |
|
132 | 137 | |
133 | 138 | echo ' |
134 | 139 | </div>'; |
@@ -158,14 +163,15 @@ discard block |
||
158 | 163 | |
159 | 164 | foreach ($category['boards'] as $board) |
160 | 165 | { |
161 | - if ($i == $limit) |
|
162 | - echo ' |
|
166 | + if ($i == $limit) { |
|
167 | + echo ' |
|
163 | 168 | </ul> |
164 | 169 | </li> |
165 | 170 | </ul> |
166 | 171 | <ul class="ignoreboards floatright"> |
167 | 172 | <li class="category"> |
168 | 173 | <ul>'; |
174 | + } |
|
169 | 175 | |
170 | 176 | echo ' |
171 | 177 | <li class="board"> |
@@ -253,17 +259,19 @@ discard block |
||
253 | 259 | <div class="roundframe noup">'; |
254 | 260 | |
255 | 261 | // Did they make any typos or mistakes, perhaps? |
256 | - if (isset($context['did_you_mean'])) |
|
257 | - echo ' |
|
262 | + if (isset($context['did_you_mean'])) { |
|
263 | + echo ' |
|
258 | 264 | <p> |
259 | 265 | ', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search2;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>. |
260 | 266 | </p>'; |
267 | + } |
|
261 | 268 | |
262 | - if (!empty($context['search_ignored'])) |
|
263 | - echo ' |
|
269 | + if (!empty($context['search_ignored'])) { |
|
270 | + echo ' |
|
264 | 271 | <p> |
265 | 272 | ', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), ' |
266 | 273 | </p>'; |
274 | + } |
|
267 | 275 | |
268 | 276 | echo ' |
269 | 277 | <form action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '"> |
@@ -286,10 +294,11 @@ discard block |
||
286 | 294 | <input type="hidden" name="sort" value="', !empty($context['search_params']['sort']) ? $context['search_params']['sort'] : 'relevance', '"> |
287 | 295 | </div>'; |
288 | 296 | |
289 | - if (!empty($context['search_params']['brd'])) |
|
290 | - foreach ($context['search_params']['brd'] as $board_id) |
|
297 | + if (!empty($context['search_params']['brd'])) { |
|
298 | + foreach ($context['search_params']['brd'] as $board_id) |
|
291 | 299 | echo ' |
292 | 300 | <input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '">'; |
301 | + } |
|
293 | 302 | |
294 | 303 | echo ' |
295 | 304 | </form> |
@@ -300,18 +309,20 @@ discard block |
||
300 | 309 | if ($context['compact']) |
301 | 310 | { |
302 | 311 | // Quick moderation set to checkboxes? Oh, how fun :/ |
303 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
304 | - echo ' |
|
312 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
313 | + echo ' |
|
305 | 314 | <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="topicForm">'; |
315 | + } |
|
306 | 316 | |
307 | 317 | echo ' |
308 | 318 | <div class="cat_bar"> |
309 | 319 | <h3 class="catbg"> |
310 | 320 | <span class="floatright">'; |
311 | 321 | |
312 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
313 | - echo ' |
|
322 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
323 | + echo ' |
|
314 | 324 | <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">'; |
325 | + } |
|
315 | 326 | echo ' |
316 | 327 | </span> |
317 | 328 | <span class="generic_icons filter"></span> ', $txt['mlist_search_results'], ': ', $context['search_params']['search'], ' |
@@ -319,15 +330,15 @@ discard block |
||
319 | 330 | </div>'; |
320 | 331 | |
321 | 332 | // Was anything even found? |
322 | - if (!empty($context['topics'])) |
|
323 | - echo ' |
|
333 | + if (!empty($context['topics'])) { |
|
334 | + echo ' |
|
324 | 335 | <div class="pagesection"> |
325 | 336 | <span>', $context['page_index'], '</span> |
326 | 337 | </div>'; |
327 | - |
|
328 | - else |
|
329 | - echo ' |
|
338 | + } else { |
|
339 | + echo ' |
|
330 | 340 | <div class="roundframe noup">', $txt['find_no_results'], '</div>'; |
341 | + } |
|
331 | 342 | |
332 | 343 | // While we have results to show ... |
333 | 344 | while ($topic = $context['get_topics']()) |
@@ -350,31 +361,35 @@ discard block |
||
350 | 361 | echo ' |
351 | 362 | <span class="floatright">'; |
352 | 363 | |
353 | - if ($options['display_quick_mod'] == 1) |
|
354 | - echo ' |
|
364 | + if ($options['display_quick_mod'] == 1) { |
|
365 | + echo ' |
|
355 | 366 | <input type="checkbox" name="topics[]" value="', $topic['id'], '">'; |
356 | - |
|
357 | - else |
|
367 | + } else |
|
358 | 368 | { |
359 | - if ($topic['quick_mod']['remove']) |
|
360 | - echo ' |
|
369 | + if ($topic['quick_mod']['remove']) { |
|
370 | + echo ' |
|
361 | 371 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons delete" title="', $txt['remove_topic'], '"></span></a>'; |
372 | + } |
|
362 | 373 | |
363 | - if ($topic['quick_mod']['lock']) |
|
364 | - echo ' |
|
374 | + if ($topic['quick_mod']['lock']) { |
|
375 | + echo ' |
|
365 | 376 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons lock" title="', $topic['is_locked'] ? $txt['set_unlock'] : $txt['set_lock'], '"></span></a>'; |
377 | + } |
|
366 | 378 | |
367 | - if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) |
|
368 | - echo ' |
|
379 | + if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) { |
|
380 | + echo ' |
|
369 | 381 | <br>'; |
382 | + } |
|
370 | 383 | |
371 | - if ($topic['quick_mod']['sticky']) |
|
372 | - echo ' |
|
384 | + if ($topic['quick_mod']['sticky']) { |
|
385 | + echo ' |
|
373 | 386 | <a href="', $scripturl, '?action=quickmod;board=' . $topic['board']['id'] . '.0;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" class="you_sure"><span class="generic_icons sticky" title="', $topic['is_sticky'] ? $txt['set_nonsticky'] : $txt['set_sticky'], '"></span></a>'; |
387 | + } |
|
374 | 388 | |
375 | - if ($topic['quick_mod']['move']) |
|
376 | - echo ' |
|
389 | + if ($topic['quick_mod']['move']) { |
|
390 | + echo ' |
|
377 | 391 | <a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><span class="generic_icons move" title="', $txt['move_topic'], '"></span></a>'; |
392 | + } |
|
378 | 393 | } |
379 | 394 | |
380 | 395 | echo ' |
@@ -384,20 +399,22 @@ discard block |
||
384 | 399 | echo ' |
385 | 400 | </div><!-- .block -->'; |
386 | 401 | |
387 | - if ($message['body_highlighted'] != '') |
|
388 | - echo ' |
|
402 | + if ($message['body_highlighted'] != '') { |
|
403 | + echo ' |
|
389 | 404 | <div class="list_posts double_height">', $message['body_highlighted'], '</div>'; |
405 | + } |
|
390 | 406 | } |
391 | 407 | |
392 | 408 | echo ' |
393 | 409 | </div><!-- $topic[css_class] -->'; |
394 | 410 | |
395 | 411 | } |
396 | - if (!empty($context['topics'])) |
|
397 | - echo ' |
|
412 | + if (!empty($context['topics'])) { |
|
413 | + echo ' |
|
398 | 414 | <div class="pagesection"> |
399 | 415 | <span>', $context['page_index'], '</span> |
400 | 416 | </div>'; |
417 | + } |
|
401 | 418 | |
402 | 419 | if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
403 | 420 | { |
@@ -406,17 +423,19 @@ discard block |
||
406 | 423 | <select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '> |
407 | 424 | <option value="">--------</option>'; |
408 | 425 | |
409 | - foreach ($context['qmod_actions'] as $qmod_action) |
|
410 | - if ($context['can_' . $qmod_action]) |
|
426 | + foreach ($context['qmod_actions'] as $qmod_action) { |
|
427 | + if ($context['can_' . $qmod_action]) |
|
411 | 428 | echo ' |
412 | 429 | <option value="' . $qmod_action . '">' . $txt['quick_mod_' . $qmod_action] . '</option>'; |
430 | + } |
|
413 | 431 | |
414 | 432 | echo ' |
415 | 433 | </select>'; |
416 | 434 | |
417 | - if ($context['can_move']) |
|
418 | - echo ' |
|
435 | + if ($context['can_move']) { |
|
436 | + echo ' |
|
419 | 437 | <span id="quick_mod_jump_to"></span>'; |
438 | + } |
|
420 | 439 | |
421 | 440 | echo ' |
422 | 441 | <input type="hidden" name="redirect_url" value="', $scripturl . '?action=search2;params=' . $context['params'], '"> |
@@ -425,13 +444,13 @@ discard block |
||
425 | 444 | } |
426 | 445 | |
427 | 446 | |
428 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) |
|
429 | - echo ' |
|
447 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics'])) { |
|
448 | + echo ' |
|
430 | 449 | <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"> |
431 | 450 | </form>'; |
451 | + } |
|
432 | 452 | |
433 | - } |
|
434 | - else |
|
453 | + } else |
|
435 | 454 | { |
436 | 455 | echo ' |
437 | 456 | <div class="cat_bar"> |
@@ -443,9 +462,10 @@ discard block |
||
443 | 462 | <span>', $context['page_index'], '</span> |
444 | 463 | </div>'; |
445 | 464 | |
446 | - if (empty($context['topics'])) |
|
447 | - echo ' |
|
465 | + if (empty($context['topics'])) { |
|
466 | + echo ' |
|
448 | 467 | <div class="information">(', $txt['search_no_results'], ')</div>'; |
468 | + } |
|
449 | 469 | |
450 | 470 | while ($topic = $context['get_topics']()) |
451 | 471 | { |
@@ -462,23 +482,27 @@ discard block |
||
462 | 482 | </div> |
463 | 483 | <div class="list_posts">', $message['body_highlighted'], '</div>'; |
464 | 484 | |
465 | - if ($topic['can_reply']) |
|
466 | - echo ' |
|
485 | + if ($topic['can_reply']) { |
|
486 | + echo ' |
|
467 | 487 | <ul class="quickbuttons">'; |
488 | + } |
|
468 | 489 | |
469 | 490 | // If they *can* reply? |
470 | - if ($topic['can_reply']) |
|
471 | - echo ' |
|
491 | + if ($topic['can_reply']) { |
|
492 | + echo ' |
|
472 | 493 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'], '"><span class="generic_icons reply_button"></span>', $txt['reply'], '</a></li>'; |
494 | + } |
|
473 | 495 | |
474 | 496 | // If they *can* quote? |
475 | - if ($topic['can_quote']) |
|
476 | - echo ' |
|
497 | + if ($topic['can_quote']) { |
|
498 | + echo ' |
|
477 | 499 | <li><a href="', $scripturl . '?action=post;topic=' . $topic['id'] . '.' . $message['start'] . ';quote=' . $message['id'] . '"><span class="generic_icons quote"></span>', $txt['quote_action'], '</a></li>'; |
500 | + } |
|
478 | 501 | |
479 | - if ($topic['can_reply']) |
|
480 | - echo ' |
|
502 | + if ($topic['can_reply']) { |
|
503 | + echo ' |
|
481 | 504 | </ul>'; |
505 | + } |
|
482 | 506 | echo ' |
483 | 507 | <br class="clear"> |
484 | 508 | </div><!-- $topic[css_class] -->'; |
@@ -497,8 +521,8 @@ discard block |
||
497 | 521 | <div class="smalltext righttext" id="search_jump_to"></div> |
498 | 522 | <script>'; |
499 | 523 | |
500 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) |
|
501 | - echo ' |
|
524 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) { |
|
525 | + echo ' |
|
502 | 526 | if (typeof(window.XMLHttpRequest) != "undefined") |
503 | 527 | aJumpTo[aJumpTo.length] = new JumpTo({ |
504 | 528 | sContainerId: "quick_mod_jump_to", |
@@ -513,6 +537,7 @@ discard block |
||
513 | 537 | bDisabled: true, |
514 | 538 | sCustomName: "move_to" |
515 | 539 | });'; |
540 | + } |
|
516 | 541 | |
517 | 542 | echo ' |
518 | 543 | if (typeof(window.XMLHttpRequest) != "undefined") |
@@ -54,18 +54,20 @@ discard block |
||
54 | 54 | <div class="windowbg2 noup" id="group_requests_panel"> |
55 | 55 | <ul>'; |
56 | 56 | |
57 | - foreach ($context['group_requests'] as $request) |
|
58 | - echo ' |
|
57 | + foreach ($context['group_requests'] as $request) { |
|
58 | + echo ' |
|
59 | 59 | <li class="smalltext"> |
60 | 60 | <a href="', $request['request_href'], '">', $request['group']['name'], '</a> ', $txt['mc_groupr_by'], ' ', $request['member']['link'], ' |
61 | 61 | </li>'; |
62 | + } |
|
62 | 63 | |
63 | 64 | // Don't have any watched users right now? |
64 | - if (empty($context['group_requests'])) |
|
65 | - echo ' |
|
65 | + if (empty($context['group_requests'])) { |
|
66 | + echo ' |
|
66 | 67 | <li> |
67 | 68 | <strong class="smalltext">', $txt['mc_group_requests_none'], '</strong> |
68 | 69 | </li>'; |
70 | + } |
|
69 | 71 | |
70 | 72 | echo ' |
71 | 73 | </ul> |
@@ -121,18 +123,20 @@ discard block |
||
121 | 123 | <div class="windowbg2 noup" id="watched_users_panel"> |
122 | 124 | <ul>'; |
123 | 125 | |
124 | - foreach ($context['watched_users'] as $user) |
|
125 | - echo ' |
|
126 | + foreach ($context['watched_users'] as $user) { |
|
127 | + echo ' |
|
126 | 128 | <li> |
127 | 129 | <span class="smalltext">', sprintf(!empty($user['last_login']) ? $txt['mc_seen'] : $txt['mc_seen_never'], $user['link'], $user['last_login']), '</span> |
128 | 130 | </li>'; |
131 | + } |
|
129 | 132 | |
130 | 133 | // Don't have any watched users right now? |
131 | - if (empty($context['watched_users'])) |
|
132 | - echo ' |
|
134 | + if (empty($context['watched_users'])) { |
|
135 | + echo ' |
|
133 | 136 | <li> |
134 | 137 | <strong class="smalltext">', $txt['mc_watched_users_none'], '</strong> |
135 | 138 | </li>'; |
139 | + } |
|
136 | 140 | |
137 | 141 | echo ' |
138 | 142 | </ul> |
@@ -188,18 +192,20 @@ discard block |
||
188 | 192 | <div class="windowbg2 noup" id="reported_posts_panel"> |
189 | 193 | <ul>'; |
190 | 194 | |
191 | - foreach ($context['reported_posts'] as $post) |
|
192 | - echo ' |
|
195 | + foreach ($context['reported_posts'] as $post) { |
|
196 | + echo ' |
|
193 | 197 | <li> |
194 | 198 | <span class="smalltext">', sprintf($txt['mc_post_report'], $post['report_link'], $post['author']['link']), '</span> |
195 | 199 | </li>'; |
200 | + } |
|
196 | 201 | |
197 | 202 | // Don't have any watched users right now? |
198 | - if (empty($context['reported_posts'])) |
|
199 | - echo ' |
|
203 | + if (empty($context['reported_posts'])) { |
|
204 | + echo ' |
|
200 | 205 | <li> |
201 | 206 | <strong class="smalltext">', $txt['mc_recent_reports_none'], '</strong> |
202 | 207 | </li>'; |
208 | + } |
|
203 | 209 | |
204 | 210 | echo ' |
205 | 211 | </ul> |
@@ -255,18 +261,20 @@ discard block |
||
255 | 261 | <div class="windowbg2 noup" id="reported_users_panel"> |
256 | 262 | <ul>'; |
257 | 263 | |
258 | - foreach ($context['reported_users'] as $user) |
|
259 | - echo ' |
|
264 | + foreach ($context['reported_users'] as $user) { |
|
265 | + echo ' |
|
260 | 266 | <li> |
261 | 267 | <span class="smalltext">', $user['user']['link'], '</span> |
262 | 268 | </li>'; |
269 | + } |
|
263 | 270 | |
264 | 271 | // Don't have any watched users right now? |
265 | - if (empty($context['reported_users'])) |
|
266 | - echo ' |
|
272 | + if (empty($context['reported_users'])) { |
|
273 | + echo ' |
|
267 | 274 | <li> |
268 | 275 | <strong class="smalltext">', $txt['mc_reported_users_none'], '</strong> |
269 | 276 | </li>'; |
277 | + } |
|
270 | 278 | |
271 | 279 | echo ' |
272 | 280 | </ul> |
@@ -313,11 +321,12 @@ discard block |
||
313 | 321 | global $context, $txt, $scripturl; |
314 | 322 | |
315 | 323 | // Let them know the action was a success. |
316 | - if (!empty($context['report_post_action'])) |
|
317 | - echo ' |
|
324 | + if (!empty($context['report_post_action'])) { |
|
325 | + echo ' |
|
318 | 326 | <div class="infobox"> |
319 | 327 | ', $txt['report_action_' . $context['report_post_action']], ' |
320 | 328 | </div>'; |
329 | + } |
|
321 | 330 | |
322 | 331 | echo ' |
323 | 332 | <div id="modnotes"> |
@@ -333,11 +342,12 @@ discard block |
||
333 | 342 | <ul class="moderation_notes">'; |
334 | 343 | |
335 | 344 | // Cycle through the notes. |
336 | - foreach ($context['notes'] as $note) |
|
337 | - echo ' |
|
345 | + foreach ($context['notes'] as $note) { |
|
346 | + echo ' |
|
338 | 347 | <li class="smalltext"> |
339 | 348 | ', ($note['can_delete'] ? '<a href="' . $note['delete_href'] . ';' . $context['mod-modnote-del_token_var'] . '=' . $context['mod-modnote-del_token'] . '" data-confirm="' . $txt['mc_reportedp_delete_confirm'] . '" class="you_sure"><span class="generic_icons delete"></span></a>' : ''), $note['time'], ' <strong>', $note['author']['link'], ':</strong> ', $note['text'], ' |
340 | 349 | </li>'; |
350 | + } |
|
341 | 351 | |
342 | 352 | echo ' |
343 | 353 | </ul> |
@@ -378,18 +388,19 @@ discard block |
||
378 | 388 | $remove_button = create_button('delete', 'remove_message', 'remove'); |
379 | 389 | |
380 | 390 | // No posts? |
381 | - if (empty($context['unapproved_items'])) |
|
382 | - echo ' |
|
391 | + if (empty($context['unapproved_items'])) { |
|
392 | + echo ' |
|
383 | 393 | <div class="windowbg2"> |
384 | 394 | <p class="centertext"> |
385 | 395 | ', $txt['mc_unapproved_' . $context['current_view'] . '_none_found'], ' |
386 | 396 | </p> |
387 | 397 | </div>'; |
388 | - else |
|
389 | - echo ' |
|
398 | + } else { |
|
399 | + echo ' |
|
390 | 400 | <div class="pagesection floatleft"> |
391 | 401 | ', $context['page_index'], ' |
392 | 402 | </div>'; |
403 | + } |
|
393 | 404 | |
394 | 405 | foreach ($context['unapproved_items'] as $item) |
395 | 406 | { |
@@ -408,14 +419,16 @@ discard block |
||
408 | 419 | <span class="floatright"> |
409 | 420 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';approve=', $item['id'], '">', $approve_button, '</a>'; |
410 | 421 | |
411 | - if ($item['can_delete']) |
|
412 | - echo ' |
|
422 | + if ($item['can_delete']) { |
|
423 | + echo ' |
|
413 | 424 | ', $context['menu_separator'], ' |
414 | 425 | <a href="', $scripturl, '?action=moderate;area=postmod;sa=', $context['current_view'], ';start=', $context['start'], ';', $context['session_var'], '=', $context['session_id'], ';delete=', $item['id'], '">', $remove_button, '</a>'; |
426 | + } |
|
415 | 427 | |
416 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
417 | - echo ' |
|
428 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
429 | + echo ' |
|
418 | 430 | <input type="checkbox" name="item[]" value="', $item['id'], '" checked> '; |
431 | + } |
|
419 | 432 | |
420 | 433 | echo ' |
421 | 434 | </span> |
@@ -425,8 +438,8 @@ discard block |
||
425 | 438 | echo ' |
426 | 439 | <div class="pagesection">'; |
427 | 440 | |
428 | - if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) |
|
429 | - echo ' |
|
441 | + if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) { |
|
442 | + echo ' |
|
430 | 443 | <div class="floatright"> |
431 | 444 | <select name="do" onchange="if (this.value != 0 && confirm(\'', $txt['mc_unapproved_sure'], '\')) submit();"> |
432 | 445 | <option value="0">', $txt['with_selected'], ':</option> |
@@ -438,12 +451,14 @@ discard block |
||
438 | 451 | <input type="submit" name="mc_go" value="', $txt['go'], '" class="button"> |
439 | 452 | </noscript> |
440 | 453 | </div>'; |
454 | + } |
|
441 | 455 | |
442 | - if (!empty($context['unapproved_items'])) |
|
443 | - echo ' |
|
456 | + if (!empty($context['unapproved_items'])) { |
|
457 | + echo ' |
|
444 | 458 | <div class="floatleft"> |
445 | 459 | <div class="pagelinks">', $context['page_index'], '</div> |
446 | 460 | </div>'; |
461 | + } |
|
447 | 462 | |
448 | 463 | echo ' |
449 | 464 | </div><!-- .pagesection --> |
@@ -464,8 +479,9 @@ discard block |
||
464 | 479 | |
465 | 480 | // We'll have a delete please bob. |
466 | 481 | // @todo Discuss this with the team and rewrite if required. |
467 | - if (empty($delete_button)) |
|
468 | - $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
482 | + if (empty($delete_button)) { |
|
483 | + $delete_button = create_button('delete', 'remove_message', 'remove', 'class="centericon"'); |
|
484 | + } |
|
469 | 485 | |
470 | 486 | $output_html = ' |
471 | 487 | <div> |
@@ -474,10 +490,11 @@ discard block |
||
474 | 490 | </div> |
475 | 491 | <div class="floatright">'; |
476 | 492 | |
477 | - if ($post['can_delete']) |
|
478 | - $output_html .= ' |
|
493 | + if ($post['can_delete']) { |
|
494 | + $output_html .= ' |
|
479 | 495 | <a href="' . $scripturl . '?action=moderate;area=userwatch;sa=post;delete=' . $post['id'] . ';start=' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" data-confirm="' . $txt['mc_watched_users_delete_post'] . '" class="you_sure">' . $delete_button . '</a> |
480 | 496 | <input type="checkbox" name="delete[]" value="' . $post['id'] . '">'; |
497 | + } |
|
481 | 498 | |
482 | 499 | $output_html .= ' |
483 | 500 | </div> |
@@ -521,12 +538,12 @@ discard block |
||
521 | 538 | <input type="submit" name="save" value="', $txt['save'], '" class="button"> |
522 | 539 | </div> |
523 | 540 | </form>'; |
524 | - } |
|
525 | - else |
|
526 | - echo ' |
|
541 | + } else { |
|
542 | + echo ' |
|
527 | 543 | <div class="windowbg"> |
528 | 544 | <div class="centertext">', $txt['mc_no_settings'], '</div> |
529 | 545 | </div>'; |
546 | + } |
|
530 | 547 | |
531 | 548 | echo ' |
532 | 549 | </div><!-- #modcenter -->'; |
@@ -622,13 +639,14 @@ discard block |
||
622 | 639 | </dd> |
623 | 640 | </dl>'; |
624 | 641 | |
625 | - if ($context['template_data']['can_edit_personal']) |
|
626 | - echo ' |
|
642 | + if ($context['template_data']['can_edit_personal']) { |
|
643 | + echo ' |
|
627 | 644 | <input type="checkbox" name="make_personal" id="make_personal"', $context['template_data']['personal'] ? ' checked' : '', '> |
628 | 645 | <label for="make_personal"> |
629 | 646 | <strong>', $txt['mc_warning_template_personal'], '</strong> |
630 | 647 | </label> |
631 | 648 | <p class="smalltext">', $txt['mc_warning_template_personal_desc'], '</p>'; |
649 | + } |
|
632 | 650 | |
633 | 651 | echo ' |
634 | 652 | <input type="submit" name="preview" id="preview_button" value="', $txt['preview'], '" class="button"> |