phpbb\search\fulltext_sphinx::index PHP Method

index() public method

Updates wordlist and wordmatch tables when a message is posted or changed
public index ( string $mode, integer $post_id, &$message, &$subject, integer $poster_id, integer $forum_id )
$mode string Contains the post mode: edit, post, reply, quote
$post_id integer The id of the post which is modified/created
$poster_id integer Post author's user id
$forum_id integer The id of the forum in which the post is located
    public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
    {
        if ($mode == 'edit') {
            $this->sphinx->UpdateAttributes($this->indexes, array('forum_id', 'poster_id'), array((int) $post_id => array((int) $forum_id, (int) $poster_id)));
        } else {
            if ($mode != 'post' && $post_id) {
                // Update topic_last_post_time for full topic
                $sql_array = array('SELECT' => 'p1.post_id', 'FROM' => array(POSTS_TABLE => 'p1'), 'LEFT_JOIN' => array(array('FROM' => array(POSTS_TABLE => 'p2'), 'ON' => 'p1.topic_id = p2.topic_id')), 'WHERE' => 'p2.post_id = ' . (int) $post_id);
                $sql = $this->db->sql_build_query('SELECT', $sql_array);
                $result = $this->db->sql_query($sql);
                $post_updates = array();
                $post_time = time();
                while ($row = $this->db->sql_fetchrow($result)) {
                    $post_updates[(int) $row['post_id']] = array($post_time);
                }
                $this->db->sql_freeresult($result);
                if (sizeof($post_updates)) {
                    $this->sphinx->UpdateAttributes($this->indexes, array('topic_last_post_time'), $post_updates);
                }
            }
        }
    }