Returns user information

@param integer $userid userid
@param array   $opts   options

@return array
978083
public function get($userid = null, $opts = array())
	{
		$this->debug->groupCollapsed(__METHOD__, $userid);
		$opts = array_merge(array(
			'localtime' => true,	// true: return formatted date/time string for user's timezone
		), $opts);
		$vals_datetime = array('createdon','lastactivity','previousactivity');
		if (is_null($userid) || $userid == $this->userid) {
			$this->debug->log('use current user');
			$user = $this->user;
		} else {
			$ignore = array( 'password' );
			$joins = array();
			foreach ($this->cfg['userForeignKeys'] as $fka) {
				if (!empty($fka['getJoin'])) {
					$joins[] = $fka['getJoin'];
				}
				if (!empty($fka['ignoreKey'])) {
					$ignore[] = $fka['userCol'];
				}
			}
			$joins = !empty($joins)
				? ' '.implode(' ', $joins)
				: '';
			$query = 'SELECT * FROM `user`'
				.' LEFT JOIN `user_auth` USING (`userid`)'
				.$joins
				.' WHERE `user`.`userid` = '.$this->db->quoteValue($userid);
			$users = $this->db->query($query)[0];
			$this->debug->table($users, 'users');
			$user = $users[0];
			foreach ($vals_datetime as $k) {
				if (isset($user[$k])) {
					$user[$k] = strtotime($user[$k]);
				}
			}
			$query = 'SELECT `right` FROM `user_rights` WHERE `userid` = '.$this->db->quoteValue($userid);
			$rights = $this->db->query($query)[0];
			foreach ($rights as $k => $a) {
				$rights[$k] = $a['right'];
			}
			$user['previousactivity'] = $user['lastactivity'];
			$user['rights'] = $rights;
			foreach ($ignore as $k) {
				unset($user[$k]);
			}
		}
		if ($opts['localtime']) {
			foreach ($vals_datetime as $k) {
				$user[$k] = $this->datetimeLocal($user[$k]);
			}
		}
		$this->debug->log('user', $user);
		$this->debug->groupEnd();
		return $user;
	}
124984
public function getUserQuery($userId)
    {
        $qb = $this->createQueryBuilder();
        $qb->select('*');

        if (is_numeric($userId)) {
            $qb->where('id = :userId');
        } else {
            $qb
                ->where($qb->expr()->like('username', ':userId'))
                ->orWhere('email = :userId')
            ;
        }
        $qb->setParameter('userId', $userId);

        return $qb;
    }
1046220
public function getUserApplications($userId, $limit = null)
    {
        $qb = $this->createQueryBuilder(null)
            ->field('user')->equals($userId)
            ->sort(['date' => -1]);
    
        if (isset($limit)) {
            $qb->limit($limit);
        }
    
        return $qb->getQuery()->execute();
    }
137728
public static function get_contact_requests_between_users(int $userid, int $requesteduserid) : array {
        global $DB;

        $sql = "SELECT *
                  FROM {message_contact_requests} mcr
                 WHERE (mcr.userid = ? AND mcr.requesteduserid = ?)
                    OR (mcr.userid = ? AND mcr.requesteduserid = ?)";
        return $DB->get_records_sql($sql, [$userid, $requesteduserid, $requesteduserid, $userid]);
    }
1206369
public function getById($userId, array $queryParams = [])
    {
        $response = $this->api->users()->getById($userId, $queryParams);

        return new UserResponse($response);
    }
599934
public function userIdToOpenid(string $userId, int $agentId = null)
    {
        $params = [
            'userid' => $userId,
            'agentid' => $agentId,
        ];

        return $this->httpPostJson('cgi-bin/user/convert_to_openid', $params);
    }
1044320
public function getUserGroups(string $userId, array $options = []): array
    {
        $query = $this->find('list', [
            'keyField' => 'id',
            'valueField' => 'name'
        ]);
        $query->matching('Users', function ($q) use ($userId) {
            return $q->where(['Users.id' => $userId]);
        });
        $query->applyOptions($options);

        return $query->toArray();
    }
626223
public function getUserOptions(string $id, string $userID): ?array
    {
        $data = Internal\Data::getValue('.temp/bearcms/userthemeoptions/' . md5($userID) . '/' . md5($id) . '.json');
        if ($data !== null) {
            $data = json_decode($data, true);
            if (isset($data['options'])) {
                return $data['options'];
            }
        }
        return null;
    }
