Beispiel #1
0
 /**
  * Sets data field value
  *
  * @param string $sFieldName index OR name (eg. 'oxarticles__oxtitle') of a data field to set
  * @param string $sValue     value of data field
  * @param int    $iDataType  field type
  *
  * @return null
  */
 protected function _setFieldData($sFieldName, $sValue, $iDataType = oxField::T_TEXT)
 {
     if ('oxvalue' === $sFieldName) {
         $iDataType = oxField::T_RAW;
     }
     return parent::_setFieldData($sFieldName, $sValue, $iDataType);
 }
Beispiel #2
0
 /**
  * Inserts object data fields in DB. Returns true on success.
  *
  * @return bool
  */
 protected function _insert()
 {
     // set oxcreate
     $sNow = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime());
     $this->oxremark__oxcreate = new oxField($sNow, oxField::T_RAW);
     $this->oxremark__oxheader = new oxField($sNow, oxField::T_RAW);
     return parent::_insert();
 }
Beispiel #3
0
 /**
  * Extends the default save method.
  * Saves only if this kind of entry do not exists.
  *
  * @return bool
  */
 public function save()
 {
     $oDb = oxDb::getDb();
     $sQ = "select 1 from oxobject2group where oxgroupsid = " . $oDb->quote($this->oxobject2group__oxgroupsid->value);
     $sQ .= " and oxobjectid = " . $oDb->quote($this->oxobject2group__oxobjectid->value);
     // does not exist
     if (!$oDb->getOne($sQ, false, false)) {
         return parent::save();
     }
 }
 /**
  * Override delete function so we can delete user group and article or category relations first.
  *
  * @param string $sOxId object ID (default null)
  *
  * @return null
  */
 public function delete($sOxId = null)
 {
     if (!$sOxId) {
         $sOxId = $this->getId();
     }
     $this->unsetDiscountRelations();
     $this->unsetUserGroups();
     $this->deleteVoucherList();
     return parent::delete($sOxId);
 }
 /**
  * Extends the default save method.
  * Saves only if this kind of entry do not exists.
  *
  * @throws DatabaseException
  *
  * @return bool
  */
 public function save()
 {
     try {
         return parent::save();
     } catch (\OxidEsales\EshopCommunity\Core\Exception\DatabaseException $exception) {
         /**
          * The table oxobject2group has an UNIQUE index on (OXGROUPSID, OXOBJECTID, OXSHOPID)
          * If there is a DatabaseException and the exception code is 1062 i.e. "Duplicate entry",
          * the exception will be discarded and the record will not be inserted.
          */
         if ($exception->getCode() != '1062') {
             throw $exception;
         }
     }
 }
 /**
  * Class constructor
  *
  * @return null
  */
 public function __construct()
 {
     parent::__construct();
     $this->init('oxaddress');
 }
 /**
  * Save this Object to database, insert or update as needed.
  *
  * @return mixed
  */
 public function save()
 {
     if (!$this->oxrecommlists__oxtitle->value) {
         throw oxNew("oxObjectException", 'EXCEPTION_RECOMMLIST_NOTITLE');
     }
     return parent::save();
 }
Beispiel #8
0
 /**
  * Deletes oxFile record from DB, removes orphan files.
  *
  * @param string $sOxId default null
  *
  * @return bool
  */
 public function delete($sOxId = null)
 {
     $sOxId = $sOxId ? $sOxId : $this->getId();
     $this->load($sOxId);
     // if record cannot be delete, abort deletion
     if ($blDeleted = parent::delete($sOxId)) {
         $this->_deleteFile();
     }
     return $blDeleted;
 }
Beispiel #9
0
 /**
  * Updates payment record in DB. Returns update status.
  *
  * @return bool
  */
 protected function _update()
 {
     $oDb = oxDb::getDb();
     //encode sensitive data
     if ($sValue = $this->oxuserpayments__oxvalue->value) {
         $sEncodedValue = $oDb->getOne("select encode( " . $oDb->quote($sValue) . ", '" . $this->getPaymentKey() . "' )", false, false);
         $this->oxuserpayments__oxvalue->setValue($sEncodedValue);
     }
     $blRet = parent::_update();
     //restore, as encoding was needed only for saving
     if ($sEncodedValue) {
         $this->oxuserpayments__oxvalue->setValue($sValue);
     }
     return $blRet;
 }
