Inheritance: extends Pimcore\Model\AbstractModel
 /**
  * Loads a list of document-types for the specicifies parameters, returns an array of Document\DocType elements
  *
  * @return array
  */
 public function load()
 {
     $docTypesData = $this->db->fetchCol("SELECT id FROM documents_doctypes" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     $docTypes = array();
     foreach ($docTypesData as $docTypeData) {
         $docTypes[] = Model\Document\DocType::getById($docTypeData);
     }
     $this->model->setDocTypes($docTypes);
     return $docTypes;
 }
Beispiel #2
0
 /**
  * Loads a list of document-types for the specicifies parameters, returns an array of Document\DocType elements
  *
  * @return array
  */
 public function load()
 {
     $docTypesData = $this->db->fetchAll($this->model->getFilter(), $this->model->getOrder());
     $docTypes = array();
     foreach ($docTypesData as $docTypeData) {
         $docTypes[] = Model\Document\DocType::getById($docTypeData["id"]);
     }
     $this->model->setDocTypes($docTypes);
     return $docTypes;
 }
 public function docTypesAction()
 {
     if ($this->getParam("data")) {
         $this->checkPermission("document_types");
         if ($this->getParam("xaction") == "destroy") {
             $id = \Zend_Json::decode($this->getParam("data"));
             $type = Document\DocType::getById($id);
             $type->delete();
             $this->_helper->json(array("success" => true, "data" => array()));
         } else {
             if ($this->getParam("xaction") == "update") {
                 $data = \Zend_Json::decode($this->getParam("data"));
                 // save type
                 $type = Document\DocType::getById($data["id"]);
                 $type->setValues($data);
                 $type->save();
                 $this->_helper->json(array("data" => $type, "success" => true));
             } else {
                 if ($this->getParam("xaction") == "create") {
                     $data = \Zend_Json::decode($this->getParam("data"));
                     unset($data["id"]);
                     // save type
                     $type = Document\DocType::create();
                     $type->setValues($data);
                     $type->save();
                     $this->_helper->json(array("data" => $type, "success" => true));
                 }
             }
         }
     } else {
         // get list of types
         $list = new Document\DocType\Listing();
         if ($this->getParam("sort")) {
             $list->setOrderKey($this->getParam("sort"));
             $list->setOrder($this->getParam("dir"));
         }
         $list->load();
         $docTypes = array();
         foreach ($list->getDocTypes() as $type) {
             if ($this->getUser()->isAllowed($type->getId(), "docType")) {
                 $docTypes[] = $type;
             }
         }
         $this->_helper->json(array("data" => $docTypes, "success" => true, "total" => count($docTypes)));
     }
     $this->_helper->json(false);
 }
 public function docTypesAction()
 {
     if ($this->getParam("data")) {
         $this->checkPermission("document_types");
         if ($this->getParam("xaction") == "destroy") {
             $data = \Zend_Json::decode($this->getParam("data"));
             if (\Pimcore\Tool\Admin::isExtJS6()) {
                 $id = $data["id"];
             } else {
                 $id = $data;
             }
             $type = Document\DocType::getById($id);
             $type->delete();
             $this->_helper->json(["success" => true, "data" => []]);
         } elseif ($this->getParam("xaction") == "update") {
             $data = \Zend_Json::decode($this->getParam("data"));
             // save type
             $type = Document\DocType::getById($data["id"]);
             $type->setValues($data);
             $type->save();
             $this->_helper->json(["data" => $type, "success" => true]);
         } elseif ($this->getParam("xaction") == "create") {
             $data = \Zend_Json::decode($this->getParam("data"));
             unset($data["id"]);
             // save type
             $type = Document\DocType::create();
             $type->setValues($data);
             $type->save();
             $this->_helper->json(["data" => $type, "success" => true]);
         }
     } else {
         // get list of types
         $list = new Document\DocType\Listing();
         $list->load();
         $docTypes = [];
         foreach ($list->getDocTypes() as $type) {
             if ($this->getUser()->isAllowed($type->getId(), "docType")) {
                 $docTypes[] = $type;
             }
         }
         $this->_helper->json(["data" => $docTypes, "success" => true, "total" => count($docTypes)]);
     }
     $this->_helper->json(false);
 }