• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/update/timemanversion18user.php
  • Класс: BitrixTimemanUpdateTimemanVersion18User
  • Вызов: TimemanVersion18User::_GetTreeSettings
static function _GetTreeSettings()
{
	global $USER_FIELD_MANAGER, $CACHE_MANAGER;

	self::$SECTIONS_SETTINGS_CACHE = [];

	$ibDept = COption::GetOptionInt('intranet', 'iblock_structure', false);

	$cache_id = 'timeman|structure_settings|' . $ibDept;

	if (CACHED_timeman_settings !== false
		&& $CACHE_MANAGER->Read(CACHED_timeman_settings, $cache_id, "timeman_structure_" . $ibDept))
	{
		self::$SECTIONS_SETTINGS_CACHE = $CACHE_MANAGER->Get($cache_id);
	}
	else
	{
		$arAllFields = $USER_FIELD_MANAGER->GetUserFields('IBLOCK_' . $ibDept . '_SECTION');

		$arUFValues = [];

		$arEnumFields = ['UF_TIMEMAN', 'UF_TM_REPORT_REQ', 'UF_TM_FREE', 'UF_REPORT_PERIOD'];
		foreach ($arEnumFields as $fld)
		{
			$dbRes = CUserFieldEnum::GetList([], [
				'USER_FIELD_ID' => $arAllFields[$fld]['ID'],
			]);
			while ($arRes = $dbRes->Fetch())
			{
				$arUFValues[$arRes['ID']] = $arRes['XML_ID'];
			}
		}

		$arSettings = ['UF_TIMEMAN', 'UF_TM_MAX_START', 'UF_TM_MIN_FINISH', 'UF_TM_MIN_DURATION', 'UF_TM_REPORT_REQ',
			'UF_TM_REPORT_TPL', 'UF_TM_FREE', 'UF_TM_REPORT_DATE', 'UF_TM_DAY', 'UF_REPORT_PERIOD', 'UF_TM_TIME', 'UF_TM_ALLOWED_DELTA'];
		$arReportSettings = ['UF_TM_REPORT_DATE', 'UF_TM_DAY', 'UF_TM_TIME'];
		$dbRes = CIBlockSection::GetList(
			["LEFT_MARGIN" => "ASC"],
			['IBLOCK_ID' => $ibDept, 'ACTIVE' => 'Y'],
			false,
			['ID', 'IBLOCK_SECTION_ID', 'UF_TIMEMAN', 'UF_TM_MAX_START', 'UF_TM_MIN_FINISH', 'UF_TM_MIN_DURATION', 'UF_TM_REPORT_REQ',
				'UF_TM_REPORT_TPL', 'UF_TM_FREE', 'UF_REPORT_PERIOD', 'UF_TM_REPORT_DATE', 'UF_TM_DAY', 'UF_TM_TIME', 'UF_TM_ALLOWED_DELTA']
		);
		while ($arRes = $dbRes->Fetch())
		{
			$arSectionSettings = [];
			foreach ($arSettings as $key)
			{
				$arSectionSettings[$key] = ($arRes[$key] && $arRes[$key] != '00:00'
					? (
					isset($arUFValues[$arRes[$key]]) && !in_array($key, $arReportSettings)
						? $arUFValues[$arRes[$key]]
						: (
					in_array($key, $arReportSettings)
						? $arRes[$key]
						: (
					is_array($arRes[$key])
						? $arRes[$key]
						: self::MakeShortTS($arRes[$key])
					)

					)
					)
					: (
					$arRes['IBLOCK_SECTION_ID'] > 0
						? '_PARENT_|' . $arRes['IBLOCK_SECTION_ID']
						: ''
					)
				);
			}

			self::$SECTIONS_SETTINGS_CACHE[$arRes['ID']] = $arSectionSettings;
		}

		if (CACHED_timeman_settings !== false)
		{
			$CACHE_MANAGER->Set($cache_id, self::$SECTIONS_SETTINGS_CACHE);
		}
	}
}