예제 #1
0
 public function isAllowed($privilege)
 {
     $id = $this->_session->getSessionId();
     if (!is_null($id)) {
         $user = $this->_userRepo->get($id);
         if (!is_null($user)) {
             if ($this->_acl->isAllowed($user->getRole(), $this->_resource, $privilege)) {
                 return true;
             } else {
                 $this->redirect('home/notprivileged?resource=' . $this->_resource . '&privilege=' . $privilege . '&role=' . $user->getRole());
             }
         }
     }
     $this->login();
 }
예제 #2
0
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #3
0
 public function __construct()
 {
     $this->openConnection();
     $this->_userId = 0;
     if (0 !== strpos($_SERVER['REQUEST_URI'], '/cron')) {
         $this->_userId = Application_Service_Session::getInstance()->getSessionId();
     }
 }
예제 #4
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $publicControllers = ['cron', 'index', 'share'];
     if (false !== array_search($request->getControllerName(), $publicControllers)) {
         return;
     }
     $user = Application_Model_UserRepository::getInstance()->get(Application_Service_Session::getInstance()->getSessionId());
     if ($user && 'admin' === $user->getRole()) {
         return;
     }
     $request->setModuleName('default');
     $request->setControllerName('maintenance');
     $request->setActionName('index');
 }