public function treeGetChildsByIdAction() { $object = Object::getById($this->getParam("node")); $objectTypes = null; $objects = []; if ($object instanceof Object\Concrete) { $class = $object->getClass(); if ($class->getShowVariants()) { $objectTypes = array(Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_VARIANT); } } if (!$objectTypes) { $objectTypes = array(Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_FOLDER); } if ($object->hasChilds($objectTypes)) { $limit = intval($this->getParam("limit")); if (!$this->getParam("limit")) { $limit = 100000000; } $offset = intval($this->getParam("start")); $childsList = new Object\Listing(); $condition = "o_parentId = '" . $object->getId() . "'"; // custom views start if ($this->getParam("view")) { $cvConfig = Tool::getCustomViewConfig(); $cv = $cvConfig[$this->getParam("view") - 1]; if ($cv["classes"]) { $cvConditions = array(); $cvClasses = explode(",", $cv["classes"]); foreach ($cvClasses as $cvClass) { $cvConditions[] = "o_classId = '" . $cvClass . "'"; } $cvConditions[] = "o_type = 'folder'"; if (count($cvConditions) > 0) { $condition .= " AND (" . implode(" OR ", $cvConditions) . ")"; } } } // custom views end if (!$this->getUser()->isAdmin()) { $userIds = $this->getUser()->getRoles(); $userIds[] = $this->getUser()->getId(); $condition .= " AND (\n (select list from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(o_path,o_key),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n OR\n (select list from users_workspaces_object where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(o_path,o_key))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n )"; } $childsList->setCondition($condition); $childsList->setLimit($limit); $childsList->setOffset($offset); $childsList->setOrderKey("FIELD(o_type, 'folder') DESC, o_key ASC", false); $childsList->setObjectTypes($objectTypes); $childs = $childsList->load(); foreach ($childs as $child) { $tmpObject = $this->getTreeNodeConfig($child); if ($child->isAllowed("list")) { $objects[] = $tmpObject; } } } //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new Model\Tool\Admin\EventDataContainer($objects); \Pimcore::getEventManager()->trigger("admin.object.treeGetChildsById.preSendData", $this, array("returnValueContainer" => $returnValueContainer)); if ($this->getParam("limit")) { $this->_helper->json(array("offset" => $offset, "limit" => $limit, "total" => $object->getChildAmount(array(Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_VARIANT), $this->getUser()), "nodes" => $returnValueContainer->getData(), "fromPaging" => intval($this->getParam("fromPaging")))); } else { $this->_helper->json($returnValueContainer->getData()); } }