/** * Updates object information in DB. */ protected function _update() { $this->oxnews__oxdate->setValue(oxRegistry::get("oxUtilsDate")->formatDBDate($this->oxnews__oxdate->value, true)); parent::_update(); }
/** * Updates category tree, returns true on success. * * @return bool */ protected function _update() { $this->setUpdateSeo(true); $this->_setUpdateSeoOnFieldChange('oxtitle'); $oDb = oxDb::getDb(); $sOldParentID = $oDb->getOne("select oxparentid from oxcategories where oxid = " . $oDb->quote($this->getId()), false, false); if ($this->_blIsSeoObject && $this->isAdmin()) { oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this); } $blRes = parent::_update(); // #872C - need to update category tree oxleft and oxright values (nested sets), // then sub trees are moved inside one root, or to another root. // this is done in 3 basic steps // 1. increase oxleft and oxright values of target root tree by $iTreeSize, where oxleft>=$iMoveAfter , oxright>=$iMoveAfter // 2. modify current subtree, we want to move by adding $iDelta to it's oxleft and oxright, where oxleft>=$sOldParentLeft and oxright<=$sOldParentRight values, // in this step we also modify rootid's if they were changed // 3. decreasing oxleft and oxright values of current root tree, where oxleft >= $sOldParentRight+1 , oxright >= $sOldParentRight+1 // did we change position in tree ? if ($this->oxcategories__oxparentid->value != $sOldParentID) { $sOldParentLeft = $this->oxcategories__oxleft->value; $sOldParentRight = $this->oxcategories__oxright->value; $iTreeSize = $sOldParentRight - $sOldParentLeft + 1; $sNewRootID = $oDb->getOne("select oxrootid from oxcategories where oxid = " . $oDb->quote($this->oxcategories__oxparentid->value), false, false); //If empty rootID, we set it to categorys oxid if ($sNewRootID == "") { //echo "<br>* ) Creating new root tree ( {$this->_sOXID} )"; $sNewRootID = $this->getId(); } $sNewParentLeft = $oDb->getOne("select oxleft from oxcategories where oxid = " . $oDb->quote($this->oxcategories__oxparentid->value), false, false); //if(!$sNewParentLeft){ //the current node has become root node, (oxrootid == "oxrootid") // $sNewParentLeft = 0; //} $iMoveAfter = $sNewParentLeft + 1; //New parentid can not be set to it's child if ($sNewParentLeft > $sOldParentLeft && $sNewParentLeft < $sOldParentRight && $this->oxcategories__oxrootid->value == $sNewRootID) { //echo "<br>* ) Can't asign category to it's child"; //Restoring old parentid, stoping further actions $sRestoreOld = "UPDATE oxcategories SET OXPARENTID = " . $oDb->quote($sOldParentID) . " WHERE oxid = " . $oDb->quote($this->getId()); $oDb->execute($sRestoreOld); return false; } //Old parent will be shifted too, if it is in the same tree if ($sOldParentLeft > $iMoveAfter && $this->oxcategories__oxrootid->value == $sNewRootID) { $sOldParentLeft += $iTreeSize; $sOldParentRight += $iTreeSize; } $iDelta = $iMoveAfter - $sOldParentLeft; //echo "Size=$iTreeSize, NewStart=$iMoveAfter, delta=$iDelta"; $sAddOld = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = " . $oDb->quote($this->oxcategories__oxrootid->value) . ";"; $sAddNew = " and oxshopid = '" . $this->getShopId() . "' and OXROOTID = " . $oDb->quote($sNewRootID) . ";"; //Updating everything after new position $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT + " . $iTreeSize . ") WHERE OXLEFT >= " . $iMoveAfter . $sAddNew); $oDb->execute("UPDATE oxcategories SET OXRIGHT = (OXRIGHT + " . $iTreeSize . ") WHERE OXRIGHT >= " . $iMoveAfter . $sAddNew); //echo "<br>1.) + $iTreeSize, >= $iMoveAfter"; $sChangeRootID = ""; if ($this->oxcategories__oxrootid->value != $sNewRootID) { //echo "<br>* ) changing root IDs ( {$this->oxcategories__oxrootid->value} -> {$sNewRootID} )"; $sChangeRootID = ", OXROOTID=" . $oDb->quote($sNewRootID); } //Updating subtree $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT + " . $iDelta . "), OXRIGHT = (OXRIGHT + " . $iDelta . ") " . $sChangeRootID . " WHERE OXLEFT >= " . $sOldParentLeft . " AND OXRIGHT <= " . $sOldParentRight . $sAddOld); //echo "<br>2.) + $iDelta, >= $sOldParentLeft and <= $sOldParentRight"; //Updating everything after old position $oDb->execute("UPDATE oxcategories SET OXLEFT = (OXLEFT - " . $iTreeSize . ") WHERE OXLEFT >= " . ($sOldParentRight + 1) . $sAddOld); $oDb->execute("UPDATE oxcategories SET OXRIGHT = (OXRIGHT - " . $iTreeSize . ") WHERE OXRIGHT >= " . ($sOldParentRight + 1) . $sAddOld); //echo "<br>3.) - $iTreeSize, >= ".($sOldParentRight+1); } if ($blRes && $this->_blIsSeoObject && $this->isAdmin()) { oxRegistry::get("oxSeoEncoderCategory")->markRelatedAsExpired($this); } return $blRes; }
/** * Executes oxarticle::_skipSaveFields() and updates article information * * @return bool */ protected function _update() { $this->_skipSaveFields(); $myConfig = $this->getConfig(); return parent::_update(); }
/** * Executes oxArticle::_skipSaveFields() and updates article information * * @return bool */ protected function _update() { $this->setUpdateSeo(true); $this->_setUpdateSeoOnFieldChange('oxtitle'); $this->_skipSaveFields(); $blRes = parent::_update(); return $blRes; }
/** * Updates object information in DB. * * @return null */ protected function _update() { $this->oxnews__oxdate->setValue(oxUtilsDate::getInstance()->formatDBDate($this->oxnews__oxdate->value, true)); parent::_update(); }