source/Application/Model/User.php
public function createUser()
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sShopID = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId();

        // check if user exists AND there is no password - in this case we update otherwise we try to insert
        $sSelect = "select oxid from oxuser where oxusername = " . $oDb->quote($this->oxuser__oxusername->value) . " and oxpassword = '' ";
        if (!$this->_blMallUsers) {
            $sSelect .= " and oxshopid = '{$sShopID}' ";
        }
        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        $masterDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();
        $oldUserId = $masterDb->getOne($sSelect);

        if ($oldUserId) {
            $this->delete($oldUserId);
        } elseif ($this->_blMallUsers) {
            // must be sure if there is no duplicate user
            $sQ = "select oxid from oxuser where oxusername = " . $oDb->quote($this->oxuser__oxusername->value) . " and oxusername != '' ";
            // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
            if ($masterDb->getOne($sQ)) {
                /** @var UserException $oEx */
                $oEx = oxNew(UserException::class);
                $oLang = Registry::getLang();
                $oEx->setMessage(sprintf($oLang->translateString('ERROR_MESSAGE_USER_USEREXISTS', $oLang->getTplLanguage()), $this->oxuser__oxusername->value));
                throw $oEx;
            }
        }

        $this->oxuser__oxshopid = new Field($sShopID, Field::T_RAW);

        $newUserId = $this->save();
        if ($newUserId === false) {
            throw oxNew(UserException::class, 'ERROR_MESSAGE_USER_USERCREATIONFAILED');
        } else {
            // @TODO the following statements make no sense and should be removed: oxuser__oxid is freshly created and the conditions will never match
            // dropping/cleaning old delivery address/payment info
            $oDb->execute("delete from oxaddress where oxaddress.oxuserid = " . $oDb->quote($this->oxuser__oxid->value));
            $oDb->execute("update oxuserpayments set oxuserpayments.oxuserid = " . $oDb->quote($this->oxuser__oxusername->value) . " where oxuserpayments.oxuserid = " . $oDb->quote($this->oxuser__oxid->value));
        }

        return $newUserId;
    }
public function createUser()
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sShopID = \OxidEsales\Eshop\Core\Registry::getConfig()->getShopId();

        // check if user exists AND there is no password - in this case we update otherwise we try to insert
        $sSelect = "select oxid from oxuser where oxusername = " . $oDb->quote($this->oxuser__oxusername->value) . " and oxpassword = '' ";
        if (!$this->_blMallUsers) {
            $sSelect .= " and oxshopid = '{$sShopID}' ";
        }
        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        $masterDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();
        $oldUserId = $masterDb->getOne($sSelect);

        if ($oldUserId) {
            $this->delete($oldUserId);
        } elseif ($this->_blMallUsers) {
            // must be sure if there is no duplicate user
            $sQ = "select oxid from oxuser where oxusername = " . $oDb->quote($this->oxuser__oxusername->value) . " and oxusername != '' ";
            // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
            if ($masterDb->getOne($sQ)) {
                /** @var UserException $oEx */
                $oEx = oxNew(UserException::class);
                $oLang = Registry::getLang();
                $oEx->setMessage(sprintf($oLang->translateString('ERROR_MESSAGE_USER_USEREXISTS', $oLang->getTplLanguage()), $this->oxuser__oxusername->value));
                throw $oEx;
            }
        }

        $this->oxuser__oxshopid = new Field($sShopID, Field::T_RAW);

        $newUserId = $this->save();
        if ($newUserId === false) {
            throw oxNew(UserException::class, 'ERROR_MESSAGE_USER_USERCREATIONFAILED');
        } else {
            // @TODO the following statements make no sense and should be removed: oxuser__oxid is freshly created and the conditions will never match
            // dropping/cleaning old delivery address/payment info
            $oDb->execute("delete from oxaddress where oxaddress.oxuserid = " . $oDb->quote($this->oxuser__oxid->value));
            $oDb->execute("update oxuserpayments set oxuserpayments.oxuserid = " . $oDb->quote($this->oxuser__oxusername->value) . " where oxuserpayments.oxuserid = " . $oDb->quote($this->oxuser__oxid->value));
        }

        return $newUserId;
    }
public function createUser ( ) { $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sShopID = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getShopId ( ) ; // check if user exists AND there is no password - in this case we update otherwise we try to insert $ sSelect = "select oxid from oxuser where oxusername = " . $ oDb -> quote ( $ this -> oxuser__oxusername -> value ) . " and oxpassword = '' " ; if ( ! $ this -> _blMallUsers ) { $ sSelect .= " and oxshopid = '{$sShopID}' " ; } // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804). $ masterDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getMaster ( ) ; $ oldUserId = $ masterDb -> getOne ( $ sSelect ) ; if ( $ oldUserId ) { $ this -> delete ( $ oldUserId ) ; } elseif ( $ this -> _blMallUsers ) { // must be sure if there is no duplicate user $ sQ = "select oxid from oxuser where oxusername = " . $ oDb -> quote ( $ this -> oxuser__oxusername -> value ) . " and oxusername != '' " ; // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804). if ( $ masterDb -> getOne ( $ sQ ) ) { /** @var UserException $oEx */ $ oEx = oxNew ( UserException :: class ) ; $ oLang = Registry :: getLang ( ) ; $ oEx -> setMessage ( sprintf ( $ oLang -> translateString ( 'ERROR_MESSAGE_USER_USEREXISTS' , $ oLang -> getTplLanguage ( ) ) , $ this -> oxuser__oxusername -> value ) ) ; throw $ oEx ; } } $ this -> oxuser__oxshopid = new Field ( $ sShopID , Field :: T_RAW ) ; $ newUserId = $ this -> save ( ) ; if ( $ newUserId === false ) { throw oxNew ( UserException :: class , 'ERROR_MESSAGE_USER_USERCREATIONFAILED' ) ; } else { // @TODO the following statements make no sense and should be removed: oxuser__oxid is freshly created and the conditions will never match // dropping/cleaning old delivery address/payment info $ oDb -> execute ( "delete from oxaddress where oxaddress.oxuserid = " . $ oDb -> quote ( $ this -> oxuser__oxid -> value ) ) ; $ oDb -> execute ( "update oxuserpayments set oxuserpayments.oxuserid = " . $ oDb -> quote ( $ this -> oxuser__oxusername -> value ) . " where oxuserpayments.oxuserid = " . $ oDb -> quote ( $ this -> oxuser__oxid -> value ) ) ; } return $ newUserId ; }
Inserts new or updates existing user

@throws UserException exception

@return bool
Inserts new or updates existing user