예제 #1
0
 /**
  * 检查用户访问权限
  */
 public function powerInit()
 {
     // 获取当前栏目的id
     $menuModel = new \MenuModel();
     $menuId = $menuModel->field('id')->where('module=:m and controller=:c and action=:a', strtolower(MODULE_NAME), strtolower(CONTROLLER_NAME), strtolower(ACTION_NAME))->select()->fetchOne();
     // 匹配用户权限
     if (ADMIN_RULES != '*' && !in_array($menuId, explode(',', ADMIN_RULES))) {
         $this->redirect('/logout/');
     }
 }