123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace Base\Controller;
- use Think\Controller;
- use Admin\Model\ColumnModel;
- /**
- * 基础控制器
- * @author Superbee
- *
- */
- class BaseController extends Controller {
- /**
- * 初始化模板
- */
- public function _initialize() {
- $this->checkLogin();
- }
- /**
- * 检查用户是否登录
- */
- private function checkLogin() {
- $admin = $this->getCurrentAdmin();
- if (empty($admin)) {
- $actionName = strtolower(CONTROLLER_NAME);
- if (!in_array($actionName, array("login"))) {
- header("location: " . __APP__ . "/Home/Login/login");
- exit;
- }
- }
- // $this->initMenu();
- }
- /**
- * 从session里面获得当前登录的管理员信息
- */
- public function getCurrentAdmin() {
- return isset($_SESSION['admin']) ? session('admin') : null;
- }
- private function initMenu() {
- $column = new ColumnModel();
- $temp = $column->menu();
- $this->assign('menu', $temp);
- }
- }
|