Exemplo n.º 1
0
    public function save() {
        if ($this->isFirstChangeStatus()) {
            $this->setDateApproved(Gpf_Common_DateUtils::now());
        }
        try {
            $authUser = new Gpf_Db_AuthUser();
            $authUser->setPrimaryKeyValue($this->authUser->getPrimaryKeyValue());
            $authUser->load();
            $this->accountUser->setAuthId($authUser->getId());
        } catch (Gpf_Exception $e) {
            try {
                $this->authUser->loadFromUsername();
                $this->accountUser->setAuthId($this->authUser->getId());
            } catch (Exception $e) {
            }
        }

        $this->inserting = !$this->user->rowExists();

        $this->checkConstraints();

        Gpf_Plugins_Engine::extensionPoint('PostAffiliate.User.beforeSave', $this);

        $this->authUser->save();
        $this->accountUser->setAuthId($this->authUser->getId());

        try {
            $this->accountUser->save();
        } catch (Gpf_Exception $e) {
            $this->authUser->delete();
            throw new Gpf_Exception($e->getMessage());
        }

        $this->user->set('accountuserid', $this->accountUser->get('accountuserid'));
        $this->initRefid($this->accountUser->getId());
        $this->initMinimupPayout();

        try {
            $this->user->save();
        } catch (Gpf_Exception $e) {
            $this->authUser->delete();
            $this->accountUser->delete();
            throw new Gpf_Exception($e->getMessage());
        }

        if($this->inserting) {
            $this->afterInsert();
        } else {
            Pap_Db_Table_CachedBanners::deleteCachedBannersForUser($this->user->getId(), $this->user->getRefId());
            Gpf_Plugins_Engine::extensionPoint('PostAffiliate.User.afterSave', $this);
        }
    }
Exemplo n.º 2
0
 /**
  * @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;
 }