• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_destination.php
  • Класс: CSocNetLogDestination
  • Вызов: CSocNetLogDestination::formatUser
static function formatUser($arUser, $arParams = array())
{
	static $siteNameFormat = false;
	static $isIntranetInstalled = false;
	static $extranetUserIdList = false;

	if ($siteNameFormat === false)
	{
		$siteNameFormat = CSite::GetNameFormat(false);
	}

	if ($isIntranetInstalled === false)
	{
		$isIntranetInstalled = (IsModuleInstalled('intranet') ? 'Y' : 'N');
	}

	if ($extranetUserIdList === false)
	{
		$extranetUserIdList = BitrixSocialnetworkComponentHelper::getExtranetUserIdList();
	}

	$arFileTmp = CFile::ResizeImageGet(
		$arUser["PERSONAL_PHOTO"],
		array('width' => 100, 'height' => 100),
		BX_RESIZE_IMAGE_EXACT,
		false
	);

	$arRes = array(
		'id' => 'U'.$arUser["ID"],
		'entityId' => $arUser["ID"]
	);

	if (ModuleManager::isModuleInstalled('intranet'))
	{
		$arRes["email"] = $arUser['EMAIL'];
	}

	$arRes = array_merge($arRes, array(
		'name' => CUser::FormatName(
			(
				!empty($arParams["NAME_TEMPLATE"])
					? $arParams["NAME_TEMPLATE"]
					: $siteNameFormat
			),
			$arUser,
			true,
			true
		),
		'avatar' => (
			empty($arFileTmp['src'])
				? ''
				: $arFileTmp['src']
		),
		'desc' => self::getUserDescription($arUser, [
			'showEmail' => !empty($arParams["ONLY_WITH_EMAIL"])
		]),
		'isExtranet' => (
			in_array($arUser["ID"], $extranetUserIdList)
				? "Y"
				: "N"
		),
		'isEmail' => (
			isset($arUser['EXTERNAL_AUTH_ID'])
			&& $arUser['EXTERNAL_AUTH_ID'] === 'email'
				? 'Y'
				: 'N'
		)
	));

	if (!empty($arUser["UF_USER_CRM_ENTITY"]))
	{
		$arRes['crmEntity'] = $arUser["UF_USER_CRM_ENTITY"];
	}

	if (!empty($arUser["ACTIVE"]))
	{
		$arRes['active'] = $arUser["ACTIVE"];
	}

	if (
		(
			isset($arParams['USE_EMAIL'])
			&& $arParams['USE_EMAIL']
		)
		|| $arRes['isEmail'] === 'Y'
	)
	{
		if ($arUser["NAME"] <> '')
		{
			$arRes['showEmail'] = "Y";
		}
	}

	$db_events = GetModuleEvents("socialnetwork", "OnSocNetLogDestinationFormatUser");
	while ($arEvent = $db_events->Fetch())
	{
		ExecuteModuleEventEx($arEvent, array($arUser, &$arRes));
	}

	$checksum = md5(serialize($arRes));
	$arRes['checksum'] = $checksum;

	$arRes['login'] = (
		$isIntranetInstalled === 'Y'
		&& isset($arParams['USE_LOGIN'])
		&& $arParams['USE_LOGIN']
			? $arUser["LOGIN"]
			: ''
	);

	$arRes['index'] = (
		isset($arUser["SEARCH_USER_CONTENT"])
			? $arUser["SEARCH_USER_CONTENT"]
			: ''
	);

	return $arRes;
}