コード例 #1
0
 public function deleteAction()
 {
     if ($this->getParam("type") == "childs") {
         $parentObject = Object::getById($this->getParam("id"));
         $list = new Object\Listing();
         $list->setCondition("o_path LIKE '" . $parentObject->getFullPath() . "/%'");
         $list->setLimit(intval($this->getParam("amount")));
         $list->setOrderKey("LENGTH(o_path)", false);
         $list->setOrder("DESC");
         $objects = $list->load();
         $deletedItems = array();
         foreach ($objects as $object) {
             $deletedItems[] = $object->getFullPath();
             if ($object->isAllowed("delete")) {
                 $object->delete();
             }
         }
         $this->_helper->json(array("success" => true, "deleted" => $deletedItems));
     } elseif ($this->getParam("id")) {
         $object = Object::getById($this->getParam("id"));
         if ($object) {
             if (!$object->isAllowed("delete")) {
                 $this->_helper->json(array("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(array("success" => true));
     }
 }