• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_tools_photo.php
  • Класс: CSocNetLogToolsPhoto
  • Вызов: CSocNetLogToolsPhoto::OnAfterSectionDrop
static function OnAfterSectionDrop($ID, $arFields, $arComponentParams, $arComponentResult)
{
	if (
		array_key_exists("IS_SOCNET", $arComponentParams)
		&& $arComponentParams["IS_SOCNET"] == "Y"
		&& array_key_exists("USER_ALIAS", $arComponentParams)
		&& $arComponentParams["USER_ALIAS"] <> ''
	)
	{
		$arTmp = explode("_", $arComponentParams["USER_ALIAS"]);
		if (
			is_array($arTmp)
			&& count($arTmp) == 2
		)
		{
			$entity_type = $arTmp[0];
			$entity_id = $arTmp[1];

			if ($entity_type == "group")
				$entity_type = SONET_ENTITY_GROUP;
			elseif ($entity_type == "user")
				$entity_type = SONET_ENTITY_USER;
		}

		if (
			!in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
			|| intval($entity_id) <= 0
		)
		{
			$entity_type = SONET_ENTITY_USER;
			$entity_id = $arComponentResult["GALLERY"]["CREATED_BY"];
		}

		if (
			!in_array($entity_type, array(SONET_ENTITY_GROUP, SONET_ENTITY_USER))
			|| intval($entity_id) <= 0
		)
			return;

	}
	else
		return;

	if (array_key_exists("SECTIONS_IN_TREE", $arFields))
	{
		foreach ($arFields["SECTIONS_IN_TREE"] as $sectionID)
		{
			$db_res = CSocNetLog::GetList(
				array(),
				array(
					"ENTITY_TYPE" => $entity_type,
					"ENTITY_ID" => $entity_id,
					"EVENT_ID" => "photo",
					"SOURCE_ID" => $sectionID
				)
			);
			while ($db_res && $res = $db_res->Fetch())
				CSocNetLog::Delete($res["ID"]);
		}
	}

	if (array_key_exists("ELEMENTS_IN_TREE", $arFields))
	{
		foreach ($arFields["ELEMENTS_IN_TREE"] as $elementID)
		{
			$db_res = CSocNetLog::GetList(
				array(),
				array(
					"ENTITY_TYPE" => $entity_type,
					"ENTITY_ID" => $entity_id,
					"EVENT_ID" => "photo_photo",
					"SOURCE_ID" => $elementID
				)
			);
			while ($db_res && $res = $db_res->Fetch())
				CSocNetLog::Delete($res["ID"]);
		}
	}
}