用户登入
@access private static
@param  int      $uid 用户ID
@param  string   $nickname 用户昵称
@return array
543893
public static function login($uid,$nickname){
        if(empty($uid) && empty($nickname)){
            return false;
        }
        $session_prefix = config('thinkcms.session_prefix');
        $user           = [
                            'uid'       => $uid,
                            'nickname'  => $nickname,
                            'time'      => time()
                        ];
        session($session_prefix.'user', $user);
        session($session_prefix.'user_sign', self::data_auth_sign($user));
        return true;
    }
93099
public function userInfo($openId) {
        $user = $this->getInfo()->parameters([
            'openid' => $openId
        ])->json();
        if (!array_key_exists('nickname', $user)) {
            return false;
        }
        $user['username'] = $user['nickname'];
        $user['avatar'] = $user['headimgurl'];
        return $user;
    }
129668
function getAccountInfoByUid($uid)
    {
        $response = $this->call( new Command\AccountInfo($uid, Command\AccountInfo::TYPE_UID) );
        if ( $ex = $response->hasException() )
            throw $ex;

        $r = $response->expected();
        $r = ($r instanceof iDataEntity) ? $r->get('result') : $r;
        return $r;
    }
1193149
public function getUidAppid($uid = '', $type = "all") {
        $key  = md5($uid . md5($uid . 'thirdAuthorizeCallback') . "_wechat");
        $data = to_array(F($key, '[get]'));
        if ($data) {
            switch ($type) {
            case 'appid':
                return $data['authorizer_appid'];
                break;
            default:
                return $data;
                break;
            }
        } else {
            return false;
        }
    }
179704
function set_nickname($username , $nickname){
        if(empty($nickname) || empty($username)){
            return false;
        }
        $token = $this->get_token();
        $header = array('Authorization: Bearer '.$token);
        $path = 'users/'.$username;
        $request_body = array("nickname"=>$nickname);
        $result = $this->api_request($path, json_encode($request_body,JSON_UNESCAPED_UNICODE) , 'PUT', $header);
        return $this->result_handler($result);
    }
69238
public function getGroup($uid){
        
        $groupIds = $this->getGroupIds($uid);
        
        $groups = DB::table($this->dbTablePrefix . $this->tableGroup)
                    ->where('id' , 'in' , $groupIds)
                    ->where('status' , '1')
                    ->order('sort asc')
                    ->select();
        
        return $groups;
        
    }
437456
public function getGroupIds($uid){
        
        $groupIds = Db::table($this->dbTablePrefix . $this->tableUserGroup)
                    ->where('user_id',$uid)
                    ->column('group_id');
        
        return $groupIds;
    }
360650
public static function getGroupMemberRoles($uid, $gid)
	{
		$db = \App::get('db');
		$sql = "SELECT r.id, r.name, r.permissions FROM `#__xgroups_roles` as r, `#__xgroups_member_roles` as m WHERE r.id=m.roleid AND m.uidNumber=" . $db->quote($uid) . " AND r.gidNumber=" . $db->quote($gid);
		$db->setQuery($sql);

		return $db->loadAssocList();
	}
191148
public function getRoleUser($uid) {

        if (empty($this->roleUser)){

            $role_user_data = $this->config['auth_cache'] ? Session::get($this->getRoleUserKey()) : [];

            if (empty($role_user_data) || !is_array($role_user_data)){

                $where = [];
                $where['user_id'] = $uid;
                $role_user_list = Db::name($this->config['role_user'])
                    ->field('role_id')
                    ->where($where)
                    ->select();

                $role_user_data = array_column($role_user_list,'role_id');

                //dump($role_user_data);

                if (empty($role_user_data)) return false;

                if ($this->config['auth_cache'])
                    Session::set($this->getRoleUserKey(),$role_user_data);
            }

            $this->roleUser = $role_user_data;

        }

        return $this->roleUser;
    }
818494
public function getRawObjectByUid(int $uid, int $languageUid = 0, array $querySettings = ['respectSysLanguage' => false]) {
    if ($uid && $uid > 0) {
      // Create a new query.
      $query = $this->createquery();

      // Set the passend language UID.
      $settings = $query->getQuerySettings();
      $settings->setLanguageUid($languageUid);

      // Apply the passed query settings.
      $query = $this->applyQuerySettings($query, $querySettings);

      // Set the query constraints.
      $query->matching($query->equals('uid', $uid));

      // Execute the query and get raw object.
      $result = $query->execute(true);

      return $result[0];
    }

    return null;
  }
