function _initialize() { parent::_initialize(); $this->bookModel = D('Book/Book'); $this->bookCategoryModel = D('Book/BookCategory'); $this->bookSectionModel = D('Book/BookSection'); import_lang('Book'); }
/** * 后台控制器初始化 */ protected function _initialize() { // 获取当前用户ID define('UID', is_login()); if (!UID) { // 还没登录 跳转到登录页面 $this->redirect('Public/login'); } /* 读取数据库中的配置 */ $config = S('DB_CONFIG_DATA'); if (!$config) { $config = api('Config/lists'); S('DB_CONFIG_DATA', $config); } C($config); //添加配置 // 是否是超级管理员 define('IS_ROOT', is_administrator()); if (!IS_ROOT && C('ADMIN_ALLOW_IP')) { // 检查IP地址访问 if (!in_array(get_client_ip(), explode(',', C('ADMIN_ALLOW_IP')))) { $this->error(L('_FORBID_403_')); } } // 检测访问权限 $access = $this->accessControl(); if ($access === false) { $this->error(L('_FORBID_403_')); } elseif ($access === null) { $dynamic = $this->checkDynamic(); //检测分类栏目有关的各项动态权限 if ($dynamic === null) { //检测非动态权限 $rule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME); if (!$this->checkRule($rule, array('in', '1,2'))) { $this->error(L('_VISIT_NOT_AUTH_')); } } elseif ($dynamic === false) { $this->error(L('_VISIT_NOT_AUTH_')); } } $this->assign('__MANAGE_COULD__', $this->checkRule('admin/module/lists', array('in', '1,2'))); $this->assign('__MENU__', $this->getMenus()); $this->assign('__MODULE_MENU__', $this->getModules()); $this->checkUpdate(); $this->getReport(); import_lang(ucfirst(CONTROLLER_NAME)); }