• Модуль: extranet
  • Путь к файлу: ~/bitrix/modules/extranet/classes/general/extranet.php
  • Класс: CExtranet
  • Вызов: CExtranet::IsProfileViewable
static function IsProfileViewable($arUser, $site_id = false, $bOnlyActive = true, $arContext = array()): bool
{
	global $USER;

	if (isset($arUser['EXTERNAL_AUTH_ID']))
	{
		if ($arUser['EXTERNAL_AUTH_ID'] === 'replica')
		{
			return true;
		}

		if ($arUser['EXTERNAL_AUTH_ID'] === 'email')
		{
			return false;
		}
	}

	// if current user is admin
	if (self::IsExtranetAdmin())
	{
		return true;
	}

	// if extranet site is not set
	if (!self::GetExtranetSiteID())
	{
		return true;
	}

	// if current user is not authorized
	if (!$USER->IsAuthorized())
	{
		return false;
	}

	// if intranet and current user is not employee
	if (
		!self::IsExtranetSite($site_id)
		&& !self::IsIntranetUser()
	)
	{
		return false;
	}

	$bNeedCheckContext = false;

	// if intranet and profile user is not employee
	if (!self::IsExtranetSite($site_id))
	{
		if (
			(
				(
					!is_array($arUser["UF_DEPARTMENT"])
					&& (int)$arUser["UF_DEPARTMENT"] > 0
				)
				|| (
					is_array($arUser["UF_DEPARTMENT"])
					&& (int)$arUser["UF_DEPARTMENT"][0] > 0
				)
			)
			&& self::IsIntranetUser()
		)
		{
			return true;
		}

		$arUsersInMyGroupsID = self::GetMyGroupsUsers(self::GetExtranetSiteID(), false, $bOnlyActive);
		if (
			!in_array($arUser["ID"], $arUsersInMyGroupsID)
			&& ((int)$arUser["ID"] !== (int)$USER->GetID())
		)
		{
			$bNeedCheckContext = true;
		}
	}

	// if extranet and profile user not public
	if (self::IsExtranetSite($site_id))
	{
		if ((int)$arUser[COption::GetOptionString("extranet", "extranet_public_uf_code", "UF_PUBLIC")] === 1)
		{
			return true;
		}

		$arUsersInMyGroupsID = self::GetMyGroupsUsers(SITE_ID);
		if (
			!in_array($arUser["ID"], $arUsersInMyGroupsID)
			&& ((int)$arUser["ID"] !== (int)$USER->GetID())
		)
		{
			$bNeedCheckContext = true;
		}
	}

	if ($bNeedCheckContext)
	{
		if (
			isset($arContext["ENTITY_TYPE"], $arContext["ENTITY_ID"])
			&& $arContext["ENTITY_TYPE"] === "LOG_ENTRY"
			&& (int)$arContext["ENTITY_ID"] > 0
		)
		{
			return CSocNetUser::CheckContext(
				$USER->GetID(),
				$arUser["ID"],
				array_merge($arContext, [ 'SITE_ID' => self::GetExtranetSiteID() ])
			);
		}

		return false;
	}

	return true;
}