• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/livefeed/forumtopic.php
  • Класс: BitrixSocialnetworkLivefeedForumTopic
  • Вызов: ForumTopic::initSourceFields
public function initSourceFields()
{
	$messageId = $this->entityId;

	if (
		$messageId > 0
		&& Loader::includeModule('forum')
	)
	{
		$res = MessageTable::getList(array(
			'filter' => array(
				'=ID' => $messageId
			),
			'select' => array('ID', 'TOPIC_ID', 'POST_MESSAGE')
		));
		if ($message = $res->fetch())
		{
			$logId = false;

			$res = LogTable::getList(array(
				'filter' => array(
					'SOURCE_ID' => $messageId,
					'@EVENT_ID' => $this->getEventId(),
				),
				'select' => array('ID')
			));
			if ($logEntryFields = $res->fetch())
			{
				$logId = (int)$logEntryFields['ID'];
			}

			if ($logId)
			{
				$res = CSocNetLog::getList(
					array(),
					array(
						'=ID' => $logId
					),
					false,
					false,
					array('ID', 'EVENT_ID', 'URL'),
					array(
						"CHECK_RIGHTS" => "Y",
						"USE_FOLLOW" => "N",
						"USE_SUBSCRIBE" => "N"
					)
				);
				if ($logFields = $res->fetch())
				{
					$this->setLogId($logFields['ID']);
					$this->setSourceFields(array_merge($message, array(
						'LOG_EVENT_ID' => $logFields['EVENT_ID'],
						'URL' => $logFields['URL']
					)));
					$this->setSourceDescription($message['POST_MESSAGE']);

					$title = '';
					$res = TopicTable::getList(array(
						'filter' => array(
							'=ID' => $message['TOPIC_ID']
						),
						'select' => array('TITLE')
					));
					if ($topic = $res->fetch())
					{
						$title = htmlspecialcharsback($topic['TITLE']);
						$title = BitrixSocialnetworkHelperMention::clear($title);

						$CBXSanitizer = new CBXSanitizer;
						$CBXSanitizer->delAllTags();
						$title = preg_replace(array("/n+/is".BX_UTF_PCRE_MODIFIER, "/s+/is".BX_UTF_PCRE_MODIFIER), " ", $CBXSanitizer->sanitizeHtml($title));

					}
					$this->setSourceTitle(truncateText($title, 100));
					$this->setSourceAttachedDiskObjects($this->getAttachedDiskObjects($this->cloneDiskObjects));
					$this->setSourceDiskObjects($this->getDiskObjects($messageId, $this->cloneDiskObjects));
				}
			}
		}
	}
}