PDA

View Full Version : Code to Post automatically


VBCoder
06-12-2005, 05:51 PM
I wrote some code to use DM to post:

$newpost =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, threadpost);
$newpost->set('forumid', 2);
$newpost->set('title', "Test " . rand());
$newpost->set('userid', "1");
$newpost->set('pagetext', "Testing Testing Testing Testing " . rand() . " " . rand());
$newpost->set('allowsmilie', 0);

if ($newpost->errors)
{
print ("Errors: ");
print_r ($newpost->errors);
} else {
print ($newpost->save());
}


After running it, the new posts do appear in the thread and post table, but, they don't show on the forum pages! (I wrote similar code to reply to threads, and got the same results).

I'm not sure what the problem is... it seems like the forum pages are denormalized and need to be rebuilt explicilty... I took a look at the build_new_post() and they used set_info() instead of plain set() - not sure what that is or if it's relevant.

Any ideas?

Zachery
06-12-2005, 06:04 PM
I wrote some code to use DM to post:

$newpost =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, threadpost);
$newpost->set('forumid', 2);
$newpost->set('title', "Test " . rand());
$newpost->set('userid', "1");
$newpost->set('pagetext', "Testing Testing Testing Testing " . rand() . " " . rand());
$newpost->set('allowsmilie', 0);

if ($newpost->errors)
{
print ("Errors: ");
print_r ($newpost->errors);
} else {
print ($newpost->save());
}


After running it, the new posts do appear in the thread and post table, but, they don't show on the forum pages! (I wrote similar code to reply to threads, and got the same results).

I'm not sure what the problem is... it seems like the forum pages are denormalized and need to be rebuilt explicilty... I took a look at the build_new_post() and they used set_info() instead of plain set() - not sure what that is or if it's relevant.

Any ideas?
Did you update the forum cache as well?

VBCoder
06-12-2005, 06:13 PM
Did you update the forum cache as well?
No, I did not. I'm not familiar with this. How do I do this?

Zachery
06-12-2005, 06:18 PM
There should be a function to update the datastore so the forums get recached.

VBCoder
06-12-2005, 06:22 PM
I don't see it being called from build_new_post(). Zachary, are you sure? If so, could you show me this function?

On old versions, I've been able to do the whole thing simply using build_new_post, so this would be a big change