• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
  • Класс: CEventCalendar
  • Вызов: CEventCalendar::GetSectionIDByOwnerId
static function GetSectionIDByOwnerId($ownerId, $ownerType, $iblockId)
{
	$cache = new CPHPCache;
	$cachePath = "event_calendar/section_id_by_owner/";
	$cacheTime = 2592000; // 30 days
	$cacheId = $ownerId."-".$ownerType."-".$iblockId;

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

	if (empty($res['section_id']) || !$res['section_id'])
	{
		$arFilter = Array(
			"SECTION_ID" => '',
			"IBLOCK_ID" => $iblockId,
			"ACTIVE"	=> "Y",
			'CHECK_PERMISSIONS' => 'N',
		);
		if ($ownerType == 'USER')
			$arFilter["CREATED_BY"] = $ownerId;
		elseif ($ownerType == 'GROUP')
			$arFilter["SOCNET_GROUP_ID"] = $ownerId;
		$rsData = CIBlockSection::GetList(Array('ID' => 'ASC'), $arFilter);
		if ($sect = $rsData->Fetch())
		{
			$section_id = $sect['ID'];
			$cache->StartDataCache($cacheTime, $cacheId, $cachePath);
			$cache->EndDataCache(array("section_id" => $section_id));
		}
		else
		{
			$section_id = false;
		}
	}

	return $section_id;
}