Пример #1
0
 /**
  * Loads a list of static routes for the specicifies parameters, returns an array of Staticroute elements
  *
  * @return array
  */
 public function load()
 {
     $itemsData = $this->db->fetchAll("SELECT id FROM recyclebin" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     $items = array();
     foreach ($itemsData as $itemData) {
         $items[] = Element_Recyclebin_Item::getById($itemData["id"]);
     }
     $this->model->setItems($items);
     return $items;
 }
 public function addAction()
 {
     $element = Element_Service::getElementById($this->_getParam("type"), $this->_getParam("id"));
     if ($element) {
         Element_Recyclebin_Item::create($element, $this->getUser());
         $this->_helper->json(array("success" => true));
     } else {
         $this->_helper->json(array("success" => false));
     }
 }
 public function deleteAction()
 {
     if ($this->_getParam("type") == "childs") {
         $parentDocument = Document::getById($this->_getParam("id"));
         $list = new Document_List();
         $list->setCondition("path LIKE '" . $parentDocument->getFullPath() . "/%'");
         $list->setLimit(intval($this->_getParam("amount")));
         $list->setOrderKey("LENGTH(path)", false);
         $list->setOrder("DESC");
         $documents = $list->load();
         $deletedItems = array();
         foreach ($documents as $document) {
             $deletedItems[] = $document->getFullPath();
             $document->delete();
         }
         $this->_helper->json(array("success" => true, "deleted" => $deletedItems));
     } else {
         if ($this->_getParam("id")) {
             $document = Document::getById($this->_getParam("id"));
             if ($document->isAllowed("delete")) {
                 Element_Recyclebin_Item::create($document, $this->getUser());
                 $document->delete();
                 $this->_helper->json(array("success" => true));
             }
         }
     }
     $this->_helper->json(array("success" => false, "message" => "missing_permission"));
 }
Пример #4
0
 public function restoreAction()
 {
     $item = Element_Recyclebin_Item::getById($this->_getParam("id"));
     $item->restore();
     $this->_helper->json(array("success" => true));
 }