Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
taskcomment.php
1<?php
3
4use \Bitrix\Forum\MessageTable;
5
6class TaskComment extends Entity
7{
13 public static function getData(int $sourceId): ?array
14 {
15 if (
16 \Bitrix\Main\Loader::includeModule('tasks') &&
17 \Bitrix\Main\Loader::includeModule('forum')
18 )
19 {
20 $res = MessageTable::getList([
21 'select' => [
22 'TOPIC_ID', 'POST_MESSAGE'
23 ],
24 'filter' => [
25 'ID' => $sourceId,
26 '=APPROVED' => 'Y'
27 ],
28 'limit' => 1
29 ]);
30 if ($comment = $res->fetch())
31 {
32 [$tasks, ] = \CTaskItem::fetchList(
34 [],
35 ['FORUM_TOPIC_ID' => $comment['TOPIC_ID']]
36 );
37 if ($tasks)
38 {
39 $params = [];
40 $taskData = $tasks[0]->getData();
41 $blocks = [[
42 'type' => 'header',
43 'content' => $taskData['TITLE']
44 ]];
45 if (\Bitrix\Main\Loader::includeModule('disk'))
46 {
47 $params = [
48 'files' => self::getDiskFiles(
49 $sourceId,
50 \Bitrix\Disk\Uf\ForumMessageConnector::class,
51 'forum'
52 )
53 ];
54 }
55 $blocks = array_merge(
56 $blocks,
57 Parser::textToBlocks($comment['POST_MESSAGE'], $params)
58 );
59 return [
60 'TITLE' => \truncateText($taskData['TITLE'], self::TITLE_LENGTH),
61 'BLOCKS' => $blocks
62 ];
63 }
64 }
65 }
66
67 return null;
68 }
69}
static getDiskFiles(int $sourceId, string $entityType, string $module)
Definition entity.php:18
static textToBlocks(string $text, array $params=[])
Definition parser.php:212