/** * Initalises the current object, if a systemid was given * @return void */ protected function initObjectInternal() { $arrRow = class_orm_rowcache::getCachedInitRow($this->getSystemid()); if ($arrRow === null) { $this->initRowCache(); $arrRow = class_orm_rowcache::getCachedInitRow($this->getSystemid()); } $this->setArrInitRow(array("system_id" => "")); $this->setStrName($arrRow["system_config_name"]); $this->setStrValue($arrRow["system_config_value"]); $this->setIntType($arrRow["system_config_type"]); $this->setIntModule($arrRow["system_config_module"]); $this->strOldValue = $this->strValue; $this->specialConfigInits(); }
/** * Initializes the object from the database. * Loads all mapped columns to the properties. * Requires that the object is identified by its systemid. * * @return void */ public function initObjectFromDb() { //try to do a default init $objReflection = new class_reflection($this->getObjObject()); if (validateSystemid($this->getObjObject()->getSystemid()) && $this->hasTargetTable()) { if (class_orm_rowcache::getCachedInitRow($this->getObjObject()->getSystemid()) !== null) { $arrRow = class_orm_rowcache::getCachedInitRow($this->getObjObject()->getSystemid()); } else { $strQuery = "SELECT *\n " . $this->getQueryBase() . "\n AND system.system_id = ? "; $arrRow = class_carrier::getInstance()->getObjDB()->getPRow($strQuery, array($this->getObjObject()->getSystemid())); } if (method_exists($this->getObjObject(), "setArrInitRow")) { $this->getObjObject()->setArrInitRow($arrRow); } //get the mapped properties $arrProperties = $objReflection->getPropertiesWithAnnotation(class_orm_base::STR_ANNOTATION_TABLECOLUMN); foreach ($arrProperties as $strPropertyName => $strColumn) { $arrColumn = explode(".", $strColumn); if (count($arrColumn) == 2) { $strColumn = $arrColumn[1]; } if (!isset($arrRow[$strColumn])) { continue; } //skip columns from the system-table, they are set later on if (count($arrColumn) == 2 && $arrColumn[0] == "system") { continue; } $strSetter = $objReflection->getSetter($strPropertyName); if ($strSetter !== null) { call_user_func(array($this->getObjObject(), $strSetter), $arrRow[$strColumn]); } } $this->initAssignmentProperties(); } }
/** * Looks up the rights for a given SystemID and going up the tree if needed (inheritance!) * * @param string $strSystemid * * @return array */ private function getPlainRightRow($strSystemid) { if (class_orm_rowcache::getCachedInitRow($strSystemid) != null && array_key_exists("right_id", class_orm_rowcache::getCachedInitRow($strSystemid))) { $arrRow = class_orm_rowcache::getCachedInitRow($strSystemid); } else { $strQuery = "SELECT *\r\n FROM " . _dbprefix_ . "system,\r\n " . _dbprefix_ . "system_right\r\n WHERE system_id = ?\r\n AND right_id = system_id "; $arrRow = $this->objDb->getPRow($strQuery, array($strSystemid)); } $arrRights = array(); if (isset($arrRow["right_id"])) { $arrRights[self::$STR_RIGHT_VIEW] = $arrRow["right_view"]; $arrRights[self::$STR_RIGHT_EDIT] = $arrRow["right_edit"]; $arrRights[self::$STR_RIGHT_DELETE] = $arrRow["right_delete"]; $arrRights[self::$STR_RIGHT_RIGHT] = $arrRow["right_right"]; $arrRights[self::$STR_RIGHT_RIGHT1] = $arrRow["right_right1"]; $arrRights[self::$STR_RIGHT_RIGHT2] = $arrRow["right_right2"]; $arrRights[self::$STR_RIGHT_RIGHT3] = $arrRow["right_right3"]; $arrRights[self::$STR_RIGHT_RIGHT4] = $arrRow["right_right4"]; $arrRights[self::$STR_RIGHT_RIGHT5] = $arrRow["right_right5"]; $arrRights[self::$STR_RIGHT_CHANGELOG] = isset($arrRow["right_changelog"]) ? $arrRow["right_changelog"] : ""; $arrRights[self::$STR_RIGHT_INHERIT] = (int) $arrRow["right_inherit"]; $arrRights["system_prev_id"] = $arrRow["system_prev_id"]; $arrRights["system_id"] = $arrRow["system_id"]; } else { $arrRights[self::$STR_RIGHT_VIEW] = ""; $arrRights[self::$STR_RIGHT_EDIT] = ""; $arrRights[self::$STR_RIGHT_DELETE] = ""; $arrRights[self::$STR_RIGHT_RIGHT] = ""; $arrRights[self::$STR_RIGHT_RIGHT1] = ""; $arrRights[self::$STR_RIGHT_RIGHT2] = ""; $arrRights[self::$STR_RIGHT_RIGHT3] = ""; $arrRights[self::$STR_RIGHT_RIGHT4] = ""; $arrRights[self::$STR_RIGHT_RIGHT5] = ""; $arrRights[self::$STR_RIGHT_CHANGELOG] = ""; $arrRights[self::$STR_RIGHT_INHERIT] = 1; $arrRights["system_prev_id"] = ""; $arrRights["system_id"] = ""; } return $arrRights; }
/** * 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; }
/** * Get the class name for a system-id. * * @param string $strSystemid * @return string */ public function getClassNameForId($strSystemid) { $strClass = ""; if (isset($this->arrClassCache[$strSystemid])) { $strClass = $this->arrClassCache[$strSystemid]; } else { //maybe the orm handler has already fetched this row $arrCacheRow = class_orm_rowcache::getCachedInitRow($strSystemid); if ($arrCacheRow != null && isset($arrCacheRow["system_class"])) { $strClass = $arrCacheRow["system_class"]; } else { $strQuery = "SELECT * FROM " . _dbprefix_ . "system where system_id = ?"; $arrRow = $this->objDB->getPRow($strQuery, array($strSystemid)); if (isset($arrRow["system_class"])) { $strClass = $arrRow["system_class"]; } } if ($strClass != "") { $this->arrClassCache[$strSystemid] = $strClass; $this->bitCacheSaveRequired = true; } } return $strClass; }
/** * Initialises the current object, if a systemid was given * @return void */ protected function initObjectInternal() { //maybe $arrRow = class_orm_rowcache::getCachedInitRow($this->getSystemid()); if ($arrRow === null) { $strQuery = "SELECT *\n FROM " . _dbprefix_ . "page_element,\n " . _dbprefix_ . "element,\n " . _dbprefix_ . "system_right,\n " . _dbprefix_ . "system\n LEFT JOIN " . _dbprefix_ . "system_date\n ON (system_id = system_date_id)\n WHERE system_id= ?\n AND page_element_ph_element = element_name\n AND system_id = page_element_id\n AND system_id = right_id\n ORDER BY page_element_ph_placeholder ASC,\n system_sort ASC"; $arrRow = $this->objDB->getPRow($strQuery, array($this->getSystemid())); } $this->setArrInitRow($arrRow); if (count($arrRow) > 1) { $this->setStrPlaceholder($arrRow["page_element_ph_placeholder"]); $this->setStrName($arrRow["page_element_ph_name"]); $this->setStrElement($arrRow["page_element_ph_element"]); $this->setStrTitle($arrRow["page_element_ph_title"]); $this->setStrLanguage($arrRow["page_element_ph_language"]); $this->setStrClassAdmin($arrRow["element_class_admin"]); $this->setStrClassPortal($arrRow["element_class_portal"]); $this->setIntCachetime($arrRow["element_cachetime"]); $this->setIntRepeat($arrRow["element_repeat"]); $this->setStrConfigVal1($arrRow["element_config1"]); $this->setStrConfigVal2($arrRow["element_config2"]); $this->setStrConfigVal3($arrRow["element_config3"]); if ($arrRow["system_date_start"] > 0) { $this->intStartDate = $arrRow["system_date_start"]; } if ($arrRow["system_date_end"] > 0) { $this->intEndDate = $arrRow["system_date_end"]; } } }