• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/user.php
  • Класс: BitrixImUser
  • Вызов: User::getArray
public function getArray($options = [])
{
	if (!$this->isExists())
	{
		return null;
	}

	$hrPhotoOption = $options['HR_PHOTO'] ?? null;
	$livechatOption = $options['LIVECHAT'] ?? null;
	$jsonOption = $options['JSON'] ?? null;
	$skipOnlineOption = $options['SKIP_ONLINE'] ?? null;

	$result = [
		'ID' => $this->getId(),
		'ACTIVE' => $this->isActive(),
		'NAME' => $this->getFullName(false),
		'FIRST_NAME' => $this->getName(false),
		'LAST_NAME' => $this->getLastName(false),
		'WORK_POSITION' => $this->getWorkPosition(false),
		'COLOR' => $this->getColor(),
		'AVATAR' => $this->getAvatar(),
		'GENDER' => $this->getGender(),
		'BIRTHDAY' => (string)$this->getBirthday(),
		'EXTRANET' => $this->isExtranet(),
		'NETWORK' => $this->isNetwork(),
		'BOT' => $this->isBot(),
		'CONNECTOR' => $this->isConnector(),
		'EXTERNAL_AUTH_ID' => $this->getExternalAuthId(),
		'STATUS' => $this->getStatus(),
		'IDLE' => $skipOnlineOption === 'Y' ? false: $this->getIdle(),
		'LAST_ACTIVITY_DATE' => $skipOnlineOption === 'Y' ? false: $this->getLastActivityDate(),
		'MOBILE_LAST_DATE' => $skipOnlineOption === 'Y' ? false: $this->getMobileLastDate(),
		'ABSENT' => $this->isAbsent(),
		'DEPARTMENTS' => $this->getDepartments(),
		'PHONES' => $this->getPhones(),
	];
	if ($hrPhotoOption)
	{
		$result['AVATAR_HR'] = $this->getAvatarHr();
	}

	//TODO: Live chat, open lines
	//Just one call, here: BitrixImOpenLinesConnector::onStartWriting and BitrixImChat::getMessages
	if ($livechatOption && !$this->isConnector())
	{
		$lineId = BitrixImOpenLinesQueue::getActualLineId(['LINE_ID' => $livechatOption, 'USER_CODE' => $options['USER_CODE']]);

		$imolUserData = BitrixImOpenLinesQueue::getUserData($lineId, $this->getId());
		if ($imolUserData)
		{
			$result = array_merge($result, $imolUserData);
			$result['AVATAR_HR'] = $result['AVATAR'];
		}
	}
	//TODO: END: Live chat, open lines

	if ($jsonOption)
	{
		foreach ($result as $key => $value)
		{
			if ($value instanceof BitrixMainTypeDateTime)
			{
				$result[$key] = date('c', $value->getTimestamp());
			}
			else if (is_string($value) && is_string($key) && in_array($key, ['AVATAR', 'AVATAR_HR']) && is_string($value) && $value && mb_strpos($value, 'http') !== 0)
			{
				$result[$key] = BitrixImCommon::getPublicDomain().$value;
			}
		}
		$result = array_change_key_case($result, CASE_LOWER);
	}

	return $result;
}