• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/user_perms.php
  • Класс: CAllSocNetUserPerms
  • Вызов: CAllSocNetUserPerms::CanPerformOperation
static function CanPerformOperation($fromUserID, $toUserID, $operation, $bCurrentUserIsAdmin = false)
{
	global $arSocNetUserOperations;

	$fromUserID = intval($fromUserID);
	$toUserID = intval($toUserID);
	if ($toUserID <= 0)
		return false;
	$operation = mb_strtolower(Trim($operation));
	if (!array_key_exists($operation, $arSocNetUserOperations))
		return false;

// use no profile private permission restrictions at the extranet site
	if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite())
		return true;

	if ($bCurrentUserIsAdmin)
		return true;
	if ($fromUserID == $toUserID)
		return true;

	$usersRelation = CSocNetUserRelations::GetRelation($fromUserID, $toUserID);

	if ($usersRelation == SONET_RELATIONS_BAN && !IsModuleInstalled("im"))
		return false;

	$toUserOperationPerms = CSocNetUserPerms::GetOperationPerms($toUserID, $operation);

	if ($toUserOperationPerms == SONET_RELATIONS_TYPE_NONE)
		return false;
	if ($toUserOperationPerms == SONET_RELATIONS_TYPE_ALL)
		return true;

	if ($toUserOperationPerms == SONET_RELATIONS_TYPE_AUTHORIZED)
	{
		return ($fromUserID > 0);
	}

	if (
		$toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS
		|| $toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS2
	)
	{
		return CSocNetUserRelations::IsFriends($fromUserID, $toUserID);
	}

	return false;
}