• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/search.php
  • Класс: CSocNetSearch
  • Вызов: CSocNetSearch::IBlockElementUpdate
function IBlockElementUpdate(&$arFields)
{
	//Do not index workflow history
	$WF_PARENT_ELEMENT_ID = intval($arFields["WF_PARENT_ELEMENT_ID"] ?? null);
	if($WF_PARENT_ELEMENT_ID > 0 && $WF_PARENT_ELEMENT_ID != intval($arFields["ID"]))
		return;

	if(!CModule::IncludeModule('search'))
		return;

	//And do not index wf drafts
	$rsElement = CIBlockElement::GetList(
		array(),
		array("=ID"=>$arFields["ID"]),
		false,
		false,
		array(
			"ID",
			"NAME",
			"IBLOCK_SECTION_ID",
			"WF_PARENT_ELEMENT_ID",
			"WF_STATUS_ID",
		)
	);
	$dbElement = $rsElement->Fetch();
	if(!$dbElement)
		return;

	if(!isset($arFields["NAME"]))
		$arFields["NAME"] = $dbElement["NAME"];

	if(!isset($arFields["IBLOCK_SECTION"]))
		$arFields["IBLOCK_SECTION"] = $dbElement["IBLOCK_SECTION_ID"];
	elseif (is_array($arFields["IBLOCK_SECTION"]) && isset($arFields["IBLOCK_SECTION"][0]))
		$arFields["IBLOCK_SECTION"] = $arFields["IBLOCK_SECTION"][0];

	switch(intval($arFields["IBLOCK_ID"]))
	{

	case intval($this->_params["PHOTO_GROUP_IBLOCK_ID"]):
		$path_template = trim($this->_params["PATH_TO_GROUP_PHOTO_ELEMENT"]);
		if($path_template <> '')
		{
			$this->IndexIBlockElement($arFields, $this->_group_id, "G", "photo", "view", $path_template, array("PREVIEW_TEXT"));
		}
		break;

	case intval($this->_params["PHOTO_USER_IBLOCK_ID"]):
		$path_template = trim($this->_params["PATH_TO_USER_PHOTO_ELEMENT"]);
		if($path_template <> '')
		{
			$this->IndexIBlockElement($arFields, $this->_user_id, "U", "photo", "view", $path_template, array("PREVIEW_TEXT"));
		}
		break;

	case intval($this->_params["CALENDAR_GROUP_IBLOCK_ID"]):
		$path_template = trim($this->_params["PATH_TO_GROUP_CALENDAR_ELEMENT"]);
		if($path_template <> '')
		{
			$this->IndexIBlockElement($arFields, $this->_group_id, "G", "calendar", "view", $path_template, array("DETAIL_TEXT"));
		}
		break;

	case intval($this->_params["FILES_GROUP_IBLOCK_ID"] ?? null):
		$path_template = trim($this->_params["PATH_TO_GROUP_FILES_ELEMENT"]);
		if($path_template <> '')
		{
			$property = mb_strtoupper(trim($this->_params["FILES_PROPERTY_CODE"]));
			if($property == '')
			{
				$property = "FILE";
			}

			$rsFile = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], "sort", "asc", array("CODE" => $property, "EMPTY" => "N"));
			$arFile = $rsFile->Fetch();
			if($arFile)
			{
				$arFile = CIBlockElement::__GetFileContent($arFile["VALUE"]);
				if(is_array($arFile))
				{
					$arFields["FILE_CONTENT"] = $arFile["CONTENT"];
					if($arFields["TAGS"] <> '')
					{
						$arFields["TAGS"] .= ",".$arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
					}
					else
					{
						$arFields["TAGS"] = $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
					}
				}
			}
			$this->IndexIBlockElement($arFields, $this->_group_id, "G", "files", "view", $path_template, array("FILE_CONTENT", "DETAIL_TEXT"));
		}
		break;

	case intval($this->_params["FILES_USER_IBLOCK_ID"] ?? null):
		$path_template = trim($this->_params["PATH_TO_USER_FILES_ELEMENT"]);
		if($path_template <> '')
		{
			$property = mb_strtoupper(trim($this->_params["FILES_PROPERTY_CODE"]));
			if($property == '')
			{
				$property = "FILE";
			}

			$rsFile = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], "sort", "asc", array("CODE" => $property, "EMPTY" => "N"));
			$arFile = $rsFile->Fetch();
			if($arFile)
			{
				$arFile = CIBlockElement::__GetFileContent($arFile["VALUE"]);
				if(is_array($arFile))
				{
					$arFields["FILE_CONTENT"] = $arFile["CONTENT"];
					if($arFields["TAGS"] <> '')
					{
						$arFields["TAGS"] .= ",".$arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
					}
					else
					{
						$arFields["TAGS"] = $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
					}
				}
			}
			$this->IndexIBlockElement($arFields, $this->_user_id, "U", "files", "view", $path_template, array("FILE_CONTENT", "DETAIL_TEXT"));
		}
		break;
	case intval(COption::GetOptionInt("wiki", "socnet_iblock_id")):
		if(CModule::IncludeModule("wiki"))
			$this->IndexIBlockElement($arFields, $this->_group_id, "G", "wiki", "view", $this->_params["PATH_TO_GROUP"]."wiki/#name#/", array("DETAIL_TEXT"));
		break;
	}
}