/** * Inserts object details to DB, returns true on success. * * @return bool */ protected function _insert() { if (!$this->oxnews__oxdate || oxRegistry::get("oxUtilsDate")->isEmptyDate($this->oxnews__oxdate->value)) { // if date field is empty, assigning current date $this->oxnews__oxdate = new oxField(date('Y-m-d')); } else { $this->oxnews__oxdate = new oxField(oxRegistry::get("oxUtilsDate")->formatDBDate($this->oxnews__oxdate->value, true)); } return parent::_insert(); }
/** * Inserts new category (and updates existing node oxLeft amd oxRight accordingly). Returns true on success. * * @return bool */ protected function _insert() { if ($this->oxcategories__oxparentid->value != "oxrootid") { // load parent $oParent = oxNew("oxCategory"); //#M317 check if parent is loaded if (!$oParent->load($this->oxcategories__oxparentid->value)) { return false; } $sAdd = " and oxshopid = '" . $this->getShopId() . "' "; // update existing nodes $oDb = oxDb::getDb(); $oDb->execute("UPDATE oxcategories SET OXLEFT = OXLEFT + 2\n WHERE OXROOTID = " . $oDb->quote($oParent->oxcategories__oxrootid->value) . "\n AND OXLEFT > " . (int) $oParent->oxcategories__oxright->value . "\n AND OXRIGHT >= " . (int) $oParent->oxcategories__oxright->value . $sAdd); $oDb->execute("UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2\n WHERE OXROOTID = " . $oDb->quote($oParent->oxcategories__oxrootid->value) . "\n AND OXRIGHT >= " . (int) $oParent->oxcategories__oxright->value . $sAdd); if (!$this->getId()) { $this->setId(); } $this->oxcategories__oxrootid = new oxField($oParent->oxcategories__oxrootid->value, oxField::T_RAW); $this->oxcategories__oxleft = new oxField($oParent->oxcategories__oxright->value, oxField::T_RAW); $this->oxcategories__oxright = new oxField($oParent->oxcategories__oxright->value + 1, oxField::T_RAW); return parent::_insert(); } else { // root entry if (!$this->getId()) { $this->setId(); } $this->oxcategories__oxrootid = new oxField($this->getId(), oxField::T_RAW); $this->oxcategories__oxleft = new oxField(1, oxField::T_RAW); $this->oxcategories__oxright = new oxField(2, oxField::T_RAW); return parent::_insert(); } }
/** * Inserts new category (and updates existing node oxleft amd oxright accordingly). Returns true on success. * * @return bool */ protected function _insert() { if ($this->oxcategories__oxparentid->value != "oxrootid") { // load parent $oParent = oxNew("oxcategory"); //#M317 check if parent is loaded if (!$oParent->load($this->oxcategories__oxparentid->value)) { return false; } $sAdd = " and oxshopid = '" . $this->getShopId() . "' "; // update existing nodes $oDB = oxDb::getDb(); $oDB->execute("UPDATE oxcategories SET OXLEFT = OXLEFT + 2\n WHERE OXROOTID = " . $oDB->quote($oParent->oxcategories__oxrootid->value) . "\n AND OXLEFT > " . (int) $oParent->oxcategories__oxright->value . "\n AND OXRIGHT >= " . (int) $oParent->oxcategories__oxright->value . $sAdd); $oDB->execute("UPDATE oxcategories SET OXRIGHT = OXRIGHT + 2\n WHERE OXROOTID = " . $oDB->quote($oParent->oxcategories__oxrootid->value) . "\n AND OXRIGHT >= " . (int) $oParent->oxcategories__oxright->value . $sAdd); //if ( !isset( $this->_sOXID) || trim( $this->_sOXID) == "") // $this->_sOXID = oxUtilsObject::getInstance()->generateUID(); //$this->oxcategories__oxid->setValue($this->_sOXID); //refactored to: if (!$this->getId()) { $this->setId(); } $this->oxcategories__oxrootid = new oxField($oParent->oxcategories__oxrootid->value, oxField::T_RAW); $this->oxcategories__oxleft = new oxField($oParent->oxcategories__oxright->value, oxField::T_RAW); $this->oxcategories__oxright = new oxField($oParent->oxcategories__oxright->value + 1, oxField::T_RAW); return parent::_insert(); } else { // root entry if (!$this->getId()) { $this->setId(); } $this->oxcategories__oxrootid = new oxField($this->getId(), oxField::T_RAW); $this->oxcategories__oxleft = new oxField(1, oxField::T_RAW); $this->oxcategories__oxright = new oxField(2, oxField::T_RAW); return parent::_insert(); } }
/** * Sets article creation date * (oxarticle::oxarticles__oxinsert). Then executes parent method * parent::_insert() and returns insertion status. * * @return bool */ protected function _insert() { // set oxinsert $sNow = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime()); $this->oxarticles__oxinsert = new oxField($sNow); if (!is_object($this->oxarticles__oxsubclass) || $this->oxarticles__oxsubclass->value == '') { $this->oxarticles__oxsubclass = new oxField('oxarticle'); } return parent::_insert(); }
/** * Sets article creation date * (oxarticle::oxarticles__oxinsert). Then executes parent method * parent::_insert() and returns insertion status. * * @return bool */ protected function _insert() { // set oxinsert $iInsertTime = time(); $now = date('Y-m-d H:i:s', $iInsertTime); $this->oxarticles__oxinsert = new oxField($now); $this->oxarticles__oxtimestamp = new oxField($now); if (!is_object($this->oxarticles__oxsubclass) || $this->oxarticles__oxsubclass->value == '') { $this->oxarticles__oxsubclass = new oxField('oxarticle'); } return parent::_insert(); }