예제 #1
0
 public function beforeAction($handlerAdapter)
 {
     $this->_m = $handlerAdapter->getModule();
     $this->_c = $handlerAdapter->getController();
     $this->_a = $handlerAdapter->getAction();
     $this->_mc = $this->_m . '/' . $this->_c;
     $this->_mca = $this->_mc . '/' . $this->_a;
     $this->_setPreCache($this->_m, $this->_mc, $this->_mca);
     $this->loginUser = Wekit::getLoginUser();
     $this->_setPreHook($this->_m, $this->_mc, $this->_mca);
     $config = Wekit::C('site');
     if ($config['visit.state'] > 0) {
         $service = Wekit::load('site.srv.PwSiteStatusService');
         $resource = $service->siteStatus($this->loginUser, $config);
         if ($resource instanceof PwError) {
             if (!($config['visit.state'] == 1 && $this->_mc == 'u/login')) {
                 $this->showError($resource->getError());
             }
         }
     }
     if (!in_array($this->_mc, array('u/login', 'u/register', 'u/findPwd')) && !$this->loginUser->getPermission('allow_visit')) {
         if ($this->loginUser->isExists()) {
             if ($this->_mca != 'u/login/logout') {
                 $this->showError(array('permission.visit.allow', array('{grouptitle}' => $this->loginUser->getGroupInfo('name'))));
             }
         } else {
             $this->forwardAction('u/login/run');
         }
     }
     if ($config['refreshtime'] > 0 && Wind::getApp()->getRequest()->isGet() && !Wind::getApp()->getRequest()->getIsAjaxRequest()) {
         if (Wekit::app()->lastRequestUri == Wekit::app()->requestUri && Wekit::app()->lastvisit + $config['refreshtime'] > Pw::getTime()) {
             $this->showError('SITE:refresh.fast');
         }
     }
     $debug = $config['debug'] || !$config['css.compress'];
     Wekit::setGlobal(array('debug' => $debug ? '/dev' : '/build'), 'theme');
     $this->setTheme('site', null);
 }