示例#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);
        }
    }