• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/socialnetwork/livefeed/crmentitycomment.php
  • Класс: Bitrix\Crm\Integration\Socialnetwork\Livefeed\CrmEntityComment
  • Вызов: CrmEntityComment::initSourceFields
public function initSourceFields()
{
	$commentId = $this->getEntityId();

	if ($commentId > 0)
	{
		$logId = false;

		$res = LogCommentTable::getList(array(
			'filter' => array(
				'=ID' => $commentId,
				'@EVENT_ID' => $this->getEventId(),
			),
			'select' => array('LOG_ID', 'MESSAGE')
		));
		if ($logComentFields = $res->fetch())
		{
			$logId = (int)$logComentFields['LOG_ID'];
		}

		if ($logId)
		{
			$res = \CSocNetLog::getList(
				array(),
				array(
					'=ID' => $logId
				),
				false,
				false,
				array('ID', 'EVENT_ID'),
				array(
					"CHECK_CRM_RIGHTS" => "Y",
					"IS_CRM" => "Y"
				)
			);
			if ($logFields = $res->fetch())
			{
				$this->setLogId($logFields['ID']);
				$this->setSourceFields(array_merge($logComentFields, array('LOG_EVENT_ID' => $logFields['EVENT_ID'])));
				$this->setSourceDescription($logComentFields['MESSAGE']);

				$title = htmlspecialcharsback($logComentFields['MESSAGE']);
				$title = preg_replace(
					"/\[USER\s*=\s*([^\]]*)\](.+?)\[\/USER\]/is".BX_UTF_PCRE_MODIFIER,
					"\\2",
					$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($commentId, $this->cloneDiskObjects));
			}
		}
	}

}