• Модуль: xdimport
  • Путь к файлу: ~/bitrix/modules/xdimport/classes/general/lf_scheme.php
  • Класс: CAllXDILFScheme
  • Вызов: CAllXDILFScheme::SetSonetLogRights
static function SetSonetLogRights($logID, $entity_type, $entity_id, $event_id)
{
	if (!CModule::IncludeModule("socialnetwork"))
	{
		return;
	}

	if (in_array($entity_type, array(SONET_SUBSCRIBE_ENTITY_USER, SONET_SUBSCRIBE_ENTITY_GROUP)))
	{
		if (in_array($event_id, array("blog_post", "forum", "photo", "blog_post_micro", "files", "wiki")))
		{
			$arLogEventTmp = CSocNetLogTools::FindLogEventByID($event_id);
			CSocNetLogRights::SetForSonet($logID, $entity_type, $entity_id, CSocNetLogTools::FindFeatureByEventID($event_id), $arLogEventTmp["OPERATION"]);
		}
		elseif (in_array($event_id, array("data", "system")) && $entity_type == SONET_SUBSCRIBE_ENTITY_GROUP)
		{
			CSocNetLogRights::Add($logID, array("SA", "S".SONET_SUBSCRIBE_ENTITY_GROUP.$entity_id, "S".SONET_SUBSCRIBE_ENTITY_GROUP.$entity_id."_".SONET_ROLES_OWNER, "S".SONET_SUBSCRIBE_ENTITY_GROUP.$entity_id."_".SONET_ROLES_MODERATOR, "S".SONET_SUBSCRIBE_ENTITY_GROUP.$entity_id."_".SONET_ROLES_USER));
		}
		elseif (in_array($event_id, array("data", "system")) && $entity_type == SONET_SUBSCRIBE_ENTITY_USER)
		{
			$perm = CSocNetUserPerms::GetOperationPerms($entity_id, "viewprofile");
			if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS)))
			{
				CSocNetLogRights::Add($logID, array("SA", "U".$entity_id, "S".SONET_SUBSCRIBE_ENTITY_USER.$entity_id."_".$perm));
			}
			elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED)
			{
				CSocNetLogRights::Add($logID, array("SA", "AU"));
			}
			elseif ($perm == SONET_RELATIONS_TYPE_ALL)
			{
				CSocNetLogRights::Add($logID, array("SA", "G2"));
			}
		}
	}
	elseif ($entity_type == SONET_SUBSCRIBE_ENTITY_PROVIDER)
	{
		$arRights = array("SA");
		$rsSchemeRights = CXDILFSchemeRights::GetList(array(), array("SCHEME_ID" => $entity_id));
		while($arSchemeRights = $rsSchemeRights->Fetch())
		{
			if (mb_substr($arSchemeRights["GROUP_CODE"], 0, 1) == "U")
			{
				if (mb_substr($arSchemeRights["GROUP_CODE"], 1) == "A")
				{
					$arRights[] = "AU";
					break;
				}
				elseif(mb_substr($arSchemeRights["GROUP_CODE"], 1) == "N")
				{
					$arRights[] = "G2";
					break;
				}
				elseif(intval(mb_substr($arSchemeRights["GROUP_CODE"], 1)) > 0)
				{
					$arRights[] = "U".mb_substr($arSchemeRights["GROUP_CODE"], 1);
				}
			}
		}
		if (count($arRights) > 0)
		{
			CSocNetLogRights::Add($logID, $arRights);
		}
	}
	elseif (defined("SONET_SUBSCRIBE_ENTITY_NEWS") && $entity_type == SONET_SUBSCRIBE_ENTITY_NEWS)
	{
		CSocNetLogRights::Add($logID, array("SA", "G2"));
	}
}