public function treeGetChildsByIdAction()
{
$assets = [];
$cv = false;
$asset = Asset::getById($this->getParam("node"));
if ($asset->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"));
}
// get assets
$childsList = new Asset\Listing();
if ($this->getUser()->isAdmin()) {
$childsList->setCondition("parentId = ? ", $asset->getId());
} else {
$userIds = $this->getUser()->getRoles();
$userIds[] = $this->getUser()->getId();
$childsList->setCondition("parentId = ? and\n (\n (select list from users_workspaces_asset where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(path,filename),cpath)=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n or\n (select list from users_workspaces_asset where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(path,filename))=1 ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\n )", $asset->getId());
}
$childsList->setLimit($limit);
$childsList->setOffset($offset);
$childsList->setOrderKey("FIELD(assets.type, 'folder') DESC, assets.filename ASC", false);
\Pimcore\Model\Element\Service::addTreeFilterJoins($cv, $childsList);
$childs = $childsList->load();
foreach ($childs as $childAsset) {
if ($childAsset->isAllowed("list")) {
$assets[] = $this->getTreeNodeConfig($childAsset);
}
}
}
if ($this->getParam("limit")) {
$this->_helper->json(["offset" => $offset, "limit" => $limit, "total" => $asset->getChildAmount($this->getUser()), "nodes" => $assets]);
} else {
$this->_helper->json($assets);
}
$this->_helper->json(false);
}