/** * @deprecated * @static * @return void */ public static function initSession() { Pimcore_Tool_Authentication::initSession(); }
public function init() { parent::init(); // log exceptions if handled by error_handler $this->checkForErrors(); // general definitions Pimcore::unsetAdminMode(); Document::setHideUnpublished(true); Object_Abstract::setHideUnpublished(true); Object_Abstract::setGetInheritedValues(true); $adminSession = null; // assign variables $this->view->controller = $this; // init website config $config = Pimcore_Config::getWebsiteConfig(); $this->config = $config; $this->view->config = $config; if (!$this->_getParam("document")) { Zend_Registry::set("pimcore_editmode", false); $this->editmode = false; $this->view->editmode = false; // no document available, continue, ... return; } else { $this->setDocument($this->_getParam("document")); } if ($this->_getParam("pimcore_editmode") || $this->_getParam("pimcore_version") || $this->_getParam("pimcore_preview") || $this->_getParam("pimcore_admin") || $this->_getParam("pimcore_object_preview")) { $specialAdminRequest = true; Pimcore_Tool_Authentication::initSession(); // start admin session $adminSession = new Zend_Session_Namespace("pimcore_admin"); } if (!$this->document->isPublished()) { if ($specialAdminRequest) { if (!$adminSession->user instanceof User) { throw new Exception("access denied for " . $this->document->getFullPath()); } } else { throw new Exception("access denied for " . $this->document->getFullPath()); } } // register global locale if the document has the system property "language" if ($this->document->getProperty("language")) { $locale = new Zend_Locale($this->document->getProperty("language")); Zend_Registry::set('Zend_Locale', $locale); } // for editmode if ($adminSession && $adminSession->user instanceof User) { if ($this->_getParam("pimcore_editmode") and !Zend_Registry::isRegistered("pimcore_editmode")) { Zend_Registry::set("pimcore_editmode", true); // check if there is the document in the session $docKey = "document_" . $this->getDocument()->getId(); $docSession = new Zend_Session_Namespace("pimcore_documents"); if ($docSession->{$docKey}) { // if there is a document in the session use it $this->setDocument($docSession->{$docKey}); } else { // set the latest available version for editmode if there is no doc in the session $latestVersion = $this->getDocument()->getLatestVersion(); if ($latestVersion) { $latestDoc = $latestVersion->loadData(); if ($latestDoc instanceof Document_PageSnippet) { $this->setDocument($latestDoc); } } } // register editmode plugin $front = Zend_Controller_Front::getInstance(); $front->registerPlugin(new Pimcore_Controller_Plugin_Frontend_Editmode($this), 1000); } else { Zend_Registry::set("pimcore_editmode", false); } } else { Zend_Registry::set("pimcore_editmode", false); } // for preview if ($adminSession && $adminSession->user instanceof User) { // document preview if ($this->_getParam("pimcore_preview")) { // get document from session $docKey = "document_" . $this->_getParam("document")->getId(); $docSession = new Zend_Session_Namespace("pimcore_documents"); if ($docSession->{$docKey}) { $this->setDocument($docSession->{$docKey}); } } // object preview if ($this->_getParam("pimcore_object_preview")) { $key = "object_" . $this->_getParam("pimcore_object_preview"); $session = new Zend_Session_Namespace("pimcore_objects"); if ($session->{$key}) { $object = $session->{$key}; // add the object to the registry so every call to Object_Abstract::getById() will return this object instead of the real one Zend_Registry::set("object_" . $object->getId(), $object); } } } // for version preview if ($this->_getParam("pimcore_version")) { if ($adminSession && $adminSession->user instanceof User) { // only get version data at the first call || because of embedded Snippets ... try { Zend_Registry::get("pimcore_version_active"); } catch (Exception $e) { $version = Version::getById($this->_getParam("pimcore_version")); $this->setDocument($version->getData()); Zend_Registry::set("pimcore_version_active", true); } } } // for public versions if ($this->_getParam("v")) { try { $version = Version::getById($this->_getParam("v")); if ($version->getPublic()) { $this->setDocument($version->getData()); } } catch (Exception $e) { } } // set some parameters $this->editmode = Zend_Registry::get("pimcore_editmode"); $this->view->editmode = Zend_Registry::get("pimcore_editmode"); }