/** * Loads the data of the current element * * @return mixed */ public final function loadElementData() { $objAnnotations = new class_reflection($this); $arrTargetTables = $objAnnotations->getAnnotationValuesFromClass(class_orm_base::STR_ANNOTATION_TARGETTABLE); $strTargetTable = ""; if (count($arrTargetTables) != 0) { $arrCachedRow = class_orm_rowcache::getCachedInitRow($this->getSystemid()); if ($arrCachedRow !== null && !isset($arrCachedRow["content_id"])) { class_orm_rowcache::removeSingleRow($this->getSystemid()); } $objORM = new class_orm_objectinit($this); $objORM->initObjectFromDb(); $arrTables = explode(".", $arrTargetTables[0]); $strTargetTable = _dbprefix_ . $arrTables[0]; } else { if ($this->getArrModule("table") != "") { $strTargetTable = $this->getArrModule("table"); } } $objORM = new class_orm_objectlist(); //Element-Table given? if ($strTargetTable != "") { $strQuery = "SELECT *\n \t\t\t\t\t FROM " . $strTargetTable . ",\n \t\t\t\t\t \t " . _dbprefix_ . "element,\n \t\t\t\t\t \t " . _dbprefix_ . "page_element,\n \t\t\t\t\t \t " . _dbprefix_ . "system_right,\n \t\t\t\t\t \t " . _dbprefix_ . "system\n \t\t\t\t\t LEFT JOIN " . _dbprefix_ . "system_date\n \t\t\t\t\t ON (system_id = system_date_id)\n \t\t\t\t\t WHERE element_name = page_element_ph_element\n \t\t\t\t\t AND page_element_id = content_id\n \t\t\t\t\t AND system_id = right_id\n \t\t\t\t\t AND system_id = content_id\n \t\t\t\t\t " . $objORM->getDeletedWhereRestriction() . "\n \t\t\t\t\t AND system_id = ? "; } else { $strQuery = "SELECT *\n \t\t\t\t\t FROM " . _dbprefix_ . "element,\n \t\t\t\t\t \t " . _dbprefix_ . "page_element,\n \t\t\t\t\t \t " . _dbprefix_ . "system_right,\n \t\t\t\t\t \t " . _dbprefix_ . "system\n \t\t\t\t\t LEFT JOIN " . _dbprefix_ . "system_date\n \t\t\t\t\t ON (system_id = system_date_id)\n \t\t\t\t\t WHERE element_name = page_element_ph_element\n \t\t\t\t\t AND page_element_id = system_id\n \t\t\t\t\t AND system_id = right_id\n \t\t\t\t\t " . $objORM->getDeletedWhereRestriction() . "\n \t\t\t\t\t AND system_id = ? "; } $this->arrElementData = class_carrier::getInstance()->getObjDB()->getPRow($strQuery, array($this->getSystemid())); class_orm_rowcache::addSingleInitRow($this->arrElementData); return $this->arrElementData; }
/** * Deletes the object from the database. The record is removed in total, so no restoring will be possible. * * @return bool * @throws class_exception */ public function deleteObjectFromDatabase() { if (!$this->getLockManager()->isAccessibleForCurrentUser()) { return false; } if ($this instanceof interface_versionable) { $objChanges = new class_module_system_changelog(); $objChanges->createLogEntry($this, class_module_system_changelog::$STR_ACTION_DELETE); } /** @var $this class_root|interface_model */ $this->objDB->transactionBegin(); //validate, if there are subrecords, so child nodes to be deleted $arrChilds = $this->objDB->getPArray("SELECT system_id FROM " . _dbprefix_ . "system where system_prev_id = ?", array($this->getSystemid())); foreach ($arrChilds as $arrOneChild) { if (validateSystemid($arrOneChild["system_id"])) { $objInstance = class_objectfactory::getInstance()->getObject($arrOneChild["system_id"]); if ($objInstance !== null) { $objInstance->deleteObjectFromDatabase(); } } } $objORM = new class_orm_objectdelete($this); $bitReturn = $objORM->deleteObject(); $this->objSortManager->fixSortOnDelete(); $bitReturn = $bitReturn && $this->deleteSystemRecord($this->getSystemid()); class_objectfactory::getInstance()->removeFromCache($this->getSystemid()); class_orm_rowcache::removeSingleRow($this->getSystemid()); //try to call other modules, maybe wanting to delete anything in addition, if the current record //is going to be deleted $bitReturn = $bitReturn && class_core_eventdispatcher::getInstance()->notifyGenericListeners(class_system_eventidentifier::EVENT_SYSTEM_RECORDDELETED, array($this->getSystemid(), get_class($this))); if ($bitReturn) { class_logger::getInstance()->addLogRow("successfully deleted record " . $this->getSystemid() . " / " . $this->getStrDisplayName(), class_logger::$levelInfo); $this->objDB->transactionCommit(); $this->objDB->flushQueryCache(); return true; } else { class_logger::getInstance()->addLogRow("error deleting record " . $this->getSystemid() . " / " . $this->getStrDisplayName(), class_logger::$levelInfo); $this->objDB->transactionRollback(); $this->objDB->flushQueryCache(); return false; } }