6if (Loader::includeModule(
'replica'))
8 class ForumMessageAttachmentHandler
extends \Bitrix\Replica\Client\AttachmentHandler
10 protected $moduleId =
"forum";
11 protected $relation =
"b_forum_message.ATTACH_ID";
13 protected $executeEventEntity =
"ForumMessage";
14 protected $parentRelation =
"b_forum_message.ID";
15 protected $diskConnectorString =
"forum_message";
17 protected $dataFields = array(
"POST_MESSAGE",
"POST_MESSAGE_HTML");
27 public static function updateUserField($messageId, $diskAttachId)
29 global $USER_FIELD_MANAGER;
30 $ufValue = $USER_FIELD_MANAGER->GetUserFieldValue(
"FORUM_MESSAGE",
"UF_FORUM_MESSAGE_DOC", $messageId);
33 $ufValue = array($diskAttachId);
35 elseif (is_array($ufValue))
37 $ufValue[] = $diskAttachId;
41 $ufValue = $diskAttachId;
43 $USER_FIELD_MANAGER->Update(
"FORUM_MESSAGE", $messageId, array(
"UF_FORUM_MESSAGE_DOC" => $ufValue));
53 public static function getUserField($messageId)
57 $messageList = \CForumMessage::getList(
63 array(
"SELECT" => array(
"UF_FORUM_MESSAGE_DOC"))
65 $messageInfo = $messageList->fetch();
69 && $messageInfo[
"UF_FORUM_MESSAGE_DOC"]
70 && $messageInfo[
"UF_FORUM_MESSAGE_DOC"][
"VALUE"]
71 && \
Bitrix\Main\Loader::includeModule(
'disk')
74 foreach ($messageInfo[
"UF_FORUM_MESSAGE_DOC"][
"VALUE"] as $attachId)
76 $attachedObject = \Bitrix\Disk\AttachedObject::getById($attachId, array(
'OBJECT'));
77 if ($attachedObject && $attachedObject->getFile())
79 $result[$attachId] = $attachedObject;
96 public function onExecuteDescriptionFix(\
Bitrix\Main\Event $event)
98 $parameters = $event->getParameters();
99 $messId = $parameters[0];
100 $fields = $parameters[1];
101 $connection = \Bitrix\Main\Application::getConnection();
102 $sqlHelper = $connection->getSqlHelper();
104 if ($this->replaceGuidsWithFiles($fields))
106 $update = $sqlHelper->prepareUpdate(
"b_forum_message", $fields);
107 if ($update[0] <>
'')
109 $sql =
"UPDATE ".$sqlHelper->quote(
"b_forum_message").
" SET ".$update[0].
" WHERE ID = ".$messId;
110 $connection->query($sql);
112 if (\
Bitrix\Main\Loader::includeModule(
'socialnetwork'))
114 $dbLogComment = \CSocNetLogComments::GetList(
115 array(
"ID" =>
"DESC"),
117 "EVENT_ID" =>
'tasks_comment',
118 "SOURCE_ID" => $messId,
122 array(
"ID",
"LOG_ID")
124 $arLogComment = $dbLogComment->fetch();
127 $parser = new \CTextParser();
128 $parser->allow = array(
143 $arFieldsForSocnet = array(
144 "LOG_ID" => intval($arLogComment[
"LOG_ID"]),
145 "MESSAGE" => $fields[
"POST_MESSAGE"],
146 "TEXT_MESSAGE" => $parser->convert4mail($fields[
"POST_MESSAGE"]),
150 $dbAddedMessageFiles = \CForumFiles::GetList(array(
"ID" =>
"ASC"), array(
"MESSAGE_ID" => $messId));
151 while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch())
153 $ufFileID[] = $arAddedMessageFiles[
"FILE_ID"];
156 if (count($ufFileID) > 0)
158 $arFieldsForSocnet[
"UF_SONET_COM_FILE"] = $ufFileID;
161 $ufDocID =
$GLOBALS[
"USER_FIELD_MANAGER"]->GetUserFieldValue(
"FORUM_MESSAGE",
"UF_FORUM_MESSAGE_DOC", intval($messId), LANGUAGE_ID);
164 $arFieldsForSocnet[
"UF_SONET_COM_DOC"] = $ufDocID;
167 \CSocNetLogComments::Update($arLogComment[
"ID"], $arFieldsForSocnet);
$GLOBALS['____1979065141']