public function deleteAction()
{
if ($this->getParam("type") == "childs") {
$parentObject = Object::getById($this->getParam("id"));
$list = new Object\Listing();
$list->setCondition("o_path LIKE '" . $parentObject->getRealFullPath() . "/%'");
$list->setLimit(intval($this->getParam("amount")));
$list->setOrderKey("LENGTH(o_path)", false);
$list->setOrder("DESC");
$objects = $list->load();
$deletedItems = [];
foreach ($objects as $object) {
$deletedItems[] = $object->getRealFullPath();
if ($object->isAllowed("delete")) {
$object->delete();
}
}
$this->_helper->json(["success" => true, "deleted" => $deletedItems]);
} elseif ($this->getParam("id")) {
$object = Object::getById($this->getParam("id"));
if ($object) {
if (!$object->isAllowed("delete")) {
$this->_helper->json(["success" => false, "message" => "missing_permission"]);
} else {
$object->delete();
}
}
// return true, even when the object doesn't exist, this can be the case when using batch delete incl. children
$this->_helper->json(["success" => true]);
}
}