Log in

View Full Version : manually inserting a thread - 3 problems


Oreamnos
05-14-2006, 12:47 AM
OK, i've almost figured out how to manually start a new thread. I can get the thread to be started with the first post with the correct username in the correct forum but I am having 3 problems.

1. The user post count is not being updated.
2. I don't know how to pass $postid from build_new_post to build_new_index
3. My search index is not being rebuilt (ie. posts aren't becoming searchable)

Here's what i have. What am i doing wrong?require_once('./global.php');
require_once(DIR . '/includes/functions_newpost.php');
require_once(DIR . '/includes/functions_databuild.php');

$post['title'] = "here is my catchy title";
$post['message'] = "some fabulous message.";
$foruminfo['forumid'] = 2;

build_new_post('thread', $foruminfo, $threadinfo, $postinfo, &$post, &$errors);
build_post_index($postid, $foruminfo['forumid'], -1);

Paul M
05-14-2006, 01:00 AM
AFAIK, calling build_new_post should increase the relevant counts and add it to the index.

The code I would use is slightly different to yours ;

$postforumid = 2;
$postforum = fetch_foruminfo($postforumid);

$post['title'] = "here is my catchy title";
$post['message'] = "some fabulous message.";

require_once('./includes/functions_newpost.php');
build_new_post('thread', $postforum , array(), array(), $newpost, $errors);

After calling this, the post and thread id's should be in $newpost['threadid'] and $newpost['postid'].

Oreamnos
05-14-2006, 01:09 AM
Thanks so much! That worked perfectly. I am posting my code containing the build_post_index here just in case anyone needs it: require_once('./global.php');
require_once(DIR . '/includes/functions_newpost.php');
require_once(DIR . '/includes/functions_databuild.php');

$postforumid = 2;
$postforum = fetch_foruminfo($postforumid);

$post['title'] = "Thread Title";
$post['message'] = "First post of new thread.";

build_new_post('thread', $postforum, array(), array(), &$post, &$errors);
build_post_index($post['postid'], $post['threadid']);