/** * Changes The item data (in the DB) from one location to another. * * @param CMS_resource $resource The resource concerned by the data location change * @param string $locationFrom The starting location among "edited", "edition", "public", "archived", "deleted" * @param string $locationTo The ending location among "edited", "edition", "public", "archived", "deleted" * @param boolean $copyOnly If true, data is not deleted from the original location * @return void * @access private */ protected function _changeDataLocation($resource, $locationFrom, $locationTo, $copyOnly = false) { if (is_array($this->_resourceInfo) && $this->_resourceInfo) { if (!parent::_changeDataLocation($resource, $locationFrom, $locationTo, $copyOnly)) { return false; } foreach ($this->_resourceInfo as $tableName => $tableInfo) { //move the data CMS_modulesCatalog::moveResourceData($this, $tableName, $tableInfo['key'], $resource->getID(), $locationFrom, $locationTo, $copyOnly); } } }
/** * Changes The item data (in the DB) from one location to another. * * @param CMS_resource $resource The resource concerned by the data location change * @param string $locationFrom The starting location among "edited", "edition", "public", "archived", "deleted" * @param string $locationTo The ending location among "edited", "edition", "public", "archived", "deleted" * @param boolean $copyOnly If true, data is not deleted from the original location * @return void * @access private */ protected function _changeDataLocation($resource, $locationFrom, $locationTo, $copyOnly = false) { //check queried data location change if (!parent::_changeDataLocation($resource, $locationFrom, $locationTo, $copyOnly)) { return false; } //get all secondary resources concerned by this validation $secondaryResourceIds = $resource->getAllSecondaryResourcesForPrimaryResource(); if (is_array($secondaryResourceIds) && $secondaryResourceIds) { foreach ($secondaryResourceIds as $secondaryResourceId) { if ($locationTo != RESOURCE_DATA_LOCATION_DELETED && $locationTo != RESOURCE_DATA_LOCATION_DEVNULL) { //move the data CMS_modulePolymodValidation::moveResourceData($this->getCodename(), $secondaryResourceId, $locationFrom, $locationTo, $copyOnly); } } } //then move resource data for concerned resource CMS_modulePolymodValidation::moveResourceData($this->getCodename(), $resource->getID(), $locationFrom, $locationTo, $copyOnly); }
/** * Changes The page data (in the DB) from one location to another. * * @param CMS_page $resource The resource concerned by the data location change * @param string $locationFrom The starting location among "edited", "edition", "public", "archived", "deleted" * @param string $locationTo The ending location among "edited", "edition", "public", "archived", "deleted" * @param boolean $copyOnly If true, data is not deleted from the original location * @return void * @access private */ function _changeDataLocation($resource, $locationFrom, $locationTo, $copyOnly = false) { if (!parent::_changeDataLocation($resource, $locationFrom, $locationTo, $copyOnly)) { return false; } // Move the client spaces $tpl = $resource->getTemplate(); if ($tpl instanceof CMS_pageTemplate && $tpl->getID() > 0) { CMS_moduleClientspace_standard_catalog::moveClientSpaces($tpl->getID(), $locationFrom, $locationTo, $copyOnly); } else { CMS_grandFather::raiseError("Bad template found for page " . $resourceID); return false; } // Move the blocks CMS_blocksCatalog::moveBlocks($resource, $locationFrom, $locationTo, $copyOnly); // Move data to the new location (delete data there before) if ($locationTo != RESOURCE_DATA_LOCATION_DEVNULL) { $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\tpagesBaseData_" . $locationTo . "\n\t\t\t\twhere\n\t\t\t\t\tpage_pbd='" . $resource->getID() . "';\n\t\t\t"; $q = new CMS_query($sql); //here we have a bug with insert into... so try with a replace $sql = "\n\t\t\t\treplace into\n\t\t\t\t\tpagesBaseData_" . $locationTo . "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tpagesBaseData_" . $locationFrom . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tpage_pbd='" . $resource->getID() . "'\n\t\t\t"; $q = new CMS_query($sql); } if (!$copyOnly) { $sql = "\n\t\t\t\tdelete from\n\t\t\t\t\tpagesBaseData_" . $locationFrom . "\n\t\t\t\twhere\n\t\t\t\t\tpage_pbd='" . $resource->getID() . "'\n\t\t\t"; $q = new CMS_query($sql); } }