I'm trying to make a plugin that does something along the line of this one:
http://mods.mybboard.net/view/rss-to-post
Only it wont be based on rss feeds.
For now I'm stuck with a simple task script that wont work (runs fine but does nothing ) - :
Basically I stripped the afore mentioned plugin's task script of anything but the thread creation part. My hunch is that fid and uid is what causes the problem, but I've no way of knowing that...
So, if anyone could kindly tell me how to correctly set those, or whatever other code I'm missing for this simple routine to work, I'd be more than gratefull.
edit: nvm - there was nothing wrong with my code, except the function needs to be named task_[exact name of php script w/o .php extension] :p
http://mods.mybboard.net/view/rss-to-post
Only it wont be based on rss feeds.
For now I'm stuck with a simple task script that wont work (runs fine but does nothing ) - :
<?php
function task_post_task($task)
{
global $db, $lang, $cache, $mybb;
// Add thread to forum (code based on MyBB 1.2.1 newthread.php)
// Set up posthandler.
require_once MYBB_ROOT."inc/datahandlers/post.php";
$posthandler = new PostDataHandler("insert");
$posthandler->action = "thread";
// Set the thread data
$new_thread = array(
"fid" => 2,
"subject" => 'oh hai thar',
"icon" => -1,
"uid" => 1,
"username" => 'phatmin',
"message" => 'this is an automated post',
"ipaddress" => '127.0.0.1',
"posthash" => '',
"savedraft" => 0,
);
// Set up the thread options
$new_thread['options'] = array(
"signature" => 'yes',
"emailnotify" => 'no',
"disablesmilies" => 'no'
);
$posthandler->set_data($new_thread);
// Now let the post handler do all the hard work.
if($posthandler->validate_thread())
{
$thread_info = $posthandler->insert_thread();
}
}
?>
Basically I stripped the afore mentioned plugin's task script of anything but the thread creation part. My hunch is that fid and uid is what causes the problem, but I've no way of knowing that...
So, if anyone could kindly tell me how to correctly set those, or whatever other code I'm missing for this simple routine to work, I'd be more than gratefull.
edit: nvm - there was nothing wrong with my code, except the function needs to be named task_[exact name of php script w/o .php extension] :p