示例#1
0
 public static function display()
 {
     if (isset($_POST['submit_bank_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_bank_account'])) {
             new BankFormProcess();
         }
         Framework\Url\Header::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, 'Affiliates');
     $oForm = new \PFBC\Form('form_bank_account', 500);
     $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="s_button" 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="http://paypal.com" target="_blank"><img src="' . PH7_URL_STATIC . PH7_IMG . 'icon/paypal_small.gif" 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).'), 'title' => t('Your Bank Account.'), '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();
 }
 public function __construct()
 {
     parent::__construct();
     $oAffModel = new AffiliateModel();
     $iProfileId = AdminCore::auth() && !Affiliate::auth() && $this->httpRequest->getExists('profile_id') ? $this->httpRequest->get('profile_id', 'int') : $this->session->get('affiliate_id');
     $oAff = $oAffModel->readProfile($iProfileId, 'Affiliates');
     if (!$this->str->equals($this->httpRequest->post('first_name'), $oAff->firstName)) {
         $oAffModel->updateProfile('firstName', $this->httpRequest->post('first_name'), $iProfileId, 'Affiliates');
         $this->session->set('affiliate_first_name', $this->httpRequest->post('first_name'));
         (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'firstName' . $iProfileId . 'Affiliates', null)->clear();
     }
     if (!$this->str->equals($this->httpRequest->post('last_name'), $oAff->lastName)) {
         $oAffModel->updateProfile('lastName', $this->httpRequest->post('last_name'), $iProfileId, 'Affiliates');
     }
     if (!$this->str->equals($this->httpRequest->post('sex'), $oAff->sex)) {
         $oAffModel->updateProfile('sex', $this->httpRequest->post('sex'), $iProfileId, 'Affiliates');
         $this->session->set('affiliate_sex', $this->httpRequest->post('sex'));
         (new Framework\Cache\Cache())->start(UserCoreModel::CACHE_GROUP, 'sex' . $iProfileId . 'Affiliates', null)->clear();
     }
     if (!$this->str->equals($this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d'), $oAff->birthDate)) {
         $oAffModel->updateProfile('birthDate', $this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d'), $iProfileId, 'Affiliates');
     }
     // Update dynamic fields.
     $oFields = $oAffModel->getInfoFields($iProfileId, 'AffiliatesInfo');
     foreach ($oFields as $sColumn => $sValue) {
         $sHRParam = $sColumn == 'description' ? Http::ONLY_XSS_CLEAN : null;
         if (!$this->str->equals($this->httpRequest->post($sColumn, $sHRParam), $sValue)) {
             $oAffModel->updateProfile($sColumn, $this->httpRequest->post($sColumn, $sHRParam), $iProfileId, 'AffiliatesInfo');
         }
     }
     unset($oFields);
     $oAffModel->setLastEdit($iProfileId, 'Affiliates');
     $oAffCache = new Affiliate();
     $oAffCache->clearReadProfileCache($iProfileId, 'Affiliates');
     $oAffCache->clearInfoFieldCache($iProfileId, 'AffiliatesInfo');
     unset($oAffModel, $oAff, $oAffCache);
     \PFBC\Form::setSuccess('form_aff_edit_account', t('Your profile has been saved successfully!'));
 }
示例#3
0
 public static function display()
 {
     if (isset($_POST['submit_aff_edit_account'])) {
         if (\PFBC\Form::isValid($_POST['submit_aff_edit_account'])) {
             new EditFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $bAdminLogged = AdminCore::auth() && !Affiliate::auth();
     // Check if the admin is logged.
     $oAffModel = new AffiliateModel();
     $oHR = new Http();
     $iProfileId = $bAdminLogged && $oHR->getExists('profile_id') ? $oHR->get('profile_id', 'int') : (new Session())->get('affiliate_id');
     $oAff = $oAffModel->readProfile($iProfileId, 'Affiliates');
     // Birth date with the date format for the date picker
     $sBirthDate = (new CDateTime())->get($oAff->birthDate)->date('m/d/Y');
     $oForm = new \PFBC\Form('form_aff_edit_account', 500);
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_aff_edit_account', 'form_aff_edit_account'));
     $oForm->addElement(new \PFBC\Element\Token('edit_account'));
     if ($bAdminLogged && $oHR->getExists('profile_id')) {
         $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="center"><a class="m_button" href="' . Uri::get('affiliate', 'admin', 'browse') . '">' . t('Back to Browse Affiliates') . '</a></p>'));
     }
     unset($oHR);
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<h2 class="underline">' . t('Global Information:') . '</h2>'));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<p class="error">' . t('Attention all your information must be complete, candid and valid.') . '</p>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Your First Name:'), 'first_name', array('id' => 'str_first_name', 'onblur' => 'CValid(this.value,this.id,2,20)', 'value' => $oAff->firstName, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_first_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Your Last Name:'), 'last_name', array('id' => 'str_last_name', 'onblur' => 'CValid(this.value,this.id,2,20)', 'value' => $oAff->lastName, 'required' => 1, 'validation' => new \PFBC\Validation\Str(2, 20))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_last_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Username:'******'username', array('description' => t('For site security, you cannot change your username.'), 'disabled' => 'disabled', 'value' => $oAff->username)));
     $oForm->addElement(new \PFBC\Element\Email(t('Your Email:'), 'mail', array('description' => t('For site security and to avoid spam, you cannot change your email address.'), 'disabled' => 'disabled', 'value' => $oAff->email)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error phone"></span>'));
     $oForm->addElement(new \PFBC\Element\Radio(t('Your Sex:'), 'sex', array('male' => t('Male'), 'female' => t('Female')), array('value' => $oAff->sex, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Date(t('Your Date of birth:'), 'birth_date', array('id' => 'birth_date', 'onblur' => 'CValid(this.value, this.id)', 'value' => $sBirthDate, 'validation' => new \PFBC\Validation\BirthDate(), 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error birth_date"></span>'));
     // Generate dynamic fields
     $oFields = $oAffModel->getInfoFields($iProfileId, 'AffiliatesInfo');
     foreach ($oFields as $sColumn => $sValue) {
         $oForm = (new DynamicFieldCoreForm($oForm, $sColumn, $sValue))->generate();
     }
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
     $oForm->render();
 }