예제 #1
0
 /**
  * This methods sets the nocache-cookie if actions in the shop are triggerd
  */
 public function setNoCacheCookie()
 {
     $controllerName = $this->buildControllerName($this->request);
     if (isset($this->autoNoCacheControllers[$controllerName])) {
         $noCacheTag = $this->autoNoCacheControllers[$controllerName];
         $this->setNoCacheTag($noCacheTag);
     }
     if ($controllerName == 'frontend/checkout' || $controllerName == 'frontend/note') {
         if (empty(Shopware()->Session()->sBasketQuantity) && empty(Shopware()->Session()->sNotesQuantity)) {
             // remove checkout-cookie
             $this->setNoCacheTag('checkout', true);
         }
     }
     if ($controllerName == 'frontend/compare' && $this->request->getActionName() == 'delete_all') {
         // remove compare cookie
         $this->setNoCacheTag('compare', true);
     }
     if (!empty(Shopware()->Session()->sNotesQuantity)) {
         // set checkout-cookie
         $this->setNoCacheTag('checkout');
     }
     if ($this->request->getModuleName() == 'frontend' && !empty(Shopware()->Session()->Admin)) {
         // set admin-cookie if admin session is present
         $this->setNoCacheTag('admin');
     }
     if ($controllerName == 'frontend/account') {
         if (in_array($this->request->getActionName(), array('ajax_logout', 'logout'))) {
             $this->setNoCacheTag('');
         }
     }
 }
예제 #2
0
 /**
  * @return null|Shopware_Components_Auth
  * @throws Enlight_Controller_Exception
  */
 public function checkAuth()
 {
     /** @var $auth Shopware_Components_Auth */
     $auth = Shopware()->Auth();
     if ($auth->hasIdentity()) {
         $auth->refresh();
     }
     $this->initLocale();
     if ($auth->hasIdentity()) {
         $identity = $auth->getIdentity();
         $this->acl = Shopware()->Acl();
         $this->aclRole = $identity->role;
         if (!$this->acl->has($this->aclResource)) {
             return $auth;
         }
         $actionName = $this->request->getActionName();
         if ($this->action instanceof Shopware_Controllers_Backend_ExtJs) {
             $rules = $this->action->getAclRules();
         }
         if (isset($rules[$actionName])) {
             $test = $rules[$actionName];
         } else {
             $test = array('privilege' => 'read');
         }
         if (!$this->isAllowed($test)) {
             throw new Enlight_Controller_Exception($test['errorMessage'] ?: 'Permission denied', 401);
         } else {
             return $auth;
         }
     }
     return null;
 }
예제 #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);
 }