32 $logEntryId = intval(
$event->getParameter(
'entity_id'));
35 $attachments =
$event->getParameter(
'attachments');
41 &&
count($attachments) > 0
44 $message = Loc::getMessage(
'SONET_MAILHANDLER_ATTACHMENTS');
56 $res = \CSocNetLog::getList(
63 array(
"ID",
"ENTITY_TYPE",
"ENTITY_ID",
"EVENT_ID",
"USER_ID",
"SOURCE_ID")
66 if (!($logEntry =
$res->fetch()))
78 $commentEvent = \CSocNetLogTools::findLogCommentEventByLogEventID($logEntry[
"EVENT_ID"]);
79 if (is_array($commentEvent))
84 "ENTITY_TYPE" => $logEntry[
"ENTITY_TYPE"],
85 "ENTITY_ID" => $logEntry[
"ENTITY_ID"],
86 "EVENT_ID" => $commentEvent[
"EVENT_ID"],
87 "=LOG_DATE" =>
$DB->currentTimeFunction(),
91 "LOG_ID" => $logEntry[
"ID"],
97 ModuleManager::isModuleInstalled(
"webdav")
98 || ModuleManager::isModuleInstalled(
"disk")
100 :
"UF_SONET_COM_FILE"
105 $attachmentRelations =
array();
107 foreach ($attachments as
$key => $attachedFile)
109 $resultId = \CSocNetLogComponent::saveFileToUF($attachedFile,
$type,
$userId);
112 $fields[$ufCode][] = $resultId;
113 $attachmentRelations[
$key] = $resultId;
117 $fields[
"MESSAGE"] = preg_replace_callback(
118 "/\[ATTACHMENT\s*=\s*([^\]]*)\]/isu",
119 function (
$matches) use ($attachmentRelations)
121 if (isset($attachmentRelations[
$matches[1]]))
123 return "[DISK FILE ID=".$attachmentRelations[
$matches[1]].
"]";
129 if (Loader::includeModule(
'disk'))
131 \Bitrix\Disk\Uf\FileUserType::setValueForAllowEdit(
"SONET_COMMENT",
true);
134 $commentId = \CSocNetLogComments::add(
$fields,
true,
false);
144 foreach (EventManager::getInstance()->findEventHandlers(
'socialnetwork',
'OnAfterSocNetLogEntryCommentAdd') as $handler)
148 "COMMENT_ID" => $commentId
152 $skipCounterIncrement =
false;
153 foreach (EventManager::getInstance()->findEventHandlers(
'socialnetwork',
'OnBeforeSocNetLogCommentCounterIncrement') as $handler)
157 $skipCounterIncrement =
true;
162 if (!$skipCounterIncrement)
164 \CSocNetLog::counterIncrement(
169 \CSocNetLogRights::checkForUserAll($logEntry[
"ID"])
173 if (
$comment = \CSocNetLogComments::getByID($commentId))
182 "TIME_FORMAT" => \CSite::getTimeFormat(),
183 "PATH_TO_USER" => $pathToUser,
184 "NAME_TEMPLATE" => \CSite::getNameFormat(
null,
$site[
"ID"]),
186 "AVATAR_SIZE" => 100,
187 "PATH_TO_SMILE" => $pathToSmile,
188 "LANGUAGE_ID" =>
$site[
"LANGUAGE_ID"],
189 "SITE_ID" =>
$site[
"ID"],