public function step1() { $iAffId = (int) (new Cookie())->get(AffiliateCore::COOKIE_NAME); $sRef = $this->session->exists('joinRef') ? $this->session->get('joinRef') : t('No reference'); // Statistics $this->session->remove('joinRef'); $aData = ['email' => $this->httpRequest->post('mail'), 'username' => $this->httpRequest->post('username'), 'first_name' => $this->httpRequest->post('first_name'), 'reference' => $sRef, 'ip' => Ip::get(), 'hash_validation' => Various::genRnd(), 'current_date' => (new CDateTime())->get()->dateTime('Y-m-d H:i:s'), 'is_active' => $this->iActiveType, 'group_id' => (int) DbConfig::getSetting('defaultMembershipGroupId'), 'affiliated_id' => $iAffId]; $aData += ['password' => Security::hashPwd($this->httpRequest->post('password'))]; $iTimeDelay = (int) DbConfig::getSetting('timeDelayUserRegistration'); if (!$this->oUserModel->checkWaitJoin($aData['ip'], $iTimeDelay, $aData['current_date'])) { \PFBC\Form::setError('form_join_user', Form::waitRegistrationMsg($iTimeDelay)); } elseif (!$this->oUserModel->join($aData)) { \PFBC\Form::setError('form_join_user', t('An error occurred during registration!<br /> Please try again with other information in the form fields or come back later.')); } else { // Successful registration in the database for step 1! /** Update the Affiliate Commission **/ if ($this->iActiveType == 0) { // Only if the user's account is already activated. AffiliateCore::updateJoinCom($iAffId, $this->config, $this->registry); } // Send email $this->oRegistration->sendMail($aData); $this->session->set('mail_step1', $this->httpRequest->post('mail')); HeaderUrl::redirect(Uri::get('user', 'signup', 'step2')); } }
public function step1() { $sBirthDate = $this->dateTime->get($this->httpRequest->post('birth_date'))->date('Y-m-d'); $iAffId = (int) (new Cookie())->get(AffiliateCore::COOKIE_NAME); $aData = ['email' => $this->httpRequest->post('mail'), 'username' => $this->httpRequest->post('username'), 'password' => $this->httpRequest->post('password'), 'first_name' => $this->httpRequest->post('first_name'), 'last_name' => $this->httpRequest->post('last_name'), 'sex' => $this->httpRequest->post('sex'), 'birth_date' => $sBirthDate, 'country' => $this->httpRequest->post('country'), 'city' => $this->httpRequest->post('city'), 'state' => $this->httpRequest->post('state'), 'zip_code' => $this->httpRequest->post('zip_code'), 'ip' => Ip::get(), 'hash_validation' => Various::genRnd(), 'current_date' => (new CDateTime())->get()->dateTime('Y-m-d H:i:s'), 'is_active' => $this->iActiveType, 'affiliated_id' => $iAffId]; $oAffModel = new AffiliateModel(); $iTimeDelay = (int) DbConfig::getSetting('timeDelayUserRegistration'); if (!$oAffModel->checkWaitJoin($aData['ip'], $iTimeDelay, $aData['current_date'], 'Affiliates')) { \PFBC\Form::setError('form_join_aff', Form::waitRegistrationMsg($iTimeDelay)); } elseif (!$oAffModel->join($aData)) { \PFBC\Form::setError('form_join_aff', t('An error occurred during registration!<br /> Please try again with other information in the form fields or come back later.')); } else { // Successful registration in the database! /** Update the Affiliate Commission **/ if ($this->iActiveType == 0) { // Only if the user's account is already activated. AffiliateCore::updateJoinCom($iAffId, $this->config, $this->registry); } // Send an email and sets the welcome message. \PFBC\Form::setSuccess('form_join_aff', t('Your affiliate account has been created! %0%', (new Registration())->sendMail($aData)->getMsg())); } unset($oAffModel); }