protected function checkUsernameIsValidEmail(Gpf_Rpc_Form $form, $operationType) { $username = $form->getFieldValue("username"); $emailValidator = new Gpf_Rpc_Form_Validator_EmailValidator(); if(Gpf::YES == Gpf_Settings::get(Gpf_Settings_Gpf::NOT_FORCE_EMAIL_USERNAMES) || $emailValidator->validate($username)) { return true; } $form->setFieldError("username", $this->_("Username must be valid email address")); $form->setErrorMessage($form->getFieldError('username')); return false; }
private function setFromEmailAndName(Pap_Mail_MassMailTemplate $template, $affiliateId) { $user = new Pap_Common_User(); $user->setAccountUserId($affiliateId); try { $user->loadFromData(array(Pap_Db_Table_Users::ACCOUNTUSERID)); } catch (Gpf_Exception $e) { Gpf_Log::debug('Unable to load sender information when sending broadcast mail from affiliateid: ' . $affiliateId . ', error: '. $e->getMessage()); return; } $email = $user->getUserName(); $name = $user->getFirstName() . ' ' . $user->getLastName(); $emailValidator = new Gpf_Rpc_Form_Validator_EmailValidator(); if ($emailValidator->validate($email)) { $template->setFromEmail($email); $template->setFromName($name); } }
/** * @return array {key == lang code, value == array {key == timeOffset, value == array of recipients}} */ private function getRecipients() { $recipients = array(); $emailValidator = new Gpf_Rpc_Form_Validator_EmailValidator(); foreach ($this->recipients as $email => $recipient) { if (!$emailValidator->validate($email)) { Gpf_Log::warning('Email will not be sent to the address "' . $email . '". Address is not valid.'); continue; } try { $authuser = new Gpf_Db_AuthUser(); $authuser->setNotificationEmail($email); $authuser->loadFromData(array(Gpf_Db_Table_AuthUsers::NOTIFICATION_EMAIL)); $recipients = $this->insertRecipient($recipients, $recipient, $this->getAccountUser($authuser->getId())); } catch (Gpf_Exception $e) { try { $authuser->setUsername($email); $authuser->loadFromUsername(); $recipients = $this->insertRecipient($recipients, $recipient, $this->getAccountUser($authuser->getId())); } catch (Gpf_DbEngine_NoRowException $e) { $recipients = $this->insertRecipient($recipients, $recipient); } } } return $recipients; }
/** * @param $email * @param $context * @return Pap_Affiliates_User */ private function createUserFromEmail($email, $context) { $context->debug('Loading affiliate by email'); $emailValidator = new Gpf_Rpc_Form_Validator_EmailValidator(); if (!$emailValidator->validate($email)) { if (!$emailValidator->validate(urldecode($email))) { $context->debug(' AutoRegisteringAffiliates - Creating affiliate stopped, not valid email address: ' . $email); return null; } $email = urldecode($email); } try { return Pap_Affiliates_User::loadFromUsername($email); } catch (Gpf_Exception $e) { if (!Pap_Common_User::isUsernameUnique($email)) { $context->debug(' AutoRegisteringAffiliates - Creating affiliate stopped, email address is used for another user: '******''); $user->setLastName(substr($email, 0, strpos($email, '@'))); //$user->setSendNotification(false); $user->save(); $signupForm->setDefaultEmailNotificationsSettings($user); $signupContext = Pap_Contexts_Signup::getContextInstance(); $signupContext->setUserObject($user); $merchantNotificationEmails = new Pap_Signup_SendNotificationEmails(); $merchantNotificationEmails->process($signupContext); $context->debug(' AutoRegisteringAffiliates - New Affiliate created successfully, email: ' . $email); Gpf_Db_Table_UserAttributes::setSetting(self::AUTO_REGISTERED_AFFILIATE, Gpf::YES, $user->getAccountUserId()); } return Pap_Affiliates_User::loadFromUsername($email); }