- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/copy/implement/task.php
- Класс: BitrixTasksCopyImplementTask
- Вызов: Task::copyComments
private function copyComments(Container $parentContainer, int $taskId, int $copiedTaskId)
{
if (!$this->commentCopier)
{
return new Result();
}
$dictionary = $parentContainer->getDictionary();
if (empty($dictionary['FORUM_TOPIC_ID']))
{
return new Result();
}
$topicId = $dictionary['FORUM_TOPIC_ID'];
$queryObject = TaskTable::getList([
'filter' => ['ID' => $copiedTaskId],
'select' => ['FORUM_TOPIC_ID'],
]);
if ($taskData = $queryObject->fetch())
{
$copiedTopicId = $taskData['FORUM_TOPIC_ID'];
}
else
{
return new Result();
}
$containerCollection = new ContainerCollection();
$dictionary = new Dictionary(['XML_ID' => 'TASK_' . $copiedTaskId]);
$queryObject = CForumMessage::getList([], ['TOPIC_ID' => $topicId]);
while ($forumMessage = $queryObject->Fetch())
{
$container = new Container($forumMessage["ID"]);
$container->setParentId($copiedTopicId);
$container->setDictionary($dictionary);
$containerCollection[] = $container;
}
$results = [];
if (!$containerCollection->isEmpty())
{
$results[] = $this->commentCopier->copy($containerCollection);
}
$result = $this->getResult($results);
if (!$result->getErrors())
{
$this->addSocnetLog(
$copiedTaskId,
$copiedTopicId,
$this->commentCopier->getMapIdsByImplementer(
CommentImplementer::class,
$result->getData()
)
);
}
return $result;
}