@@ -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 | * The main designating function for modifying profiles. Loads up info, determins what to do, etc. |
@@ -29,18 +30,21 @@ discard block |
||
| 29 | 30 | global $modSettings, $memberContext, $profile_vars, $post_errors, $smcFunc; |
| 30 | 31 | |
| 31 | 32 | // Don't reload this as we may have processed error strings. |
| 32 | - if (empty($post_errors)) |
|
| 33 | - loadLanguage('Profile+Drafts'); |
|
| 33 | + if (empty($post_errors)) { |
|
| 34 | + loadLanguage('Profile+Drafts'); |
|
| 35 | + } |
|
| 34 | 36 | loadTemplate('Profile'); |
| 35 | 37 | |
| 36 | 38 | require_once($sourcedir . '/Subs-Menu.php'); |
| 37 | 39 | |
| 38 | 40 | // Did we get the user by name... |
| 39 | - if (isset($_REQUEST['user'])) |
|
| 40 | - $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 41 | + if (isset($_REQUEST['user'])) { |
|
| 42 | + $memberResult = loadMemberData($_REQUEST['user'], true, 'profile'); |
|
| 43 | + } |
|
| 41 | 44 | // ... or by id_member? |
| 42 | - elseif (!empty($_REQUEST['u'])) |
|
| 43 | - $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 45 | + elseif (!empty($_REQUEST['u'])) { |
|
| 46 | + $memberResult = loadMemberData((int) $_REQUEST['u'], false, 'profile'); |
|
| 47 | + } |
|
| 44 | 48 | // If it was just ?action=profile, edit your own profile, but only if you're not a guest. |
| 45 | 49 | else |
| 46 | 50 | { |
@@ -50,8 +54,9 @@ discard block |
||
| 50 | 54 | } |
| 51 | 55 | |
| 52 | 56 | // Check if loadMemberData() has returned a valid result. |
| 53 | - if (!$memberResult) |
|
| 54 | - fatal_lang_error('not_a_user', false, 404); |
|
| 57 | + if (!$memberResult) { |
|
| 58 | + fatal_lang_error('not_a_user', false, 404); |
|
| 59 | + } |
|
| 55 | 60 | |
| 56 | 61 | // If all went well, we have a valid member ID! |
| 57 | 62 | list ($memID) = $memberResult; |
@@ -67,8 +72,9 @@ discard block |
||
| 67 | 72 | |
| 68 | 73 | // Group management isn't actually a permission. But we need it to be for this, so we need a phantom permission. |
| 69 | 74 | // And we care about what the current user can do, not what the user whose profile it is. |
| 70 | - if ($user_info['mod_cache']['gq'] != '0=1') |
|
| 71 | - $user_info['permissions'][] = 'approve_group_requests'; |
|
| 75 | + if ($user_info['mod_cache']['gq'] != '0=1') { |
|
| 76 | + $user_info['permissions'][] = 'approve_group_requests'; |
|
| 77 | + } |
|
| 72 | 78 | |
| 73 | 79 | // If paid subscriptions are enabled, make sure we actually have at least one subscription available... |
| 74 | 80 | $context['subs_available'] = false; |
@@ -436,21 +442,25 @@ discard block |
||
| 436 | 442 | foreach ($section['areas'] as $area_id => $area) |
| 437 | 443 | { |
| 438 | 444 | // If it said no permissions that meant it wasn't valid! |
| 439 | - if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) |
|
| 440 | - $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
| 445 | + if (empty($area['permission'][$context['user']['is_owner'] ? 'own' : 'any'])) { |
|
| 446 | + $profile_areas[$section_id]['areas'][$area_id]['enabled'] = false; |
|
| 447 | + } |
|
| 441 | 448 | // Otherwise pick the right set. |
| 442 | - else |
|
| 443 | - $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
| 449 | + else { |
|
| 450 | + $profile_areas[$section_id]['areas'][$area_id]['permission'] = $area['permission'][$context['user']['is_owner'] ? 'own' : 'any']; |
|
| 451 | + } |
|
| 444 | 452 | |
| 445 | 453 | // Password required in most cases |
| 446 | - if (!empty($area['password'])) |
|
| 447 | - $context['password_areas'][] = $area_id; |
|
| 454 | + if (!empty($area['password'])) { |
|
| 455 | + $context['password_areas'][] = $area_id; |
|
| 456 | + } |
|
| 448 | 457 | } |
| 449 | 458 | } |
| 450 | 459 | |
| 451 | 460 | // Is there an updated message to show? |
| 452 | - if (isset($_GET['updated'])) |
|
| 453 | - $context['profile_updated'] = $txt['profile_updated_own']; |
|
| 461 | + if (isset($_GET['updated'])) { |
|
| 462 | + $context['profile_updated'] = $txt['profile_updated_own']; |
|
| 463 | + } |
|
| 454 | 464 | |
| 455 | 465 | // Set a few options for the menu. |
| 456 | 466 | $menuOptions = array( |
@@ -465,8 +475,9 @@ discard block |
||
| 465 | 475 | $profile_include_data = createMenu($profile_areas, $menuOptions); |
| 466 | 476 | |
| 467 | 477 | // No menu means no access. |
| 468 | - if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) |
|
| 469 | - fatal_lang_error('no_access', false); |
|
| 478 | + if (!$profile_include_data && (!$user_info['is_guest'] || validateSession())) { |
|
| 479 | + fatal_lang_error('no_access', false); |
|
| 480 | + } |
|
| 470 | 481 | |
| 471 | 482 | // Make a note of the Unique ID for this menu. |
| 472 | 483 | $context['profile_menu_id'] = $context['max_menu_id']; |
@@ -492,8 +503,9 @@ discard block |
||
| 492 | 503 | if ($current_area == $area_id) |
| 493 | 504 | { |
| 494 | 505 | // This can't happen - but is a security check. |
| 495 | - if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) |
|
| 496 | - fatal_lang_error('no_access', false); |
|
| 506 | + if ((isset($section['enabled']) && $section['enabled'] == false) || (isset($area['enabled']) && $area['enabled'] == false)) { |
|
| 507 | + fatal_lang_error('no_access', false); |
|
| 508 | + } |
|
| 497 | 509 | |
| 498 | 510 | // Are we saving data in a valid area? |
| 499 | 511 | if (isset($area['sc']) && (isset($_REQUEST['save']) || $context['do_preview'])) |
@@ -512,12 +524,14 @@ discard block |
||
| 512 | 524 | } |
| 513 | 525 | |
| 514 | 526 | // Does this require session validating? |
| 515 | - if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) |
|
| 516 | - $security_checks['validate'] = true; |
|
| 527 | + if (!empty($area['validate']) || (isset($_REQUEST['save']) && !$context['user']['is_owner'])) { |
|
| 528 | + $security_checks['validate'] = true; |
|
| 529 | + } |
|
| 517 | 530 | |
| 518 | 531 | // Permissions for good measure. |
| 519 | - if (!empty($profile_include_data['permission'])) |
|
| 520 | - $security_checks['permission'] = $profile_include_data['permission']; |
|
| 532 | + if (!empty($profile_include_data['permission'])) { |
|
| 533 | + $security_checks['permission'] = $profile_include_data['permission']; |
|
| 534 | + } |
|
| 521 | 535 | |
| 522 | 536 | // Either way got something. |
| 523 | 537 | $found_area = true; |
@@ -526,21 +540,26 @@ discard block |
||
| 526 | 540 | } |
| 527 | 541 | |
| 528 | 542 | // Oh dear, some serious security lapse is going on here... we'll put a stop to that! |
| 529 | - if (!$found_area) |
|
| 530 | - fatal_lang_error('no_access', false); |
|
| 543 | + if (!$found_area) { |
|
| 544 | + fatal_lang_error('no_access', false); |
|
| 545 | + } |
|
| 531 | 546 | |
| 532 | 547 | // Release this now. |
| 533 | 548 | unset($profile_areas); |
| 534 | 549 | |
| 535 | 550 | // Now the context is setup have we got any security checks to carry out additional to that above? |
| 536 | - if (isset($security_checks['session'])) |
|
| 537 | - checkSession($security_checks['session']); |
|
| 538 | - if (isset($security_checks['validate'])) |
|
| 539 | - validateSession(); |
|
| 540 | - if (isset($security_checks['validateToken'])) |
|
| 541 | - validateToken($token_name, $token_type); |
|
| 542 | - if (isset($security_checks['permission'])) |
|
| 543 | - isAllowedTo($security_checks['permission']); |
|
| 551 | + if (isset($security_checks['session'])) { |
|
| 552 | + checkSession($security_checks['session']); |
|
| 553 | + } |
|
| 554 | + if (isset($security_checks['validate'])) { |
|
| 555 | + validateSession(); |
|
| 556 | + } |
|
| 557 | + if (isset($security_checks['validateToken'])) { |
|
| 558 | + validateToken($token_name, $token_type); |
|
| 559 | + } |
|
| 560 | + if (isset($security_checks['permission'])) { |
|
| 561 | + isAllowedTo($security_checks['permission']); |
|
| 562 | + } |
|
| 544 | 563 | |
| 545 | 564 | // Create a token if needed. |
| 546 | 565 | if (isset($security_checks['needsToken']) || isset($security_checks['validateToken'])) |
@@ -550,8 +569,9 @@ discard block |
||
| 550 | 569 | } |
| 551 | 570 | |
| 552 | 571 | // File to include? |
| 553 | - if (isset($profile_include_data['file'])) |
|
| 554 | - require_once($sourcedir . '/' . $profile_include_data['file']); |
|
| 572 | + if (isset($profile_include_data['file'])) { |
|
| 573 | + require_once($sourcedir . '/' . $profile_include_data['file']); |
|
| 574 | + } |
|
| 555 | 575 | |
| 556 | 576 | // Build the link tree. |
| 557 | 577 | $context['linktree'][] = array( |
@@ -559,17 +579,19 @@ discard block |
||
| 559 | 579 | 'name' => sprintf($txt['profile_of_username'], $context['member']['name']), |
| 560 | 580 | ); |
| 561 | 581 | |
| 562 | - if (!empty($profile_include_data['label'])) |
|
| 563 | - $context['linktree'][] = array( |
|
| 582 | + if (!empty($profile_include_data['label'])) { |
|
| 583 | + $context['linktree'][] = array( |
|
| 564 | 584 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'], |
| 565 | 585 | 'name' => $profile_include_data['label'], |
| 566 | 586 | ); |
| 587 | + } |
|
| 567 | 588 | |
| 568 | - if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) |
|
| 569 | - $context['linktree'][] = array( |
|
| 589 | + if (!empty($profile_include_data['current_subsection']) && $profile_include_data['subsections'][$profile_include_data['current_subsection']][0] != $profile_include_data['label']) { |
|
| 590 | + $context['linktree'][] = array( |
|
| 570 | 591 | 'url' => $scripturl . '?action=profile' . ($memID != $user_info['id'] ? ';u=' . $memID : '') . ';area=' . $profile_include_data['current_area'] . ';sa=' . $profile_include_data['current_subsection'], |
| 571 | 592 | 'name' => $profile_include_data['subsections'][$profile_include_data['current_subsection']][0], |
| 572 | 593 | ); |
| 594 | + } |
|
| 573 | 595 | |
| 574 | 596 | // Set the template for this area and add the profile layer. |
| 575 | 597 | $context['sub_template'] = $profile_include_data['function']; |
@@ -595,12 +617,14 @@ discard block |
||
| 595 | 617 | if ($check_password) |
| 596 | 618 | { |
| 597 | 619 | // Check to ensure we're forcing SSL for authentication |
| 598 | - if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) |
|
| 599 | - fatal_lang_error('login_ssl_required'); |
|
| 620 | + if (!empty($modSettings['force_ssl']) && empty($maintenance) && !httpsOn()) { |
|
| 621 | + fatal_lang_error('login_ssl_required'); |
|
| 622 | + } |
|
| 600 | 623 | |
| 601 | 624 | // You didn't even enter a password! |
| 602 | - if (trim($_POST['oldpasswrd']) == '') |
|
| 603 | - $post_errors[] = 'no_password'; |
|
| 625 | + if (trim($_POST['oldpasswrd']) == '') { |
|
| 626 | + $post_errors[] = 'no_password'; |
|
| 627 | + } |
|
| 604 | 628 | |
| 605 | 629 | // Since the password got modified due to all the $_POST cleaning, lets undo it so we can get the correct password |
| 606 | 630 | $_POST['oldpasswrd'] = un_htmlspecialchars($_POST['oldpasswrd']); |
@@ -609,42 +633,43 @@ discard block |
||
| 609 | 633 | $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($cur_profile['member_name'], $_POST['oldpasswrd'], false)), true); |
| 610 | 634 | |
| 611 | 635 | // Bad password!!! |
| 612 | - if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) |
|
| 613 | - $post_errors[] = 'bad_password'; |
|
| 636 | + if (!$good_password && !hash_verify_password($user_profile[$memID]['member_name'], un_htmlspecialchars(stripslashes($_POST['oldpasswrd'])), $user_info['passwd'])) { |
|
| 637 | + $post_errors[] = 'bad_password'; |
|
| 638 | + } |
|
| 614 | 639 | |
| 615 | 640 | // Warn other elements not to jump the gun and do custom changes! |
| 616 | - if (in_array('bad_password', $post_errors)) |
|
| 617 | - $context['password_auth_failed'] = true; |
|
| 641 | + if (in_array('bad_password', $post_errors)) { |
|
| 642 | + $context['password_auth_failed'] = true; |
|
| 643 | + } |
|
| 618 | 644 | } |
| 619 | 645 | |
| 620 | 646 | // Change the IP address in the database. |
| 621 | - if ($context['user']['is_owner']) |
|
| 622 | - $profile_vars['member_ip'] = $user_info['ip']; |
|
| 647 | + if ($context['user']['is_owner']) { |
|
| 648 | + $profile_vars['member_ip'] = $user_info['ip']; |
|
| 649 | + } |
|
| 623 | 650 | |
| 624 | 651 | // Now call the sub-action function... |
| 625 | 652 | if ($current_area == 'activateaccount') |
| 626 | 653 | { |
| 627 | - if (empty($post_errors)) |
|
| 628 | - activateAccount($memID); |
|
| 629 | - } |
|
| 630 | - elseif ($current_area == 'deleteaccount') |
|
| 654 | + if (empty($post_errors)) { |
|
| 655 | + activateAccount($memID); |
|
| 656 | + } |
|
| 657 | + } elseif ($current_area == 'deleteaccount') |
|
| 631 | 658 | { |
| 632 | 659 | if (empty($post_errors)) |
| 633 | 660 | { |
| 634 | 661 | deleteAccount2($memID); |
| 635 | 662 | redirectexit(); |
| 636 | 663 | } |
| 637 | - } |
|
| 638 | - elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
| 664 | + } elseif ($current_area == 'groupmembership' && empty($post_errors)) |
|
| 639 | 665 | { |
| 640 | 666 | $msg = groupMembership2($profile_vars, $post_errors, $memID); |
| 641 | 667 | |
| 642 | 668 | // Whatever we've done, we have nothing else to do here... |
| 643 | 669 | redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=groupmembership' . (!empty($msg) ? ';msg=' . $msg : '')); |
| 644 | - } |
|
| 645 | - elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) |
|
| 646 | - saveProfileFields(); |
|
| 647 | - else |
|
| 670 | + } elseif (in_array($current_area, array('account', 'forumprofile', 'theme'))) { |
|
| 671 | + saveProfileFields(); |
|
| 672 | + } else |
|
| 648 | 673 | { |
| 649 | 674 | $force_redirect = true; |
| 650 | 675 | // Ensure we include this. |
@@ -660,34 +685,36 @@ discard block |
||
| 660 | 685 | // Load the language file so we can give a nice explanation of the errors. |
| 661 | 686 | loadLanguage('Errors'); |
| 662 | 687 | $context['post_errors'] = $post_errors; |
| 663 | - } |
|
| 664 | - elseif (!empty($profile_vars)) |
|
| 688 | + } elseif (!empty($profile_vars)) |
|
| 665 | 689 | { |
| 666 | 690 | // If we've changed the password, notify any integration that may be listening in. |
| 667 | - if (isset($profile_vars['passwd'])) |
|
| 668 | - call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
| 691 | + if (isset($profile_vars['passwd'])) { |
|
| 692 | + call_integration_hook('integrate_reset_pass', array($cur_profile['member_name'], $cur_profile['member_name'], $_POST['passwrd2'])); |
|
| 693 | + } |
|
| 669 | 694 | |
| 670 | 695 | updateMemberData($memID, $profile_vars); |
| 671 | 696 | |
| 672 | 697 | // What if this is the newest member? |
| 673 | - if ($modSettings['latestMember'] == $memID) |
|
| 674 | - updateStats('member'); |
|
| 675 | - elseif (isset($profile_vars['real_name'])) |
|
| 676 | - updateSettings(array('memberlist_updated' => time())); |
|
| 698 | + if ($modSettings['latestMember'] == $memID) { |
|
| 699 | + updateStats('member'); |
|
| 700 | + } elseif (isset($profile_vars['real_name'])) { |
|
| 701 | + updateSettings(array('memberlist_updated' => time())); |
|
| 702 | + } |
|
| 677 | 703 | |
| 678 | 704 | // If the member changed his/her birthdate, update calendar statistics. |
| 679 | - if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) |
|
| 680 | - updateSettings(array( |
|
| 705 | + if (isset($profile_vars['birthdate']) || isset($profile_vars['real_name'])) { |
|
| 706 | + updateSettings(array( |
|
| 681 | 707 | 'calendar_updated' => time(), |
| 682 | 708 | )); |
| 709 | + } |
|
| 683 | 710 | |
| 684 | 711 | // Anything worth logging? |
| 685 | 712 | if (!empty($context['log_changes']) && !empty($modSettings['modlog_enabled'])) |
| 686 | 713 | { |
| 687 | 714 | $log_changes = array(); |
| 688 | 715 | require_once($sourcedir . '/Logging.php'); |
| 689 | - foreach ($context['log_changes'] as $k => $v) |
|
| 690 | - $log_changes[] = array( |
|
| 716 | + foreach ($context['log_changes'] as $k => $v) { |
|
| 717 | + $log_changes[] = array( |
|
| 691 | 718 | 'action' => $k, |
| 692 | 719 | 'log_type' => 'user', |
| 693 | 720 | 'extra' => array_merge($v, array( |
@@ -695,14 +722,16 @@ discard block |
||
| 695 | 722 | 'member_affected' => $memID, |
| 696 | 723 | )), |
| 697 | 724 | ); |
| 725 | + } |
|
| 698 | 726 | |
| 699 | 727 | logActions($log_changes); |
| 700 | 728 | } |
| 701 | 729 | |
| 702 | 730 | // Have we got any post save functions to execute? |
| 703 | - if (!empty($context['profile_execute_on_save'])) |
|
| 704 | - foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
| 731 | + if (!empty($context['profile_execute_on_save'])) { |
|
| 732 | + foreach ($context['profile_execute_on_save'] as $saveFunc) |
|
| 705 | 733 | $saveFunc(); |
| 734 | + } |
|
| 706 | 735 | |
| 707 | 736 | // Let them know it worked! |
| 708 | 737 | $context['profile_updated'] = $context['user']['is_owner'] ? $txt['profile_updated_own'] : sprintf($txt['profile_updated_else'], $cur_profile['member_name']); |
@@ -716,27 +745,31 @@ discard block |
||
| 716 | 745 | if (!empty($post_errors)) |
| 717 | 746 | { |
| 718 | 747 | // Set all the errors so the template knows what went wrong. |
| 719 | - foreach ($post_errors as $error_type) |
|
| 720 | - $context['modify_error'][$error_type] = true; |
|
| 748 | + foreach ($post_errors as $error_type) { |
|
| 749 | + $context['modify_error'][$error_type] = true; |
|
| 750 | + } |
|
| 721 | 751 | } |
| 722 | 752 | // If it's you then we should redirect upon save. |
| 723 | - elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) |
|
| 724 | - redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
| 725 | - elseif (!empty($force_redirect)) |
|
| 726 | - redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
| 753 | + elseif (!empty($profile_vars) && $context['user']['is_owner'] && !$context['do_preview']) { |
|
| 754 | + redirectexit('action=profile;area=' . $current_area . (!empty($current_sa) ? ';sa=' . $current_sa : '') . ';updated'); |
|
| 755 | + } elseif (!empty($force_redirect)) { |
|
| 756 | + redirectexit('action=profile' . ($context['user']['is_owner'] ? '' : ';u=' . $memID) . ';area=' . $current_area); |
|
| 757 | + } |
|
| 727 | 758 | |
| 728 | 759 | |
| 729 | 760 | // Get the right callable. |
| 730 | 761 | $call = call_helper($profile_include_data['function'], true); |
| 731 | 762 | |
| 732 | 763 | // Is it valid? |
| 733 | - if (!empty($call)) |
|
| 734 | - call_user_func($call, $memID); |
|
| 764 | + if (!empty($call)) { |
|
| 765 | + call_user_func($call, $memID); |
|
| 766 | + } |
|
| 735 | 767 | |
| 736 | 768 | // Set the page title if it's not already set... |
| 737 | - if (!isset($context['page_title'])) |
|
| 738 | - $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
| 739 | -} |
|
| 769 | + if (!isset($context['page_title'])) { |
|
| 770 | + $context['page_title'] = $txt['profile'] . (isset($txt[$current_area]) ? ' - ' . $txt[$current_area] : ''); |
|
| 771 | + } |
|
| 772 | + } |
|
| 740 | 773 | |
| 741 | 774 | /** |
| 742 | 775 | * Set up the requirements for the profile popup - the area that is shown as the popup menu for the current user. |
@@ -859,16 +892,18 @@ discard block |
||
| 859 | 892 | if (!allowedTo('admin_forum') && $area != 'register') |
| 860 | 893 | { |
| 861 | 894 | // If it's the owner they can see two types of private fields, regardless. |
| 862 | - if ($memID == $user_info['id']) |
|
| 863 | - $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 864 | - else |
|
| 865 | - $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 895 | + if ($memID == $user_info['id']) { |
|
| 896 | + $where .= $area == 'summary' ? ' AND private < 3' : ' AND (private = 0 OR private = 2)'; |
|
| 897 | + } else { |
|
| 898 | + $where .= $area == 'summary' ? ' AND private < 2' : ' AND private = 0'; |
|
| 899 | + } |
|
| 866 | 900 | } |
| 867 | 901 | |
| 868 | - if ($area == 'register') |
|
| 869 | - $where .= ' AND show_reg != 0'; |
|
| 870 | - elseif ($area != 'summary') |
|
| 871 | - $where .= ' AND show_profile = {string:area}'; |
|
| 902 | + if ($area == 'register') { |
|
| 903 | + $where .= ' AND show_reg != 0'; |
|
| 904 | + } elseif ($area != 'summary') { |
|
| 905 | + $where .= ' AND show_profile = {string:area}'; |
|
| 906 | + } |
|
| 872 | 907 | |
| 873 | 908 | // Load all the relevant fields - and data. |
| 874 | 909 | $request = $smcFunc['db_query']('', ' |
@@ -893,8 +928,9 @@ discard block |
||
| 893 | 928 | $fieldOptions = explode(',', $row['field_options']); |
| 894 | 929 | foreach ($fieldOptions as $k => $v) |
| 895 | 930 | { |
| 896 | - if (empty($currentKey)) |
|
| 897 | - $currentKey = $v === $value ? $k : 0; |
|
| 931 | + if (empty($currentKey)) { |
|
| 932 | + $currentKey = $v === $value ? $k : 0; |
|
| 933 | + } |
|
| 898 | 934 | } |
| 899 | 935 | } |
| 900 | 936 | |
@@ -906,13 +942,15 @@ discard block |
||
| 906 | 942 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
| 907 | 943 | { |
| 908 | 944 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
| 909 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
| 910 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 945 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
| 946 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 947 | + } |
|
| 911 | 948 | } |
| 912 | 949 | |
| 913 | 950 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
| 914 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') |
|
| 915 | - continue; |
|
| 951 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') { |
|
| 952 | + continue; |
|
| 953 | + } |
|
| 916 | 954 | |
| 917 | 955 | // HTML for the input form. |
| 918 | 956 | $output_html = $value; |
@@ -921,8 +959,7 @@ discard block |
||
| 921 | 959 | $true = (!$exists && $row['default_value']) || $value; |
| 922 | 960 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>'; |
| 923 | 961 | $output_html = $true ? $txt['yes'] : $txt['no']; |
| 924 | - } |
|
| 925 | - elseif ($row['field_type'] == 'select') |
|
| 962 | + } elseif ($row['field_type'] == 'select') |
|
| 926 | 963 | { |
| 927 | 964 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
| 928 | 965 | $options = explode(',', $row['field_options']); |
@@ -930,13 +967,13 @@ discard block |
||
| 930 | 967 | { |
| 931 | 968 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 932 | 969 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
| 933 | - if ($true) |
|
| 934 | - $output_html = $v; |
|
| 970 | + if ($true) { |
|
| 971 | + $output_html = $v; |
|
| 972 | + } |
|
| 935 | 973 | } |
| 936 | 974 | |
| 937 | 975 | $input_html .= '</select>'; |
| 938 | - } |
|
| 939 | - elseif ($row['field_type'] == 'radio') |
|
| 976 | + } elseif ($row['field_type'] == 'radio') |
|
| 940 | 977 | { |
| 941 | 978 | $input_html = '<fieldset>'; |
| 942 | 979 | $options = explode(',', $row['field_options']); |
@@ -944,37 +981,38 @@ discard block |
||
| 944 | 981 | { |
| 945 | 982 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 946 | 983 | $input_html .= '<label for="customfield_' . $row['col_name'] . '_' . $k . '"><input type="radio" name="customfield[' . $row['col_name'] . ']" id="customfield_' . $row['col_name'] . '_' . $k . '" value="' . $k . '"' . ($true ? ' checked' : '') . '>' . $v . '</label><br>'; |
| 947 | - if ($true) |
|
| 948 | - $output_html = $v; |
|
| 984 | + if ($true) { |
|
| 985 | + $output_html = $v; |
|
| 986 | + } |
|
| 949 | 987 | } |
| 950 | 988 | $input_html .= '</fieldset>'; |
| 951 | - } |
|
| 952 | - elseif ($row['field_type'] == 'text') |
|
| 989 | + } elseif ($row['field_type'] == 'text') |
|
| 953 | 990 | { |
| 954 | 991 | $input_html = '<input type="text" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($row['field_length'] != 0 ? ' maxlength="' . $row['field_length'] . '"' : '') . ' size="' . ($row['field_length'] == 0 || $row['field_length'] >= 50 ? 50 : ($row['field_length'] > 30 ? 30 : ($row['field_length'] > 10 ? 20 : 10))) . '" value="' . un_htmlspecialchars($value) . '"' . ($row['show_reg'] == 2 ? ' required' : '') . '>'; |
| 955 | - } |
|
| 956 | - else |
|
| 992 | + } else |
|
| 957 | 993 | { |
| 958 | 994 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
| 959 | 995 | $input_html = '<textarea name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . (!empty($rows) ? ' rows="' . $rows . '"' : '') . (!empty($cols) ? ' cols="' . $cols . '"' : '') . ($row['show_reg'] == 2 ? ' required' : '') . '>' . un_htmlspecialchars($value) . '</textarea>'; |
| 960 | 996 | } |
| 961 | 997 | |
| 962 | 998 | // Parse BBCode |
| 963 | - if ($row['bbc']) |
|
| 964 | - $output_html = parse_bbc($output_html); |
|
| 965 | - elseif ($row['field_type'] == 'textarea') |
|
| 966 | - // Allow for newlines at least |
|
| 999 | + if ($row['bbc']) { |
|
| 1000 | + $output_html = parse_bbc($output_html); |
|
| 1001 | + } elseif ($row['field_type'] == 'textarea') { |
|
| 1002 | + // Allow for newlines at least |
|
| 967 | 1003 | $output_html = strtr($output_html, array("\n" => '<br>')); |
| 1004 | + } |
|
| 968 | 1005 | |
| 969 | 1006 | // Enclosing the user input within some other text? |
| 970 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
| 971 | - $output_html = strtr($row['enclose'], array( |
|
| 1007 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
| 1008 | + $output_html = strtr($row['enclose'], array( |
|
| 972 | 1009 | '{SCRIPTURL}' => $scripturl, |
| 973 | 1010 | '{IMAGES_URL}' => $settings['images_url'], |
| 974 | 1011 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 975 | 1012 | '{INPUT}' => un_htmlspecialchars($output_html), |
| 976 | 1013 | '{KEY}' => $currentKey |
| 977 | 1014 | )); |
| 1015 | + } |
|
| 978 | 1016 | |
| 979 | 1017 | $context['custom_fields'][] = array( |
| 980 | 1018 | 'name' => $row['field_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 | * Shows a listing of registered members. |
@@ -110,8 +111,9 @@ discard block |
||
| 110 | 111 | |
| 111 | 112 | $context['custom_profile_fields'] = getCustFieldsMList(); |
| 112 | 113 | |
| 113 | - if (!empty($context['custom_profile_fields']['columns'])) |
|
| 114 | - $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 114 | + if (!empty($context['custom_profile_fields']['columns'])) { |
|
| 115 | + $context['columns'] += $context['custom_profile_fields']['columns']; |
|
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | $context['colspan'] = 0; |
| 117 | 119 | $context['disabled_fields'] = isset($modSettings['disabled_profile_fields']) ? array_flip(explode(',', $modSettings['disabled_profile_fields'])) : array(); |
@@ -147,12 +149,12 @@ discard block |
||
| 147 | 149 | call_integration_hook('integrate_memberlist_buttons'); |
| 148 | 150 | |
| 149 | 151 | // Jump to the sub action. |
| 150 | - if (isset($subActions[$context['listing_by']])) |
|
| 151 | - call_helper($subActions[$context['listing_by']][1]); |
|
| 152 | - |
|
| 153 | - else |
|
| 154 | - call_helper($subActions['all'][1]); |
|
| 155 | -} |
|
| 152 | + if (isset($subActions[$context['listing_by']])) { |
|
| 153 | + call_helper($subActions[$context['listing_by']][1]); |
|
| 154 | + } else { |
|
| 155 | + call_helper($subActions['all'][1]); |
|
| 156 | + } |
|
| 157 | + } |
|
| 156 | 158 | |
| 157 | 159 | /** |
| 158 | 160 | * List all members, page by page, with sorting. |
@@ -177,8 +179,9 @@ discard block |
||
| 177 | 179 | if ($use_cache) |
| 178 | 180 | { |
| 179 | 181 | // Maybe there's something cached already. |
| 180 | - if (!empty($modSettings['memberlist_cache'])) |
|
| 181 | - $memberlist_cache = $smcFunc['json_decode']($modSettings['memberlist_cache'], true); |
|
| 182 | + if (!empty($modSettings['memberlist_cache'])) { |
|
| 183 | + $memberlist_cache = $smcFunc['json_decode']($modSettings['memberlist_cache'], true); |
|
| 184 | + } |
|
| 182 | 185 | |
| 183 | 186 | // The chunk size for the cached index. |
| 184 | 187 | $cache_step_size = 500; |
@@ -234,13 +237,15 @@ discard block |
||
| 234 | 237 | } |
| 235 | 238 | |
| 236 | 239 | // Set defaults for sort (real_name) and start. (0) |
| 237 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 238 | - $_REQUEST['sort'] = 'real_name'; |
|
| 240 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 241 | + $_REQUEST['sort'] = 'real_name'; |
|
| 242 | + } |
|
| 239 | 243 | |
| 240 | 244 | if (!is_numeric($_REQUEST['start'])) |
| 241 | 245 | { |
| 242 | - if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) |
|
| 243 | - fatal_error('Hacker?', false); |
|
| 246 | + if (preg_match('~^[^\'\\\\/]~' . ($context['utf8'] ? 'u' : ''), $smcFunc['strtolower']($_REQUEST['start']), $match) === 0) { |
|
| 247 | + fatal_error('Hacker?', false); |
|
| 248 | + } |
|
| 244 | 249 | |
| 245 | 250 | $_REQUEST['start'] = $match[0]; |
| 246 | 251 | |
@@ -259,16 +264,18 @@ discard block |
||
| 259 | 264 | } |
| 260 | 265 | |
| 261 | 266 | $context['letter_links'] = ''; |
| 262 | - for ($i = 97; $i < 123; $i++) |
|
| 263 | - $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 267 | + for ($i = 97; $i < 123; $i++) { |
|
| 268 | + $context['letter_links'] .= '<a href="' . $scripturl . '?action=mlist;sa=all;start=' . chr($i) . '#letter' . chr($i) . '">' . strtoupper(chr($i)) . '</a> '; |
|
| 269 | + } |
|
| 264 | 270 | |
| 265 | 271 | // Sort out the column information. |
| 266 | 272 | foreach ($context['columns'] as $col => $column_details) |
| 267 | 273 | { |
| 268 | 274 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sort=' . $col . ';start=0'; |
| 269 | 275 | |
| 270 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 271 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 276 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 277 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 278 | + } |
|
| 272 | 279 | |
| 273 | 280 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 274 | 281 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -317,8 +324,9 @@ discard block |
||
| 317 | 324 | elseif ($use_cache && $_REQUEST['sort'] === 'real_name') |
| 318 | 325 | { |
| 319 | 326 | $first_offset = floor(($memberlist_cache['num_members'] - $modSettings['defaultMaxMembers'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 320 | - if ($first_offset < 0) |
|
| 321 | - $first_offset = 0; |
|
| 327 | + if ($first_offset < 0) { |
|
| 328 | + $first_offset = 0; |
|
| 329 | + } |
|
| 322 | 330 | $second_offset = ceil(($memberlist_cache['num_members'] - $_REQUEST['start']) / $cache_step_size) * $cache_step_size; |
| 323 | 331 | |
| 324 | 332 | $where = 'mem.real_name BETWEEN {string:real_name_low} AND {string:real_name_high}'; |
@@ -328,8 +336,9 @@ discard block |
||
| 328 | 336 | } |
| 329 | 337 | |
| 330 | 338 | $custom_fields_qry = ''; |
| 331 | - if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) |
|
| 332 | - $custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']]; |
|
| 339 | + if (!empty($context['custom_profile_fields']['join'][$_REQUEST['sort']])) { |
|
| 340 | + $custom_fields_qry = $context['custom_profile_fields']['join'][$_REQUEST['sort']]; |
|
| 341 | + } |
|
| 333 | 342 | |
| 334 | 343 | // Select the members from the database. |
| 335 | 344 | $request = $smcFunc['db_query']('', ' |
@@ -399,12 +408,13 @@ discard block |
||
| 399 | 408 | ) |
| 400 | 409 | ); |
| 401 | 410 | $context['custom_search_fields'] = array(); |
| 402 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 403 | - $context['custom_search_fields'][$row['col_name']] = array( |
|
| 411 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 412 | + $context['custom_search_fields'][$row['col_name']] = array( |
|
| 404 | 413 | 'colname' => $row['col_name'], |
| 405 | 414 | 'name' => $row['field_name'], |
| 406 | 415 | 'desc' => $row['field_desc'], |
| 407 | 416 | ); |
| 417 | + } |
|
| 408 | 418 | $smcFunc['db_free_result']($request); |
| 409 | 419 | |
| 410 | 420 | // They're searching.. |
@@ -417,23 +427,27 @@ discard block |
||
| 417 | 427 | $context['old_search_value'] = urlencode($_REQUEST['search']); |
| 418 | 428 | |
| 419 | 429 | // No fields? Use default... |
| 420 | - if (empty($_POST['fields'])) |
|
| 421 | - $_POST['fields'] = array('name'); |
|
| 430 | + if (empty($_POST['fields'])) { |
|
| 431 | + $_POST['fields'] = array('name'); |
|
| 432 | + } |
|
| 422 | 433 | |
| 423 | 434 | // Set defaults for how the results are sorted |
| 424 | - if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) |
|
| 425 | - $_REQUEST['sort'] = 'real_name'; |
|
| 435 | + if (!isset($_REQUEST['sort']) || !isset($context['columns'][$_REQUEST['sort']])) { |
|
| 436 | + $_REQUEST['sort'] = 'real_name'; |
|
| 437 | + } |
|
| 426 | 438 | |
| 427 | 439 | // Build the column link / sort information. |
| 428 | 440 | foreach ($context['columns'] as $col => $column_details) |
| 429 | 441 | { |
| 430 | 442 | $context['columns'][$col]['href'] = $scripturl . '?action=mlist;sa=search;start=0;sort=' . $col; |
| 431 | 443 | |
| 432 | - if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) |
|
| 433 | - $context['columns'][$col]['href'] .= ';desc'; |
|
| 444 | + if ((!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) || ($col != $_REQUEST['sort'] && !empty($column_details['default_sort_rev']))) { |
|
| 445 | + $context['columns'][$col]['href'] .= ';desc'; |
|
| 446 | + } |
|
| 434 | 447 | |
| 435 | - if (isset($_POST['search']) && isset($_POST['fields'])) |
|
| 436 | - $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 448 | + if (isset($_POST['search']) && isset($_POST['fields'])) { |
|
| 449 | + $context['columns'][$col]['href'] .= ';search=' . $_POST['search'] . ';fields=' . implode(',', $_POST['fields']); |
|
| 450 | + } |
|
| 437 | 451 | |
| 438 | 452 | $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '" rel="nofollow">' . $context['columns'][$col]['label'] . '</a>'; |
| 439 | 453 | $context['columns'][$col]['selected'] = $_REQUEST['sort'] == $col; |
@@ -456,8 +470,7 @@ discard block |
||
| 456 | 470 | { |
| 457 | 471 | $fields = allowedTo('moderate_forum') ? array('member_name', 'real_name') : array('real_name'); |
| 458 | 472 | $search_fields[] = 'name'; |
| 459 | - } |
|
| 460 | - else |
|
| 473 | + } else |
|
| 461 | 474 | { |
| 462 | 475 | $fields = array(); |
| 463 | 476 | $search_fields = array(); |
@@ -482,9 +495,10 @@ discard block |
||
| 482 | 495 | $search_fields[] = 'email'; |
| 483 | 496 | } |
| 484 | 497 | |
| 485 | - if ($smcFunc['db_case_sensitive']) |
|
| 486 | - foreach ($fields as $key => $field) |
|
| 498 | + if ($smcFunc['db_case_sensitive']) { |
|
| 499 | + foreach ($fields as $key => $field) |
|
| 487 | 500 | $fields[$key] = 'LOWER(' . $field . ')'; |
| 501 | + } |
|
| 488 | 502 | |
| 489 | 503 | $customJoin = array(); |
| 490 | 504 | $customCount = 10; |
@@ -503,8 +517,9 @@ discard block |
||
| 503 | 517 | } |
| 504 | 518 | |
| 505 | 519 | // No search fields? That means you're trying to hack things |
| 506 | - if (empty($search_fields)) |
|
| 507 | - fatal_lang_error('invalid_search_string', false); |
|
| 520 | + if (empty($search_fields)) { |
|
| 521 | + fatal_lang_error('invalid_search_string', false); |
|
| 522 | + } |
|
| 508 | 523 | |
| 509 | 524 | $query = $_POST['search'] == '' ? '= {string:blank_string}' : ($smcFunc['db_case_sensitive'] ? 'LIKE LOWER({string:search})' : 'LIKE {string:search}'); |
| 510 | 525 | |
@@ -542,8 +557,7 @@ discard block |
||
| 542 | 557 | ); |
| 543 | 558 | printMemberListRows($request); |
| 544 | 559 | $smcFunc['db_free_result']($request); |
| 545 | - } |
|
| 546 | - else |
|
| 560 | + } else |
|
| 547 | 561 | { |
| 548 | 562 | // These are all the possible fields. |
| 549 | 563 | $context['search_fields'] = array( |
@@ -558,14 +572,14 @@ discard block |
||
| 558 | 572 | { |
| 559 | 573 | unset($context['search_fields']['email']); |
| 560 | 574 | $context['search_defaults'] = array('name'); |
| 561 | - } |
|
| 562 | - else |
|
| 575 | + } else |
|
| 563 | 576 | { |
| 564 | 577 | $context['search_defaults'] = array('name', 'email'); |
| 565 | 578 | } |
| 566 | 579 | |
| 567 | - foreach ($context['custom_search_fields'] as $field) |
|
| 568 | - $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 580 | + foreach ($context['custom_search_fields'] as $field) { |
|
| 581 | + $context['search_fields']['cust_' . $field['colname']] = sprintf($txt['mlist_search_by'], $field['name']); |
|
| 582 | + } |
|
| 569 | 583 | |
| 570 | 584 | $context['sub_template'] = 'search'; |
| 571 | 585 | $context['old_search'] = isset($_GET['search']) ? $_GET['search'] : (isset($_POST['search']) ? $smcFunc['htmlspecialchars']($_POST['search']) : ''); |
@@ -607,12 +621,14 @@ discard block |
||
| 607 | 621 | $smcFunc['db_free_result']($result); |
| 608 | 622 | |
| 609 | 623 | // Avoid division by zero... |
| 610 | - if ($most_posts == 0) |
|
| 611 | - $most_posts = 1; |
|
| 624 | + if ($most_posts == 0) { |
|
| 625 | + $most_posts = 1; |
|
| 626 | + } |
|
| 612 | 627 | |
| 613 | 628 | $members = array(); |
| 614 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
| 615 | - $members[] = $row['id_member']; |
|
| 629 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
| 630 | + $members[] = $row['id_member']; |
|
| 631 | + } |
|
| 616 | 632 | |
| 617 | 633 | // Load all the members for display. |
| 618 | 634 | loadMemberData($members); |
@@ -620,8 +636,9 @@ discard block |
||
| 620 | 636 | $context['members'] = array(); |
| 621 | 637 | foreach ($members as $member) |
| 622 | 638 | { |
| 623 | - if (!loadMemberContext($member)) |
|
| 624 | - continue; |
|
| 639 | + if (!loadMemberContext($member)) { |
|
| 640 | + continue; |
|
| 641 | + } |
|
| 625 | 642 | |
| 626 | 643 | $context['members'][$member] = $memberContext[$member]; |
| 627 | 644 | $context['members'][$member]['post_percent'] = round(($context['members'][$member]['real_posts'] * 100) / $most_posts); |
@@ -639,8 +656,9 @@ discard block |
||
| 639 | 656 | $fieldOptions = explode(',', $column['options']); |
| 640 | 657 | foreach ($fieldOptions as $k => $v) |
| 641 | 658 | { |
| 642 | - if (empty($currentKey)) |
|
| 643 | - $currentKey = $v === $value ? $k : 0; |
|
| 659 | + if (empty($currentKey)) { |
|
| 660 | + $currentKey = $v === $value ? $k : 0; |
|
| 661 | + } |
|
| 644 | 662 | } |
| 645 | 663 | } |
| 646 | 664 | |
@@ -651,21 +669,22 @@ discard block |
||
| 651 | 669 | continue; |
| 652 | 670 | } |
| 653 | 671 | |
| 654 | - if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) |
|
| 655 | - $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 656 | - |
|
| 657 | - elseif ($column['type'] == 'check') |
|
| 658 | - $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 672 | + if ($column['bbc'] && !empty($context['members'][$member]['options'][$key])) { |
|
| 673 | + $context['members'][$member]['options'][$key] = strip_tags(parse_bbc($context['members'][$member]['options'][$key])); |
|
| 674 | + } elseif ($column['type'] == 'check') { |
|
| 675 | + $context['members'][$member]['options'][$key] = $context['members'][$member]['options'][$key] == 0 ? $txt['no'] : $txt['yes']; |
|
| 676 | + } |
|
| 659 | 677 | |
| 660 | 678 | // Enclosing the user input within some other text? |
| 661 | - if (!empty($column['enclose'])) |
|
| 662 | - $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 679 | + if (!empty($column['enclose'])) { |
|
| 680 | + $context['members'][$member]['options'][$key] = strtr($column['enclose'], array( |
|
| 663 | 681 | '{SCRIPTURL}' => $scripturl, |
| 664 | 682 | '{IMAGES_URL}' => $settings['images_url'], |
| 665 | 683 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 666 | 684 | '{INPUT}' => $context['members'][$member]['options'][$key], |
| 667 | 685 | '{KEY}' => $currentKey |
| 668 | 686 | )); |
| 687 | + } |
|
| 669 | 688 | } |
| 670 | 689 | } |
| 671 | 690 | } |
@@ -707,17 +726,17 @@ discard block |
||
| 707 | 726 | ); |
| 708 | 727 | |
| 709 | 728 | // Get the right sort method depending on the cust field type. |
| 710 | - if ($row['field_type'] != 'check') |
|
| 711 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 729 | + if ($row['field_type'] != 'check') { |
|
| 730 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 712 | 731 | 'down' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 ASC, COALESCE(t' . $row['col_name'] . '.value, \'\') DESC', |
| 713 | 732 | 'up' => 'LENGTH(t' . $row['col_name'] . '.value) > 0 DESC, COALESCE(t' . $row['col_name'] . '.value, \'\') ASC' |
| 714 | 733 | ); |
| 715 | - |
|
| 716 | - else |
|
| 717 | - $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 734 | + } else { |
|
| 735 | + $cpf['columns'][$row['col_name']]['sort'] = array( |
|
| 718 | 736 | 'down' => 't' . $row['col_name'] . '.value DESC', |
| 719 | 737 | 'up' => 't' . $row['col_name'] . '.value ASC' |
| 720 | 738 | ); |
| 739 | + } |
|
| 721 | 740 | |
| 722 | 741 | $cpf['join'][$row['col_name']] = 'LEFT JOIN {db_prefix}themes AS t' . $row['col_name'] . ' ON (t' . $row['col_name'] . '.variable = {literal:' . $row['col_name'] . '} AND t' . $row['col_name'] . '.id_theme = 1 AND t' . $row['col_name'] . '.id_member = mem.id_member)'; |
| 723 | 742 | } |