コード例 #1
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
    /**
     * @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);
    }
コード例 #2
0
 protected function executePostRequest(Gpf_Rpc_Params $params)
 {
     $signupFormHandler = new Pap_Signup_AffiliateForm();
     return $signupFormHandler->add($params);
 }
コード例 #3
0
 protected function registerAffiliate() {
     $this->debug("Start registering affiliate, params Name='".$this->getUserFirstName()."', Surname='".$this->getUserLastName()."', username='******'");
     
     if ($this->allRequireValues()) {
         try {
             $signupForm = new Pap_Signup_AffiliateForm();
             $form = $signupForm->add($this->createSignupParams());
             if (!$form->isSuccessful()) {
                 $this->debug('Creating affiliate error: ' . $form->getErrorMessage());
             } else {
                 $this->debug('Affiliate created successfully: ' . $form->getInfoMessage());
             }
         } catch (Gpf_Exception $e) {
             $this->debug("Error while saving affiliate: " . $e->getMessage());
         }
     } else {
         $this->debug("Some essential values for creating new affiliate account is missing, process stopped");
     }
     $this->debug("End registering affiliate");
 }