计算用户头像子路径

@param int $userId 用户ID
@return string
336800
public function getAvatarSubPath($userId)
    {
        $id = sprintf("%09d", $userId);
        $dir1 = substr($id, 0, 3);
        $dir2 = substr($id, 3, 2);
        $dir3 = substr($id, 5, 2);
        return $dir1 . '/' . $dir2 . '/' . $dir3 . '/';
    }
281353
public function getById($userid)
    {
        $filter = new IteratorFilter();
        $filter->addRelation($this->getUserDefinition()->getUserid(), Relation::EQUAL, $userid);
        return $this->getUser($filter);
    }
1295760
public function getPermissionTable($userId)
    {
        if ($this->_permissionTable === null) {
            $this->_permissionTable = (new Query())
                ->select(['*'])
                ->from('{{%admin_user_group}}')
                ->innerJoin('{{%admin_group_auth}}', '{{%admin_user_group}}.group_id={{%admin_group_auth}}.group_id')
                ->innerJoin('{{%admin_auth}}', '{{%admin_group_auth}}.auth_id = {{%admin_auth}}.id')
                ->where(['{{%admin_user_group}}.user_id' => $userId])
                ->all();
        }
        
        return $this->_permissionTable;
    }
825950
public function getAlternatesortstring1ByUserId($userID) {
        return DB::table('email_messages')
            ->join('email_attachments', 'email_messages.id', '=', 'email_attachments.email_messages_id')
            ->select('email_attachments.alternate_sort_string1')
            ->where('email_messages.user_id', '=', $userID)
            ->distinct()
            ->orderBy('email_attachments.alternate_sort_string1', 'desc')
            ->get()
        ;
    }
779072
public static function getAllMenuIdArrByUserId($userId)
    {
        $data = static::find()
            ->findByUserId($userId)
            ->asArray()
            ->all();

        $menuIdArr = [];
        foreach ($data as $item) {
            $menu = DpAdminMenu::find()
                ->findByMenuId($item['menu_id'])
                ->asArray()
                ->one();
            if ($menu) {
                $menuIdArr[] = $item['menu_id'];
            }
        }

        return $menuIdArr;
    }
1351265
public function userBlacklistQuery($userId) {
        try{
            if(empty($userId))
                throw new Exception('用户 Id 不能为空');
            $ret = $this->curl('/user/blacklist/query', array('userId' => $userId));
            if(empty($ret))
                throw new Exception('请求失败');
            return $ret;
        }catch (Exception $e) {
            print_r($e->getMessage());
        }
    }
301020
private function _userId($userId)
    {
        if (!$userId) {
            $currentUser = Craft::$app->getUser()->getIdentity();
            if ($currentUser) {
                $userId = $currentUser->id;
            }
        }
        return (int)($userId);
    }
678114
public static function getUser($userId)
    {
        /** @var \tao_models_classes_UserService $userService */
        $userService = ServiceManager::getServiceManager()->get(\tao_models_classes_UserService::SERVICE_ID);
        $user = $userService->getUserById($userId);
        return $user;
    }
1007654
public static function getAvatarPath($userId)
    {
        $id = sprintf("%09d", $userId);
        $dir1 = substr($id, 0, 3);
        $dir2 = substr($id, 3, 2);
        $dir3 = substr($id, 5, 2);
        return 'avatar' . '/' . $dir1 . '/' . $dir2 . '/' . $dir3 . '/' . substr($userId, -2);
    }
660273
private function get_gradebook_data_for_user($userid) {
        if (isset($this->gradinginfo->items[0]) && $this->gradinginfo->items[0]->grades[$userid]) {
            return $this->gradinginfo->items[0]->grades[$userid];
        }
        return false;
    }
242150
public function findUser ($userId) {
    $query = $this->database->pdo->prepare('SELECT username, points FROM users WHERE userId = :userId');
    $query->bindParam(':userId', $userId);

    $query->execute();
    return (object) $query->fetch(PDO::FETCH_ASSOC);
  }
549413
public function groupUserGagRollback($userId,$groupId) {
        try{
            if(empty($userId))
                throw new Exception('用户 Id 不能为空');
            if(empty($groupId))
                throw new Exception('群组 Id 不能为空');
            $params['userId'] = $userId;
            $params['groupId'] = $groupId;
            $ret = $this->curl('/group/user/gag/rollback',$params);
            if(empty($ret))
                throw new Exception('请求失败');
            return $ret;
        }catch (Exception $e) {
            print_r($e->getMessage());
        }
    }
1111653
public function load($userId)
    {
        try {
            return $this->innerGateway->load($userId);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
141436
public function getUserInfo($uid) {

        $userinfo = [];

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

            $userinfo = $this->config['auth_cache'] ? Session::get($this->getUserKey($uid)) : [];

            if (empty($userinfo) || !is_array($userinfo)){
                $user = Db::name($this->config['users']);
                // 获取用户表主键
                $_pk = is_string($user->getPk()) ? $user->getPk() : 'id';

                $userinfo = $user->field($this->config['users_auth_fields'])->where($_pk, $uid)->find();

                if ($this->config['auth_cache'])
                    Session::set($this->getUserKey($uid),$userinfo);
            }


            $this->userInfo = $userinfo;
        }

        return $this->userInfo;
    }
90826
public function GetCount($UserID = '') {
      $this->SQL
         ->Select('a.ActivityID', 'count', 'ActivityCount')
         ->From('Activity a')
         ->Join('ActivityType t', 'a.ActivityTypeID = t.ActivityTypeID');
      
      if ($UserID != '') {
         $this->SQL
            ->BeginWhereGroup()
            ->Where('a.ActivityUserID', $UserID)
            ->OrWhere('a.RegardingUserID', $UserID)
            ->EndWhereGroup();
      }
      
      $Session = Gdn::Session();
      if (!$Session->IsValid() || $Session->UserID != $UserID)
         $this->SQL->Where('t.Public', '1');

      $this->FireEvent('BeforeGetCount');
      return $this->SQL
         ->Get()
         ->FirstRow()
         ->ActivityCount;
   }
278321
public function inviteUser($userId)
    {
        $result = $this->httpRaw(self::WECHAT_USER_INVITE_PREFIX, [
            'userid' => $userId
        ], [
            'access_token' => $this->getAccessToken(),
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok' ? $result['type'] : $this->dump($result);
    }
1214149
public function get_user_enrolments($userid) {
        global $DB;
        list($instancessql, $params, $filter) = $this->get_instance_sql();
        $params['userid'] = $userid;
        $userenrolments = $DB->get_records_select('user_enrolments', "enrolid $instancessql AND userid = :userid", $params);
        $instances = $this->get_enrolment_instances();
        $plugins = $this->get_enrolment_plugins(false);
        $inames = $this->get_enrolment_instance_names();
        foreach ($userenrolments as &$ue) {
            $ue->enrolmentinstance     = $instances[$ue->enrolid];
            $ue->enrolmentplugin       = $plugins[$ue->enrolmentinstance->enrol];
            $ue->enrolmentinstancename = $inames[$ue->enrolmentinstance->id];
        }
        return $userenrolments;
    }