|
本帖最后由 Closer 于 2016-3-16 17:07 编辑
最近在看AuotCodeIgniter,在登录时,部分代码请大家帮忙解释下,
class Manage extends Admin_Controller {
function __construct()
{
parent::__construct();
$this->load->model(array('Times_model'));
}
}
class Admin_Controller extends Member_Controller{
function __construct(){
define("IN_ADMIN", TRUE);
parent::__construct();
}
protected function check_member() {
if(!$this->user_id&&!($this->page_data['folder_name']=='adminpanel'&&$this->page_data['controller_name']=='manage'&&$this->page_data['method_name']=='login'))
{
$this->showmessage('请您重新登录',site_url('adminpanel/manage/login'));
exit(0);
}
$_datainfo = $this->Member_model->get_one(array('user_id'=>$this->user_id,'username'=>$this->user_name));
if(!($this->page_data['folder_name']=='adminpanel'&&$this->page_data['controller_name']=='manage'&&$this->page_data['method_name']=='login')&&!$_datainfo)
{
$this->showmessage('请您重新登录',site_url('adminpanel/manage/login'));
exit(0);
}else if($_datainfo){
$this->current_member_info = $_datainfo;
}
}
}
class Member_Controller extends Front_Controller{
public $module_info,$user_id,$group_id,$current_member_info,$menu_side_list,$cache_module_menu_arr,$current_role_priv_arr;
function __construct(){
parent::__construct();
define("IN_MEMBER", TRUE);
$this->module_info = $this->config->item('module');
$this->cache_module_menu_arr = getcache('cache_module_menu_all');
$this->user_id = intval($this->session->userdata('user_id'));
$this->user_name = $this->security->xss_clean($this->session->userdata('user_name'));
$this->group_id = intval($this->session->userdata('group_id'));
$_cache_member_role_priv_arr = getcache('cache_member_role_priv');
$this->current_role_priv_arr = $this->group_id==SUPERADMIN_GROUP_ID?$this->cache_module_menu_arr: (isset($_cache_member_role_priv_arr[$this->group_id])?$_cache_member_role_priv_arr[$this->group_id]:NULL);
$this->check_member();//实际调用的是父类的check_member()
$this->check_priv();
}
/**
* 判断用户是否已经登陆
*/
protected function check_member() {
//以下内容预计不会被输出
echo "什么时候调用我啊,我是Member_Controller的check_member()";
exit;
$_datainfo = $this->Member_model->get_one(array('user_id'=>$this->user_id,'username'=>$this->user_name));
if(!($this->page_data['folder_name']=='member'&&$this->page_data['controller_name']=='manage'&&$this->page_data['method_name']=='login')&&!$_datainfo)
{
$this->showmessage('请您重新登录',site_url('member/manage/login'));
exit(0);
}else if($_datainfo){
$this->current_member_info = $_datainfo;
}
}
} |
|