public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document"))); } Element\Editlock::lock($this->getParam("id"), "document"); $snippet = Document\Snippet::getById($this->getParam("id")); $modificationDate = $snippet->getModificationDate(); $snippet = $this->getLatestVersion($snippet); $snippet->setVersions(array_splice($snippet->getVersions(), 0, 1)); $snippet->getScheduledTasks(); $snippet->idPath = Element\Service::getIdPath($snippet); $snippet->userPermissions = $snippet->getUserPermissions(); $snippet->setLocked($snippet->isLocked()); $snippet->setParent(null); if ($snippet->getContentMasterDocument()) { $snippet->contentMasterDocumentPath = $snippet->getContentMasterDocument()->getRealFullPath(); } $this->minimizeProperties($snippet); // unset useless data $snippet->setElements(null); if ($snippet->isAllowed("view")) { $this->_helper->json($snippet); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")]); } Element\Editlock::lock($this->getParam("id"), "document"); $link = Document\Hardlink::getById($this->getParam("id")); $link = clone $link; $link->idPath = Element\Service::getIdPath($link); $link->userPermissions = $link->getUserPermissions(); $link->setLocked($link->isLocked()); $link->setParent(null); if ($link->getSourceDocument()) { $link->sourcePath = $link->getSourceDocument()->getRealFullPath(); } $this->addTranslationsData($link); $this->minimizeProperties($link); //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new \Pimcore\Model\Tool\Admin\EventDataContainer(object2array($link)); \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $link, "returnValueContainer" => $returnValueContainer]); if ($link->isAllowed("view")) { $this->_helper->json($returnValueContainer->getData()); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "document")]); } Element\Editlock::lock($this->getParam("id"), "document"); $email = Document\Newsletter::getById($this->getParam("id")); $email = clone $email; $email = $this->getLatestVersion($email); $versions = Element\Service::getSafeVersionInfo($email->getVersions()); $email->setVersions(array_splice($versions, 0, 1)); $email->idPath = Element\Service::getIdPath($email); $email->userPermissions = $email->getUserPermissions(); $email->setLocked($email->isLocked()); $email->setParent(null); // unset useless data $email->setElements(null); $email->childs = null; $this->addTranslationsData($email); $this->minimizeProperties($email); //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new \Pimcore\Model\Tool\Admin\EventDataContainer(object2array($email)); \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $email, "returnValueContainer" => $returnValueContainer]); if ($email->isAllowed("view")) { $this->_helper->json($returnValueContainer->getData()); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document"))); } Element\Editlock::lock($this->getParam("id"), "document"); $page = Document\Page::getById($this->getParam("id")); $page = $this->getLatestVersion($page); $page->setVersions(array_splice($page->getVersions(), 0, 1)); $page->getScheduledTasks(); $page->idPath = Element\Service::getIdPath($page); $page->userPermissions = $page->getUserPermissions(); $page->setLocked($page->isLocked()); $page->setParent(null); if ($page->getContentMasterDocument()) { $page->contentMasterDocumentPath = $page->getContentMasterDocument()->getRealFullPath(); } // get depending redirects $redirectList = new Redirect\Listing(); $redirectList->setCondition("target = ?", $page->getId()); $page->redirects = $redirectList->load(); // unset useless data $page->setElements(null); $page->childs = null; // cleanup properties $this->minimizeProperties($page); if ($page->isAllowed("view")) { $this->_helper->json($page); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (\Pimcore\Model\Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(["editlock" => \Pimcore\Model\Element\Editlock::getByElement($this->getParam("id"), "document")]); } \Pimcore\Model\Element\Editlock::lock($this->getParam("id"), "document"); $page = Document\Printpage::getById($this->getParam("id")); $page = $this->getLatestVersion($page); $page->getVersions(); $page->getScheduledTasks(); $page->idPath = Service::getIdPath($page); $page->userPermissions = $page->getUserPermissions(); $page->setLocked($page->isLocked()); if ($page->getContentMasterDocument()) { $page->contentMasterDocumentPath = $page->getContentMasterDocument()->getRealFullPath(); } $this->addTranslationsData($page); // unset useless data $page->setElements(null); $page->childs = null; // cleanup properties $this->minimizeProperties($page); //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new \Pimcore\Model\Tool\Admin\EventDataContainer(object2array($page)); \Pimcore::getEventManager()->trigger("admin.document.get.preSendData", $this, ["document" => $page, "returnValueContainer" => $returnValueContainer]); if ($page->isAllowed("view")) { $this->_helper->json($returnValueContainer->getData()); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "asset")) { $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "asset")]); } Element\Editlock::lock($this->getParam("id"), "asset"); $asset = Asset::getById(intval($this->getParam("id"))); $asset = clone $asset; if (!$asset instanceof Asset) { $this->_helper->json(["success" => false, "message" => "asset doesn't exist"]); } $asset->setMetadata(Asset\Service::expandMetadataForEditmode($asset->getMetadata())); $asset->setProperties(Element\Service::minimizePropertiesForEditmode($asset->getProperties())); //$asset->getVersions(); $asset->getScheduledTasks(); $asset->idPath = Element\Service::getIdPath($asset); $asset->userPermissions = $asset->getUserPermissions(); $asset->setLocked($asset->isLocked()); $asset->setParent(null); if ($asset instanceof Asset\Text) { $asset->data = $asset->getData(); } if ($asset instanceof Asset\Image) { $imageInfo = []; if ($asset->getWidth() && $asset->getHeight()) { $imageInfo["dimensions"] = []; $imageInfo["dimensions"]["width"] = $asset->getWidth(); $imageInfo["dimensions"]["height"] = $asset->getHeight(); } if (function_exists("exif_read_data") && is_file($asset->getFileSystemPath())) { $supportedTypes = [IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM]; if (in_array(@exif_imagetype($asset->getFileSystemPath()), $supportedTypes)) { $exif = @exif_read_data($asset->getFileSystemPath()); if (is_array($exif)) { $imageInfo["exif"] = []; foreach ($exif as $name => $value) { if (is_string($value) && strlen($value) < 50 || is_numeric($value)) { // this is to ensure that the data can be converted to json (must be utf8) if (mb_check_encoding($value, "UTF-8")) { $imageInfo["exif"][$name] = $value; } } } } } } $asset->imageInfo = $imageInfo; } $asset->setStream(null); //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new Model\Tool\Admin\EventDataContainer(object2array($asset)); \Pimcore::getEventManager()->trigger("admin.asset.get.preSendData", $this, ["asset" => $asset, "returnValueContainer" => $returnValueContainer]); if ($asset->isAllowed("view")) { $this->_helper->json($returnValueContainer->getData()); } $this->_helper->json(["success" => false, "message" => "missing_permission"]); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "asset")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "asset"))); } Element\Editlock::lock($this->getParam("id"), "asset"); $asset = Asset::getById(intval($this->getParam("id"))); if (!$asset instanceof Asset) { $this->_helper->json(array("success" => false, "message" => "asset doesn't exist")); } $asset->setMetadata(Asset\Service::expandMetadataForEditmode($asset->getMetadata())); $asset->setProperties(Element\Service::minimizePropertiesForEditmode($asset->getProperties())); //$asset->getVersions(); $asset->getScheduledTasks(); $asset->idPath = Element\Service::getIdPath($asset); $asset->userPermissions = $asset->getUserPermissions(); $asset->setLocked($asset->isLocked()); $asset->setParent(null); if ($asset instanceof Asset\Text) { $asset->data = $asset->getData(); } if ($asset instanceof Asset\Image) { $imageInfo = array(); if ($asset->getWidth() && $asset->getHeight()) { $imageInfo["dimensions"] = array(); $imageInfo["dimensions"]["width"] = $asset->getWidth(); $imageInfo["dimensions"]["height"] = $asset->getHeight(); } if (function_exists("exif_read_data") && is_file($asset->getFileSystemPath())) { $supportedTypes = array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM); if (in_array(exif_imagetype($asset->getFileSystemPath()), $supportedTypes)) { $exif = @exif_read_data($asset->getFileSystemPath()); if (is_array($exif)) { $imageInfo["exif"] = array(); foreach ($exif as $name => $value) { if (is_string($value) && strlen($value) < 50 || is_numeric($value)) { // this is to ensure that the data can be converted to json (must be utf8) if (mb_check_encoding($value, "UTF-8")) { $imageInfo["exif"][$name] = $value; } } } } } } $asset->imageInfo = $imageInfo; } $asset->setStream(null); if ($asset->isAllowed("view")) { $this->_helper->json($asset); } $this->_helper->json(array("success" => false, "message" => "missing_permission")); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "asset")) { $this->_helper->json(["editlock" => Element\Editlock::getByElement($this->getParam("id"), "asset")]); } Element\Editlock::lock($this->getParam("id"), "asset"); $asset = Asset::getById(intval($this->getParam("id"))); $asset = clone $asset; if (!$asset instanceof Asset) { $this->_helper->json(["success" => false, "message" => "asset doesn't exist"]); } $asset->setMetadata(Asset\Service::expandMetadataForEditmode($asset->getMetadata())); $asset->setProperties(Element\Service::minimizePropertiesForEditmode($asset->getProperties())); //$asset->getVersions(); $asset->getScheduledTasks(); $asset->idPath = Element\Service::getIdPath($asset); $asset->userPermissions = $asset->getUserPermissions(); $asset->setLocked($asset->isLocked()); $asset->setParent(null); if ($asset instanceof Asset\Text) { $asset->data = $asset->getData(); } if ($asset instanceof Asset\Image) { $imageInfo = []; if ($asset->getWidth() && $asset->getHeight()) { $imageInfo["dimensions"] = []; $imageInfo["dimensions"]["width"] = $asset->getWidth(); $imageInfo["dimensions"]["height"] = $asset->getHeight(); } $exifData = $asset->getEXIFData(); if (!empty($exifData)) { $imageInfo["exif"] = $exifData; } $iptcData = $asset->getIPTCData(); if (!empty($exifData)) { $imageInfo["iptc"] = $iptcData; } $imageInfo["exiftoolAvailable"] = (bool) \Pimcore\Tool\Console::getExecutable("exiftool"); $asset->imageInfo = $imageInfo; } $asset->setStream(null); //Hook for modifying return value - e.g. for changing permissions based on object data //data need to wrapped into a container in order to pass parameter to event listeners by reference so that they can change the values $returnValueContainer = new Model\Tool\Admin\EventDataContainer(object2array($asset)); \Pimcore::getEventManager()->trigger("admin.asset.get.preSendData", $this, ["asset" => $asset, "returnValueContainer" => $returnValueContainer]); if ($asset->isAllowed("view")) { $this->_helper->json($returnValueContainer->getData()); } $this->_helper->json(["success" => false, "message" => "missing_permission"]); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document"))); } Element\Editlock::lock($this->getParam("id"), "document"); $folder = Document\Folder::getById($this->getParam("id")); $folder->idPath = Element\Service::getIdPath($folder); $folder->userPermissions = $folder->getUserPermissions(); $folder->setLocked($folder->isLocked()); $folder->setParent(null); $this->minimizeProperties($folder); if ($folder->isAllowed("view")) { $this->_helper->json($folder); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "document"))); } Element\Editlock::lock($this->getParam("id"), "document"); $email = Document\Email::getById($this->getParam("id")); $email = $this->getLatestVersion($email); $email->setVersions(array_splice($email->getVersions(), 0, 1)); $email->idPath = Element\Service::getIdPath($email); $email->userPermissions = $email->getUserPermissions(); $email->setLocked($email->isLocked()); $email->setParent(null); // unset useless data $email->setElements(null); $email->childs = null; // cleanup properties $this->minimizeProperties($email); if ($email->isAllowed("view")) { $this->_helper->json($email); } $this->_helper->json(false); }
public function getDataByIdAction() { // check for lock if (\Pimcore\Model\Element\Editlock::isLocked($this->getParam("id"), "document")) { $this->_helper->json(["editlock" => \Pimcore\Model\Element\Editlock::getByElement($this->getParam("id"), "document")]); } \Pimcore\Model\Element\Editlock::lock($this->getParam("id"), "document"); $page = Document\Printpage::getById($this->getParam("id")); $page = $this->getLatestVersion($page); $page->getVersions(); $page->getScheduledTasks(); $page->idPath = Service::getIdPath($page); $page->userPermissions = $page->getUserPermissions(); $page->setLocked($page->isLocked()); // unset useless data $page->setElements(null); $page->childs = null; // cleanup properties $this->minimizeProperties($page); if ($page->isAllowed("view")) { $this->_helper->json($page); } $this->_helper->json(false); }
public function logoutAction() { $controller = $this; // clear open edit locks for this session \Pimcore\Model\Element\Editlock::clearSession(session_id()); Tool\Session::useSession(function ($adminSession) use($controller) { if ($adminSession->user instanceof User) { \Pimcore::getEventManager()->trigger("admin.login.logout", $controller, ["user" => $adminSession->user]); $adminSession->user = null; } \Zend_Session::destroy(); }); // cleanup pimcore-cookies => 315554400 => strtotime('1980-01-01') setcookie("pimcore_opentabs", false, 315554400, "/"); $this->redirect("/admin/login/"); }
public function getFolderAction() { // check for lock if (Element\Editlock::isLocked($this->getParam("id"), "object")) { $this->_helper->json(array("editlock" => Element\Editlock::getByElement($this->getParam("id"), "object"))); } Element\Editlock::lock($this->getParam("id"), "object"); $object = Object::getById(intval($this->getParam("id"))); if ($object->isAllowed("view")) { $objectData = array(); $objectData["general"] = array(); $objectData["idPath"] = Element\Service::getIdPath($object); $allowedKeys = array("o_published", "o_key", "o_id", "o_type", "o_path", "o_modificationDate", "o_creationDate", "o_userOwner", "o_userModification"); foreach (get_object_vars($object) as $key => $value) { if (strstr($key, "o_") && in_array($key, $allowedKeys)) { $objectData["general"][$key] = $value; } } $objectData["general"]["fullpath"] = $object->getFullPath(); $objectData["general"]["o_locked"] = $object->isLocked(); $objectData["properties"] = Element\Service::minimizePropertiesForEditmode($object->getProperties()); $objectData["userPermissions"] = $object->getUserPermissions(); $objectData["classes"] = $object->getDao()->getClasses(); // grid-config $configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "-user_" . $this->getUser()->getId() . ".psf"; if (is_file($configFile)) { $gridConfig = Tool\Serialize::unserialize(file_get_contents($configFile)); if ($gridConfig) { $objectData["selectedClass"] = $gridConfig["classId"]; } } $this->_helper->json($objectData); } else { \Logger::debug("prevented getting folder id [ " . $object->getId() . " ] because of missing permissions"); $this->_helper->json(array("success" => false, "message" => "missing_permission")); } }
public function unlockElementAction() { Element\Editlock::unlock($this->getParam("id"), $this->getParam("type")); exit; }
public function indexAction() { // IE compatibility //$this->getResponse()->setHeader("X-UA-Compatible", "IE=8; IE=9", true); // clear open edit locks for this session (in the case of a reload, ...) \Pimcore\Model\Element\Editlock::clearSession(session_id()); // check maintenance $maintenance_enabled = false; $manager = Model\Schedule\Manager\Factory::getManager("maintenance.pid"); $lastExecution = $manager->getLastExecution(); if ($lastExecution) { if (time() - $lastExecution < 610) { // maintenance script should run at least every 10 minutes + a little tolerance $maintenance_enabled = true; } } $this->view->maintenance_enabled = \Zend_Json::encode($maintenance_enabled); // configuration $sysConfig = Config::getSystemConfig(); $this->view->config = $sysConfig; //mail settings $mailIncomplete = false; if ($sysConfig->email) { if (!$sysConfig->email->debug->emailaddresses) { $mailIncomplete = true; } if (!$sysConfig->email->sender->email) { $mailIncomplete = true; } if ($sysConfig->email->method == "smtp" && !$sysConfig->email->smtp->host) { $mailIncomplete = true; } } $this->view->mail_settings_complete = \Zend_Json::encode(!$mailIncomplete); // report configuration $this->view->report_config = Config::getReportConfig(); // customviews config $cvConfig = Tool::getCustomViewConfig(); $cvData = array(); if ($cvConfig) { foreach ($cvConfig as $node) { $tmpData = $node; $rootNode = Model\Object::getByPath($tmpData["rootfolder"]); if ($rootNode) { $tmpData["rootId"] = $rootNode->getId(); $tmpData["allowedClasses"] = explode(",", $tmpData["classes"]); $tmpData["showroot"] = (bool) $tmpData["showroot"]; $cvData[] = $tmpData; } } } $this->view->customview_config = $cvData; // upload limit $max_upload = filesize2bytes(ini_get("upload_max_filesize") . "B"); $max_post = filesize2bytes(ini_get("post_max_size") . "B"); $upload_mb = min($max_upload, $max_post); $this->view->upload_max_filesize = $upload_mb; // csrf token $user = $this->getUser(); $this->view->csrfToken = Tool\Session::useSession(function ($adminSession) use($user) { if (!isset($adminSession->csrfToken) && !$adminSession->csrfToken) { $adminSession->csrfToken = sha1(microtime() . $user->getName() . uniqid()); } return $adminSession->csrfToken; }); if (\Pimcore\Tool\Admin::isExtJS6()) { $this->forward("index6"); } }
public function indexAction() { // clear open edit locks for this session (in the case of a reload, ...) \Pimcore\Model\Element\Editlock::clearSession(session_id()); // check maintenance $maintenance_enabled = false; $manager = Model\Schedule\Manager\Factory::getManager("maintenance.pid"); $lastExecution = $manager->getLastExecution(); if ($lastExecution) { if (time() - $lastExecution < 610) { // maintenance script should run at least every 10 minutes + a little tolerance $maintenance_enabled = true; } } $this->view->maintenance_enabled = \Zend_Json::encode($maintenance_enabled); // configuration $sysConfig = Config::getSystemConfig(); $this->view->config = $sysConfig; //mail settings $mailIncomplete = false; if ($sysConfig->email) { if (!$sysConfig->email->debug->emailaddresses) { $mailIncomplete = true; } if (!$sysConfig->email->sender->email) { $mailIncomplete = true; } if ($sysConfig->email->method == "smtp" && !$sysConfig->email->smtp->host) { $mailIncomplete = true; } } $this->view->mail_settings_complete = \Zend_Json::encode(!$mailIncomplete); // report configuration $this->view->report_config = Config::getReportConfig(); $cvData = []; // still needed when publishing objects $cvConfig = Tool::getCustomViewConfig(); if ($cvConfig) { foreach ($cvConfig as $node) { $tmpData = $node; // backwards compatibility $treeType = $tmpData["treetype"] ? $tmpData["treetype"] : "object"; $rootNode = Model\Element\Service::getElementByPath($treeType, $tmpData["rootfolder"]); if ($rootNode) { $tmpData["rootId"] = $rootNode->getId(); $tmpData["allowedClasses"] = $tmpData["classes"] ? explode(",", $tmpData["classes"]) : null; $tmpData["showroot"] = (bool) $tmpData["showroot"]; // Check if a user has privileges to that node if ($rootNode->isAllowed("list")) { $cvData[] = $tmpData; } } } } $this->view->customview_config = $cvData; // upload limit $max_upload = filesize2bytes(ini_get("upload_max_filesize") . "B"); $max_post = filesize2bytes(ini_get("post_max_size") . "B"); $upload_mb = min($max_upload, $max_post); $this->view->upload_max_filesize = $upload_mb; // session lifetime (gc) $session_gc_maxlifetime = ini_get("session.gc_maxlifetime"); if (empty($session_gc_maxlifetime)) { $session_gc_maxlifetime = 120; } $this->view->session_gc_maxlifetime = $session_gc_maxlifetime; // csrf token $user = $this->getUser(); $this->view->csrfToken = Tool\Session::useSession(function ($adminSession) use($user) { if (!isset($adminSession->csrfToken) && !$adminSession->csrfToken) { $adminSession->csrfToken = sha1(microtime() . $user->getName() . uniqid()); } return $adminSession->csrfToken; }); if (\Pimcore\Tool\Admin::isExtJS6()) { $this->forward("index6"); } }