<commit_before><?php
/**
 * @author         <NAME> <<EMAIL>>
 * @copyright      (c) 2012-2018, <NAME>. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Module / User / Form
 */

namespace PH7;

use PH7\Framework\Registry\Registry;
use PH7\Framework\Session\Session;
use PH7\Framework\Url\Header;

class PrivacyForm
{
    public static function display()
    {
        $oUserModel = new UserCoreModel;
        $iProfileId = (int)(new Session)->get('member_id');

        if (isset($_POST['submit_privacy_account'])) {
            if (\PFBC\Form::isValid($_POST['submit_privacy_account'])) {
                new PrivacyFormProcess($iProfileId, $oUserModel);
            }

            Header::redirect();
        }

        $oPrivacy = $oUserModel->getPrivacySetting($iProfileId);

        $oForm = new \PFBC\Form('form_privacy_account');
        $oForm->configure(['action' => '']);
        $oForm->addElement(new \PFBC\Element\Hidden('submit_privacy_account', 'form_privacy_account'));
        $oForm->addElement(new \PFBC\Element\Token('privacy_account'));
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Profile:') . '</u></h3>'));
        $oForm->addElement(new \PFBC\Element\Radio(t('Who can view your profile?'), 'privacy_profile', ['all' => t('Everyone (including people who are not %0% members).', Registry::getInstance()->site_name), 'only_members' => t('Only %0% members who are logged in.', Registry::getInstance()->site_name), 'only_me' => t('Only me.')], ['value' => $oPrivacy->privacyProfile, 'required' => 1]));
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Web search engine:') . '</u></h3>'));
        $oForm->addElement(new \PFBC\Element\Radio(t('Do you want to be included in search results?'), 'search_profile', ['yes' => t("Yes, include my profile in search results (%site_name%'s search, Google, Bing, Yahoo, etc.)."), 'no' => t('No, do not include my profile in search results.')], ['value' => $oPrivacy->searchProfile, 'required' => 1]));
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Show profile visitors:') . '</u></h3>'));
        $oForm->addElement(new \PFBC\Element\Radio(t('Would you like to display members that have viewed your profile?'), 'user_save_views', ['yes' => t('Yes, display members who viewed my profile (Selecting this option will allow other members to see that you visited their profile).'), 'no' => t('No, don\'t display members who viewed my profile. (Selecting this option will prevent you from seeing who visited your profile).')], ['value' => $oPrivacy->userSaveViews, 'required' => 1]));
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Presence:') . '</u></h3>'));
        $oForm->addElement(new \PFBC\Element\Select(t('Your status <div class="user_status right" id="status_div"></div>'), 'user_status', [UserModel::ONLINE_STATUS => t('Online'), UserModel::BUSY_STATUS => t('Busy'), UserModel::AWAY_STATUS => t('Away'), UserModel::OFFLINE_STATUS => 'Offline'], ['id' => 'status', 'onchange' => 'init_status()', 'value' => $oUserModel->getUserStatus($iProfileId), 'required' => 1]));
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<script>$(function(){ init_status() });</script>'));
        $oForm->addElement(new \PFBC\Element\Button);
        $oForm->render();
    }
}
<commit_msg>Refactoring: Use PrivacyCore constants + Better Indentation + Make "Offline" translatable<commit_after><?php
/**
 * @author         <NAME> <<EMAIL>>
 * @copyright      (c) 2012-2018, <NAME>. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Module / User / Form
 */

namespace PH7;

use PH7\Framework\Registry\Registry;
use PH7\Framework\Session\Session;
use PH7\Framework\Url\Header;

class PrivacyForm
{
    public static function display()
    {
        $oUserModel = new UserCoreModel;
        $iProfileId = (int)(new Session)->get('member_id');

        if (isset($_POST['submit_privacy_account'])) {
            if (\PFBC\Form::isValid($_POST['submit_privacy_account'])) {
                new PrivacyFormProcess($iProfileId, $oUserModel);
            }

            Header::redirect();
        }

        $oPrivacy = $oUserModel->getPrivacySetting($iProfileId);

        $oForm = new \PFBC\Form('form_privacy_account');
        $oForm->configure(['action' => '']);
        $oForm->addElement(new \PFBC\Element\Hidden('submit_privacy_account', 'form_privacy_account'));
        $oForm->addElement(new \PFBC\Element\Token('privacy_account'));
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Profile:') . '</u></h3>'));
        $oForm->addElement(
            new \PFBC\Element\Radio(
                t('Who can view your profile?'),
                'privacy_profile',
                [
                    PrivacyCore::ALL => t('Everyone (including people who are not %0% members).', Registry::getInstance()->site_name),
                    PrivacyCore::ONLY_USERS => t('Only %0% members who are logged in.', Registry::getInstance()->site_name),
                    PrivacyCore::ONLY_ME => t('Only me.')
                ],
                [
                    'value' => $oPrivacy->privacyProfile,
                    'required' => 1
                ]
            )
        );
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Web search engine:') . '</u></h3>'));
        $oForm->addElement(
            new \PFBC\Element\Radio(
                t('Do you want to be included in search results?'),
                'search_profile',
                [
                    PrivacyCore::YES => t("Yes, include my profile in search results (%site_name%'s search, Google, Bing, Yahoo, etc.)."),
                    PrivacyCore::NO => t('No, do not include my profile in search results.')
                ],
                [
                    'value' => $oPrivacy->searchProfile,
                    'required' => 1
                ]
            )
        );
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Show profile visitors:') . '</u></h3>'));
        $oForm->addElement(
            new \PFBC\Element\Radio(
                t('Would you like to display members that have viewed your profile?'),
                'user_save_views',
                [
                    PrivacyCore::YES => t('Yes, display members who viewed my profile (Selecting this option will allow other members to see that you visited their profile).'),
                    PrivacyCore::NO => t('No, don\'t display members who viewed my profile. (Selecting this option will prevent you from seeing who visited your profile).')
                ],
                [
                    'value' => $oPrivacy->userSaveViews,
                    'required' => 1
                ]
            )
        );
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h3><u>' . t('Presence:') . '</u></h3>'));
        $oForm->addElement(
            new \PFBC\Element\Select(
                t('Your status <div class="user_status right" id="status_div"></div>'),
                'user_status',
                [
                    UserModel::ONLINE_STATUS => t('Online'),
                    UserModel::BUSY_STATUS => t('Busy'),
                    UserModel::AWAY_STATUS => t('Away'),
                    UserModel::OFFLINE_STATUS => t('Offline')
                ],
                [
                    'id' => 'status',
                    'onchange' => 'init_status()',
                    'value' => $oUserModel->getUserStatus($iProfileId),
                    'required' => 1
                ]
            )
        );
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<script>$(function(){ init_status() });</script>'));
        $oForm->addElement(new \PFBC\Element\Button);
        $oForm->render();
    }
}

{'fraction_non_alphanumeric': 0.16571641051065938, 'fraction_numerical': 0.007188894397620228, 'mean_word_length': 2.4438753734528382, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 139, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '976922', 'n_tokens_mistral': 2377, 'n_tokens_neox': 2294, 'n_words': 522}