32 $logEntryId = intval($event->getParameter(
'entity_id'));
33 $userId = intval($event->getParameter(
'from'));
34 $message = trim($event->getParameter(
'content'));
35 $attachments = $event->getParameter(
'attachments');
41 && count($attachments) > 0
56 $res = \CSocNetLog::getList(
63 array(
"ID",
"ENTITY_TYPE",
"ENTITY_ID",
"EVENT_ID",
"USER_ID",
"SOURCE_ID")
66 if (!($logEntry = $res->fetch()))
71 $siteId = \Bitrix\Socialnetwork\Util::getSiteIdByLogId($logEntry[
"ID"]);
72 $res = \CSite::getByID($siteId);
73 $site = $res->fetch();
75 $pathToUser = Config\Option::get(
"main",
"TOOLTIP_PATH_TO_USER",
false, $siteId);
76 $pathToSmile = Config\Option::get(
"socialnetwork",
"smile_page",
false, $siteId);
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(),
88 "MESSAGE" => $message,
89 "TEXT_MESSAGE" => $message,
91 "LOG_ID" => $logEntry[
"ID"],
93 "CURRENT_USER_ID" => $userId
97 ModuleManager::isModuleInstalled(
"webdav")
98 || ModuleManager::isModuleInstalled(
"disk")
100 :
"UF_SONET_COM_FILE"
102 $fields[$ufCode] = array();
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*([^\]]*)\]/is".BX_UTF_PCRE_MODIFIER,
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)
146 ExecuteModuleEventEx($handler, array($logEntry, array(
147 "SITE_ID" => $siteId,
148 "COMMENT_ID" => $commentId
152 $skipCounterIncrement =
false;
153 foreach (EventManager::getInstance()->findEventHandlers(
'socialnetwork',
'OnBeforeSocNetLogCommentCounterIncrement') as $handler)
155 if (ExecuteModuleEventEx($handler, array($logEntry)) ===
false)
157 $skipCounterIncrement =
true;
162 if (!$skipCounterIncrement)
164 \CSocNetLog::counterIncrement(
169 \CSocNetLogRights::checkForUserAll($logEntry[
"ID"])
173 if ($comment = \CSocNetLogComments::getByID($commentId))
175 \Bitrix\Socialnetwork\ComponentHelper::addLiveComment(
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"],