45 'select' => [
'ID',
'LOG_ID',
'MESSAGE',
'SHARE_DEST',
'EVENT_ID' ]
47 if ($logComentFields = $res->fetch())
49 $logId = (int)$logComentFields[
'LOG_ID'];
54 $res = \CSocNetLog::getList(
61 array(
'ID',
'EVENT_ID'),
63 "CHECK_RIGHTS" =>
"Y",
65 "USE_SUBSCRIBE" =>
"N"
68 if ($logFields = $res->fetch())
71 $this->
setSourceFields(array_merge($logComentFields, array(
'LOG_EVENT_ID' => $logFields[
'EVENT_ID'])));
74 $title = htmlspecialcharsback($logComentFields[
'MESSAGE']);
75 $title = \Bitrix\Socialnetwork\Helper\Mention::clear($title);
77 $CBXSanitizer = new \CBXSanitizer;
78 $CBXSanitizer->delAllTags();
79 $title = preg_replace(array(
"/\n+/is".BX_UTF_PCRE_MODIFIER,
"/\s+/is".BX_UTF_PCRE_MODIFIER),
" ", $CBXSanitizer->sanitizeHtml($title));
148 public function add($params = array())
152 static $parser =
null;
155 isset($params[
'AUTHOR_ID'])
156 && (int)$params[
'AUTHOR_ID'] > 0
157 ? (
int)$params[
'AUTHOR_ID']
162 isset($params[
'MESSAGE'])
163 && (string)$params[
'MESSAGE'] !==
''
173 $module = ($params[
'MODULE'] ??
'tasks');
183 if ($parser ===
null)
185 $parser = new \CTextParser();
188 $commentEventId =
false;
191 if (in_array($this->
getLogEventId(), $providerIntranetNewUser->getEventId(),
true))
193 $commentEventId =
'intranet_new_user_comment';
196 if (!$commentEventId)
199 if (in_array($this->
getLogEventId(), $providerBitrix24NewUser->getEventId(),
true))
201 $commentEventId =
'bitrix24_new_user_comment';
205 if (!$commentEventId)
208 if (in_array($this->
getLogEventId(), $providerPhotogalleryAlbum->getEventId(),
true))
210 $commentEventId =
'photoalbum_comment';
214 if (!$commentEventId)
216 $commentEventId =
'data_comment';
219 $sonetCommentFields = array(
222 "EVENT_ID" => $commentEventId,
223 "MESSAGE" => $message,
224 "TEXT_MESSAGE" => $parser->convert4mail($message),
225 "MODULE_ID" => $module,
227 "RATING_TYPE_ID" =>
"LOG_COMMENT",
228 "USER_ID" => $authorId,
229 "=LOG_DATE" => \CDatabase::currentTimeFunction(),
232 if (!empty($params[
'SHARE_DEST']))
234 $sonetCommentFields[
'SHARE_DEST'] = $params[
'SHARE_DEST'];
237 if ($sonetCommentId = \CSocNetLogComments::add($sonetCommentFields,
false,
false))
239 \CSocNetLogComments::update($sonetCommentId, array(
240 "RATING_ENTITY_ID" => $sonetCommentId
245 'sonetCommentId' => $sonetCommentId,
246 'sourceCommentId' => $sonetCommentId