/** * issued before saving an object. can modify aData for saving * * @param oxBase $oShopObject shop object * @param array $aData data to prepare * @param bool $blAllowCustomShopId if allow custom shop id * * @return array */ protected function _preAssignObject($oShopObject, $aData, $blAllowCustomShopId) { if (!isset($aData['OXSTOCKFLAG'])) { if (!$aData['OXID'] || !$oShopObject->exists($aData['OXID'])) { // default value is 1 according to eShop admin functionality $aData['OXSTOCKFLAG'] = 1; } } $aData = parent::_preAssignObject($oShopObject, $aData, $blAllowCustomShopId); return $aData; }
/** * Checks if user exists in database. * * @param string $sOXID object ID (default null) * * @return bool */ public function exists($sOXID = null) { if (!$sOXID) { $sOXID = $this->getId(); } //#5901 if physical record exists return true unconditionally if (parent::exists($sOXID)) { $this->setId($sOXID); return true; } //additional username check //This part is used by not yet saved user object, to detect the case when such username exists in db. //Basically it is called when anonymous visitor enters existing username for newsletter subscription //see Newsletter::send() //TODO: transfer this validation to newsletter part $sShopSelect = ''; if (!$this->_blMallUsers && $this->oxuser__oxrights->value != 'malladmin') { $sShopSelect = ' AND oxshopid = "' . $this->getConfig()->getShopId() . '" '; } // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804). $masterDb = oxDb::getMaster(); $sSelect = 'SELECT oxid FROM ' . $this->getViewName() . ' WHERE ( oxusername = '******' ) '; $sSelect .= $sShopSelect; if ($sOxid = $masterDb->getOne($sSelect)) { // update - set oxid $this->setId($sOxid); return true; } return false; }