<?PHP
/* ====================
Seditio - Website engine
Copyright Neocrome
http://www.neocrome.net
[BEGIN_SED]
File=plugins/xsearch/xsearch.topic.add.php
Version=1.0
Updated=2009-jan-13
Type=Plugin
Author=Dmitry Lapin
Description=
[END_SED]
[BEGIN_SED_EXTPLUGIN]
Code=xsearch
Part=topicadd
File=xsearch.topic.add
Hooks=forums.newtopic.newtopic.done
Tags=
Order=98
[END_SED_EXTPLUGIN]
==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

$fpid = sed_sql_result(sed_sql_query("SELECT LAST_INSERT_ID()"), 0, 0);

require_once("plugins/xsearch/inc/xsearch.common.php");

$words = textToBaseFormWords($newmsg);
$words = implode(" ", $words);

// Insert forum post index
$sql = sed_sql_query("UPDATE `$db_forum_posts`
			SET fp_index='".sed_sql_prep($words)."' WHERE fp_id='".$fpid."'");

// Insert topic title index
$sql = sed_sql_query("SELECT p.fp_topicid, t.ft_title
			FROM `$db_forum_posts` p
			LEFT JOIN `$db_forum_topics` AS t ON t.ft_id=p.fp_topicid
			WHERE fp_id='$fpid' LIMIT 1");
$ft = sed_sql_fetcharray($sql);

$words = textToBaseFormWords($ft['ft_title']);
$words = implode(" ", $words);

$sql = sed_sql_query("UPDATE `$db_forum_topics`
			SET ft_index='".sed_sql_prep($words)."' WHERE ft_id='".$ft['fp_topicid']."'");

?>