1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
forumtopic.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Livefeed;
4
5use Bitrix\Forum\MessageTable;
6use Bitrix\Forum\TopicTable;
7use Bitrix\Main\Config\Option;
8use Bitrix\Main\Loader;
9use Bitrix\Socialnetwork\LogTable;
10
11final class ForumTopic extends Provider
12{
13 public const PROVIDER_ID = 'FORUM_TOPIC';
14 public const CONTENT_TYPE_ID = 'FORUM_TOPIC';
15
16 public static function getId(): string
17 {
18 return static::PROVIDER_ID;
19 }
20
21 public function getEventId(): array
22 {
23 return [ 'forum' ];
24 }
25
26 public function getType(): string
27 {
29 }
30
31 final public function setEntityId($topicId): void // patch TOPIC->POST
32 {
33 $topicId = (int)$topicId;
34 $messageId = 0;
35
36 if (
37 $topicId > 0
38 && Loader::includeModule('forum')
39 )
40 {
41 $res = MessageTable::getList(array(
42 'order' => array('ID' => 'ASC'),
43 'filter' => array(
44 'TOPIC_ID' => $topicId,
45 ),
46 'select' => array('ID')
47 ));
48 if ($message = $res->fetch())
49 {
50 $messageId = $message['ID'];
51 }
52 }
53
54 $this->entityId = $messageId;
55 }
56
57 public function getCommentProvider(): Provider
58 {
59 return new ForumPost();
60 }
61
62 public function initSourceFields()
63 {
65
66 if (
67 $messageId > 0
68 && Loader::includeModule('forum')
69 )
70 {
71 $res = MessageTable::getList(array(
72 'filter' => array(
73 '=ID' => $messageId
74 ),
75 'select' => array('ID', 'TOPIC_ID', 'POST_MESSAGE')
76 ));
77 if ($message = $res->fetch())
78 {
79 $logId = false;
80
82 'filter' => array(
83 'SOURCE_ID' => $messageId,
84 '@EVENT_ID' => $this->getEventId(),
85 ),
86 'select' => array('ID')
87 ));
88 if ($logEntryFields = $res->fetch())
89 {
90 $logId = (int)$logEntryFields['ID'];
91 }
92
93 if ($logId)
94 {
95 $res = \CSocNetLog::getList(
96 array(),
97 array(
98 '=ID' => $logId
99 ),
100 false,
101 false,
102 array('ID', 'EVENT_ID', 'URL'),
103 array(
104 "CHECK_RIGHTS" => "Y",
105 "USE_FOLLOW" => "N",
106 "USE_SUBSCRIBE" => "N"
107 )
108 );
109 if ($logFields = $res->fetch())
110 {
111 $this->setLogId($logFields['ID']);
112 $this->setSourceFields(array_merge($message, array(
113 'LOG_EVENT_ID' => $logFields['EVENT_ID'],
114 'URL' => $logFields['URL']
115 )));
116 $this->setSourceDescription($message['POST_MESSAGE']);
117
118 $title = '';
119 $res = TopicTable::getList(array(
120 'filter' => array(
121 '=ID' => $message['TOPIC_ID']
122 ),
123 'select' => array('TITLE')
124 ));
125 if ($topic = $res->fetch())
126 {
127 $title = htmlspecialcharsback($topic['TITLE']);
129
130 $CBXSanitizer = new \CBXSanitizer;
131 $CBXSanitizer->delAllTags();
132 $title = preg_replace(array("/\n+/isu", "/\s+/isu"), " ", $CBXSanitizer->sanitizeHtml($title));
133
134 }
135 $this->setSourceTitle(truncateText($title, 100));
136 $this->setSourceAttachedDiskObjects($this->getAttachedDiskObjects($this->cloneDiskObjects));
137 $this->setSourceDiskObjects($this->getDiskObjects($messageId, $this->cloneDiskObjects));
138 }
139 }
140 }
141 }
142 }
143
144 protected function getAttachedDiskObjects($clone = false)
145 {
146 return $this->getEntityAttachedDiskObjects([
147 'userFieldEntity' => 'FORUM_MESSAGE',
148 'userFieldCode' => 'UF_FORUM_MESSAGE_DOC',
149 'clone' => $clone,
150 ]);
151 }
152
153 public static function canRead($params): bool
154 {
155 return true;
156 }
157
158 protected function getPermissions(array $post): string
159 {
160 return self::PERMISSION_READ;
161 }
162
163 public function getLiveFeedUrl()
164 {
165 $pathToMessage = '';
166
167 if (
168 ($message = $this->getSourceFields())
169 && !empty($message)
170 )
171 {
172 $pathToMessage = str_replace(
173 "#GROUPS_PATH#",
174 Option::get('socialnetwork', 'workgroups_page', '/workgroups/', $this->getSiteId()),
175 $message['URL']
176 );
177 }
178
179 return $pathToMessage;
180 }
181
182 public function getAdditionalData($params = []): array
183 {
184 $result = array();
185
186 if (
188 || !Loader::includeModule('forum')
189 )
190 {
191 return $result;
192 }
193
194 $res = MessageTable::getList(array(
195 'filter' => array(
196 '@ID' => $params['id']
197 ),
198 'select' => array('ID', 'USE_SMILES')
199 ));
200
201 while ($message = $res->fetch())
202 {
203 $data = $message;
204 unset($data['ID']);
205 $result[$message['ID']] = $data;
206 }
207
208 return $result;
209 }
210}
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
Определения callback_ismscenter.php:26
static getList(array $parameters=array())
Определения datamanager.php:431
static clear(string $text='')
Определения mention.php:98
Определения forumpost.php:22
getAdditionalData($params=[])
Определения forumtopic.php:182
getPermissions(array $post)
Определения forumtopic.php:158
getAttachedDiskObjects($clone=false)
Определения forumtopic.php:144
static canRead($params)
Определения forumtopic.php:153
setSourceFields(array $fields)
Определения provider.php:639
checkAdditionalDataParams(&$params)
Определения provider.php:1466
setSourceDiskObjects(array $files)
Определения provider.php:756
setSourceAttachedDiskObjects(array $diskAttachedObjects)
Определения provider.php:751
getEntityAttachedDiskObjects(array $params=[])
Определения provider.php:1495
setSourceDescription($description)
Определения provider.php:654
getDiskObjects($entityId, $clone=false)
Определения provider.php:834
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
htmlspecialcharsback($str)
Определения tools.php:2693
$message
Определения payment.php:8
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$post
Определения template.php:8
$title
Определения pdf.php:123