• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/mysql/messages.php
  • Класс: CSocNetMessages
  • Вызов: CSocNetMessages::Add
static function Add($arFields)
{
	global $DB;

	if (IsModuleInstalled("im") && CModule::IncludeModule("im"))
	{
		if ($arFields["MESSAGE_TYPE"] == SONET_MESSAGE_SYSTEM)
		{
			$ID = CIMNotify::Add($arFields);
			return $ID;
		}
		else
		{
			CIMMessenger::SpeedFileDelete($arFields['TO_USER_ID'], IM_SPEED_MESSAGE);
		}
	}

	if (defined("INTASK_SKIP_SOCNET_MESSAGES1") && INTASK_SKIP_SOCNET_MESSAGES1)
		$arFields["=DATE_VIEW"] = $DB->CurrentTimeFunction();

	$arFields1 = BitrixSocialnetworkUtil::getEqualityFields($arFields);

	if (!CSocNetMessages::CheckFields("ADD", $arFields))
		return false;

	$db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetMessagesAdd");
	while ($arEvent = $db_events->Fetch())
		if (ExecuteModuleEventEx($arEvent, array(&$arFields))===false)
			return false;

	$arInsert = $DB->PrepareInsert("b_sonet_messages", $arFields);
	BitrixSocialnetworkUtil::processEqualityFieldsToInsert($arFields1, $arInsert);

	$ID = false;
	if ($arInsert[0] <> '')
	{
		$strSql =
			"INSERT INTO b_sonet_messages(".$arInsert[0].") ".
			"VALUES(".$arInsert[1].")";
		$DB->Query($strSql, False, "File: ".__FILE__."
Line: ".__LINE__); $ID = intval($DB->LastID()); $events = GetModuleEvents("socialnetwork", "OnSocNetMessagesAdd"); while ($arEvent = $events->Fetch()) ExecuteModuleEventEx($arEvent, array($ID, $arFields)); //CSocNetMessages::SendEvent($ID, "SONET_NEW_MESSAGE"); CSocNetMessages::__SpeedFileCreate($arFields["TO_USER_ID"]); } return $ID; }