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

	$elementId = $this->entityId;

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

	$photoFields = [];

	if (isset($cache[$elementId]))
	{
		$photoFields = $cache[$elementId];
	}
	elseif (Loader::includeModule('iblock'))
	{
		$res = self::$iblockElementClass::getList([
			'filter' => [
				'=ID' => $elementId
			],
			'select' => [ 'ID', 'NAME' ]
		]);
		if ($element = $res->fetch())
		{
			$logId = false;

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

			if ($logId)
			{
				$res = self::$logClass::getList(
					[],
					[
						'=ID' => $logId
					],
					false,
					false,
					[ 'ID', 'EVENT_ID', 'URL' ],
					[
						"CHECK_RIGHTS" => "Y",
						"USE_FOLLOW" => "N",
						"USE_SUBSCRIBE" => "N"
					]
				);
				if ($logFields = $res->fetch())
				{
					$photoFields = array_merge($element, [
						'LOG_ID' => $logFields['ID'],
						'LOG_EVENT_ID' => $logFields['EVENT_ID'],
						'URL' => $logFields['URL']
					]);
				}
			}
		}

		$cache[$elementId] = $photoFields;
	}

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

	$this->setLogId($photoFields['LOG_ID']);
	$this->setSourceFields($photoFields);

	$title = $photoFields['NAME'];
	$this->setSourceDescription($title);
	$this->setSourceTitle($title);
}