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); }
private function _moderateRegistration($iId, $iStatus) { if (isset($iId, $iStatus)) { if ($oUser = $this->oAdminModel->readProfile($iId)) { if ($iStatus == 0) { // We leave the user in disapproval, after we can ban or delete it. $sSubject = t('Your membership account has been declined'); $this->sMsg = t('Sorry, Your membership account has been declined.'); } elseif ($iStatus == 1) { // Approve User $this->oAdminModel->approve($oUser->profileId, 1); /** Update the Affiliate Commission **/ AffiliateCore::updateJoinCom($oUser->affiliatedId, $this->config, $this->registry); $sSubject = t('Your membership account has been activated'); $this->sMsg = t('Congratulations! Your account has been approved by our team of administrators.<br />You can now %0% to meeting new people!', '<a href="' . Uri::get('user', 'main', 'login') . '"><b>' . t('log in') . '</b></a>'); } else { // Error... $this->sMsg = null; } if (!empty($this->sMsg)) { // Set message $this->view->content = t('Dear %0%,', $oUser->firstName) . '<br />' . $this->sMsg; $this->view->footer = t('You are receiving this mail because we received an application for registration with the email "%0%" has been provided in the form of %site_name% (%site_url%).', $oUser->email) . '<br />' . t('If you think someone has used your email address without your knowledge to create an account on %site_name%, please contact us using our contact form available on our website.'); // Send email $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/core/moderate_registration.tpl', $oUser->email); $aInfo = ['to' => $oUser->email, 'subject' => $sSubject]; (new Framework\Mail\Mail())->send($aInfo, $sMessageHtml); $this->oAdmin->clearReadProfileCache($oUser->profileId); $sOutputMsg = t('Done!'); } else { $sOutputMsg = t('Error! Bad argument in the url.'); } } else { $sOutputMsg = t('The user is not found!'); } } else { $sOutputMsg = t('Error! Missing argument in the url.'); } return $sOutputMsg; }
/** * Message and Redirection for Activate Account. * * @param string $sEmail * @param string $sHash * @param object \PH7\Framework\Config\Config $oConfig * @param object \PH7\Framework\Registry\Registry $oRegistry * @param string $sMod (user, affiliate, newsletter). Default 'user' * @return void */ public function activateAccount($sEmail, $sHash, Framework\Config\Config $oConfig, Framework\Registry\Registry $oRegistry, $sMod = 'user') { $sTable = Framework\Mvc\Model\Engine\Util\Various::convertModToTable($sMod); $sRedirectLoginUrl = $sMod == 'newsletter' ? PH7_URL_ROOT : ($sMod == 'affiliate' ? Uri::get('affiliate', 'home', 'login') : Uri::get('user', 'main', 'login')); $sRedirectIndexUrl = $sMod == 'newsletter' ? PH7_URL_ROOT : ($sMod == 'affiliate' ? Uri::get('affiliate', 'home', 'index') : Uri::get('user', 'main', 'index')); $sSuccessMsg = $sMod == 'newsletter' ? t('Your subscription to our newsletters has been successfully validated!') : t('Your account has been successfully validated. You can now login!'); if (isset($sEmail, $sHash)) { $oUserModel = new AffiliateCoreModel(); if ($oUserModel->validateAccount($sEmail, $sHash, $sTable)) { $iId = $oUserModel->getId($sEmail, null, $sTable); if ($sMod != 'newsletter') { $this->clearReadProfileCache($iId, $sTable); } /** Update the Affiliate Commission **/ $iAffId = $oUserModel->getAffiliatedId($iId); AffiliateCore::updateJoinCom($iAffId, $oConfig, $oRegistry); Header::redirect($sRedirectLoginUrl, $sSuccessMsg); } else { Header::redirect($sRedirectLoginUrl, t('Oops! The URL is either invalid or you already have activated your account.'), 'error'); } unset($oUserModel); } else { Header::redirect($sRedirectIndexUrl, t('Invalid approach, please use the link that has been send to your email.'), 'error'); } }