• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
  • Класс: CEventCalendar
  • Вызов: CEventCalendar::CheckSectionProperties
function CheckSectionProperties($iblockId, $ownerType = "")
{
	$bRes = false;
	if ($ownerType != 'USER' && $ownerType != 'GROUP')
		$ownerType = '';

	$cachePath = $this->cachePath.'checked/';
	$cacheTime = 31536000; // 1 year
	$cacheId = 'sect_'.$iblockId.$ownerType;
	$cache = new CPHPCache;

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

	if (!$bRes)
	{
		// Check UF for iblock sections
		global $EC_UserFields, $USER_FIELD_MANAGER;

		$arProps = array(
			array('COL', 'Color'),
			array('EXP', 'Export'),
			array('STATUS', 'Private status')
		);

		for($i = 0, $l = count($arProps); $i < $l; $i++)
		{
			$key = "UF_".$ownerType."_CAL_".$arProps[$i][0];
			$ent_id = "IBLOCK_".$iblockId."_SECTION";
			if (empty($EC_UserFields) || empty($EC_UserFields[$key]))
			{
				$db_res = CUserTypeEntity::GetList(array('ID'=>'ASC'), array("ENTITY_ID" => $ent_id, "FIELD_NAME" => $key));
				if (!$db_res || !($r = $db_res->GetNext()))
				{
					$arFields = Array(
						"ENTITY_ID" => $ent_id,
						"FIELD_NAME" => $key,
						"USER_TYPE_ID" => "string",
						"MULTIPLE" => "N",
						"MANDATORY" => "N",
					);
					$arFieldName = array();
					$rsLanguage = CLanguage::GetList();
					while($arLanguage = $rsLanguage->Fetch())
						$arFieldName[$arLanguage["LID"]] = $arProps[$i][1];
					$arFields["EDIT_FORM_LABEL"] = $arFieldName;
					$obUserField  = new CUserTypeEntity;
					$r = $obUserField->Add($arFields);
					$USER_FIELD_MANAGER->arFieldsCache = array();
				}
				$EC_UserFields = $USER_FIELD_MANAGER->GetUserFields($ent_id);
			}
		}

		$cache->StartDataCache($cacheTime, $cacheId, $cachePath);
		$cache->EndDataCache(array("id" => $iblockId.$ownerType));
	}
}