public function saveAction() { if ($this->_getParam("id")) { $page = Document_Email::getById($this->_getParam("id")); $page = $this->getLatestVersion($page); $page->getPermissionsForUser($this->getUser()); $page->setUserModification($this->getUser()->getId()); // save to session $key = "document_" . $this->_getParam("id"); $session = new Zend_Session_Namespace("pimcore_documents"); $session->{$key} = $page; if ($this->_getParam("task") == "unpublish") { $page->setPublished(false); } if ($this->_getParam("task") == "publish") { $page->setPublished(true); } // only save when publish or unpublish if ($this->_getParam("task") == "publish" && $page->isAllowed("publish") or $this->_getParam("task") == "unpublish" && $page->isAllowed("unpublish")) { $this->setValuesToDocument($page); try { $page->save(); $this->_helper->json(array("success" => true)); } catch (Exception $e) { Logger::err($e); $this->_helper->json(array("success" => false, "message" => $e->getMessage())); } } else { if ($page->isAllowed("save")) { $this->setValuesToDocument($page); try { $page->saveVersion(); $this->_helper->json(array("success" => true)); } catch (Exception $e) { Logger::err($e); $this->_helper->json(array("success" => false, "message" => $e->getMessage())); } } } } $this->_helper->json(false); }