Example #1
0
 /**
  * Get a list of the sibling documents
  *
  * @param array $objectTypes
  * @param bool $unpublished
  * @return array
  */
 public function getSiblings($objectTypes = array(self::OBJECT_TYPE_OBJECT, self::OBJECT_TYPE_FOLDER), $unpublished = false)
 {
     if ($this->o_siblings === null || $this->lastGetSiblingObjectTypes != $objectTypes) {
         $list = new Listing();
         $list->setUnpublished($unpublished);
         // string conversion because parentId could be 0
         $list->addConditionParam("o_parentId = ?", (string) $this->getParentId());
         $list->addConditionParam("o_id != ?", $this->getId());
         $list->setOrderKey("o_key");
         $list->setObjectTypes($objectTypes);
         $list->setOrder("asc");
         $this->o_siblings = $list->load();
     }
     return $this->o_siblings;
 }
 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));
     }
 }
Example #3
0
 /**
  * @return void
  */
 public function delete()
 {
     // delete all objects using this class
     $list = new Listing();
     $list->setCondition("o_classId = ?", $this->getId());
     $list->load();
     foreach ($list->getObjects() as $o) {
         $o->delete();
     }
     $this->deletePhpClasses();
     // empty object cache
     try {
         Cache::clearTag("class_" . $this->getId());
     } catch (\Exception $e) {
     }
     // empty output cache
     try {
         Cache::clearTag("output");
     } catch (\Exception $e) {
     }
     $customLayouts = new ClassDefinition\CustomLayout\Listing();
     $customLayouts->setCondition("classId = " . $this->getId());
     $customLayouts = $customLayouts->load();
     foreach ($customLayouts as $customLayout) {
         $customLayout->delete();
     }
     $this->getDao()->delete();
 }