예제 #1
0
/**
 * 验证权限 view_auth_check
 * @param null $rule
 * @return bool
 */
function view_auth_check($rule = NULL)
{
    /* 管理员允许访问任何页面 */
    if (IS_ROOT) {
        return true;
    }
    /* 验证权限 */
    $Auth = new \Manager\ORG\Auth();
    $rule = substr(strtolower($rule), 1);
    if ($Auth->check($rule, UID)) {
        return true;
    }
    return false;
}
 /**
  * 更新用户登录信息
  * @param $id
  * @param $username
  */
 protected function update_login($uid = NULL, $username = NULL)
 {
     if ($uid && $username) {
         session('user_id', $uid);
         session('user_name', $username);
         /* 读取用户权限 */
         $authRules = array();
         if ($uid != C('MANAGER_ADMINISTRATOR')) {
             $Auth = new \Manager\ORG\Auth();
             $authList = $Auth->getAuthList($uid, 1);
             foreach ($authList as $k => $v) {
                 $authRules[] = $v['menu_id'];
             }
         }
         session('auth_rules', array_unique($authRules));
         logs_action_operate('登陆成功');
     }
     return false;
 }
예제 #3
0
 /**
  * 权限检测 checkRule
  * @param string $rule 检测的规则
  * @param string $mode check模式
  * @return boolean
  */
 protected final function checkRule($rule, $type = 1, $mode = 'url')
 {
     if (IS_ROOT) {
         return true;
         //管理员允许访问任何页面
     }
     static $Auth = NULL;
     if (!$Auth) {
         $Auth = new \Manager\ORG\Auth();
     }
     if (!$Auth->check($rule, UID, $type, $mode)) {
         return false;
     }
     return true;
 }