• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/search_reindex.php
  • Класс: CSocNetSearchReindex
  • Вызов: CSocNetSearchReindex::UpdateForumTopicIndex
function UpdateForumTopicIndex($topic_id, $entity_type, $entity_id, $feature, $operation, $path_template)
{
	global $DB;

	if(!CModule::IncludeModule("forum"))
		return;

	$topic_id = intval($topic_id);

	$rsForumTopic = $DB->Query("SELECT FORUM_ID FROM b_forum_topic WHERE ID = ".$topic_id);
	$arForumTopic = $rsForumTopic->Fetch();
	if(!$arForumTopic)
		return;

	$arGroups = $this->GetSearchGroups(
		$entity_type,
		$entity_id,
		$feature,
		$operation
	);

	CSearch::ChangePermission("forum", $arGroups, false, $arForumTopic["FORUM_ID"], $topic_id);

	$rsForumMessages = $DB->Query("
		SELECT ID
		FROM b_forum_message
		WHERE TOPIC_ID = ".intval($topic_id)."
	");
	while($arMessage = $rsForumMessages->Fetch())
	{
		$url = str_replace(
			array(
				"#topic_id#",
				"#message_id#",
				"#action#",
			),
			array(
				$arTopic["ID"],
				$arMessage["ID"],
				"",
			),
			$path_template
		);

		CSearch::ChangeSite("forum", array(
			SITE_ID => $url,
		), $arMessage["ID"]);

		$this->_counter++;
	}

	$arParams = $this->GetSearchParams(
		$entity_type,
		$entity_id,
		$feature,
		$operation
	);

	CSearch::ChangeIndex("forum", array("UPD" => $this->_sess_id, "PARAMS"=>$arParams), false, $arForumTopic["FORUM_ID"], $topic_id);
}