Well it seems noone cared to help or just didn't know how so I sought out the information I wanted and I will be nice and show you the class I wrote specifically for my forums. So you may want to modify it to suite your needs. However, I am trying to be nice by adding this here so please do not flame my coding style..
Code:
<?php
require_once('global.php');
require_once('includes/class_dm.php');
require_once('includes/class_dm_poll.php');
require_once('includes/class_dm_threadpost.php');
require_once('includes/functions_databuild.php');
define(FORUM_ID, 29); //-> Forum Id of poster's forum
define(USER_ID, 1); //-> User Id of poster
$instance = $vbulletin; //-> Fix for FATAL ERROR: Registry not found
class ThreadPoll
{
var $threadId,
$pollId,
$forumId;
function ThreadPoll()
{
$forumId = FORUM_ID;
}
function InitPoll($question)
{
global $instance;
$poll =& datamanager_init('Poll', $instance, ERRTYPE_STANDARD);
$poll->setr('question', $question);
$poll->set_option("YES");
$poll->set_option("NO");
$poll->set_vote(0);
$poll->pre_save();
if (!empty($poll->errors))
{
echo ($poll->errors);
exit;
}
$this->pollId = $poll->save();
unset($poll);
}
function InitThread($title, $pagetext)
{
global $instance;
$thread =& datamanager_init('Thread_FirstPost', $instance, ERRTYPE_ARRAY, 'threadpost');
$forumInfo = fetch_foruminfo($forumId);
$thread->set('forumid', FORUM_ID);
$thread->setr('title', $title);
$thread->setr('pagetext', $pagetext);
$thread->setr('pollid', $this->pollId);
$thread->set('userid', USER_ID);
$thread->set('open', 1);
$thread->set('visible', 1);
$thread->set('allowsmilie', 1);
$thread->set_info('forum', $forumInfo);
$thread->set_info('thread', array());
$thread->pre_save();
if (!empty($thread->errors))
{
print_r($thread->errors);
exit;
}
$threadId = $thread->save();
unset($thread);
}
function BuildThread()
{
build_thread_counters($threadId);
build_forum_counters(FORUM_ID);
}
}
$obj = new ThreadPoll;
$obj->InitPoll("Poll Question");
$obj->InitThread("Title of the thread", "Text to be display in first post.. use \n for new line");
$obj->BuildThread();
?>