• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_tools.php
  • Класс: CSocNetLogTools
  • Вызов: CSocNetLogTools::FormatEvent_GetURL
static function FormatEvent_GetURL($arFields, $bAbsolute = false)
{
	$url = false;
	static $arSiteServerName;

	if (!$arSiteServerName)
	{
		$arSiteServerName = array();
	}

	if ($arFields["URL"] <> '')
	{
		if (
			!$bAbsolute
			&& (
				mb_strpos($arFields["URL"], "http://") === 0
				|| mb_strpos($arFields["URL"], "https://") === 0
			)
		)
		{
			$bAbsolute = true;
		}

		if (!$bAbsolute)
		{
			if (
				($arFields["ENTITY_TYPE"] ?? null) == SONET_ENTITY_GROUP
				&& CModule::IncludeModule("extranet")
			)
			{
				$server_name = "#SERVER_NAME#";
			}
			else
			{
				$rsLogSite = CSocNetLog::GetSite($arFields["ID"] ?? null);
				$siteID = null;
				if($arLogSite = $rsLogSite->Fetch())
				{
					$siteID = $arLogSite["LID"];
				}

				if (in_array($siteID, $arSiteServerName))
				{
					$server_name = $arSiteServerName[$siteID];
				}
				else
				{
					$rsSites = CSite::GetByID($siteID);
					$arSite = $rsSites->Fetch();
					$server_name = ($arSite["SERVER_NAME"] <> '' ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $GLOBALS["SERVER_NAME"]));
					$arSiteServerName[$siteID] = $server_name;
				}
			}

			$protocol = (CMain::IsHTTPS() ? "https" : "http");
			$url = $protocol."://".$server_name.$arFields["URL"];
		}
		else
		{
			$url = $arFields["URL"];
		}
	}

	return $url;
}