public function saveAction()
 {
     if ($this->_getParam("id")) {
         $link = Document_Link::getById($this->_getParam("id"));
         $this->setValuesToDocument($link);
         $link->setModificationDate(time());
         $link->setUserModification($this->getUser()->getId());
         if ($this->_getParam("task") == "unpublish") {
             $link->setPublished(false);
         }
         if ($this->_getParam("task") == "publish") {
             $link->setPublished(true);
         }
         // only save when publish or unpublish
         if ($this->_getParam("task") == "publish" && $link->isAllowed("publish") || $this->_getParam("task") == "unpublish" && $link->isAllowed("unpublish")) {
             $link->save();
             $this->_helper->json(array("success" => true));
         }
     }
     $this->_helper->json(false);
 }
Esempio n. 2
0
 /**
  * creates a new document
  * @return void
  * @depends testDocumentPageCreate
  */
 public function testDocumentLinkCreate()
 {
     $document = $this->createRandomDocument("link");
     $this->assertTrue($document->getId() > 0);
     $document->setKey($document->getKey() . "_data");
     $document->setProperties($this->getRandomProperties("document"));
     $refetch = Document_Link::getById($document->getId());
     //$this->assertTrue($refetch instanceof Document_Link);
     $linkedDoc = $this->createRandomDocument("page");
     $data["linktype"] = "internal";
     $data["internalType"] = "document";
     $data["internal"] = $linkedDoc->getId();
     $document->setObject($linkedDoc);
     $document->setValues($data);
     $document->save();
     $this->assertTrue(Test_Tool::documentsAreEqual($document, $refetch, false));
 }