Beispiel #1
0
 /**
  * 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();
     }
 }
Beispiel #2
0
 /**
  * @param Enlight_Controller_Request_Request $request
  */
 public function refreshBasket($request)
 {
     $currentController = $request->getParam('requestController', $request->getControllerName());
     $sessionId = (string) Enlight_Components_Session::getId();
     if (!empty($currentController) && !empty($sessionId)) {
         $userId = (int) Shopware()->Session()->sUserId;
         $userAgent = (string) $request->getServer("HTTP_USER_AGENT");
         $sql = "\n                UPDATE s_order_basket\n                SET lastviewport = ?,\n                    useragent = ?,\n                    userID = ?\n                WHERE sessionID=?\n            ";
         Shopware()->Db()->query($sql, array($currentController, $userAgent, $userId, $sessionId));
     }
 }
Beispiel #3
0
 /**
  * Returns the full path of the action name.
  * To generate the full action path the module, controller and action name must be set in the given request object.
  * The module, controller and action path is imploded by '_'.
  *
  * @param Enlight_Controller_Request_Request $request
  * @return string
  */
 public function getFullActionName(Enlight_Controller_Request_Request $request)
 {
     $parts = array($this->formatModuleName($request->getModuleName()), $this->formatControllerName($request->getControllerName()), $this->formatActionName($request->getActionName()));
     return implode('_', $parts);
 }
Beispiel #4
0
 /**
  * @param Request $request
  * @return string
  */
 private function buildControllerName(Request $request)
 {
     $controllerName = strtolower($request->getModuleName() . '/' . $request->getControllerName());
     return $controllerName;
 }
Beispiel #5
0
 /**
  * @param Request $request
  */
 protected function initServiceMode($request)
 {
     $config = $this->Application()->Config();
     if (!empty($config->setOffline) && strpos($config->offlineIp, $request->getClientIp()) === false) {
         if ($request->getControllerName() != 'error') {
             $request->setControllerName('error')->setActionName('service')->setDispatched(false);
         }
     }
 }