Beispiel #10
0
 /**
  * Sets article creation date
  * (oxorderarticle::oxorderarticles__oxtimestamp). Then executes parent method
  * parent::_insert() and returns insertion status.
  *
  * @return bool
  */
 protected function _insert()
 {
     $iInsertTime = time();
     $now = date('Y-m-d H:i:s', $iInsertTime);
     $this->oxorderarticles__oxtimestamp = new oxField($now);
     return parent::_insert();
 }
 /**
  * We need to check if we unsubscribe here
  *
  * @return mixed oxid on success or false on failure
  */
 protected function _update()
 {
     if (($this->_blWasSubscribed || $this->_blWasPreSubscribed) && !$this->oxnewssubscribed__oxdboptin->value) {
         // set unsubscription date
         $this->oxnewssubscribed__oxunsubscribed->setValue(date('Y-m-d H:i:s'));
         // 0001974 Same object can be called many times without requiring to renew date.
         // If so happens, it would have _aSkipSaveFields set to skip date field. So need to check and
         // release if _aSkipSaveFields are set for field oxunsubscribed.
         $aSkipSaveFieldsKeys = array_keys($this->_aSkipSaveFields, 'oxunsubscribed');
         foreach ($aSkipSaveFieldsKeys as $iSkipSaveFieldKey) {
             unset($this->_aSkipSaveFields[$iSkipSaveFieldKey]);
         }
     } else {
         // don't update date
         $this->_aSkipSaveFields[] = 'oxunsubscribed';
     }
     return parent::_update();
 }
