function ReindexIBlock($iblock_id, $entity_type, $feature, $operation, $path_template, $arFieldList, $last_id)
{
global $DB;
if(!CModule::IncludeModule("iblock"))
return false;
$arSections = array();
$rsElements = CIBlockElement::GetList(
array("ID"=>"asc"),
array(
"IBLOCK_ID" => $iblock_id,
">ID" => intval($last_id),
"CHECK_PERMISSIONS" => "N",
),
false, false,
array_merge(
array("ID", "IBLOCK_ID", "IBLOCK_TYPE_ID", "NAME", "TAGS", "TIMESTAMP_X", "IBLOCK_SECTION_ID"),
$arFieldList
)
);
while($arFields = $rsElements->Fetch())
{
if(!array_key_exists($arFields["IBLOCK_SECTION_ID"], $arSections))
{
$rsPath = CIBlockSection::GetNavChain($arFields["IBLOCK_ID"], $arFields["IBLOCK_SECTION_ID"]);
$arSection = $rsPath->Fetch();
if($entity_type == "G")
$arSections[$arFields["IBLOCK_SECTION_ID"]] = intval($arSection["SOCNET_GROUP_ID"]);
else
$arSections[$arFields["IBLOCK_SECTION_ID"]] = intval($arSection["CREATED_BY"]);
}
$entity_id = $arSections[$arFields["IBLOCK_SECTION_ID"]];
if($entity_id)
{
$url = str_replace(
array(
"#user_id#",
"#group_id#",
"#user_alias#",
"#section_id#",
"#element_id#",
"#task_id#",
"#name#",
),
array(
$entity_id,
$entity_id,
($entity_type == "G"? "group_": "user_").$entity_id,
$arFields["IBLOCK_SECTION_ID"],
$arFields["ID"],
$arFields["ID"],
rawurlencode($arFields["NAME"]),
),
$path_template
);
$body = "";
if($feature == "wiki")
$CWikiParser = new CWikiParser();
foreach($arFieldList as $field)
{
$text = "";
if($field == "PREVIEW_TEXT" || $field == "DETAIL_TEXT")
{
if(isset($CWikiParser))
$text = HTMLToTxt($CWikiParser->parseForSearch($arFields[$field]));
elseif(isset($arFields[$field."_TYPE"]) && $arFields[$field."_TYPE"] === "html")
$text = HTMLToTxt($arFields[$field]);
else
$text = $arFields[$field];
}
elseif($field == $this->_file_property)
{
$arFile = CIBlockElement::__GetFileContent($arFields[$this->_file_property."_VALUE"]);
if(is_array($arFile))
{
$text = $arFile["CONTENT"];
$arFields["TAGS"] .= ",".$arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
}
}
elseif($field == "PROPERTY_FORUM_TOPIC_ID")
{
$topic_id = intval($arFields["PROPERTY_FORUM_TOPIC_ID_VALUE"]);
if($topic_id)
$this->UpdateForumTopicIndex($topic_id, $entity_type, $entity_id, $feature, $operation, $this->Url($url, array("MID" => "#message_id#"), "message#message_id#"));
}
$body .= $text."nr";
}
if(isset($CWikiParser))
$title = preg_replace('/^category:/i'.BX_UTF_PCRE_MODIFIER, GetMessage('CATEGORY_NAME').':', $arFields['NAME']);
else
$title = $arFields["NAME"];
$arPermissions = $this->GetSearchGroups(
$entity_type,
$entity_id,
$feature,
$operation
);
if (CIBlock::GetArrayByID($arFields["IBLOCK_ID"], "RIGHTS_MODE") == "E")
{
$obElementRights = new CIBlockElementRights($arFields["IBLOCK_ID"], $arFields["ID"]);
$arPermissions = $obElementRights->GetGroups(array("element_read"));
}
CSearch::Index("socialnetwork", $arFields["ID"], array(
"LAST_MODIFIED" => $arFields["TIMESTAMP_X"],
"TITLE" => $title,
"BODY" => $body,
"SITE_ID" => array(SITE_ID => $url),
"PARAM1" => $arFields["IBLOCK_TYPE_ID"],
"PARAM2" => $arFields["IBLOCK_ID"],
"PARAM3" => $entity_id,
"TAGS" => $arFields["TAGS"],
"PERMISSIONS" => $arPermissions,
"PARAMS" => $this->GetSearchParams(
$entity_type,
$entity_id,
$feature,
$operation
),
"REINDEX_FLAG" => true,
), true, $this->_sess_id);
$this->_counter++;
}
if($this->_end_time && $this->_end_time <= time())
return $arFields["ID"];
}
return false;
}