|  |  |  | 
|---|
|  |  |  | public $layout = APP_ROOT.'/modules/Admin/views/layout/adminLayout.phtml'; | 
|---|
|  |  |  | public $defaultMsgTemplate = 'common/showmsg.phtml'; | 
|---|
|  |  |  | public $config = array(); | 
|---|
|  |  |  | public $session = array(); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @var boolean 是否开启用户验证 authenticate | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  | public $currentRequest = ''; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public function init(){ | 
|---|
|  |  |  | $session = Yaf_Session::getInstance(); | 
|---|
|  |  |  | if(!$session->has('user')){ | 
|---|
|  |  |  | $this->session = Yaf_Session::getInstance(); | 
|---|
|  |  |  | if(!$this->session->has('user')){ | 
|---|
|  |  |  | $this->redirect('/user_login.html'); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //初始化redis | 
|---|
|  |  |  | $this->redis = System_Service_Locator::getInstance()->get('redis'); | 
|---|
|  |  |  | if(!$this->redis->exists('modules') ){ | 
|---|
|  |  |  | $this->redis->set('modules', $this->getModules()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //更新角色权限 | 
|---|
|  |  |  | if(!$this->redis->exists('role_auth')){ | 
|---|
|  |  |  | Util::updateRoleAuth(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | $role_auth = $this->redis->get('role_auth'); | 
|---|
|  |  |  | $module_service = new Service_Module(); | 
|---|
|  |  |  | // $current_module = $module_service->getModuleInfo(array('module' => strtolower($this->_request->module), 'controller' => strtolower($this->_request->controller), 'action' => strtolower($this->_request->action))); | 
|---|
|  |  |  | // if($current_module){ | 
|---|
|  |  |  | //   if(!in_array($current_module['_id'], $role_auth[$this->session['user']['role_id']])){ | 
|---|
|  |  |  | //     $this->redirect('/error/show/type/no_auth'); | 
|---|
|  |  |  | //   } | 
|---|
|  |  |  | //  } | 
|---|
|  |  |  | // else{ | 
|---|
|  |  |  | //    $this->redirect('/error/show/type/not_found'); | 
|---|
|  |  |  | // } | 
|---|
|  |  |  | parent::init(); | 
|---|
|  |  |  | // $currentRequest = '/' . strtolower( implode('/', [ | 
|---|
|  |  |  | ///         $this->_request->module, | 
|---|
|  |  |  | 
|---|
|  |  |  | return json_encode($data, JSON_UNESCAPED_UNICODE); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取栏目列表 | 
|---|
|  |  |  | * @return [type] [description] | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public function getModules(){ | 
|---|
|  |  |  | $this->module_service = new Service_Module(); | 
|---|
|  |  |  | return $this->module_service->getModuleList(array(), array(), array('level' => 1)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|