Beispiel #12
0
 /**
  * returns long name
  *
  * @param string $sFieldName - field name
  *
  * @return string
  */
 protected function _getFieldLongName($sFieldName)
 {
     $aFieldNames = array('oxorderfiles__oxarticletitle', 'oxorderfiles__oxarticleartnum', 'oxorderfiles__oxordernr', 'oxorderfiles__oxorderdate', 'oxorderfiles__oxispaid', 'oxorderfiles__oxpurchasedonly');
     if (in_array($sFieldName, $aFieldNames)) {
         return $sFieldName;
     }
     return parent::_getFieldLongName($sFieldName);
 }
 /**
  * Checks if all required fields are filled.
  * Returns array of invalid fields or empty array if all fields are fine.
  *
  * @param oxBase $oObject Address fields with values.
  *
  * @return bool If any invalid field exist.
  */
 public function validateFields($oObject)
 {
     $aRequiredFields = $this->getRequiredFields();
     $oFieldValidator = $this->getFieldValidator();
     $aInvalidFields = array();
     foreach ($aRequiredFields as $sFieldName) {
         if (!$oFieldValidator->validateFieldValue($oObject->getFieldData($sFieldName))) {
             $aInvalidFields[] = $sFieldName;
         }
     }
     $this->_setInvalidFields($aInvalidFields);
     return empty($aInvalidFields);
 }
 /**
  * Class constructor, initiates parent constructor (parent::oxBase()) and sets table name.
  */
 public function __construct()
 {
     parent::__construct();
     $this->init('oxobject2category');
 }
 /**
  * Inserts new guestbook entry. Returns true on success.
  *
  * @return bool
  */
 protected function _insert()
 {
     // set oxcreate
     $this->oxgbentries__oxcreate = new oxField(date('Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime()));
     return parent::_insert();
 }
 /**
  * Class constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->init($this->_sClassName);
 }
 /**
  * post saving hook. can finish transactions if needed or ajust related data
  *
  * @param oxBase $oShopObject shop object
  * @param data   $aData       data to save
  *
  * @return mixed data to return
  */
 protected function _postSaveObject($oShopObject, $aData)
 {
     $sOXID = $oShopObject->getId();
     $oShopObject->onChange(null, $sOXID, $sOXID);
     // returning ID on success
     return $sOXID;
 }
Beispiel #18
0
 public function __construct()
 {
     parent::__construct();
     $this->_initModuleManager();
 }
Beispiel #19
0
 /**
  * Extra getter to guarantee compatibility with templates
  *
  * @param string $sName name of variable to get
  *
  * @return string
  */
 public function __get($sName)
 {
     switch ($sName) {
         // simple voucher mapping
         case 'sVoucherId':
             return $this->getId();
             break;
         case 'sVoucherNr':
             return $this->oxvouchers__oxvouchernr;
             break;
         case 'fVoucherdiscount':
             return $this->oxvouchers__oxdiscount;
             break;
     }
     return parent::__get($sName);
 }
Beispiel #20
0
 /**
  * Deletes current basket history
  *
  * @param string $sOXID Object ID(default null)
  *
  * @return bool
  */
 public function delete($sOXID = null)
 {
     if (!$sOXID) {
         $sOXID = $this->getId();
     }
     $blDelete = false;
     if ($sOXID && ($blDelete = parent::delete($sOXID))) {
         // cleaning up related data
         $oDb = oxDb::getDb();
         $sQ = "delete from oxuserbasketitems where oxbasketid = " . $oDb->quote($sOXID);
         $oDb->execute($sQ);
     }
     return $blDelete;
 }
Beispiel #21
0
 /**
  * Delete this object from the database, returns true on success.
  *
  * @param string $sOXID Object ID(default null)
  *
  * @return bool
  */
 public function delete($sOXID = null)
 {
     $blDeleted = parent::delete($sOXID);
     if ($blDeleted) {
         $oDB = oxDb::getDb();
         $sOXID = $oDB->quote($sOXID);
         //delete the record
         foreach ($this->_getLanguageSetTables() as $sSetTbl) {
             $oDB->execute("delete from {$sSetTbl} where oxid = {$sOXID}");
         }
     }
     return $blDeleted;
 }
 /**
  * post saving hook. can finish transactions if needed or ajust related data
  *
  * @param oxBase $oShopObject shop object
  * @param data   $aData       data to save
  *
  * @return mixed data to return
  */
 protected function _postSaveObject($oShopObject, $aData)
 {
     // returning ID on success
     return $oShopObject->getId();
 }
Beispiel #23
0
 /**
  * Class constructor, initiates parent constructor (parent::oxBase()).
  */
 public function __construct()
 {
     parent::__construct();
     $this->init('oxratings');
 }
 /**
  * Inserts object data into DB, returns true on success.
  *
  * @return bool
  */
 protected function _insert()
 {
     // set oxinsert value
     $this->oxpricealarm__oxinsert = new oxField(date('Y-m-d', oxRegistry::get("oxUtilsDate")->getTime()));
     return parent::_insert();
 }
Beispiel #25
0
 /**
  * Force getUpdateFieldValue.
  *
  * @param string $sFieldName fiels name
  * @param object $oField     field object
  *
  * @return mixed
  */
 public function getUpdateFieldValue($sFieldName, $oField)
 {
     return parent::_getUpdateFieldValue($sFieldName, $oField);
 }
Beispiel #26
0
 /**
  * Updates payment record in DB. Returns update status.
  *
  * @return bool
  */
 protected function _update()
 {
     //encode sensitive data
     if ($sValue = $this->oxuserpayments__oxvalue->value) {
         // Function is called from inside a transaction in Category::save (see ESDEV-3804 and ESDEV-3822).
         // No need to explicitly force master here.
         $database = oxDb::getDb();
         $sEncodedValue = $database->getOne("select encode( " . $database->quote($sValue) . ", '" . $this->getPaymentKey() . "' )");
         $this->oxuserpayments__oxvalue->setValue($sEncodedValue);
     }
     $blRet = parent::_update();
     //restore, as encoding was needed only for saving
     if ($sEncodedValue) {
         $this->oxuserpayments__oxvalue->setValue($sValue);
     }
     return $blRet;
 }
 /**
  * Sets data field value
  *
  * @param string $sFieldName index OR name (eg. 'oxarticles__oxtitle') of a data field to set
  * @param string $sValue     value of data field
  * @param int    $iDataType  field type
  *
  * @return null
  */
 protected function _setFieldData($sFieldName, $sValue, $iDataType = oxField::T_TEXT)
 {
     if ('oxsellist' === strtolower($sFieldName) || 'oxuserbasketitems__oxsellist' === strtolower($sFieldName) || 'oxpersparam' === strtolower($sFieldName) || 'oxuserbasketitems__oxpersparam' === strtolower($sFieldName)) {
         $iDataType = oxField::T_RAW;
     }
     return parent::_setFieldData($sFieldName, $sValue, $iDataType);
 }
 /**
  * Create object 2 object connection in databse
  *
  * @param array  $aData         db fields and values
  * @param string $sObj2ObjTable table name
  */
 public function createObj2Obj($aData, $sObj2ObjTable)
 {
     if (empty($aData)) {
         return;
     }
     $iCnt = count($aData);
     for ($i = 0; $i < $iCnt; $i++) {
         $oObj = new oxBase();
         $oObj->init($sObj2ObjTable);
         if ($iCnt < 2) {
             $aObj = $aData[$i];
         } else {
             $aObj = $aData;
         }
         foreach ($aObj as $sKey => $sValue) {
             $sField = $sObj2ObjTable . "__" . $sKey;
             $oObj->{$sField} = new oxField($sValue, oxField::T_RAW);
         }
         $oObj->save();
     }
 }
 /**
  * Class constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->init('paymill_fastcheckout');
 }
Beispiel #30
0
 /**
  * Class constructor, initiates parent constructor (parent::oxBase()).
  */
 public function __construct()
 {
     parent::__construct();
     $this->init('hbovarmaps');
 }