58749
public function my_removeUid($uid)
    {
        if (get_instance()->isCluster()) {
            $this->map[$this->node_name]->remove($uid);
            foreach ($this->client as $client) {
                $client->removeNodeUid($this->node_name, $uid);
            }
            if (Start::isLeader()) {
                get_instance()->pub('$SYS/uidcount', $this->countOnline());
            }
        }
        $this->my_clearUidSub($uid);
    }
1072144
public function get($uid) {
  $query = new \Peyote\Select('media');
  $query->columns('media.uid',
                  'media.file',
                  'media.format',
                  'media.hash',
                  'media.width',
                  'media.height',
                  'media.size',
                  'media.type',
                  'storage.type AS storage_type',
                  'storage.id AS storage_id',
                  'storage.path',
                  'storage.endpoint',
                  'storage.bucket')
        ->join('storage', 'inner')
        ->on('storage.id', '=', 'media.storage')
        ->where('media.uid', '=', $uid);
  $results = $this->db->fetch($query);
  $formatter = new \Rych\ByteSize\Formatter\Binary;
  $bytesize = new \Rych\ByteSize\ByteSize($formatter);
  foreach ($results as $m) {
   $result[$m['type']] = $m;
   $siteURL = $this->siteURL();
   switch ($m['storage_type']) {
    case 'local':
     $result[$m['type']]['url'] = $siteURL['scheme'] .'://' . $m['path'] . $result[$m['type']]['file'];
     break;
    case 's3':
     $result[$m['type']]['url'] = $siteURL['scheme'] .'://' . $m['bucket'] . '.' . $m['endpoint'] . '/' . $result[$m['type']]['file'];
     break;
   }
   $result[$m['type']]['readable_size'] = $bytesize->format($result[$m['type']]['size']);
  }
  return $result;
 }
679313
public function getUserinfo($uid = null)
	{
		$ret = array();
		if (extension_loaded('posix')) {
			if (is_null($uid)) {
				$uid = posix_geteuid();	// get effective userid
			} elseif (is_string($uid)) {
				// username passed?
				$ret = posix_getpwnam($uid);
			}
			if (empty($ret)) {
				$ret = posix_getpwuid($uid);
			}
			$ret['group'] = posix_getgrgid($uid_info['gid']);
			unset($ret['gid']);	// is inside group array
		}
		return $ret;
	}
496935
public function getGroups($uid) {
        static $groups = array();
        if (isset($groups[$uid]))
            return $groups[$uid];
        $user_groups = M()
            ->table($this->_config['AUTH_GROUP_ACCESS'] . ' a')
            ->where("a.uid='$uid' and g.status='1'")
            ->join($this->_config['AUTH_GROUP']." g on a.group_id=g.id")
            ->field('uid,group_id,title,rules')->select();
        $groups[$uid]=$user_groups?:array();
        return $groups[$uid];
    }
321945
public function thirdAccountInformation($uid = '') {
        $component_access_token = $this->componentAccessToken();
        #提交数据
        $data = array(
            "component_appid"  => C("wechat", "componentAppid"),
            "authorizer_appid" => $this->getUidAppid($uid, "appid"),
        );
        #提交的URL地址
        $url = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=$component_access_token";
        $res = to_array($this->httpPost($url, $data));
        if ($res && isset($res['authorizer_info'])) {
            return $res;
        } else {
            return false;
        }
    }
1133004
public function serverGetByUid($uid)
  {
    foreach($this->serverList() as $server)
    {
      if($server["virtualserver_unique_identifier"] == $uid) return $server;
    }

    throw new Exception("invalid serverID", 0x400);
  }
220721
public function clientGetByUid($uid)
  {
    foreach($this->clientList() as $client)
    {
      if($client["client_unique_identifier"] == $uid) return $client;
    }

    throw new TeamSpeak3_Adapter_ServerQuery_Exception("invalid clientID", 0x200);
  }