1349245
public static function get_active_tokens($userid) {
        global $DB;

        $sql = 'SELECT t.*, s.name as servicename FROM {external_tokens} t JOIN
                {external_services} s ON t.externalserviceid = s.id WHERE
                t.userid = :userid AND (t.validuntil IS NULL OR t.validuntil > :now)';
        $params = array('userid' => $userid, 'now' => time());
        return $DB->get_records_sql($sql, $params);
    }
1088189
public function get_user_roles($userid) {
        $roles = array();
        $ras = get_user_roles($this->context, $userid, true, 'c.contextlevel DESC, r.sortorder ASC');
        $plugins = $this->get_enrolment_plugins(false);
        foreach ($ras as $ra) {
            if ($ra->contextid != $this->context->id) {
                if (!array_key_exists($ra->roleid, $roles)) {
                    $roles[$ra->roleid] = null;
                }
                // higher ras, course always takes precedence
                continue;
            }
            if (array_key_exists($ra->roleid, $roles) && $roles[$ra->roleid] === false) {
                continue;
            }
            $changeable = true;
            if ($ra->component) {
                $changeable = false;
                if (strpos($ra->component, 'enrol_') === 0) {
                    $plugin = substr($ra->component, 6);
                    if (isset($plugins[$plugin])) {
                        $changeable = !$plugins[$plugin]->roles_protected();
                    }
                }
            }

            $roles[$ra->roleid] = $changeable;
        }
        return $roles;
    }
537793
public function read(array $opts) {
        $translatorevents = [];

        $feedback = parent::parseFeedback($opts);

        // Push question statements to $translatorevents['events'].
        foreach ($feedback->questions as $questionId => $questionAttempt) {
            array_push(
                $translatorevents,
                $this->questionStatement(
                    parent::read($opts)[0],
                    $questionAttempt
                )
            );
        }

        return $translatorevents;
    }
1082199
public function getUser(string $userid)
    {
        $cl = $this->getUserClass();
        $user = new $cl;
        return $user->obtainByUserID($userid);
    }
1173892
public function listCounters($userId, $optParams = array()) {
      $params = array('userId' => $userId);
      $params = array_merge($params, $optParams);
      $data = $this->__call('list', array($params));
      if ($this->useObjects()) {
        return new Google_Counters($data);
      } else {
        return $data;
      }
    }
698217
public function get($profileId, $optParams = array()) {
      $params = array('profileId' => $profileId);
      $params = array_merge($params, $optParams);
      $data = $this->__call('get', array($params));
      if ($this->useObjects()) {
        return new UserProfile($data);
      } else {
        return $data;
      }
    }
1136797
public function listBadges($userId, $optParams = array()) {
      $params = array('userId' => $userId);
      $params = array_merge($params, $optParams);
      $data = $this->__call('list', array($params));
      if ($this->useObjects()) {
        return new BadgeList($data);
      } else {
        return $data;
      }
    }
1008252
public static function getRoles($userId)
    {
        global $PPHP;
        $db = $PPHP['db'];
        $roles = $db->selectList("SELECT role FROM users_roles WHERE userId=? ORDER BY role ASC", array($userId));
        return $roles !== false ? $roles : array();
    }
1234787
public function getNotifications($id = null, $userId = null, $userRole = null) {
		$fields = [
			$this->alias . '.id',
			$this->alias . '.user_id',
			$this->alias . '.user_role',
			$this->alias . '.tag',
			$this->alias . '.title',
			$this->alias . '.body',
			$this->alias . '.data',
		];
		$conditions = [
			'AND' => [
				$this->alias . '.expires >=' => date('Y-m-d H:i:s'),
				'OR' => [
					[
						'AND' => [
							$this->alias . '.user_id' => '',
							$this->alias . '.user_role' => '',
						]
					]
				]
			]
		];
		if (!empty($id)) {
			$conditions['AND'][][$this->alias . '.id >'] = (int)$id;
		}
		if (!empty($userId)) {
			$conditions['AND']['OR'][][$this->alias . '.user_id'] = (int)$userId;
		}
		if (!empty($userRole)) {
			$conditions['AND']['OR'][]['AND'] = [
				$this->alias . '.user_role & ' . (int)$userRole . ' > 0',
				$this->alias . '.user_id' => '',
			];
		}

		$order = [$this->alias . '.id' => 'asc'];

		return $this->find('all', compact('fields', 'conditions', 'order'));
	}