Esempio n. 1
0
 public static function is_allowed($permission = 'default', $site_id = 0, $type = NULL)
 {
     $verify = true;
     $site_ids = role::get_site_ids($type);
     //超级管理员root不需要检查权限 zhu modify
     if (role::is_root()) {
         $verify = true;
     } else {
         if ($site_id > 0 && !in_array($site_id, $site_ids)) {
             $verify = false;
         }
         $acl = Session::instance()->get(self::$acl_tag);
         if ($acl) {
             $acl = unserialize($acl);
         } else {
             $acl = self::acl_init();
         }
         $manager = role::get_manager();
         $verify = $acl->is_allowed($manager["username"], $permission);
     }
     //验证操作
     if ($verify) {
         return $site_ids;
     } else {
         if (request::is_ajax()) {
             $return_struct = array('status' => 0, 'code' => 501, 'msg' => Kohana::lang('o_global.access_denied'), 'content' => array());
             die(json_encode($return_struct));
         } else {
             $referrer = tool::referrer_url();
             remind::set('权限不足', $referrer, 'error');
         }
     }
 }
Esempio n. 2
0
 /**
  * 判断用户的操作权限
  *
  * @param <String> $model_flag
  * @return <type>
  */
 public static function check($model_flag = 'default')
 {
     //zhu modify
     $verify = self::verify($model_flag);
     //验证操作
     if ($verify) {
         return $verify;
     } else {
         if (request::is_ajax()) {
             $return_struct = array('status' => 0, 'code' => 501, 'msg' => Kohana::lang('o_global.access_denied'), 'content' => array());
             die(json_encode($return_struct));
         } else {
             $referrer = tool::referrer_url();
             remind::set('权限不足', $referrer, 'error');
         }
     }
 }