1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
comment.php
См. документацию.
1<?php
3
8
10{
11 const COMMENT_COPY_ERROR = "COMMENT_COPY_ERROR";
12
13 protected $ufEntityObject = "FORUM_MESSAGE";
14 protected $ufDiskFileField = "UF_FORUM_MESSAGE_DOC";
15
21 public function add(Container $container, array $fields)
22 {
23 $messageId = \CForumMessage::add($fields);
24
25 if (!$messageId)
26 {
27 $this->result->addError(new Error("Error creating a new comment", self::COMMENT_COPY_ERROR));
28 }
29
30 return $messageId;
31 }
32
33 public function update($commentId, array $fields)
34 {
35 return \CForumMessage::update($commentId, $fields);
36 }
37
45 public function getFields(Container $container, $entityId)
46 {
47 $message = \CForumMessage::getByIDEx($entityId);
48 return ($message ? $message : []);
49 }
50
58 public function prepareFieldsToCopy(Container $container, array $fields)
59 {
60 unset($fields["ID"]);
61
62 if ($container->getParentId())
63 {
64 $fields["TOPIC_ID"] = $container->getParentId();
65 }
66
67 $dictionary = $container->getDictionary();
68
69 if (!empty($dictionary["XML_ID"]))
70 {
71 $fields["XML_ID"] = $dictionary["XML_ID"];
72 }
73
74 return $fields;
75 }
76
85 public function copyChildren(Container $container, $entityId, $copiedEntityId)
86 {
87 $this->copyUfFields($entityId, $copiedEntityId, $this->ufEntityObject);
88
89 return new Result();
90 }
91
99 public function updateAttachedIdsInText(int $id, array $attachedIds, callable $auxiliaryCallback): void
100 {
101 list($field, $text) = $this->getText($id);
102
103 $detailText = call_user_func_array($auxiliaryCallback, [
104 $text,
105 $this->ufEntityObject,
106 $id,
107 $this->ufDiskFileField,
108 $attachedIds
109 ]);
110
111 $this->update($id, [$field => $detailText]);
112 }
113
114 protected function getText($commentId)
115 {
116 $queryObject = \CForumMessage::getlist([], [
117 "ID" => $commentId], false, 0, ["SELECT" => ["POST_MESSAGE"]]);
118
119 if ($fields = $queryObject->fetch())
120 {
121 return ["POST_MESSAGE", $fields["POST_MESSAGE"]];
122 }
123 else
124 {
125 return ["POST_MESSAGE", ""];
126 }
127 }
128}
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
getText($commentId)
Определения comment.php:114
getFields(Container $container, $entityId)
Определения comment.php:45
updateAttachedIdsInText(int $id, array $attachedIds, callable $auxiliaryCallback)
Определения comment.php:99
const COMMENT_COPY_ERROR
Определения comment.php:11
add(Container $container, array $fields)
Определения comment.php:21
update($commentId, array $fields)
Определения comment.php:33
copyChildren(Container $container, $entityId, $copiedEntityId)
Определения comment.php:85
prepareFieldsToCopy(Container $container, array $fields)
Определения comment.php:58
getParentId()
Определения container.php:70
getDictionary()
Определения container.php:89
copyUfFields(int $entityId, int $copiedEntityId, string $ufObject)
Определения copyimplementer.php:67
Определения error.php:15
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entityId
Определения payment.php:4
$message
Определения payment.php:8
$text
Определения template_pdf.php:79
$fields
Определения yandex_run.php:501