• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/lib/util.php
  • Класс: BitrixIntranetUtil
  • Вызов: Util::isExtranetUser
static function isExtranetUser(int $userId = null): bool
{
	if (!BitrixMainLoader::includeModule('extranet'))
	{
		return false;
	}

	$extranetGroupId = (int)BitrixMainConfigOption::get('extranet', 'extranet_group', 0);
	if (!$extranetGroupId)
	{
		return false;
	}

	if (is_null($userId))
	{
		global $USER;
		$userId = $USER->GetID();
		if ($userId <= 0)
		{
			return false;
		}

		$userGroups =  $USER->GetUserGroupArray();
	}
	else
	{
		if ($userId <= 0)
		{
			return false;
		}

		$userGroups = BitrixMainUserTable::getUserGroupIds($userId);
	}
	$userGroups = array_map('intval', $userGroups);

	return in_array($extranetGroupId, $userGroups, true);
}