<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 / Affiliate / Form
 */

namespace PH7;

use PH7\Framework\Mvc\Request\Http;
use PH7\Framework\Mvc\Router\Uri;
use PH7\Framework\Session\Session;
use PH7\Framework\Url\Header as UrlHeader;

class BankForm
{
    public static function display()
    {
        if (isset($_POST['submit_bank_account'])) {
            if (\PFBC\Form::isValid($_POST['submit_bank_account'])) {
                new BankFormProcess();
            }

            UrlHeader::redirect();
        }

        $oHR = new Http;
        $iProfileId = (AdminCore::auth() && !Affiliate::auth() && $oHR->getExists('profile_id')) ? $oHR->get('profile_id', 'int') : (new Session)->get('affiliate_id');
        $oAff = (new AffiliateModel)->readProfile($iProfileId, DbTableName::AFFILIATE);

        $oForm = new \PFBC\Form('form_bank_account');
        $oForm->configure(array('action' => ''));
        $oForm->addElement(new \PFBC\Element\Hidden('submit_bank_account', 'form_bank_account'));
        $oForm->addElement(new \PFBC\Element\Token('bank_account'));

        if (AdminCore::auth() && !Affiliate::auth() && $oHR->getExists('profile_id')) {
            $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="bold btn btn-default btn-md" href="' . Uri::get('affiliate', 'admin', 'browse') . '">' . t('Return to back affiliates browse') . '</a></p>'));
        }
        unset($oHR);

        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h2 class="underline">' . t('Bank Information:') . '</h2>'));
        $sHtmlPayPalIcon = '<a href="https://www.paypal.com" rel="noopener" target="_blank"><img src="' . PH7_URL_STATIC . PH7_IMG . 'icon/paypal-small.svg" alt="PayPal" title="PayPal"></a><br />';
        $oForm->addElement(new \PFBC\Element\Email($sHtmlPayPalIcon . t('Your Bank Account:'), 'bank_account', array('id' => 'email_paypal', 'onblur' => 'CValid(this.value,this.id)', 'description' => t('Your Bank Account (PayPal Email Address).'), 'value' => $oAff->bankAccount, 'validation' => new \PFBC\Validation\BankAccount, 'required' => 1)));
        $oForm->addElement(new \PFBC\Element\HtmlExternal('<span class="input_error email_paypal"></span>'));
        $oForm->addElement(new \PFBC\Element\Button);
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
        $oForm->render();
    }
}<commit_msg>[Coding Style Improved] Add method that checks if admin is logged (and not affiliate users)<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 / Affiliate / Form
 */

namespace PH7;

use PH7\Framework\Mvc\Request\Http;
use PH7\Framework\Mvc\Router\Uri;
use PH7\Framework\Session\Session;
use PH7\Framework\Url\Header as UrlHeader;

class BankForm
{
    public static function display()
    {
        if (isset($_POST['submit_bank_account'])) {
            if (\PFBC\Form::isValid($_POST['submit_bank_account'])) {
                new BankFormProcess();
            }

            UrlHeader::redirect();
        }

        $oHR = new Http;
        $iProfileId = (self::isAdminLogged() && $oHR->getExists('profile_id')) ? $oHR->get('profile_id', 'int') : (new Session)->get('affiliate_id');
        $oAff = (new AffiliateModel)->readProfile($iProfileId, DbTableName::AFFILIATE);

        $oForm = new \PFBC\Form('form_bank_account');
        $oForm->configure(array('action' => ''));
        $oForm->addElement(new \PFBC\Element\Hidden('submit_bank_account', 'form_bank_account'));
        $oForm->addElement(new \PFBC\Element\Token('bank_account'));

        if (AdminCore::auth() && !Affiliate::auth() && $oHR->getExists('profile_id')) {
            $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="bold btn btn-default btn-md" href="' . Uri::get('affiliate', 'admin', 'browse') . '">' . t('Return to back affiliates browse') . '</a></p>'));
        }
        unset($oHR);

        $oForm->addElement(new \PFBC\Element\HTMLExternal('<h2 class="underline">' . t('Bank Information:') . '</h2>'));
        $sHtmlPayPalIcon = '<a href="https://www.paypal.com" rel="noopener" target="_blank"><img src="' . PH7_URL_STATIC . PH7_IMG . 'icon/paypal-small.svg" alt="PayPal" title="PayPal"></a><br />';
        $oForm->addElement(new \PFBC\Element\Email($sHtmlPayPalIcon . t('Your Bank Account:'), 'bank_account', array('id' => 'email_paypal', 'onblur' => 'CValid(this.value,this.id)', 'description' => t('Your Bank Account (PayPal Email Address).'), 'value' => $oAff->bankAccount, 'validation' => new \PFBC\Validation\BankAccount, 'required' => 1)));
        $oForm->addElement(new \PFBC\Element\HtmlExternal('<span class="input_error email_paypal"></span>'));
        $oForm->addElement(new \PFBC\Element\Button);
        $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
        $oForm->render();
    }

    /**
     * @return bool
     */
    private static function isAdminLogged()
    {
        return AdminCore::auth() && !Affiliate::auth();
    }
}
{'fraction_non_alphanumeric': 0.18929150892374255, 'fraction_numerical': 0.00829277086713539, 'mean_word_length': 3.477804681194512, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 85, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '134741', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1773, 'n_words': 334}