• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/component/loglist/paramphotogallery.php
  • Класс: BitrixSocialnetworkComponentLogListParamPhotogallery
  • Вызов: ParamPhotogallery::prepareParentPhotogalleryParams
public function prepareParentPhotogalleryParams(&$componentParams): void
{
	if (
		(
			(string)$componentParams['PHOTO_GROUP_IBLOCK_TYPE'] === ''
			|| (int)$componentParams['PHOTO_GROUP_IBLOCK_ID'] <= 0
		)
		&& Loader::includeModule('iblock'))
	{
		$ttl = 60*60*24;
		$cacheId = 'sonet_group_photo_iblock_'.SITE_ID;
		$cacheDir = '/bitrix/sonet_group_photo_iblock';
		$cache = new CPHPCache;

		if($cache->initCache($ttl, $cacheId, $cacheDir))
		{
			$cacheData = $cache->getVars();
			$componentParams['PHOTO_GROUP_IBLOCK_TYPE'] = $cacheData['PHOTO_GROUP_IBLOCK_TYPE'];
			$componentParams['PHOTO_GROUP_IBLOCK_ID'] = $cacheData['PHOTO_GROUP_IBLOCK_ID'];
			unset($cacheData);
		}
		else
		{
			$res = CIBlockType::getById('photos');
			if ($IBlockTypeFields = $res->fetch())
			{
				$resIBlock = CIBlock::getList(
					[ 'SORT' => 'ASC' ],
					[
						'IBLOCK_TYPE' => $IBlockTypeFields['ID'],
						'CODE' => [ 'group_photogallery', 'group_photogallery_'.SITE_ID ],
						'ACTIVE' => 'Y',
						'SITE_ID' => SITE_ID
					]
				);
				if ($IBlockFields = $resIBlock->fetch())
				{
					$componentParams['PHOTO_GROUP_IBLOCK_TYPE'] = $IBlockFields['IBLOCK_TYPE_ID'];
					$componentParams['PHOTO_GROUP_IBLOCK_ID'] = $IBlockFields['ID'];
				}
			}

			if ($cache->startDataCache())
			{
				$cache->endDataCache([
					'PHOTO_GROUP_IBLOCK_TYPE' => $componentParams['PHOTO_GROUP_IBLOCK_TYPE'],
					'PHOTO_GROUP_IBLOCK_ID' => $componentParams['PHOTO_GROUP_IBLOCK_ID']
				]);
			}
		}
		unset($cache);
	}
}