/** * This pre-dispatch event-hook checks backend permissions * * @param \Enlight_Event_EventArgs $args * @throws Enlight_Controller_Exception * @return void */ public function onPreDispatchBackend(Enlight_Event_EventArgs $args) { $this->action = $args->getSubject(); $this->request = $this->action->Request(); $this->aclResource = strtolower($this->request->getControllerName()); if ($this->request->getModuleName() != 'backend' || in_array($this->aclResource, array('error'))) { return; } if ($this->shouldAuth()) { if ($this->checkAuth() === null) { if ($this->request->isXmlHttpRequest()) { throw new Enlight_Controller_Exception('Unauthorized', 401); } else { $this->action->redirect('backend/'); } } } else { $this->initLocale(); } }
/** * Sets the shopware cache headers */ public function setControllerOptions() { $controllerName = $this->request->getModuleName() . '/' . $this->request->getControllerName(); if(isset($this->controllerOptions[$controllerName]) && $this->request->getParam('rewriteUrl')) { $options = $this->controllerOptions[$controllerName]; $query = $this->request->getQuery(); $result = array_intersect_key($query, $options); $cookie = 'controller-options-' . $this->request->getBaseUrl() . $this->request->getPathInfo(); if(count($result) > 0) { $options = $this->request->getCookie($cookie); if($options !== null) { parse_str($options, $options); } else { $options = array(); } $options = array_merge($options, $result); ksort($options); $options = http_build_query($options, '', '&'); $this->response->setCookie( $cookie, $options, 0, null, //$this->request->getBasePath() . '/', $this->request->getHttpHost() ); $location = array_diff($query, $result); $location = $this->action->Front()->Router()->assemble($location); $this->action->redirect($location); } else { $options = $this->request->getCookie($cookie); if($options !== null) { parse_str($options, $options); $this->request->setQuery($options); } } } }