Nimlh?g
07-16-2006, 12:19 PM
I'm working on a script, which requires multiple threads to be posted in a newly created forum.
In order to do that, I've created a little function which takes some basic info like forumid, userid, title and post content, and creates a Thread_FirstPost datamanager instance and then saves the post.
This works like a charm .. only .. it'll post the first post, and then nothing. Once I call the function once, it simply won't do anything anymore after that.
What am I doing wrong here?
Function:
// we'll be needing these :)
require_once(DIR .'/includes/class_dm.php');
require_once(DIR .'/includes/class_dm_threadpost.php');
function postThread( &$vbulletin, $forumid, $userid, $title, $text, $open=1, $sticky=0, $iconid=1, $allowsmilie=1 )
{
$visible = '1'; // we want the post to be visible
// need a datamanager to post a new thread
$newThread =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$foruminfo = verify_id('forum', $forumid, 0, 1); // post in this forum
$newThread->set('forumid', $forumid); // set the forumid
$newThread->set('userid', $userid); // post as this user
$newThread->set('pagetext', $text); // post this post
$newThread->set('title', $title); // post with this title
$newThread->set('allowsmilie', $allowsmilie); // allow smilies, or not
$newThread->set('visible', $visible); // make the post visible
$newThread->set( 'open', $open ); // locked/unlocked
$newThread->set( 'sticky', $sticky ); // sticky/unsticky
$newThread->set( 'iconid', $iconid ); // post icon
$newThread->set_info('forum', $foruminfo); // set the forum information
$newThread->save(); // save the post
unset( $newThread, $pagetext );
}
Any suggestions?
In order to do that, I've created a little function which takes some basic info like forumid, userid, title and post content, and creates a Thread_FirstPost datamanager instance and then saves the post.
This works like a charm .. only .. it'll post the first post, and then nothing. Once I call the function once, it simply won't do anything anymore after that.
What am I doing wrong here?
Function:
// we'll be needing these :)
require_once(DIR .'/includes/class_dm.php');
require_once(DIR .'/includes/class_dm_threadpost.php');
function postThread( &$vbulletin, $forumid, $userid, $title, $text, $open=1, $sticky=0, $iconid=1, $allowsmilie=1 )
{
$visible = '1'; // we want the post to be visible
// need a datamanager to post a new thread
$newThread =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$foruminfo = verify_id('forum', $forumid, 0, 1); // post in this forum
$newThread->set('forumid', $forumid); // set the forumid
$newThread->set('userid', $userid); // post as this user
$newThread->set('pagetext', $text); // post this post
$newThread->set('title', $title); // post with this title
$newThread->set('allowsmilie', $allowsmilie); // allow smilies, or not
$newThread->set('visible', $visible); // make the post visible
$newThread->set( 'open', $open ); // locked/unlocked
$newThread->set( 'sticky', $sticky ); // sticky/unsticky
$newThread->set( 'iconid', $iconid ); // post icon
$newThread->set_info('forum', $foruminfo); // set the forum information
$newThread->save(); // save the post
unset( $newThread, $pagetext );
}
Any suggestions?