• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
  • Класс: CEventCalendar
  • Вызов: CEventCalendar::CheckParentProperty
function CheckParentProperty($iblockId, $parentIblock = false)
{
	$cachePath = $this->cachePath.'checked/';
	$cacheId = 'parent_property_'.$iblockId;
	$cacheTime = 31536000; // 1 year
	$cache = new CPHPCache;

	if ($cache->InitCache($cacheTime, $cacheId, $cachePath))
	{
		$res = $cache->GetVars();
		$bRes = $res['id'] == $iblockId;
	}

	if (!$bRes)
	{
		$rsProperty = CIBlockProperty::GetList(array(), array(
			"IBLOCK_ID" => $iblockId,
			"TYPE" => "E",
			"CODE" => "PARENT",
		));
		$arProperty = $rsProperty->Fetch();
		if(!$arProperty)
		{
			$obProperty = new CIBlockProperty;
			$obProperty->Add(array(
				"IBLOCK_ID" => $iblockId,
				"ACTIVE" => "Y",
				"PROPERTY_TYPE" => "E",
				"LINK_IBLOCK_ID" => $parentIblock ? $parentIblock: $iblockId,
				"MULTIPLE" => "N",
				"NAME" => GetMessage("EC_PARENT_EVENT"),
				"CODE" => "PARENT",
			));
		}
		$cache->StartDataCache($cacheTime, $cacheId, $cachePath);
		$cache->EndDataCache(array("id" => $iblockId));
	}
}