• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/lib/update/timemanversion18user.php
  • Класс: BitrixTimemanUpdateTimemanVersion18User
  • Вызов: TimemanVersion18User::GetSectionSettings
static function GetSectionSettings($section_id, $arNeededSettings = null)
{
	if (null == self::$SECTIONS_SETTINGS_CACHE)
	{
		self::_GetTreeSettings();
	}

	if ($section_id > 0)
	{
		$res = self::GetSectionPersonalSettings($section_id);

		$arSettings = is_array($arNeededSettings) ? $arNeededSettings : ['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'];

		if (is_array($res) && count($arSettings) > 0)
		{
			$parent = 0;
			foreach ($res as $key => $v)
			{
				if (!in_array($key, $arSettings))
				{
					unset($res[$key]);
				}
			}

			foreach ($arSettings as $k => $key)
			{
				if (!is_array($res[$key]) && mb_substr($res[$key], 0, 8) == '_PARENT_')
				{
					$parent = intval(mb_substr($res[$key], 9));
					unset($res[$key]);
				}
				else
				{
					unset($arSettings[$k]);
				}
			}

			if (count($arSettings) > 0 && $parent > 0)
			{
				$res = array_merge($res, self::GetSectionSettings($parent, $arSettings));
			}

			if ($arNeededSettings === null)
			{
				foreach ($res as $key => $value)
				{
					if (!is_array($res[$key]) && mb_substr($res[$key], 0, 8) == '_PARENT_')
					{
						$res[$key] = '';
					}
				}
			}

			if (isset($res['UF_TIMEMAN']) && !$res['UF_TIMEMAN'])
			{
				$res['UF_TIMEMAN'] = 'Y';
			}
			if (isset($res['UF_TM_REPORT_TPL']) && !is_array($res['UF_TM_REPORT_TPL']))
			{
				$res['UF_TM_REPORT_TPL'] = [];
			}

			return $res;
		}
	}

	return [];
}