/** * @param Object\Concrete $object * @return void */ public function delete(Object\Concrete $object) { // update data for store table $storeTable = $this->model->getDefinition()->getTableName($object->getClass(), false); $this->db->delete($storeTable, $this->db->quoteInto("o_id = ?", $object->getId())); // update data for query table $queryTable = $this->model->getDefinition()->getTableName($object->getClass(), true); $oldData = $this->db->fetchRow("SELECT * FROM " . $queryTable . " WHERE o_id = ?", $object->getId()); $this->db->delete($queryTable, $this->db->quoteInto("o_id = ?", $object->getId())); //update data for relations table $this->db->delete("object_relations_" . $object->getClassId(), "src_id = " . $object->getId() . " AND ownertype = 'objectbrick' AND ownername = '" . $this->model->getFieldname() . "' AND position = '" . $this->model->getType() . "'"); $this->inheritanceHelper = new Object\Concrete\Dao\InheritanceHelper($object->getClassId(), "o_id", $storeTable, $queryTable); $this->inheritanceHelper->resetFieldsToCheck(); $objectVars = get_object_vars($this->model); foreach ($objectVars as $key => $value) { $fd = $this->model->getDefinition()->getFieldDefinition($key); if ($fd) { if ($fd->getQueryColumnType()) { //exclude untouchables if value is not an array - this means data has not been loaded //get changed fields for inheritance if ($fd instanceof Object\ClassDefinition\Data\CalculatedValue) { continue; } if ($fd->isRelationType()) { if ($oldData[$key] != null) { $this->inheritanceHelper->addRelationToCheck($key, $fd); } } else { if ($oldData[$key] != null) { $this->inheritanceHelper->addFieldToCheck($key, $fd); } } if (method_exists($fd, "delete")) { $fd->delete($object); } } } } $this->inheritanceHelper->doDelete($object->getId()); $this->inheritanceHelper->resetFieldsToCheck(); }
/** * @param Object\Concrete $object * @return void */ public function delete($object) { $db = Resource::get(); $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND " . $db->quoteInto("fieldname = ?", $this->getName())); }
/** * @param Object\Concrete $object */ public function delete(Object\Concrete $object) { // empty or create all relevant tables $fieldDef = $object->getClass()->getFieldDefinition($this->model->getFieldname()); foreach ($fieldDef->getAllowedTypes() as $type) { try { $definition = Object\Fieldcollection\Definition::getByKey($type); } catch (\Exception $e) { continue; } $tableName = $definition->getTableName($object->getClass()); try { $this->db->delete($tableName, $this->db->quoteInto("o_id = ?", $object->getId()) . " AND " . $this->db->quoteInto("fieldname = ?", $this->model->getFieldname())); } catch (\Exception $e) { // create definition if it does not exist $definition->createUpdateTable($object->getClass()); } } // empty relation table $this->db->delete("object_relations_" . $object->getClassId(), "ownertype = 'fieldcollection' AND " . $this->db->quoteInto("ownername = ?", $this->model->getFieldname()) . " AND " . $this->db->quoteInto("src_id = ?", $object->getId())); }
/** * @param Concrete $object * @return array */ public static function getValidLayouts(Concrete $object) { $user = AdminTool::getCurrentUser(); $resultList = array(); $isMasterAllowed = $user->getAdmin(); $permissionSet = $object->getPermissions("layouts", $user); $layoutPermissions = self::getLayoutPermissions($object->getClassId(), $permissionSet); if (!$layoutPermissions || isset($layoutPermissions[0])) { $isMasterAllowed = true; } if ($user->getAdmin()) { $superLayout = new ClassDefinition\CustomLayout(); $superLayout->setId(-1); $superLayout->setName("Master (Admin Mode)"); $resultList[-1] = $superLayout; } if ($isMasterAllowed) { $master = new ClassDefinition\CustomLayout(); $master->setId(0); $master->setName("Master"); $resultList[0] = $master; } $classId = $object->getClassId(); $list = new ClassDefinition\CustomLayout\Listing(); $list->setOrderKey("name"); $condition = "classId = " . $list->quote($classId); if (count($layoutPermissions) && !$isMasterAllowed) { $layoutIds = array_values($layoutPermissions); $condition .= " AND id IN (" . implode(",", $layoutIds) . ")"; } $list->setCondition($condition); $list = $list->load(); if (!count($resultList) && !count($list) || count($resultList) == 1 && !count($list)) { return array(); } foreach ($list as $customLayout) { $resultList[$customLayout->getId()] = $customLayout; } return $resultList; }
/** * @param Object\Concrete $object * @return void */ public function delete($object, $params = []) { $db = Db::get(); if ($params && $params["context"] && $params["context"]["containerType"] == "fieldcollection" && $params["context"]["subContainerType"] == "localizedfield") { $context = $params["context"]; $index = $context["index"]; $containerName = $context["fieldname"]; $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND ownertype = 'localizedfield' AND " . $db->quoteInto("ownername LIKE ?", "/fieldcollection~" . $containerName . "/" . $index . "/%") . " AND " . $db->quoteInto("fieldname = ?", $this->getName())); } else { $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND " . $db->quoteInto("fieldname = ?", $this->getName())); } }