/** * Original function * @see Admin_DocumentController::treeGetChildsByIdAction() */ public function treeGetChildsByIdAction() { $languages = Tool::getValidLanguages(); $language = $this->_getParam("language", reset($languages)); $document = Document::getById($this->getParam("node")); $documents = array(); if ($document->hasChilds()) { $limit = intval($this->getParam("limit")); if (!$this->getParam("limit")) { $limit = 100000000; } $offset = intval($this->getParam("start")); $list = new Document\Listing(); if ($this->getUser()->isAdmin()) { $list->setCondition("parentId = ? ", $document->getId()); } else { $userIds = $this->getUser()->getRoles(); $userIds[] = $this->getUser()->getId(); $list->setCondition("parentId = ? and\r\n (\r\n (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(path,`key`),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\r\n or\r\n (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(path,`key`))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\r\n )", $document->getId()); } $list->setOrderKey("index"); $list->setOrder("asc"); $list->setLimit($limit); $list->setOffset($offset); $childsList = $list->load(); foreach ($childsList as $childDocument) { // only display document if listing is allowed for the current user if ($childDocument->isAllowed("list")) { if ($childDocument instanceof Document\Page && $childDocument->hasProperty('isLanguageRoot') && $childDocument->getProperty('isLanguageRoot') == 1) { if ($childDocument->getKey() == $language) { // $documents[] = $this->getTreeNodeConfig($childDocument); $config = $this->getTreeNodeConfig($childDocument); $config['expanded'] = true; $documents[] = $config; } } else { $documents[] = $this->getTreeNodeConfig($childDocument); } } } } if ($this->getParam("limit")) { $this->_helper->json(array("offset" => $offset, "limit" => $limit, "total" => $document->getChildAmount($this->getUser()), "nodes" => $documents)); } else { $this->_helper->json($documents); } $this->_helper->json(false); }
public function treeGetChildsByIdAction() { $document = Document::getById($this->getParam("node")); $documents = []; $cv = false; if ($document->hasChilds()) { $limit = intval($this->getParam("limit")); if (!$this->getParam("limit")) { $limit = 100000000; } $offset = intval($this->getParam("start")); if ($this->getParam("view")) { $cv = \Pimcore\Model\Element\Service::getCustomViewById($this->getParam("view")); } $list = new Document\Listing(); if ($this->getUser()->isAdmin()) { $list->setCondition("parentId = ? ", $document->getId()); } else { $userIds = $this->getUser()->getRoles(); $userIds[] = $this->getUser()->getId(); $list->setCondition("parentId = ? and\n (\n (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(path,`key`),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n or\n (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(path,`key`))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n )", $document->getId()); } $list->setOrderKey(["index", "id"]); $list->setOrder(["asc", "asc"]); $list->setLimit($limit); $list->setOffset($offset); \Pimcore\Model\Element\Service::addTreeFilterJoins($cv, $list); $childsList = $list->load(); foreach ($childsList as $childDocument) { // only display document if listing is allowed for the current user if ($childDocument->isAllowed("list")) { $documents[] = $this->getTreeNodeConfig($childDocument); } } } if ($this->getParam("limit")) { $this->_helper->json(["offset" => $offset, "limit" => $limit, "total" => $document->getChildAmount($this->getUser()), "nodes" => $documents]); } else { $this->_helper->json($documents); } $this->_helper->json(false); }