@@ -886,16 +886,16 @@ |
||
| 886 | 886 | $context['custom_fields_required'] = false; |
| 887 | 887 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
| 888 | 888 | { |
| 889 | - $value = $user_profile[$memID]['options'][$row['col_name']]; |
|
| 890 | - $currentKey = 0; |
|
| 891 | - if (!empty($row['field_options'])) { |
|
| 892 | - $fieldOptions = explode(',', $row['field_options']); |
|
| 893 | - foreach ($fieldOptions as $k => $v) { |
|
| 894 | - if (empty($currentKey)) { |
|
| 895 | - $currentKey = $v === $value ? $k : 0; |
|
| 896 | - } |
|
| 897 | - } |
|
| 898 | - } |
|
| 889 | + $value = $user_profile[$memID]['options'][$row['col_name']]; |
|
| 890 | + $currentKey = 0; |
|
| 891 | + if (!empty($row['field_options'])) { |
|
| 892 | + $fieldOptions = explode(',', $row['field_options']); |
|
| 893 | + foreach ($fieldOptions as $k => $v) { |
|
| 894 | + if (empty($currentKey)) { |
|
| 895 | + $currentKey = $v === $value ? $k : 0; |
|
| 896 | + } |
|
| 897 | + } |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | 900 | // Shortcut. |
| 901 | 901 | $exists = $memID && isset($user_profile[$memID], $user_profile[$memID]['options'][$row['col_name']]); |
@@ -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']('', ' |
@@ -905,13 +940,15 @@ discard block |
||
| 905 | 940 | if (isset($_POST['customfield']) && isset($_POST['customfield'][$row['col_name']])) |
| 906 | 941 | { |
| 907 | 942 | $value = $smcFunc['htmlspecialchars']($_POST['customfield'][$row['col_name']]); |
| 908 | - if (in_array($row['field_type'], array('select', 'radio'))) |
|
| 909 | - $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 943 | + if (in_array($row['field_type'], array('select', 'radio'))) { |
|
| 944 | + $value = ($options = explode(',', $row['field_options'])) && isset($options[$value]) ? $options[$value] : ''; |
|
| 945 | + } |
|
| 910 | 946 | } |
| 911 | 947 | |
| 912 | 948 | // Don't show the "disabled" option for the "gender" field if we are on the "summary" area. |
| 913 | - if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') |
|
| 914 | - continue; |
|
| 949 | + if ($area == 'summary' && $row['col_name'] == 'cust_gender' && $value == 'None') { |
|
| 950 | + continue; |
|
| 951 | + } |
|
| 915 | 952 | |
| 916 | 953 | // HTML for the input form. |
| 917 | 954 | $output_html = $value; |
@@ -920,8 +957,7 @@ discard block |
||
| 920 | 957 | $true = (!$exists && $row['default_value']) || $value; |
| 921 | 958 | $input_html = '<input type="checkbox" name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"' . ($true ? ' checked' : '') . '>'; |
| 922 | 959 | $output_html = $true ? $txt['yes'] : $txt['no']; |
| 923 | - } |
|
| 924 | - elseif ($row['field_type'] == 'select') |
|
| 960 | + } elseif ($row['field_type'] == 'select') |
|
| 925 | 961 | { |
| 926 | 962 | $input_html = '<select name="customfield[' . $row['col_name'] . ']" id="customfield[' . $row['col_name'] . ']"><option value="-1"></option>'; |
| 927 | 963 | $options = explode(',', $row['field_options']); |
@@ -929,13 +965,13 @@ discard block |
||
| 929 | 965 | { |
| 930 | 966 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 931 | 967 | $input_html .= '<option value="' . $k . '"' . ($true ? ' selected' : '') . '>' . $v . '</option>'; |
| 932 | - if ($true) |
|
| 933 | - $output_html = $v; |
|
| 968 | + if ($true) { |
|
| 969 | + $output_html = $v; |
|
| 970 | + } |
|
| 934 | 971 | } |
| 935 | 972 | |
| 936 | 973 | $input_html .= '</select>'; |
| 937 | - } |
|
| 938 | - elseif ($row['field_type'] == 'radio') |
|
| 974 | + } elseif ($row['field_type'] == 'radio') |
|
| 939 | 975 | { |
| 940 | 976 | $input_html = '<fieldset>'; |
| 941 | 977 | $options = explode(',', $row['field_options']); |
@@ -943,37 +979,38 @@ discard block |
||
| 943 | 979 | { |
| 944 | 980 | $true = (!$exists && $row['default_value'] == $v) || $value == $v; |
| 945 | 981 | $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>'; |
| 946 | - if ($true) |
|
| 947 | - $output_html = $v; |
|
| 982 | + if ($true) { |
|
| 983 | + $output_html = $v; |
|
| 984 | + } |
|
| 948 | 985 | } |
| 949 | 986 | $input_html .= '</fieldset>'; |
| 950 | - } |
|
| 951 | - elseif ($row['field_type'] == 'text') |
|
| 987 | + } elseif ($row['field_type'] == 'text') |
|
| 952 | 988 | { |
| 953 | 989 | $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' : '') . '>'; |
| 954 | - } |
|
| 955 | - else |
|
| 990 | + } else |
|
| 956 | 991 | { |
| 957 | 992 | @list ($rows, $cols) = @explode(',', $row['default_value']); |
| 958 | 993 | $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>'; |
| 959 | 994 | } |
| 960 | 995 | |
| 961 | 996 | // Parse BBCode |
| 962 | - if ($row['bbc']) |
|
| 963 | - $output_html = parse_bbc($output_html); |
|
| 964 | - elseif ($row['field_type'] == 'textarea') |
|
| 965 | - // Allow for newlines at least |
|
| 997 | + if ($row['bbc']) { |
|
| 998 | + $output_html = parse_bbc($output_html); |
|
| 999 | + } elseif ($row['field_type'] == 'textarea') { |
|
| 1000 | + // Allow for newlines at least |
|
| 966 | 1001 | $output_html = strtr($output_html, array("\n" => '<br>')); |
| 1002 | + } |
|
| 967 | 1003 | |
| 968 | 1004 | // Enclosing the user input within some other text? |
| 969 | - if (!empty($row['enclose']) && !empty($output_html)) |
|
| 970 | - $output_html = strtr($row['enclose'], array( |
|
| 1005 | + if (!empty($row['enclose']) && !empty($output_html)) { |
|
| 1006 | + $output_html = strtr($row['enclose'], array( |
|
| 971 | 1007 | '{SCRIPTURL}' => $scripturl, |
| 972 | 1008 | '{IMAGES_URL}' => $settings['images_url'], |
| 973 | 1009 | '{DEFAULT_IMAGES_URL}' => $settings['default_images_url'], |
| 974 | 1010 | '{INPUT}' => un_htmlspecialchars($output_html), |
| 975 | 1011 | '{KEY}' => $currentKey |
| 976 | 1012 | )); |
| 1013 | + } |
|
| 977 | 1014 | |
| 978 | 1015 | $context['custom_fields'][] = array( |
| 979 | 1016 | 'name' => $row['field_name'], |