Esempio n. 1
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     if ($request->isXmlHttpRequest()) {
         return;
     }
     $module = $request->getModuleName();
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     $isAllowed = false;
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $user = Zend_Auth::getInstance()->getIdentity();
         require_once APPLICATION_PATH . '/modules/core/services/Acl.php';
         $acl = Core_Services_Acl::getInstance();
         if (in_array(strtolower($module . '_' . $controller . '_' . $action), array('default_index_index', 'identity_account_logout'))) {
             $isAllowed = true;
         } else {
             $isAllowed = $acl->isUserOrRoleAllowed($user, $module, $controller, $action);
         }
     }
     if (!$isAllowed) {
         if (Zend_Auth::getInstance()->hasIdentity()) {
             $forwardAction = 'deny';
         } else {
             $forwardAction = 'login';
         }
         $sReturn = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
         $sReturn = base64_encode($sReturn);
         $request->setModuleName('core')->setControllerName('Auth')->setActionName($forwardAction)->setParam('returnUrl', $sReturn)->setDispatched(true);
     }
 }
Esempio n. 2
0
 /**
  * @return Core_Services_Acl
  */
 public static function getInstance()
 {
     if (null == self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }