• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/notify.php
  • Класс: CIntranetNotify
  • Вызов: CIntranetNotify::OnSendMentionGetEntityFields
static function OnSendMentionGetEntityFields($arCommentFields)
{
	if ($arCommentFields["EVENT_ID"] !== SONET_INTRANET_NEW_USER_COMMENT_EVENT_ID)
	{
		return false;
	}

	if (!Loader::includeModule('socialnetwork'))
	{
		return true;
	}

	$dbLog = CSocNetLog::GetList(
		array(),
		array(
			"ID" => $arCommentFields["LOG_ID"],
			"EVENT_ID" => SONET_INTRANET_NEW_USER_EVENT_ID
		),
		false,
		false,
		array("ID", "USER_ID")
	);

	if (
		($arLog = $dbLog->Fetch())
		&& ((int)$arLog["USER_ID"] > 0)
	)
	{
		$genderSuffix = "";
		$dbUsers = CUser::GetList("ID", "desc",
			array("ID" => $arCommentFields["USER_ID"].' | '.$arLog["USER_ID"]),
			array("PERSONAL_GENDER", "LOGIN", "NAME", "LAST_NAME", "SECOND_NAME")
		);
		while ($arUser = $dbUsers->Fetch())
		{
			if ((int)$arUser["ID"] === (int)$arCommentFields["USER_ID"])
			{
				$genderSuffix = $arUser["PERSONAL_GENDER"];
			}
			if ((int)$arUser["ID"] === (int)$arLog["USER_ID"])
			{
				$nameFormatted = CUser::FormatName(CSite::GetNameFormat(), $arUser);
			}
		}

		$strPathToLogEntry = str_replace("#log_id#", $arLog["ID"], COption::GetOptionString("socialnetwork", "log_entry_page", "/company/personal/log/#log_id#/", SITE_ID));
		$strPathToLogEntryComment = $strPathToLogEntry.(mb_strpos($strPathToLogEntry, "?") !== false ? "&" : "?")."commentID=".$arCommentFields["ID"];

		$arReturn = array(
			"URL" => $strPathToLogEntryComment,
			"NOTIFY_MODULE" => "intranet",
			"NOTIFY_TAG" => "INTRANET_NEW_USER|COMMENT_MENTION|".$arCommentFields["ID"],
			"NOTIFY_MESSAGE" => Loc::getMessage("I_NEW_USER_MENTION".($genderSuffix !== '' ? "_" . $genderSuffix : ""), Array("#title#" => "".$nameFormatted."")),
			"NOTIFY_MESSAGE_OUT" => Loc::getMessage("I_NEW_USER_MENTION".($genderSuffix !== '' ? "_" . $genderSuffix : ""), Array("#title#" => $nameFormatted))." ("."#server_name##url#)"
		);

		return $arReturn;
	}

	return false;
}