• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/utils.php
  • Класс: CIntranetUtils
  • Вызов: CIntranetUtils::GetDeparmentsTree
static function GetDeparmentsTree($section_id = 0, $bFlat = false)
{
	if (null == self::$SECTIONS_SETTINGS_CACHE)
		self::_GetDeparmentsTree();

	if (!$section_id)
	{
		if (!$bFlat)
			return self::$SECTIONS_SETTINGS_CACHE['TREE'];
		else
			return array_keys(self::$SECTIONS_SETTINGS_CACHE['DATA']);
	}

	$arSections = self::$SECTIONS_SETTINGS_CACHE['TREE'][$section_id] ?? null;

	if (is_array($arSections) && !empty($arSections))
	{
		if ($bFlat)
		{
			foreach ($arSections as $subsection_id)
			{
				$arSections = array_merge($arSections, self::GetDeparmentsTree($subsection_id, $bFlat));
			}
		}
		else
		{
			$arSections = array($section_id => $arSections);
			foreach ($arSections[$section_id] as $subsection_id)
			{
				$arSections += self::GetDeparmentsTree($subsection_id, $bFlat);
			}
		}
	}

	return is_array($arSections) ? $arSections : array();
}