• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/user.php
  • Класс: CAllUser
  • Вызов: CAllUser::GetSubordinateGroups
static function GetSubordinateGroups(int $userID = null): array
{
	global $USER;

	static $groupsCache = [];

	if ($userID === null && $USER instanceof self)
	{
		$userID = (int)$USER->getId();

		// groups from the session
		$userGroups = $USER->GetUserGroupArray();
	}
	elseif ($userID > 0)
	{
		// groups from the DB
		$userGroups = static::GetUserGroup($userID);
	}
	else
	{
		return [];
	}

	if (isset($groupsCache[$userID]))
	{
		$result = $groupsCache[$userID];
	}
	else
	{
		$result = CGroup::GetSubordinateGroups($userGroups);

		$groupsCache[$userID] = $result;
	}

	return $result;
}