- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_livefeed.php
- Класс: CCalendarLiveFeed
- Вызов: CCalendarLiveFeed::OnAfterCommentAddBefore
static function OnAfterCommentAddBefore($entityType, $eventId, $arData)
{
if ($entityType !== "EV")
{
return;
}
$res = [];
$logId = false;
$commentXmlId = $arData['PARAMS']['XML_ID'];
$parentRes = false;
// Simple events have simple id's like "EVENT_".$eventId, for them
// we don't want to create second socnet log entry (mantis: 82011)
if ($commentXmlId !== "EVENT_".$eventId)
{
$dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "calendar", "SOURCE_ID" => $eventId), false, false, array("ID", "ENTITY_ID", "USER_ID", "TITLE", "MESSAGE", "SOURCE_ID", "PARAMS"));
$createNewSocnetLogEntry = true;
while ($arRes = $dbRes->Fetch())
{
if ((string)$arRes['PARAMS'] !== "")
{
$arRes['PARAMS'] = unserialize($arRes['PARAMS'], ['allowed_classes' => false]);
if (!is_array($arRes['PARAMS']))
{
$arRes['PARAMS'] = [];
}
}
if (isset($arRes['PARAMS']['COMMENT_XML_ID']) && $arRes['PARAMS']['COMMENT_XML_ID'] === $commentXmlId)
{
$logId = $arRes['ID'];
$createNewSocnetLogEntry = false;
}
else
{
$parentRes = $arRes;
}
}
if ($createNewSocnetLogEntry && $parentRes)
{
$arSoFields = [
"ENTITY_TYPE" => SONET_SUBSCRIBE_ENTITY_USER,
"ENTITY_ID" => $parentRes["ENTITY_ID"],
"EVENT_ID" => "calendar",
"USER_ID" => $parentRes["USER_ID"],
"SITE_ID" => SITE_ID,
"TITLE_TEMPLATE" => "#TITLE#",
"TITLE" => $parentRes["TITLE"],
"MESSAGE" => $parentRes["MESSAGE"],
"TEXT_MESSAGE" => '',
"SOURCE_ID" => $parentRes["SOURCE_ID"],
"ENABLE_COMMENTS" => "Y",
"CALLBACK_FUNC" => false,
"=LOG_DATE" => CDatabase::CurrentTimeFunction(),
"PARAMS" => serialize([
"COMMENT_XML_ID" => $commentXmlId
])
];
$logId = CSocNetLog::Add($arSoFields, false);
$arCodes = [];
$rsRights = CSocNetLogRights::GetList([], array("LOG_ID" => $parentRes["ID"]));
while ($arRights = $rsRights->Fetch())
{
$arCodes[] = $arRights['GROUP_CODE'];
}
CSocNetLogRights::Add($logId, $arCodes);
}
}
if ($logId)
{
$res['LOG_ENTRY_ID'] = $logId;
}
return $res;
}