@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | |
20 | 21 | /** |
@@ -44,8 +45,9 @@ discard block |
||
44 | 45 | $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (allowedTo('manage_membergroups') ? 'index' : 'settings'); |
45 | 46 | |
46 | 47 | // Is it elsewhere? |
47 | - if (isset($subActions[$_REQUEST['sa']][2])) |
|
48 | - require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
48 | + if (isset($subActions[$_REQUEST['sa']][2])) { |
|
49 | + require_once($sourcedir . '/' . $subActions[$_REQUEST['sa']][2]); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // Do the permission check, you might not be allowed her. |
51 | 53 | isAllowedTo($subActions[$_REQUEST['sa']][1]); |
@@ -104,19 +106,20 @@ discard block |
||
104 | 106 | 'function' => function ($rowData) use ($scripturl) |
105 | 107 | { |
106 | 108 | // Since the moderator group has no explicit members, no link is needed. |
107 | - if ($rowData['id_group'] == 3) |
|
108 | - $group_name = $rowData['group_name']; |
|
109 | - else |
|
109 | + if ($rowData['id_group'] == 3) { |
|
110 | + $group_name = $rowData['group_name']; |
|
111 | + } else |
|
110 | 112 | { |
111 | 113 | $color_style = empty($rowData['online_color']) ? '' : sprintf(' style="color: %1$s;"', $rowData['online_color']); |
112 | 114 | $group_name = sprintf('<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>', $scripturl, $rowData['id_group'], $color_style, $rowData['group_name']); |
113 | 115 | } |
114 | 116 | |
115 | 117 | // Add a help option for moderator and administrator. |
116 | - if ($rowData['id_group'] == 1) |
|
117 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
118 | - elseif ($rowData['id_group'] == 3) |
|
119 | - $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
118 | + if ($rowData['id_group'] == 1) { |
|
119 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_administrator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
120 | + } elseif ($rowData['id_group'] == 3) { |
|
121 | + $group_name .= sprintf(' (<a href="%1$s?action=helpadmin;help=membergroup_moderator" onclick="return reqOverlayDiv(this.href);">?</a>)', $scripturl); |
|
122 | + } |
|
120 | 123 | |
121 | 124 | return $group_name; |
122 | 125 | }, |
@@ -330,12 +333,14 @@ discard block |
||
330 | 333 | call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); |
331 | 334 | |
332 | 335 | // Update the post groups now, if this is a post group! |
333 | - if (isset($_POST['min_posts'])) |
|
334 | - updateStats('postgroups'); |
|
336 | + if (isset($_POST['min_posts'])) { |
|
337 | + updateStats('postgroups'); |
|
338 | + } |
|
335 | 339 | |
336 | 340 | // You cannot set permissions for post groups if they are disabled. |
337 | - if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) |
|
338 | - $_POST['perm_type'] = ''; |
|
341 | + if ($postCountBasedGroup && empty($modSettings['permission_enable_postgroups'])) { |
|
342 | + $_POST['perm_type'] = ''; |
|
343 | + } |
|
339 | 344 | |
340 | 345 | if ($_POST['perm_type'] == 'predefined') |
341 | 346 | { |
@@ -365,8 +370,9 @@ discard block |
||
365 | 370 | $smcFunc['db_free_result']($request); |
366 | 371 | |
367 | 372 | // Protected groups are... well, protected! |
368 | - if ($copy_type == 1) |
|
369 | - fatal_lang_error('membergroup_does_not_exist'); |
|
373 | + if ($copy_type == 1) { |
|
374 | + fatal_lang_error('membergroup_does_not_exist'); |
|
375 | + } |
|
370 | 376 | } |
371 | 377 | |
372 | 378 | // Don't allow copying of a real priviledged person! |
@@ -384,18 +390,20 @@ discard block |
||
384 | 390 | $inserts = array(); |
385 | 391 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
386 | 392 | { |
387 | - if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) |
|
388 | - $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
393 | + if (empty($context['illegal_permissions']) || !in_array($row['permission'], $context['illegal_permissions'])) { |
|
394 | + $inserts[] = array($id_group, $row['permission'], $row['add_deny']); |
|
395 | + } |
|
389 | 396 | } |
390 | 397 | $smcFunc['db_free_result']($request); |
391 | 398 | |
392 | - if (!empty($inserts)) |
|
393 | - $smcFunc['db_insert']('insert', |
|
399 | + if (!empty($inserts)) { |
|
400 | + $smcFunc['db_insert']('insert', |
|
394 | 401 | '{db_prefix}permissions', |
395 | 402 | array('id_group' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
396 | 403 | $inserts, |
397 | 404 | array('id_group', 'permission') |
398 | 405 | ); |
406 | + } |
|
399 | 407 | |
400 | 408 | $request = $smcFunc['db_query']('', ' |
401 | 409 | SELECT id_profile, permission, add_deny |
@@ -406,17 +414,19 @@ discard block |
||
406 | 414 | ) |
407 | 415 | ); |
408 | 416 | $inserts = array(); |
409 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
410 | - $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
417 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
418 | + $inserts[] = array($id_group, $row['id_profile'], $row['permission'], $row['add_deny']); |
|
419 | + } |
|
411 | 420 | $smcFunc['db_free_result']($request); |
412 | 421 | |
413 | - if (!empty($inserts)) |
|
414 | - $smcFunc['db_insert']('insert', |
|
422 | + if (!empty($inserts)) { |
|
423 | + $smcFunc['db_insert']('insert', |
|
415 | 424 | '{db_prefix}board_permissions', |
416 | 425 | array('id_group' => 'int', 'id_profile' => 'int', 'permission' => 'string', 'add_deny' => 'int'), |
417 | 426 | $inserts, |
418 | 427 | array('id_group', 'id_profile', 'permission') |
419 | 428 | ); |
429 | + } |
|
420 | 430 | |
421 | 431 | // Also get some membergroup information if we're copying and not copying from guests... |
422 | 432 | if ($copy_id > 0 && $_POST['perm_type'] == 'copy') |
@@ -469,14 +479,15 @@ discard block |
||
469 | 479 | $changed_boards['allow'] = array(); |
470 | 480 | $changed_boards['deny'] = array(); |
471 | 481 | $changed_boards['ignore'] = array(); |
472 | - foreach ($accesses as $group_id => $action) |
|
473 | - $changed_boards[$action][] = (int) $group_id; |
|
482 | + foreach ($accesses as $group_id => $action) { |
|
483 | + $changed_boards[$action][] = (int) $group_id; |
|
484 | + } |
|
474 | 485 | |
475 | 486 | foreach (array('allow', 'deny') as $board_action) |
476 | 487 | { |
477 | 488 | // Only do this if they have special access requirements. |
478 | - if (!empty($changed_boards[$board_action])) |
|
479 | - $smcFunc['db_query']('', ' |
|
489 | + if (!empty($changed_boards[$board_action])) { |
|
490 | + $smcFunc['db_query']('', ' |
|
480 | 491 | UPDATE {db_prefix}boards |
481 | 492 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
482 | 493 | WHERE id_board IN ({array_int:board_list})', |
@@ -488,11 +499,13 @@ discard block |
||
488 | 499 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
489 | 500 | ) |
490 | 501 | ); |
502 | + } |
|
491 | 503 | } |
492 | 504 | |
493 | 505 | // If this is joinable then set it to show group membership in people's profiles. |
494 | - if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) |
|
495 | - updateSettings(array('show_group_membership' => 1)); |
|
506 | + if (empty($modSettings['show_group_membership']) && $_POST['group_type'] > 1) { |
|
507 | + updateSettings(array('show_group_membership' => 1)); |
|
508 | + } |
|
496 | 509 | |
497 | 510 | // Rebuild the group cache. |
498 | 511 | updateSettings(array( |
@@ -513,8 +526,9 @@ discard block |
||
513 | 526 | $context['undefined_group'] = !isset($_REQUEST['postgroup']) && !isset($_REQUEST['generalgroup']); |
514 | 527 | $context['allow_protected'] = allowedTo('admin_forum'); |
515 | 528 | |
516 | - if (!empty($modSettings['deny_boards_access'])) |
|
517 | - loadLanguage('ManagePermissions'); |
|
529 | + if (!empty($modSettings['deny_boards_access'])) { |
|
530 | + loadLanguage('ManagePermissions'); |
|
531 | + } |
|
518 | 532 | |
519 | 533 | $result = $smcFunc['db_query']('', ' |
520 | 534 | SELECT id_group, group_name |
@@ -531,11 +545,12 @@ discard block |
||
531 | 545 | ) |
532 | 546 | ); |
533 | 547 | $context['groups'] = array(); |
534 | - while ($row = $smcFunc['db_fetch_assoc']($result)) |
|
535 | - $context['groups'][] = array( |
|
548 | + while ($row = $smcFunc['db_fetch_assoc']($result)) { |
|
549 | + $context['groups'][] = array( |
|
536 | 550 | 'id' => $row['id_group'], |
537 | 551 | 'name' => $row['group_name'] |
538 | 552 | ); |
553 | + } |
|
539 | 554 | $smcFunc['db_free_result']($result); |
540 | 555 | |
541 | 556 | $request = $smcFunc['db_query']('', ' |
@@ -552,12 +567,13 @@ discard block |
||
552 | 567 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
553 | 568 | { |
554 | 569 | // This category hasn't been set up yet.. |
555 | - if (!isset($context['categories'][$row['id_cat']])) |
|
556 | - $context['categories'][$row['id_cat']] = array( |
|
570 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
571 | + $context['categories'][$row['id_cat']] = array( |
|
557 | 572 | 'id' => $row['id_cat'], |
558 | 573 | 'name' => $row['cat_name'], |
559 | 574 | 'boards' => array() |
560 | 575 | ); |
576 | + } |
|
561 | 577 | |
562 | 578 | // Set this board up, and let the template know when it's a child. (indent them..) |
563 | 579 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -605,8 +621,9 @@ discard block |
||
605 | 621 | require_once($sourcedir . '/Subs-Membergroups.php'); |
606 | 622 | $result = deleteMembergroups((int) $_REQUEST['group']); |
607 | 623 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
608 | - if ($result === 'group_cannot_delete_sub') |
|
609 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
624 | + if ($result === 'group_cannot_delete_sub') { |
|
625 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
626 | + } |
|
610 | 627 | |
611 | 628 | // Go back to the membergroup index. |
612 | 629 | redirectexit('action=admin;area=membergroups;'); |
@@ -628,8 +645,9 @@ discard block |
||
628 | 645 | |
629 | 646 | $_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0; |
630 | 647 | |
631 | - if (!empty($modSettings['deny_boards_access'])) |
|
632 | - loadLanguage('ManagePermissions'); |
|
648 | + if (!empty($modSettings['deny_boards_access'])) { |
|
649 | + loadLanguage('ManagePermissions'); |
|
650 | + } |
|
633 | 651 | |
634 | 652 | // Make sure this group is editable. |
635 | 653 | if (!empty($_REQUEST['group'])) |
@@ -651,8 +669,9 @@ discard block |
||
651 | 669 | } |
652 | 670 | |
653 | 671 | // Now, do we have a valid id? |
654 | - if (empty($_REQUEST['group'])) |
|
655 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
672 | + if (empty($_REQUEST['group'])) { |
|
673 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
674 | + } |
|
656 | 675 | |
657 | 676 | // People who can manage boards are a bit special. |
658 | 677 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -683,8 +702,9 @@ discard block |
||
683 | 702 | require_once($sourcedir . '/Subs-Membergroups.php'); |
684 | 703 | $result = deleteMembergroups($_REQUEST['group']); |
685 | 704 | // Need to throw a warning if it went wrong, but this is the only one we have a message for... |
686 | - if ($result === 'group_cannot_delete_sub') |
|
687 | - fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
705 | + if ($result === 'group_cannot_delete_sub') { |
|
706 | + fatal_lang_error('membergroups_cannot_delete_paid', false); |
|
707 | + } |
|
688 | 708 | |
689 | 709 | redirectexit('action=admin;area=membergroups;'); |
690 | 710 | } |
@@ -761,16 +781,18 @@ discard block |
||
761 | 781 | $request = $smcFunc['db_query']('', ' |
762 | 782 | SELECT id_board |
763 | 783 | FROM {db_prefix}boards'); |
764 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
765 | - $accesses[(int) $row['id_board']] = 'allow'; |
|
784 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
785 | + $accesses[(int) $row['id_board']] = 'allow'; |
|
786 | + } |
|
766 | 787 | $smcFunc['db_free_result']($request); |
767 | 788 | } |
768 | 789 | |
769 | 790 | $changed_boards['allow'] = array(); |
770 | 791 | $changed_boards['deny'] = array(); |
771 | 792 | $changed_boards['ignore'] = array(); |
772 | - foreach ($accesses as $group_id => $action) |
|
773 | - $changed_boards[$action][] = (int) $group_id; |
|
793 | + foreach ($accesses as $group_id => $action) { |
|
794 | + $changed_boards[$action][] = (int) $group_id; |
|
795 | + } |
|
774 | 796 | |
775 | 797 | foreach (array('allow', 'deny') as $board_action) |
776 | 798 | { |
@@ -786,8 +808,8 @@ discard block |
||
786 | 808 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
787 | 809 | ) |
788 | 810 | ); |
789 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
790 | - $smcFunc['db_query']('', ' |
|
811 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
812 | + $smcFunc['db_query']('', ' |
|
791 | 813 | UPDATE {db_prefix}boards |
792 | 814 | SET {raw:column} = {string:member_group_access} |
793 | 815 | WHERE id_board = {int:current_board}', |
@@ -797,11 +819,12 @@ discard block |
||
797 | 819 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
798 | 820 | ) |
799 | 821 | ); |
822 | + } |
|
800 | 823 | $smcFunc['db_free_result']($request); |
801 | 824 | |
802 | 825 | // Add the membergroup to all boards that hadn't been set yet. |
803 | - if (!empty($changed_boards[$board_action])) |
|
804 | - $smcFunc['db_query']('', ' |
|
826 | + if (!empty($changed_boards[$board_action])) { |
|
827 | + $smcFunc['db_query']('', ' |
|
805 | 828 | UPDATE {db_prefix}boards |
806 | 829 | SET {raw:column} = CASE WHEN {raw:column} = {string:blank_string} THEN {string:group_id_string} ELSE CONCAT({raw:column}, {string:comma_group}) END |
807 | 830 | WHERE id_board IN ({array_int:board_list}) |
@@ -815,6 +838,7 @@ discard block |
||
815 | 838 | 'column' => $board_action == 'allow' ? 'member_groups' : 'deny_member_groups', |
816 | 839 | ) |
817 | 840 | ); |
841 | + } |
|
818 | 842 | } |
819 | 843 | } |
820 | 844 | |
@@ -840,12 +864,14 @@ discard block |
||
840 | 864 | ) |
841 | 865 | ); |
842 | 866 | $updates = array(); |
843 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
844 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
867 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
868 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
869 | + } |
|
845 | 870 | $smcFunc['db_free_result']($request); |
846 | 871 | |
847 | - foreach ($updates as $additional_groups => $memberArray) |
|
848 | - updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
872 | + foreach ($updates as $additional_groups => $memberArray) { |
|
873 | + updateMemberData($memberArray, array('additional_groups' => implode(',', array_diff(explode(',', $additional_groups), array((int) $_REQUEST['group']))))); |
|
874 | + } |
|
849 | 875 | |
850 | 876 | // Sorry, but post groups can't moderate boards |
851 | 877 | $request = $smcFunc['db_query']('', ' |
@@ -855,8 +881,7 @@ discard block |
||
855 | 881 | 'current_group' => (int) $_REQUEST['group'], |
856 | 882 | ) |
857 | 883 | ); |
858 | - } |
|
859 | - elseif ($_REQUEST['group'] != 3) |
|
884 | + } elseif ($_REQUEST['group'] != 3) |
|
860 | 885 | { |
861 | 886 | // Making it a hidden group? If so remove everyone with it as primary group (Actually, just make them additional). |
862 | 887 | if ($_POST['group_hidden'] == 2) |
@@ -871,8 +896,9 @@ discard block |
||
871 | 896 | ) |
872 | 897 | ); |
873 | 898 | $updates = array(); |
874 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
875 | - $updates[$row['additional_groups']][] = $row['id_member']; |
|
899 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
900 | + $updates[$row['additional_groups']][] = $row['id_member']; |
|
901 | + } |
|
876 | 902 | $smcFunc['db_free_result']($request); |
877 | 903 | |
878 | 904 | foreach ($updates as $additional_groups => $memberArray) |
@@ -914,8 +940,9 @@ discard block |
||
914 | 940 | $smcFunc['db_free_result']($request); |
915 | 941 | |
916 | 942 | // Do we need to update the setting? |
917 | - if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) |
|
918 | - updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
943 | + if ((empty($modSettings['show_group_membership']) && $have_joinable) || (!empty($modSettings['show_group_membership']) && !$have_joinable)) { |
|
944 | + updateSettings(array('show_group_membership' => $have_joinable ? 1 : 0)); |
|
945 | + } |
|
919 | 946 | } |
920 | 947 | |
921 | 948 | // Do we need to set inherited permissions? |
@@ -948,8 +975,9 @@ discard block |
||
948 | 975 | { |
949 | 976 | $moderators[$k] = trim($moderators[$k]); |
950 | 977 | |
951 | - if (strlen($moderators[$k]) == 0) |
|
952 | - unset($moderators[$k]); |
|
978 | + if (strlen($moderators[$k]) == 0) { |
|
979 | + unset($moderators[$k]); |
|
980 | + } |
|
953 | 981 | } |
954 | 982 | |
955 | 983 | // Find all the id_member's for the member_name's in the list. |
@@ -965,8 +993,9 @@ discard block |
||
965 | 993 | 'count' => count($moderators), |
966 | 994 | ) |
967 | 995 | ); |
968 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
969 | - $group_moderators[] = $row['id_member']; |
|
996 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
997 | + $group_moderators[] = $row['id_member']; |
|
998 | + } |
|
970 | 999 | $smcFunc['db_free_result']($request); |
971 | 1000 | } |
972 | 1001 | } |
@@ -974,8 +1003,9 @@ discard block |
||
974 | 1003 | if (!empty($_POST['moderator_list'])) |
975 | 1004 | { |
976 | 1005 | $moderators = array(); |
977 | - foreach ($_POST['moderator_list'] as $moderator) |
|
978 | - $moderators[] = (int) $moderator; |
|
1006 | + foreach ($_POST['moderator_list'] as $moderator) { |
|
1007 | + $moderators[] = (int) $moderator; |
|
1008 | + } |
|
979 | 1009 | |
980 | 1010 | if (!empty($moderators)) |
981 | 1011 | { |
@@ -989,8 +1019,9 @@ discard block |
||
989 | 1019 | 'num_moderators' => count($moderators), |
990 | 1020 | ) |
991 | 1021 | ); |
992 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
993 | - $group_moderators[] = $row['id_member']; |
|
1022 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1023 | + $group_moderators[] = $row['id_member']; |
|
1024 | + } |
|
994 | 1025 | $smcFunc['db_free_result']($request); |
995 | 1026 | } |
996 | 1027 | } |
@@ -1002,8 +1033,9 @@ discard block |
||
1002 | 1033 | if (!empty($group_moderators)) |
1003 | 1034 | { |
1004 | 1035 | $mod_insert = array(); |
1005 | - foreach ($group_moderators as $moderator) |
|
1006 | - $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
1036 | + foreach ($group_moderators as $moderator) { |
|
1037 | + $mod_insert[] = array($_REQUEST['group'], $moderator); |
|
1038 | + } |
|
1007 | 1039 | |
1008 | 1040 | $smcFunc['db_insert']('insert', |
1009 | 1041 | '{db_prefix}group_moderators', |
@@ -1037,8 +1069,9 @@ discard block |
||
1037 | 1069 | 'current_group' => (int) $_REQUEST['group'], |
1038 | 1070 | ) |
1039 | 1071 | ); |
1040 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
1041 | - fatal_lang_error('membergroup_does_not_exist', false); |
|
1072 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
1073 | + fatal_lang_error('membergroup_does_not_exist', false); |
|
1074 | + } |
|
1042 | 1075 | $row = $smcFunc['db_fetch_assoc']($request); |
1043 | 1076 | $smcFunc['db_free_result']($request); |
1044 | 1077 | |
@@ -1075,14 +1108,16 @@ discard block |
||
1075 | 1108 | ) |
1076 | 1109 | ); |
1077 | 1110 | $context['group']['moderators'] = array(); |
1078 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1079 | - $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
1111 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1112 | + $context['group']['moderators'][$row['id_member']] = $row['real_name']; |
|
1113 | + } |
|
1080 | 1114 | $smcFunc['db_free_result']($request); |
1081 | 1115 | |
1082 | 1116 | $context['group']['moderator_list'] = empty($context['group']['moderators']) ? '' : '"' . implode('", "', $context['group']['moderators']) . '"'; |
1083 | 1117 | |
1084 | - if (!empty($context['group']['moderators'])) |
|
1085 | - list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
1118 | + if (!empty($context['group']['moderators'])) { |
|
1119 | + list ($context['group']['last_moderator_id']) = array_slice(array_keys($context['group']['moderators']), -1); |
|
1120 | + } |
|
1086 | 1121 | |
1087 | 1122 | // Get a list of boards this membergroup is allowed to see. |
1088 | 1123 | $context['boards'] = array(); |
@@ -1102,12 +1137,13 @@ discard block |
||
1102 | 1137 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
1103 | 1138 | { |
1104 | 1139 | // This category hasn't been set up yet.. |
1105 | - if (!isset($context['categories'][$row['id_cat']])) |
|
1106 | - $context['categories'][$row['id_cat']] = array( |
|
1140 | + if (!isset($context['categories'][$row['id_cat']])) { |
|
1141 | + $context['categories'][$row['id_cat']] = array( |
|
1107 | 1142 | 'id' => $row['id_cat'], |
1108 | 1143 | 'name' => $row['cat_name'], |
1109 | 1144 | 'boards' => array() |
1110 | 1145 | ); |
1146 | + } |
|
1111 | 1147 | |
1112 | 1148 | // Set this board up, and let the template know when it's a child. (indent them..) |
1113 | 1149 | $context['categories'][$row['id_cat']]['boards'][$row['id_board']] = array( |
@@ -1135,8 +1171,9 @@ discard block |
||
1135 | 1171 | } |
1136 | 1172 | |
1137 | 1173 | $max_boards = ceil(count($temp_boards) / 2); |
1138 | - if ($max_boards == 1) |
|
1139 | - $max_boards = 2; |
|
1174 | + if ($max_boards == 1) { |
|
1175 | + $max_boards = 2; |
|
1176 | + } |
|
1140 | 1177 | } |
1141 | 1178 | |
1142 | 1179 | // Get a list of all the image formats we can select. |
@@ -1159,19 +1196,22 @@ discard block |
||
1159 | 1196 | $image_info = getimagesize($settings['default_theme_dir'] . '/images/membericons/' . $value); |
1160 | 1197 | |
1161 | 1198 | // If this is bigger than 128 in width or 32 in height, skip this one. |
1162 | - if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) |
|
1163 | - continue; |
|
1199 | + if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32) { |
|
1200 | + continue; |
|
1201 | + } |
|
1164 | 1202 | |
1165 | 1203 | // Else it's valid. Add it in. |
1166 | - else |
|
1167 | - $context['possible_icons'][] = $value; |
|
1204 | + else { |
|
1205 | + $context['possible_icons'][] = $value; |
|
1206 | + } |
|
1168 | 1207 | } |
1169 | 1208 | } |
1170 | 1209 | } |
1171 | 1210 | |
1172 | 1211 | // Insert our JS, if we have possible icons. |
1173 | - if (!empty($context['possible_icons'])) |
|
1174 | - loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
1212 | + if (!empty($context['possible_icons'])) { |
|
1213 | + loadJavaScriptFile('icondropdown.js', array('validate' => true), 'smf_icondropdown'); |
|
1214 | + } |
|
1175 | 1215 | |
1176 | 1216 | loadJavaScriptFile('suggest.js', array('defer' => false), 'smf_suggest'); |
1177 | 1217 | |
@@ -1193,8 +1233,9 @@ discard block |
||
1193 | 1233 | ) |
1194 | 1234 | ); |
1195 | 1235 | $context['inheritable_groups'] = array(); |
1196 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
1197 | - $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
1236 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
1237 | + $context['inheritable_groups'][$row['id_group']] = $row['group_name']; |
|
1238 | + } |
|
1198 | 1239 | $smcFunc['db_free_result']($request); |
1199 | 1240 | |
1200 | 1241 | call_integration_hook('integrate_view_membergroup'); |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -29,8 +30,9 @@ discard block |
||
29 | 30 | |
30 | 31 | $supported = function_exists('zend_shm_cache_fetch') || function_exists('output_cache_get'); |
31 | 32 | |
32 | - if ($test) |
|
33 | - return $supported; |
|
33 | + if ($test) { |
|
34 | + return $supported; |
|
35 | + } |
|
34 | 36 | return parent::isSupported() && $supported; |
35 | 37 | } |
36 | 38 | |
@@ -42,10 +44,11 @@ discard block |
||
42 | 44 | $key = $this->prefix . strtr($key, ':/', '-_'); |
43 | 45 | |
44 | 46 | // Zend's pricey stuff. |
45 | - if (function_exists('zend_shm_cache_fetch')) |
|
46 | - return zend_shm_cache_fetch('SMF::' . $key); |
|
47 | - elseif (function_exists('output_cache_get')) |
|
48 | - return output_cache_get($key, $ttl); |
|
47 | + if (function_exists('zend_shm_cache_fetch')) { |
|
48 | + return zend_shm_cache_fetch('SMF::' . $key); |
|
49 | + } elseif (function_exists('output_cache_get')) { |
|
50 | + return output_cache_get($key, $ttl); |
|
51 | + } |
|
49 | 52 | } |
50 | 53 | |
51 | 54 | /** |
@@ -55,10 +58,11 @@ discard block |
||
55 | 58 | { |
56 | 59 | $key = $this->prefix . strtr($key, ':/', '-_'); |
57 | 60 | |
58 | - if (function_exists('zend_shm_cache_store')) |
|
59 | - return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
60 | - elseif (function_exists('output_cache_put')) |
|
61 | - return output_cache_put($key, $value); |
|
61 | + if (function_exists('zend_shm_cache_store')) { |
|
62 | + return zend_shm_cache_store('SMF::' . $key, $value, $ttl); |
|
63 | + } elseif (function_exists('output_cache_put')) { |
|
64 | + return output_cache_put($key, $value); |
|
65 | + } |
|
62 | 66 | } |
63 | 67 | |
64 | 68 | /** |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('No direct access...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Used for the "custom search index" option |
@@ -54,8 +55,9 @@ discard block |
||
54 | 55 | return; |
55 | 56 | } |
56 | 57 | |
57 | - if (empty($modSettings['search_custom_index_config'])) |
|
58 | - return; |
|
58 | + if (empty($modSettings['search_custom_index_config'])) { |
|
59 | + return; |
|
60 | + } |
|
59 | 61 | |
60 | 62 | $this->indexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
61 | 63 | |
@@ -118,21 +120,23 @@ discard block |
||
118 | 120 | |
119 | 121 | $subwords = text2words($word, $this->min_word_length, true); |
120 | 122 | |
121 | - if (empty($modSettings['search_force_index'])) |
|
122 | - $wordsSearch['words'][] = $word; |
|
123 | + if (empty($modSettings['search_force_index'])) { |
|
124 | + $wordsSearch['words'][] = $word; |
|
125 | + } |
|
123 | 126 | |
124 | 127 | // Excluded phrases don't benefit from being split into subwords. |
125 | - if (count($subwords) > 1 && $isExcluded) |
|
126 | - return; |
|
127 | - else |
|
128 | + if (count($subwords) > 1 && $isExcluded) { |
|
129 | + return; |
|
130 | + } else |
|
128 | 131 | { |
129 | 132 | foreach ($subwords as $subword) |
130 | 133 | { |
131 | 134 | if ($smcFunc['strlen']($subword) >= $this->min_word_length && !in_array($subword, $this->bannedWords)) |
132 | 135 | { |
133 | 136 | $wordsSearch['indexed_words'][] = $subword; |
134 | - if ($isExcluded) |
|
135 | - $wordsExclude[] = $subword; |
|
137 | + if ($isExcluded) { |
|
138 | + $wordsExclude[] = $subword; |
|
139 | + } |
|
136 | 140 | } |
137 | 141 | } |
138 | 142 | } |
@@ -153,8 +157,9 @@ discard block |
||
153 | 157 | $query_where = array(); |
154 | 158 | $query_params = $search_data['params']; |
155 | 159 | |
156 | - if ($query_params['id_search']) |
|
157 | - $query_select['id_search'] = '{int:id_search}'; |
|
160 | + if ($query_params['id_search']) { |
|
161 | + $query_select['id_search'] = '{int:id_search}'; |
|
162 | + } |
|
158 | 163 | |
159 | 164 | $count = 0; |
160 | 165 | foreach ($words['words'] as $regularWord) |
@@ -163,30 +168,37 @@ discard block |
||
163 | 168 | $query_params['complex_body_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($regularWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $regularWord), '\\\'') . '[[:>:]]'; |
164 | 169 | } |
165 | 170 | |
166 | - if ($query_params['user_query']) |
|
167 | - $query_where[] = '{raw:user_query}'; |
|
168 | - if ($query_params['board_query']) |
|
169 | - $query_where[] = 'm.id_board {raw:board_query}'; |
|
171 | + if ($query_params['user_query']) { |
|
172 | + $query_where[] = '{raw:user_query}'; |
|
173 | + } |
|
174 | + if ($query_params['board_query']) { |
|
175 | + $query_where[] = 'm.id_board {raw:board_query}'; |
|
176 | + } |
|
170 | 177 | |
171 | - if ($query_params['topic']) |
|
172 | - $query_where[] = 'm.id_topic = {int:topic}'; |
|
173 | - if ($query_params['min_msg_id']) |
|
174 | - $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
175 | - if ($query_params['max_msg_id']) |
|
176 | - $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
178 | + if ($query_params['topic']) { |
|
179 | + $query_where[] = 'm.id_topic = {int:topic}'; |
|
180 | + } |
|
181 | + if ($query_params['min_msg_id']) { |
|
182 | + $query_where[] = 'm.id_msg >= {int:min_msg_id}'; |
|
183 | + } |
|
184 | + if ($query_params['max_msg_id']) { |
|
185 | + $query_where[] = 'm.id_msg <= {int:max_msg_id}'; |
|
186 | + } |
|
177 | 187 | |
178 | 188 | $count = 0; |
179 | - if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) |
|
180 | - foreach ($query_params['excluded_phrases'] as $phrase) |
|
189 | + if (!empty($query_params['excluded_phrases']) && empty($modSettings['search_force_index'])) { |
|
190 | + foreach ($query_params['excluded_phrases'] as $phrase) |
|
181 | 191 | { |
182 | 192 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_phrase_' . $count . '}'; |
193 | + } |
|
183 | 194 | $query_params['exclude_subject_phrase_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($phrase, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $phrase), '\\\'') . '[[:>:]]'; |
184 | 195 | } |
185 | 196 | $count = 0; |
186 | - if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) |
|
187 | - foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
197 | + if (!empty($query_params['excluded_subject_words']) && empty($modSettings['search_force_index'])) { |
|
198 | + foreach ($query_params['excluded_subject_words'] as $excludedWord) |
|
188 | 199 | { |
189 | 200 | $query_where[] = 'subject NOT ' . (empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? ' LIKE ' : ' RLIKE ') . '{string:exclude_subject_words_' . $count . '}'; |
201 | + } |
|
190 | 202 | $query_params['exclude_subject_words_' . $count++] = empty($modSettings['search_match_words']) || $search_data['no_regexp'] ? '%' . strtr($excludedWord, array('_' => '\\_', '%' => '\\%')) . '%' : '[[:<:]]' . addcslashes(preg_replace(array('/([\[\]$.+*?|{}()])/'), array('[$1]'), $excludedWord), '\\\'') . '[[:>:]]'; |
191 | 203 | } |
192 | 204 | |
@@ -199,8 +211,7 @@ discard block |
||
199 | 211 | { |
200 | 212 | $query_left_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_word = ' . $indexedWord . ' AND lsw' . $numTables . '.id_msg = m.id_msg)'; |
201 | 213 | $query_where[] = '(lsw' . $numTables . '.id_word IS NULL)'; |
202 | - } |
|
203 | - else |
|
214 | + } else |
|
204 | 215 | { |
205 | 216 | $query_inner_join[] = '{db_prefix}log_search_words AS lsw' . $numTables . ' ON (lsw' . $numTables . '.id_msg = ' . ($prev_join === 0 ? 'm' : 'lsw' . $prev_join) . '.id_msg)'; |
206 | 217 | $query_where[] = 'lsw' . $numTables . '.id_word = ' . $indexedWord; |
@@ -236,16 +247,18 @@ discard block |
||
236 | 247 | $customIndexSettings = smf_json_decode($modSettings['search_custom_index_config'], true); |
237 | 248 | |
238 | 249 | $inserts = array(); |
239 | - foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) |
|
240 | - $inserts[] = array($word, $msgOptions['id']); |
|
250 | + foreach (text2words($msgOptions['body'], $customIndexSettings['bytes_per_word'], true) as $word) { |
|
251 | + $inserts[] = array($word, $msgOptions['id']); |
|
252 | + } |
|
241 | 253 | |
242 | - if (!empty($inserts)) |
|
243 | - $smcFunc['db_insert']('ignore', |
|
254 | + if (!empty($inserts)) { |
|
255 | + $smcFunc['db_insert']('ignore', |
|
244 | 256 | '{db_prefix}log_search_words', |
245 | 257 | array('id_word' => 'int', 'id_msg' => 'int'), |
246 | 258 | $inserts, |
247 | 259 | array('id_word', 'id_msg') |
248 | 260 | ); |
261 | + } |
|
249 | 262 | } |
250 | 263 | |
251 | 264 | /** |
@@ -288,8 +301,9 @@ discard block |
||
288 | 301 | if (!empty($inserted_words)) |
289 | 302 | { |
290 | 303 | $inserts = array(); |
291 | - foreach ($inserted_words as $word) |
|
292 | - $inserts[] = array($word, $msgOptions['id']); |
|
304 | + foreach ($inserted_words as $word) { |
|
305 | + $inserts[] = array($word, $msgOptions['id']); |
|
306 | + } |
|
293 | 307 | $smcFunc['db_insert']('insert', |
294 | 308 | '{db_prefix}log_search_words', |
295 | 309 | array('id_word' => 'string', 'id_msg' => 'int'), |
@@ -13,8 +13,9 @@ discard block |
||
13 | 13 | * @version 2.1 Beta 3 |
14 | 14 | */ |
15 | 15 | |
16 | -if (!defined('SMF')) |
|
16 | +if (!defined('SMF')) { |
|
17 | 17 | die('No direct access...'); |
18 | +} |
|
18 | 19 | |
19 | 20 | /** |
20 | 21 | * Show the database queries for debugging |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | global $scripturl, $settings, $context, $db_connection, $boarddir, $smcFunc, $txt, $db_show_debug; |
31 | 32 | |
32 | 33 | // We should have debug mode enabled, as well as something to display! |
33 | - if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) |
|
34 | - fatal_lang_error('no_access', false); |
|
34 | + if (!isset($db_show_debug) || $db_show_debug !== true || !isset($_SESSION['debug'])) { |
|
35 | + fatal_lang_error('no_access', false); |
|
36 | + } |
|
35 | 37 | |
36 | 38 | // Don't allow except for administrators. |
37 | 39 | isAllowedTo('admin_forum'); |
@@ -41,10 +43,11 @@ discard block |
||
41 | 43 | { |
42 | 44 | $_SESSION['view_queries'] = $_SESSION['view_queries'] == 1 ? 0 : 1; |
43 | 45 | |
44 | - if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) |
|
45 | - redirectexit(); |
|
46 | - else |
|
47 | - redirectexit($_SESSION['old_url']); |
|
46 | + if (strpos($_SESSION['old_url'], 'action=viewquery') !== false) { |
|
47 | + redirectexit(); |
|
48 | + } else { |
|
49 | + redirectexit($_SESSION['old_url']); |
|
50 | + } |
|
48 | 51 | } |
49 | 52 | |
50 | 53 | call_integration_hook('integrate_egg_nog'); |
@@ -83,26 +86,28 @@ discard block |
||
83 | 86 | foreach ($query as $line) |
84 | 87 | { |
85 | 88 | preg_match('/^(\t*)/', $line, $temp); |
86 | - if (strlen($temp[0]) < $min_indent || $min_indent == 0) |
|
87 | - $min_indent = strlen($temp[0]); |
|
89 | + if (strlen($temp[0]) < $min_indent || $min_indent == 0) { |
|
90 | + $min_indent = strlen($temp[0]); |
|
91 | + } |
|
92 | + } |
|
93 | + foreach ($query as $l => $dummy) { |
|
94 | + $query[$l] = substr($dummy, $min_indent); |
|
88 | 95 | } |
89 | - foreach ($query as $l => $dummy) |
|
90 | - $query[$l] = substr($dummy, $min_indent); |
|
91 | 96 | $query_data['q'] = implode("\n", $query); |
92 | 97 | |
93 | 98 | // Make the filenames look a bit better. |
94 | - if (isset($query_data['f'])) |
|
95 | - $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
99 | + if (isset($query_data['f'])) { |
|
100 | + $query_data['f'] = preg_replace('~^' . preg_quote($boarddir, '~') . '~', '...', $query_data['f']); |
|
101 | + } |
|
96 | 102 | |
97 | 103 | $is_select_query = substr(trim($query_data['q']), 0, 6) == 'SELECT'; |
98 | - if ($is_select_query) |
|
99 | - $select = $query_data['q']; |
|
100 | - elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
104 | + if ($is_select_query) { |
|
105 | + $select = $query_data['q']; |
|
106 | + } elseif (preg_match('~^INSERT(?: IGNORE)? INTO \w+(?:\s+\([^)]+\))?\s+(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
101 | 107 | { |
102 | 108 | $is_select_query = true; |
103 | 109 | $select = $matches[1]; |
104 | - } |
|
105 | - elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
110 | + } elseif (preg_match('~^CREATE TEMPORARY TABLE .+?(SELECT .+)$~s', trim($query_data['q']), $matches) != 0) |
|
106 | 111 | { |
107 | 112 | $is_select_query = true; |
108 | 113 | $select = $matches[1]; |
@@ -110,10 +115,11 @@ discard block |
||
110 | 115 | // Temporary tables created in earlier queries are not explainable. |
111 | 116 | if ($is_select_query) |
112 | 117 | { |
113 | - foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) |
|
114 | - if (strpos($select, $tmp) !== false) |
|
118 | + foreach (array('log_topics_unread', 'topics_posted_in', 'tmp_log_search_topics', 'tmp_log_search_messages') as $tmp) { |
|
119 | + if (strpos($select, $tmp) !== false) |
|
115 | 120 | { |
116 | 121 | $is_select_query = false; |
122 | + } |
|
117 | 123 | break; |
118 | 124 | } |
119 | 125 | } |
@@ -124,13 +130,15 @@ discard block |
||
124 | 130 | ', nl2br(str_replace("\t", ' ', $smcFunc['htmlspecialchars']($query_data['q']))), ' |
125 | 131 | </a><br>'; |
126 | 132 | |
127 | - if (!empty($query_data['f']) && !empty($query_data['l'])) |
|
128 | - echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
133 | + if (!empty($query_data['f']) && !empty($query_data['l'])) { |
|
134 | + echo sprintf($txt['debug_query_in_line'], $query_data['f'], $query_data['l']); |
|
135 | + } |
|
129 | 136 | |
130 | - if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) |
|
131 | - echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
132 | - else |
|
133 | - echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
137 | + if (isset($query_data['s'], $query_data['t']) && isset($txt['debug_query_which_took_at'])) { |
|
138 | + echo sprintf($txt['debug_query_which_took_at'], round($query_data['t'], 8), round($query_data['s'], 8)); |
|
139 | + } else { |
|
140 | + echo sprintf($txt['debug_query_which_took'], round($query_data['t'], 8)); |
|
141 | + } |
|
134 | 142 | |
135 | 143 | echo ' |
136 | 144 | </div>'; |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Format a topic to be printer friendly. |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | global $board_info, $smcFunc, $modSettings; |
33 | 34 | |
34 | 35 | // Redirect to the boardindex if no valid topic id is provided. |
35 | - if (empty($topic)) |
|
36 | - redirectexit(); |
|
36 | + if (empty($topic)) { |
|
37 | + redirectexit(); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | if (!empty($modSettings['disable_print_topic'])) |
39 | 41 | { |
@@ -59,8 +61,9 @@ discard block |
||
59 | 61 | ) |
60 | 62 | ); |
61 | 63 | // Redirect to the boardindex if no valid topic id is provided. |
62 | - if ($smcFunc['db_num_rows']($request) == 0) |
|
63 | - redirectexit(); |
|
64 | + if ($smcFunc['db_num_rows']($request) == 0) { |
|
65 | + redirectexit(); |
|
66 | + } |
|
64 | 67 | $row = $smcFunc['db_fetch_assoc']($request); |
65 | 68 | $smcFunc['db_free_result']($request); |
66 | 69 | |
@@ -134,20 +137,21 @@ discard block |
||
134 | 137 | foreach ($guestinfo as $i => $guestvoted) |
135 | 138 | { |
136 | 139 | $guestvoted = explode(',', $guestvoted); |
137 | - if ($guestvoted[0] == $row['id_poll']) |
|
138 | - break; |
|
140 | + if ($guestvoted[0] == $row['id_poll']) { |
|
141 | + break; |
|
142 | + } |
|
139 | 143 | } |
140 | 144 | // Has the poll been reset since guest voted? |
141 | 145 | if ($pollinfo['reset_poll'] > $guestvoted[1]) |
142 | 146 | { |
143 | 147 | // Remove the poll info from the cookie to allow guest to vote again |
144 | 148 | unset($guestinfo[$i]); |
145 | - if (!empty($guestinfo)) |
|
146 | - $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
147 | - else |
|
148 | - unset($_COOKIE['guest_poll_vote']); |
|
149 | - } |
|
150 | - else |
|
149 | + if (!empty($guestinfo)) { |
|
150 | + $_COOKIE['guest_poll_vote'] = ';' . implode(';', $guestinfo); |
|
151 | + } else { |
|
152 | + unset($_COOKIE['guest_poll_vote']); |
|
153 | + } |
|
154 | + } else |
|
151 | 155 | { |
152 | 156 | // What did they vote for? |
153 | 157 | unset($guestvoted[0], $guestvoted[1]); |
@@ -233,8 +237,9 @@ discard block |
||
233 | 237 | $context['poster_name'] = $row['poster_name']; |
234 | 238 | $context['post_time'] = timeformat($row['poster_time'], false); |
235 | 239 | $context['parent_boards'] = array(); |
236 | - foreach ($board_info['parent_boards'] as $parent) |
|
237 | - $context['parent_boards'][] = $parent['name']; |
|
240 | + foreach ($board_info['parent_boards'] as $parent) { |
|
241 | + $context['parent_boards'][] = $parent['name']; |
|
242 | + } |
|
238 | 243 | |
239 | 244 | // Split the topics up so we can print them. |
240 | 245 | $request = $smcFunc['db_query']('', ' |
@@ -266,8 +271,9 @@ discard block |
||
266 | 271 | 'id_msg' => $row['id_msg'], |
267 | 272 | ); |
268 | 273 | |
269 | - if (!isset($context['topic_subject'])) |
|
270 | - $context['topic_subject'] = $row['subject']; |
|
274 | + if (!isset($context['topic_subject'])) { |
|
275 | + $context['topic_subject'] = $row['subject']; |
|
276 | + } |
|
271 | 277 | } |
272 | 278 | $smcFunc['db_free_result']($request); |
273 | 279 | |
@@ -275,8 +281,9 @@ discard block |
||
275 | 281 | if (isset($_REQUEST['images']) && !empty($modSettings['attachmentEnable']) && allowedTo('view_attachments')) |
276 | 282 | { |
277 | 283 | $messages = array(); |
278 | - foreach ($context['posts'] as $temp) |
|
279 | - $messages[] = $temp['id_msg']; |
|
284 | + foreach ($context['posts'] as $temp) { |
|
285 | + $messages[] = $temp['id_msg']; |
|
286 | + } |
|
280 | 287 | |
281 | 288 | // build the request |
282 | 289 | $request = $smcFunc['db_query']('', ' |
@@ -295,8 +302,9 @@ discard block |
||
295 | 302 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
296 | 303 | { |
297 | 304 | $temp[$row['id_attach']] = $row; |
298 | - if (!isset($context['printattach'][$row['id_msg']])) |
|
299 | - $context['printattach'][$row['id_msg']] = array(); |
|
305 | + if (!isset($context['printattach'][$row['id_msg']])) { |
|
306 | + $context['printattach'][$row['id_msg']] = array(); |
|
307 | + } |
|
300 | 308 | } |
301 | 309 | $smcFunc['db_free_result']($request); |
302 | 310 | ksort($temp); |
@@ -313,8 +321,7 @@ discard block |
||
313 | 321 | $row['height'] = floor($row['height'] * ($modSettings['max_image_width'] / $row['width'])); |
314 | 322 | $row['width'] = $modSettings['max_image_width']; |
315 | 323 | } |
316 | - } |
|
317 | - elseif (!empty($modSettings['max_image_width'])) |
|
324 | + } elseif (!empty($modSettings['max_image_width'])) |
|
318 | 325 | { |
319 | 326 | if ($row['height'] > $modSettings['max_image_height']) |
320 | 327 | { |
@@ -61,7 +61,7 @@ |
||
61 | 61 | $server = trim($servers[array_rand($servers)]); |
62 | 62 | |
63 | 63 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
64 | + if (strpos($server, '/') !== false) |
|
65 | 65 | $host = $server; |
66 | 66 | else |
67 | 67 | { |
@@ -11,8 +11,9 @@ discard block |
||
11 | 11 | * @version 2.1 Beta 3 |
12 | 12 | */ |
13 | 13 | |
14 | -if (!defined('SMF')) |
|
14 | +if (!defined('SMF')) { |
|
15 | 15 | die('Hacking attempt...'); |
16 | +} |
|
16 | 17 | |
17 | 18 | /** |
18 | 19 | * Our Cache API class |
@@ -34,8 +35,9 @@ discard block |
||
34 | 35 | |
35 | 36 | $supported = class_exists('memcache'); |
36 | 37 | |
37 | - if ($test) |
|
38 | - return $supported; |
|
38 | + if ($test) { |
|
39 | + return $supported; |
|
40 | + } |
|
39 | 41 | return parent::isSupported() && $supported && !empty($cache_memcached); |
40 | 42 | } |
41 | 43 | |
@@ -61,9 +63,9 @@ discard block |
||
61 | 63 | $server = trim($servers[array_rand($servers)]); |
62 | 64 | |
63 | 65 | // Normal host names do not contain slashes, while e.g. unix sockets do. Assume alternative transport pipe with port 0. |
64 | - if (strpos($server,'/') !== false) |
|
65 | - $host = $server; |
|
66 | - else |
|
66 | + if (strpos($server,'/') !== false) { |
|
67 | + $host = $server; |
|
68 | + } else |
|
67 | 69 | { |
68 | 70 | $server = explode(':', $server); |
69 | 71 | $host = $server[0]; |
@@ -71,10 +73,11 @@ discard block |
||
71 | 73 | } |
72 | 74 | |
73 | 75 | // Don't wait too long: yes, we want the server, but we might be able to run the query faster! |
74 | - if (empty($db_persist)) |
|
75 | - $connected = $this->memcache->connect($host, $port); |
|
76 | - else |
|
77 | - $connected = $this->memcache->pconnect($host, $port); |
|
76 | + if (empty($db_persist)) { |
|
77 | + $connected = $this->memcache->connect($host, $port); |
|
78 | + } else { |
|
79 | + $connected = $this->memcache->pconnect($host, $port); |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | |
80 | 83 | return $connected; |
@@ -90,8 +93,9 @@ discard block |
||
90 | 93 | $value = $this->memcache->get($key); |
91 | 94 | |
92 | 95 | // $value should return either data or false (from failure, key not found or empty array). |
93 | - if ($value === false) |
|
94 | - return null; |
|
96 | + if ($value === false) { |
|
97 | + return null; |
|
98 | + } |
|
95 | 99 | return $value; |
96 | 100 | } |
97 | 101 | |
@@ -132,8 +136,9 @@ discard block |
||
132 | 136 | $config_vars[] = $txt['cache_memcache_settings']; |
133 | 137 | $config_vars[] = array('cache_memcached', $txt['cache_memcache_servers'], 'file', 'text', 0, 'cache_memcached', 'postinput' => '<br /><div class="smalltext"><em>' . $txt['cache_memcache_servers_subtext'] . '</em></div>'); |
134 | 138 | |
135 | - if (!isset($context['settings_post_javascript'])) |
|
136 | - $context['settings_post_javascript'] = ''; |
|
139 | + if (!isset($context['settings_post_javascript'])) { |
|
140 | + $context['settings_post_javascript'] = ''; |
|
141 | + } |
|
137 | 142 | |
138 | 143 | $context['settings_post_javascript'] .= ' |
139 | 144 | $("#cache_accelerator").change(function (e) { |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Locks a topic... either by way of a moderator or the topic starter. |
@@ -32,8 +33,9 @@ discard block |
||
32 | 33 | global $topic, $user_info, $sourcedir, $board, $smcFunc; |
33 | 34 | |
34 | 35 | // Just quit if there's no topic to lock. |
35 | - if (empty($topic)) |
|
36 | - fatal_lang_error('not_a_topic', false); |
|
36 | + if (empty($topic)) { |
|
37 | + fatal_lang_error('not_a_topic', false); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | checkSession('get'); |
39 | 41 | |
@@ -55,23 +57,28 @@ discard block |
||
55 | 57 | |
56 | 58 | // Can you lock topics here, mister? |
57 | 59 | $user_lock = !allowedTo('lock_any'); |
58 | - if ($user_lock && $starter == $user_info['id']) |
|
59 | - isAllowedTo('lock_own'); |
|
60 | - else |
|
61 | - isAllowedTo('lock_any'); |
|
60 | + if ($user_lock && $starter == $user_info['id']) { |
|
61 | + isAllowedTo('lock_own'); |
|
62 | + } else { |
|
63 | + isAllowedTo('lock_any'); |
|
64 | + } |
|
62 | 65 | |
63 | 66 | // Locking with high privileges. |
64 | - if ($locked == '0' && !$user_lock) |
|
65 | - $locked = '1'; |
|
67 | + if ($locked == '0' && !$user_lock) { |
|
68 | + $locked = '1'; |
|
69 | + } |
|
66 | 70 | // Locking with low privileges. |
67 | - elseif ($locked == '0') |
|
68 | - $locked = '2'; |
|
71 | + elseif ($locked == '0') { |
|
72 | + $locked = '2'; |
|
73 | + } |
|
69 | 74 | // Unlocking - make sure you don't unlock what you can't. |
70 | - elseif ($locked == '2' || ($locked == '1' && !$user_lock)) |
|
71 | - $locked = '0'; |
|
75 | + elseif ($locked == '2' || ($locked == '1' && !$user_lock)) { |
|
76 | + $locked = '0'; |
|
77 | + } |
|
72 | 78 | // You cannot unlock this! |
73 | - else |
|
74 | - fatal_lang_error('locked_by_admin', 'user'); |
|
79 | + else { |
|
80 | + fatal_lang_error('locked_by_admin', 'user'); |
|
81 | + } |
|
75 | 82 | |
76 | 83 | // Actually lock the topic in the database with the new value. |
77 | 84 | $smcFunc['db_query']('', ' |
@@ -85,8 +92,9 @@ discard block |
||
85 | 92 | ); |
86 | 93 | |
87 | 94 | // If they are allowed a "moderator" permission, log it in the moderator log. |
88 | - if (!$user_lock) |
|
89 | - logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
95 | + if (!$user_lock) { |
|
96 | + logAction($locked ? 'lock' : 'unlock', array('topic' => $topic, 'board' => $board)); |
|
97 | + } |
|
90 | 98 | // Notify people that this topic has been locked? |
91 | 99 | sendNotifications($topic, empty($locked) ? 'unlock' : 'lock'); |
92 | 100 | |
@@ -112,8 +120,9 @@ discard block |
||
112 | 120 | isAllowedTo('make_sticky'); |
113 | 121 | |
114 | 122 | // You can't sticky a board or something! |
115 | - if (empty($topic)) |
|
116 | - fatal_lang_error('not_a_topic', false); |
|
123 | + if (empty($topic)) { |
|
124 | + fatal_lang_error('not_a_topic', false); |
|
125 | + } |
|
117 | 126 | |
118 | 127 | checkSession('get'); |
119 | 128 | |
@@ -147,8 +156,9 @@ discard block |
||
147 | 156 | // Log this sticky action - always a moderator thing. |
148 | 157 | logAction(empty($is_sticky) ? 'sticky' : 'unsticky', array('topic' => $topic, 'board' => $board)); |
149 | 158 | // Notify people that this topic has been stickied? |
150 | - if (empty($is_sticky)) |
|
151 | - sendNotifications($topic, 'sticky'); |
|
159 | + if (empty($is_sticky)) { |
|
160 | + sendNotifications($topic, 'sticky'); |
|
161 | + } |
|
152 | 162 | |
153 | 163 | // Take them back to the now stickied topic. |
154 | 164 | redirectexit('topic=' . $topic . '.' . $_REQUEST['start'] . ';moderate'); |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 3 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * 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']('boardindex_fetch_boards', ' |
@@ -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']; |
@@ -160,14 +165,12 @@ discard block |
||
160 | 165 | { |
161 | 166 | $this_category[$row_board['id_board']]['board_class'] = 'redirect'; |
162 | 167 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['redirect_board']; |
163 | - } |
|
164 | - elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
168 | + } elseif ($this_category[$row_board['id_board']]['new'] || $context['user']['is_guest']) |
|
165 | 169 | { |
166 | 170 | // If we're showing to guests, we want to give them the idea that something interesting is going on! |
167 | 171 | $this_category[$row_board['id_board']]['board_class'] = 'on'; |
168 | 172 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['new_posts']; |
169 | - } |
|
170 | - else |
|
173 | + } else |
|
171 | 174 | { |
172 | 175 | $this_category[$row_board['id_board']]['board_tooltip'] = $txt['old_posts']; |
173 | 176 | } |
@@ -218,14 +221,16 @@ discard block |
||
218 | 221 | // Child of a child... just add it on... |
219 | 222 | elseif (!empty($boardIndexOptions['countChildPosts'])) |
220 | 223 | { |
221 | - if (!isset($parent_map)) |
|
222 | - $parent_map = array(); |
|
224 | + if (!isset($parent_map)) { |
|
225 | + $parent_map = array(); |
|
226 | + } |
|
223 | 227 | |
224 | - if (!isset($parent_map[$row_board['id_parent']])) |
|
225 | - foreach ($this_category as $id => $board) |
|
228 | + if (!isset($parent_map[$row_board['id_parent']])) { |
|
229 | + foreach ($this_category as $id => $board) |
|
226 | 230 | { |
227 | 231 | if (!isset($board['children'][$row_board['id_parent']])) |
228 | 232 | continue; |
233 | + } |
|
229 | 234 | |
230 | 235 | $parent_map[$row_board['id_parent']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
231 | 236 | $parent_map[$row_board['id_board']] = array(&$this_category[$id], &$this_category[$id]['children'][$row_board['id_parent']]); |
@@ -246,8 +251,9 @@ discard block |
||
246 | 251 | continue; |
247 | 252 | } |
248 | 253 | // Found a child of a child - skip. |
249 | - else |
|
250 | - continue; |
|
254 | + else { |
|
255 | + continue; |
|
256 | + } |
|
251 | 257 | |
252 | 258 | // Prepare the subject, and make sure it's not too long. |
253 | 259 | censorText($row_board['subject']); |
@@ -268,12 +274,13 @@ discard block |
||
268 | 274 | 'topic' => $row_board['id_topic'] |
269 | 275 | ); |
270 | 276 | |
271 | - if (!empty($settings['avatars_on_boardIndex'])) |
|
272 | - $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
277 | + if (!empty($settings['avatars_on_boardIndex'])) { |
|
278 | + $this_last_post['member']['avatar'] = set_avatar_data(array( |
|
273 | 279 | 'avatar' => $row_board['avatar'], |
274 | 280 | 'email' => $row_board['email_address'], |
275 | 281 | 'filename' => !empty($row['member_filename']) ? $row_board['member_filename'] : '', |
276 | 282 | )); |
283 | + } |
|
277 | 284 | |
278 | 285 | // Provide the href and link. |
279 | 286 | if ($row_board['subject'] != '') |
@@ -285,8 +292,7 @@ discard block |
||
285 | 292 | link, href, subject, start (where they should go for the first unread post.), |
286 | 293 | and member. (which has id, name, link, href, username in it.) */ |
287 | 294 | $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['time']); |
288 | - } |
|
289 | - else |
|
295 | + } else |
|
290 | 296 | { |
291 | 297 | $this_last_post['href'] = ''; |
292 | 298 | $this_last_post['link'] = $txt['not_applicable']; |
@@ -294,8 +300,9 @@ discard block |
||
294 | 300 | } |
295 | 301 | |
296 | 302 | // Set the last post in the parent board. |
297 | - 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']))) |
|
298 | - $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
303 | + 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']))) { |
|
304 | + $this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post; |
|
305 | + } |
|
299 | 306 | // Just in the child...? |
300 | 307 | if ($isChild) |
301 | 308 | { |
@@ -305,15 +312,17 @@ discard block |
||
305 | 312 | $this_category[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != ''; |
306 | 313 | } |
307 | 314 | // No last post for this board? It's not new then, is it..? |
308 | - elseif ($row_board['poster_name'] == '') |
|
309 | - $this_category[$row_board['id_board']]['new'] = false; |
|
315 | + elseif ($row_board['poster_name'] == '') { |
|
316 | + $this_category[$row_board['id_board']]['new'] = false; |
|
317 | + } |
|
310 | 318 | |
311 | 319 | // Determine a global most recent topic. |
312 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) |
|
313 | - $latest_post = array( |
|
320 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($row_board['poster_time']) && $row_board['poster_time'] > $latest_post['timestamp'] && !$ignoreThisBoard) { |
|
321 | + $latest_post = array( |
|
314 | 322 | 'timestamp' => $row_board['poster_time'], |
315 | 323 | 'ref' => &$this_category[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'], |
316 | 324 | ); |
325 | + } |
|
317 | 326 | } |
318 | 327 | $smcFunc['db_free_result']($result_boards); |
319 | 328 | |
@@ -330,8 +339,9 @@ discard block |
||
330 | 339 | if (!empty($moderators[$board['id']])) |
331 | 340 | { |
332 | 341 | $categories[$k]['boards'][$j]['moderators'] = $moderators[$board['id']]; |
333 | - foreach ($moderators[$board['id']] as $moderator) |
|
334 | - $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
342 | + foreach ($moderators[$board['id']] as $moderator) { |
|
343 | + $categories[$k]['boards'][$j]['link_moderators'][] = $moderator['link']; |
|
344 | + } |
|
335 | 345 | } |
336 | 346 | if (!empty($groups[$board['id']])) |
337 | 347 | { |
@@ -344,16 +354,16 @@ discard block |
||
344 | 354 | } |
345 | 355 | } |
346 | 356 | } |
347 | - } |
|
348 | - else |
|
357 | + } else |
|
349 | 358 | { |
350 | 359 | foreach ($this_category as $k => $board) |
351 | 360 | { |
352 | 361 | if (!empty($moderators[$board['id']])) |
353 | 362 | { |
354 | 363 | $this_category[$k]['moderators'] = $moderators[$board['id']]; |
355 | - foreach ($moderators[$board['id']] as $moderator) |
|
356 | - $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
364 | + foreach ($moderators[$board['id']] as $moderator) { |
|
365 | + $this_category[$k]['link_moderators'][] = $moderator['link']; |
|
366 | + } |
|
357 | 367 | } |
358 | 368 | if (!empty($groups[$board['id']])) |
359 | 369 | { |
@@ -367,20 +377,23 @@ discard block |
||
367 | 377 | } |
368 | 378 | } |
369 | 379 | |
370 | - if ($boardIndexOptions['include_categories']) |
|
371 | - sortCategories($categories); |
|
372 | - else |
|
373 | - sortBoards($this_category); |
|
380 | + if ($boardIndexOptions['include_categories']) { |
|
381 | + sortCategories($categories); |
|
382 | + } else { |
|
383 | + sortBoards($this_category); |
|
384 | + } |
|
374 | 385 | |
375 | 386 | // By now we should know the most recent post...if we wanna know it that is. |
376 | - if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) |
|
377 | - $context['latest_post'] = $latest_post['ref']; |
|
387 | + if (!empty($boardIndexOptions['set_latest_post']) && !empty($latest_post['ref'])) { |
|
388 | + $context['latest_post'] = $latest_post['ref']; |
|
389 | + } |
|
378 | 390 | |
379 | 391 | // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. |
380 | - if ($boardIndexOptions['include_categories']) |
|
381 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
382 | - else |
|
383 | - call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
392 | + if ($boardIndexOptions['include_categories']) { |
|
393 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$categories)); |
|
394 | + } else { |
|
395 | + call_integration_hook('integrate_getboardtree', array($boardIndexOptions, &$this_category)); |
|
396 | + } |
|
384 | 397 | |
385 | 398 | return $boardIndexOptions['include_categories'] ? $categories : $this_category; |
386 | 399 | } |
@@ -19,10 +19,10 @@ |
||
19 | 19 | */ |
20 | 20 | class GroupAct_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | - /** |
|
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | - * @return bool Always returns true |
|
25 | - */ |
|
22 | + /** |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | + * @return bool Always returns true |
|
25 | + */ |
|
26 | 26 | public function execute() |
27 | 27 | { |
28 | 28 | global $sourcedir, $smcFunc, $language, $modSettings; |
@@ -132,8 +132,9 @@ discard block |
||
132 | 132 | 'GROUPNAME' => $user['group_name'], |
133 | 133 | ); |
134 | 134 | |
135 | - if (!empty($custom_reason)) |
|
136 | - $replacements['REASON'] = $custom_reason; |
|
135 | + if (!empty($custom_reason)) { |
|
136 | + $replacements['REASON'] = $custom_reason; |
|
137 | + } |
|
137 | 138 | |
138 | 139 | $emaildata = loadEmailTemplate($email_template_name, $replacements, $user['language']); |
139 | 140 | |
@@ -142,8 +143,8 @@ discard block |
||
142 | 143 | } |
143 | 144 | |
144 | 145 | // Insert the alerts if any |
145 | - if (!empty($alert_rows)) |
|
146 | - $smcFunc['db_insert']('', |
|
146 | + if (!empty($alert_rows)) { |
|
147 | + $smcFunc['db_insert']('', |
|
147 | 148 | '{db_prefix}user_alerts', |
148 | 149 | array( |
149 | 150 | 'alert_time' => 'int', 'id_member' => 'int', 'content_type' => 'string', |
@@ -152,6 +153,7 @@ discard block |
||
152 | 153 | $alert_rows, |
153 | 154 | array() |
154 | 155 | ); |
156 | + } |
|
155 | 157 | } |
156 | 158 | |
157 | 159 | return true; |