• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/livefeed/logevent.php
  • Класс: BitrixSocialnetworkLivefeedLogEvent
  • Вызов: LogEvent::initSourceFields
public function initSourceFields()
{
	static $cache = [];
	static $schemeCache = [];

	$logId = $this->entityId;

	if ($logId <= 0)
	{
		return;
	}

	if (isset($cache[$logId]))
	{
		$logEntryFields = $cache[$logId];
	}
	else
	{
		$res = LogTable::getList([
			'filter' => [
				'=ID' => $logId,
				'@EVENT_ID' => $this->getEventId(),
			],
			'select' => [ 'ID', 'TITLE', 'MESSAGE', 'PARAMS' ]
		]);

		$logEntryFields = $res->fetch();
		$cache[$logId] = $logEntryFields;
	}

	if (empty($logEntryFields))
	{
		return;
	}

	$entryParams = unserialize($logEntryFields['PARAMS'], [ 'allowed_classes' => false ]);

	if (
		!is_array($entryParams)
		&& !empty($logEntryFields['PARAMS'])
	)
	{
		$tmp = explode("&", $logEntryFields['PARAMS']);
		if (is_array($tmp) && count($tmp) > 0)
		{
			$entryParams = array();
			foreach($tmp as $pair)
			{
				[$key, $value] = explode("=", $pair);
				$entryParams[$key] = $value;
			}
		}
	}

	$html = false;
	$logEntryFields['SCHEME_FIELDS'] = [];

	$schemeId = (is_array($entryParams) && isset($entryParams['SCHEME_ID']) ? (int)$entryParams['SCHEME_ID'] : 0);
	if ($schemeId > 0)
	{
		$schemeFields = [];
		if (isset($schemeCache[$schemeId]))
		{
			$schemeFields = $schemeCache[$schemeId];
		}
		elseif (Loader::includeModule('xdimport'))
		{
			$res = CXDILFScheme::getById($schemeId);
			$schemeFields = $res->fetch();
			$schemeCache[$schemeId] = $schemeFields;
		}

		$logEntryFields['SCHEME_FIELDS'] = $schemeFields;
	}

	$this->setLogId($logEntryFields['ID']);
	$this->setSourceFields($logEntryFields);
	$this->setSourceTitle($logEntryFields['TITLE']);

	if (
		!empty($logEntryFields['SCHEME_FIELDS'])
		&& isset($logEntryFields['SCHEME_FIELDS']['IS_HTML'])
	)
	{
		$html = ($logEntryFields['SCHEME_FIELDS']['IS_HTML'] === "Y");
	}

	if ($html)
	{
		$description = htmlspecialcharsback($logEntryFields['MESSAGE']);
		$sanitizer = new CBXSanitizer();
		$sanitizer->applyDoubleEncode(false);
		$sanitizer->setLevel(CBXSanitizer::SECURE_LEVEL_LOW);
		$this->setSourceDescription($sanitizer->sanitizeHtml($description));
	}
	else
	{
		$this->setSourceDescription(htmlspecialcharsEx($logEntryFields['MESSAGE']));
	}
}