• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/utils.php
  • Класс: CIntranetUtils
  • Вызов: CIntranetUtils::GetSubordinateDepartments
static function GetSubordinateDepartments($USER_ID = null, $bRecursive = false)
{
	global $USER;

	$arSections = array();

	if (!$USER_ID && $USER)
		$USER_ID = $USER->GetID();

	if ($USER_ID)
	{
		if (null == self::$SECTIONS_SETTINGS_CACHE)
			self::_GetDeparmentsTree();

		foreach (self::$SECTIONS_SETTINGS_CACHE['DATA'] as $arSection)
		{
			if ($arSection['UF_HEAD'] == $USER_ID)
			{
				$arSections[] = $arSection['ID'];
			}
		}

		if ($bRecursive && !empty($arSections))
		{
			foreach ($arSections as $section_id)
			{
				$arSections  = array_merge($arSections, self::GetDeparmentsTree($section_id, true));
			}
		}
	}

	return $arSections;
}