<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/*
 * 访问权限管理
 */

class Permission {

    var $CI;

    public function __construct() {
        $this->CI = & get_instance();
        log_message('debug', "Access permission Class Initialized");
    }

    function is_admin($auto_redirect = true) {
        $session_admin = $this->CI->session->userdata('session_admin');
        if (empty($session_admin)) {
            if ($auto_redirect) {
                redirect(site_url('login'));
            } else {
                return false;
            }
        } else {
            //设置站点代号为用户所属站点
            $this->CI->config->set_item('site_code', isset($session_admin->a_sitecode) ? $session_admin->a_sitecode : 'cht');
        }
    }

}
