• Модуль: timeman
  • Путь к файлу: ~/bitrix/modules/timeman/classes/general/timeman_user.php
  • Класс: CTimeManUser
  • Вызов: CTimeManUser::__GetSettings
protected function __GetSettings($arNeededSettings, $bPersonal = false)
{
	global $CACHE_MANAGER;

	$cat = intval($bPersonal);

	if (!isset($this->SETTINGS[$cat]) || !is_array($this->SETTINGS[$cat]))
	{
		$this->SETTINGS[$cat] = [];

		$cache_id = 'timeman|structure_settings|u' . $this->USER_ID . '_' . $cat;

		if (CACHED_timeman_settings !== false
			&& $CACHE_MANAGER->Read(
				CACHED_timeman_settings,
				$cache_id,
				"timeman_structure_" . COption::GetOptionInt('intranet', 'iblock_structure', false)
			)
		)
		{
			$this->SETTINGS[$cat] = $CACHE_MANAGER->Get($cache_id);
		}
		else
		{
			$this->SETTINGS[$cat] = $bPersonal ? $this->_GetPersonalSettings() : $this->_GetSettings();

			if (CACHED_timeman_settings !== false)
			{
				$CACHE_MANAGER->Set($cache_id, $this->SETTINGS[$cat]);
			}
		}
	}
	if (is_null($arNeededSettings) ||
		(is_array($arNeededSettings) && array_key_exists('UF_TM_FREE', $arNeededSettings)))
	{
		$this->SETTINGS[$cat]['UF_TM_FREE'] = false;
		$userSchedules = BitrixTimemanServiceDependencyManager::getInstance()
			->getScheduleProvider()
			->findSchedulesByUserId($this->USER_ID, ['select' => ['ID', 'SCHEDULE_TYPE',]]);
		foreach ($userSchedules as $userSchedule)
		{
			if ($userSchedule->isFlextime())
			{
				$this->SETTINGS[$cat]['UF_TM_FREE'] = true;
				break;
			}
		}
	}

	$arSettings = $this->SETTINGS[$cat];

	if (is_array($arNeededSettings) && count($arNeededSettings) > 0)
	{
		foreach ($arSettings as $set => $value)
		{
			if (!in_array($set, $arNeededSettings))
			{
				unset($arSettings[$set]);
			}
		}
	}

	return $arSettings;
}