/** * Writes the resource into persistence (MySQL for now). * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { $this->_status->writeToPersistence(); $sql_fields = "\n\t\t\tstatus_res='" . $this->_status->getID() . "',\n\t\t\teditorsStack_res='" . SensitiveIO::sanitizeSQLString($this->_editors->getTextDefinition()) . "'\n\t\t"; if ($this->_id) { $sql = "\n\t\t\t\tupdate\n\t\t\t\t\tresources\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields . "\n\t\t\t\twhere\n\t\t\t\t\tid_res='" . $this->_id . "'\n\t\t\t"; } else { $sql = "\n\t\t\t\tinsert into\n\t\t\t\t\tresources\n\t\t\t\tset\n\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { return false; } elseif (!$this->_id) { $this->_id = $q->getLastInsertedID(); } return true; }
/** * Writes the block data into persistence (destroys previous and insert new) * * @param integer $pageID The page which contains the client space, DB ID * @param integer $clientSpaceID The client space which contains the row, DB ID * @param integer $rowID The row which contains the block, DB ID * @param integer $location The location we want to completly remove the block from * @param boolean $public The precision needed for USERSPACE location * @param array(mixed=>mixed) $data The data indexed by data type (value, file, alt_tag, ...), * @return boolean true on success, false on failure * @access public */ function writeToPersistence($pageID, $clientSpaceID, $rowID, $location, $public, $data) { if (!SensitiveIO::isInSet($location, CMS_resourceStatus::getAllLocations())) { $this->raiseError("writeToPersistence was given a bad location"); return false; } }
/** * Process the module validations. Note that the EMails sent to either the transferred validator or the editors were sent before. * * @param CMS_resourceValidation $resourceValidation The resource validation to process * @param integer $result The result of the validation process. See VALIDATION_OPTION constants * @return boolean true on success, false on failure to process * @access public */ function processValidation($resourceValidation, $result, $lastValidation = true) { if (!CMS_poly_object_catalog::hasPrimaryResource($this->getCodename())) { $this->raiseError("Module have not any primary resource !"); return false; } if (!$resourceValidation instanceof CMS_resourceValidation) { $this->raiseError("ResourceValidation is not a valid CMS_resourceValidation object"); return false; } if (!SensitiveIO::isInSet($result, CMS_resourceValidation::getAllValidationOptions())) { $this->raiseError("ProcessValidation : result is not a valid validation option"); return false; } //Tell the resource of the changes $resource = $resourceValidation->getResource(); $editions = $resourceValidation->getEditions(); //add a call to all modules for validation specific treatment $modulesCodes = new CMS_modulesCodes(); //add a call to modules after validation $modulesCodes->getModulesCodes(MODULE_TREATMENT_BEFORE_VALIDATION_TREATMENT, '', $resource, array('result' => $result, 'lastvalidation' => $lastValidation, 'module' => $this->_codename)); switch ($result) { case VALIDATION_OPTION_REFUSE: //validation was refused, adjust the array of validations refused $all_editions = CMS_resourceStatus::getAllEditions(); foreach ($all_editions as $aEdition) { if ($aEdition & $editions) { if (RESOURCE_EDITION_LOCATION & $aEdition && $resource->getProposedLocation() == RESOURCE_LOCATION_DELETED) { $resource->removeProposedLocation(); } else { $resource->addValidationRefused($aEdition); } } } break; case VALIDATION_OPTION_ACCEPT: //if one of the edition was the location, only treat this one. Move the data. if ($editions & RESOURCE_EDITION_LOCATION) { if ($resource->getLocation() == RESOURCE_LOCATION_USERSPACE) { //pulling resource out of USERSPACE switch ($resource->getProposedLocation()) { case RESOURCE_LOCATION_DELETED: $locationTo = RESOURCE_DATA_LOCATION_DELETED; break; } //first, move edited $this->_changeDataLocation($resource, RESOURCE_DATA_LOCATION_EDITED, $locationTo); //then delete public $this->_changeDataLocation($resource, RESOURCE_DATA_LOCATION_PUBLIC, RESOURCE_DATA_LOCATION_DEVNULL); //mark item as deleted CMS_modulePolymodValidation::markDeletedItem($resource->getID()); } else { if ($resource->getProposedLocation() == RESOURCE_LOCATION_USERSPACE) { //Pushing resource to USERSPACE switch ($resource->getLocation()) { case RESOURCE_LOCATION_DELETED: $locationFrom = RESOURCE_DATA_LOCATION_DELETED; break; } //if resource was published, copy data to public table if ($resource->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED) { $this->_changeDataLocation($resource, $locationFrom, RESOURCE_DATA_LOCATION_PUBLIC, true); } //move data from its location to edited $this->_changeDataLocation($resource, $locationFrom, RESOURCE_DATA_LOCATION_EDITED); } else { //the move entirely takes place outside of USERSPACE (archived to deleted hopefully) switch ($resource->getLocation()) { case RESOURCE_LOCATION_DELETED: $locationFrom = RESOURCE_DATA_LOCATION_DELETED; break; } switch ($resource->getProposedLocation()) { case RESOURCE_LOCATION_DELETED: $locationTo = RESOURCE_DATA_LOCATION_DELETED; break; } $this->_changeDataLocation($resource, $locationFrom, $locationTo); if ($locationTo == RESOURCE_DATA_LOCATION_DELETED) { //mark item as deleted CMS_modulePolymodValidation::markDeletedItem($resource->getID()); } } } $resource->validateProposedLocation(); } else { $all_editions = CMS_resourceStatus::getAllEditions(); $this->_changeDataLocation($resource, RESOURCE_DATA_LOCATION_EDITED, RESOURCE_DATA_LOCATION_PUBLIC, true); foreach ($all_editions as $aEdition) { if ($aEdition & $editions) { $resource->validateEdition($aEdition); } } } break; } //if resource is a polyobject, we need to save only it resource (parent) status if (!$resource instanceof CMS_poly_object) { $resource->writeToPersistence(); } else { $resource->writeToPersistence(false); //Clear polymod cache //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => $this->_codename)); CMS_cache::clearTypeCache('polymod'); } $modulesCodes->getModulesCodes(MODULE_TREATMENT_AFTER_VALIDATION_TREATMENT, '', $resource, array('result' => $result, 'lastvalidation' => $lastValidation, 'module' => $this->_codename)); return true; }
/** * Deletes the block from a location (public, archived, deleted, edited) * * @param integer $pageID The page which contains the client space, DB ID * @param integer $clientSpaceID The client space which contains the row, DB ID * @param integer $rowID The row which contains the block, DB ID * @param integer $location The location we want to completly remove the block from * @param boolean $public The precision needed for USERSPACE location * @param boolean $withfile : delete the attached file if any (default : false) * @return boolean true on success, false on failure * @access public */ function delFromLocation($pageID, $clientSpaceID, $rowID, $location, $public = false, $withfile = false) { if (!SensitiveIO::isInSet($location, CMS_resourceStatus::getAllLocations())) { $this->raiseError("DelFromLocation was given a bad location"); return false; } if ($withfile) { $data = $this->getRawData($pageID, $clientSpaceID, $rowID, $location, $public); $folder = $this->_getFolderName($location, $public); if ($data['file']) { //get folder for files if (file_exists(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data['file'])) { @unlink(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data['file']); } } if ($data['enlargedFile']) { //get folder for files if (file_exists(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data['enlargedFile'])) { @unlink(PATH_MODULES_FILES_STANDARD_FS . '/' . $folder . '/' . $data['enlargedFile']); } } if ($data['externalLink']) { $link = new CMS_href($data["externalLink"]); $file = $link->getFileLink(true, MOD_STANDARD_CODENAME, $folder, PATH_RELATIVETO_FILESYSTEM); if (file_exists($file)) { @unlink($file); } } } $table = $this->_getDataTableName($location, $public); $sql = "\n\t\t\tdelete from\n\t\t\t\t" . $table . "\n\t\t\twhere\n\t\t\t\tpage='" . $pageID . "'\n\t\t\t\tand clientSpaceID='" . $clientSpaceID . "'\n\t\t\t\tand rowID='" . $rowID . "'\n\t\t\t\tand blockID='" . $this->_tagID . "'\n\t\t"; $q = new CMS_query($sql); return true; }
/** * Write to persistence * * @return boolean true on success, false on failure * @access public */ function writeToPersistence() { $sql_fields = "\n\t\t\t\tuser_log='" . SensitiveIO::sanitizeSQLString($this->_user->getUserId()) . "',\n\t\t\t\taction_log='" . SensitiveIO::sanitizeSQLString($this->_action) . "',\n\t\t\t\tdatetime_log='" . SensitiveIO::sanitizeSQLString($this->_datetime->getDBValue()) . "',\n\t\t\t\ttextData_log='" . SensitiveIO::sanitizeSQLString($this->_textData) . "',\n\t\t\t\tlabel_log='" . SensitiveIO::sanitizeSQLString($this->_label) . "',\n\t\t\t\tmodule_log='" . SensitiveIO::sanitizeSQLString($this->_module) . "',\n\t\t\t\tresource_log='" . SensitiveIO::sanitizeSQLString($this->_resource) . "',\n\t\t\t\trsAfterLocation_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getLocation()) . "',\n\t\t\t\trsAfterProposedFor_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getProposedFor()) . "',\n\t\t\t\trsAfterEditions_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getEditions()) . "',\n\t\t\t\trsAfterValidationsRefused_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getValidationRefused()) . "',\n\t\t\t\trsAfterPublication_log='" . SensitiveIO::sanitizeSQLString($this->_resourceStatusAfter->getPublication()) . "'\t\n\t\t\t"; if ($this->_id) { $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tlog\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields . "\n\t\t\t\t\twhere\n\t\t\t\t\t\tid_log='" . $this->_id . "'\n\t\t\t\t"; } else { $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tlog\n\t\t\t\t\tset\n\t\t\t\t\t\t" . $sql_fields; } $q = new CMS_query($sql); if ($q->hasError()) { return false; } else { $this->_id = $q->getLastInsertedID(); } return true; }
/** * Deletes the block from a location (public, archived, deleted, edited) * * @param integer $pageID The page which contains the client space, DB ID * @param integer $clientSpaceID The client space which contains the row, DB ID * @param integer $rowID The row which contains the block, DB ID * @param integer $location The location we want to completly remove the block from * @param boolean $public The precision needed for USERSPACE location * @return boolean true on success, false on failure * @access public */ function delFromLocation($pageID, $clientSpaceID, $rowID, $location, $public = false) { if (!SensitiveIO::isInSet($location, CMS_resourceStatus::getAllLocations())) { $this->raiseError("DelFromLocation was given a bad location"); return false; } $table = $this->_getDataTableName($location, $public); $sql = "\n\t\t\tdelete from\n\t\t\t\t" . $table . "\n\t\t\twhere\n\t\t\t\tpage='" . $pageID . "'\n\t\t\t\tand clientSpaceID='" . $clientSpaceID . "'\n\t\t\t\tand rowID='" . $rowID . "'\n\t\t\t\tand blockID='" . $this->_tagID . "'\n\t\t"; $q = new CMS_query($sql); return true; }
/** * Data access method : get the status representation HTML string * * @param boolean $tinyOutput If set to true, returns a compact version of the representation. * @return string the status HTML representation * @access public */ function getStatusRepresentation($tinyOutput = false, $user = false, $modCodeName = false, $resourceID = false) { return $this->_status->getHTML($tinyOutput, $user, $modCodeName, $resourceID); }
/** * Deletes the block from a location (public, archived, deleted, edited) * * @param integer $pageID The page which contains the client space, DB ID * @param integer $clientSpaceID The client space which contains the row, DB ID * @param integer $rowID The row which contains the block, DB ID * @param integer $location The location we want to completly remove the block from * @param boolean $public The precision needed for USERSPACE location * @param boolean $withfile : delete the attached file if any (default : false) * @return boolean true on success, false on failure * @access public */ function delFromLocation($pageID, $clientSpaceID, $rowID, $location, $public = false, $withfile = false) { if (!SensitiveIO::isInSet($location, CMS_resourceStatus::getAllLocations())) { $this->raiseError("DelFromLocation was given a bad location"); return false; } if ($withfile) { $data = $this->getRawData($pageID, $clientSpaceID, $rowID, $location, $public); $link = new CMS_href($data["value"]); if ($link->getLinkType() == RESOURCE_LINK_TYPE_FILE) { //get file path $file = $link->getFileLink(true, MOD_STANDARD_CODENAME, $location, PATH_RELATIVETO_FILESYSTEM, true); if (file_exists($file)) { @unlink($file); } } } $table = $this->_getDataTableName($location, $public); $sql = "\n\t\t\tdelete from\n\t\t\t\t" . $table . "\n\t\t\twhere\n\t\t\t\tpage='" . $pageID . "'\n\t\t\t\tand clientSpaceID='" . $clientSpaceID . "'\n\t\t\t\tand rowID='" . $rowID . "'\n\t\t\t\tand blockID='" . $this->_tagID . "'\n\t\t"; $q = new CMS_query($sql); return true; }