PDA

View Full Version : Using Data Manager to create thread from outside vBulletin


mouth
09-28-2009, 01:41 PM
Hi,

New vBulletin user, having just converted from phpBB with ~15,000 users and ~1million posts. Impex worked great :) No mods (yet), just 3.8.4 out of the box. I'm good with PHP, but not enough to get my head around the data managers :o

I've read the official docs for the data mangers, read and searched through this site, and even googled and found a few examples. Spent several hours trying to get my data managers usage working, but after still failing I thought I'd ask my first post on here.

My site has an external (to vBulletin) event calendar that users can add events too (after moderation). A thread/topic was then created in phpBB for that new calendar entry with some initial text and a link back to the calendar entry details. I am trying to replicate this functionality through to vBulletin.

Is there a full and working example code available for using the data managers from outside vBulletin to create a new thread in vBulletin? I think my issue in getting this working is a combination of lacking information in the officials doc's teamed with outdated/wrong examples found in here and via google.

For your giggles, here's the code I'm currently have (after many iterations and changes) but which I still can't get to create a new thread ....

<?php

$forums_path = $_SERVER['DOCUMENT_ROOT'] . '/forums';
define('CWD', $forums_path);

require_once(CWD . '/global.php');
require_once(CWD . '/includes/class_dm.php');
require_once(CWD . '/includes/class_dm_threadpost.php');
require_once(CWD . '/includes/functions_databuild.php');

$threaddm = new vB_DataManager_Thread_FirstPost($vbulletin, ERRTYPE_STANDARD);
$post_userid = 1; // Admin
$userid = 1;
$user_name = 'Admin';
$allow_smilie = '1';
$visible = '1';

$forum_id = 65;
$title = strip_tags("Testing 1-2-3");
$post_text = strip_tags("abc 123");

$threaddm->do_set('forumid', $forum_id);
$threaddm->do_set('postuserid', $post_userid);
$threaddm->do_set('userid', $userid);
$threaddm->do_set('username', $user_name);
$threaddm->do_set('posttext', $post_text);
$threaddm->do_set('title', $title);
$threaddm->do_set('allowsmilie', $allow_smilie);
$threaddm->do_set('visible', $visible);
$threaddm->save();

build_forum_counters($forum_id);

?>

When I run the above, I get a standard forums (template) page with a message of "A required field called pagetext is missing or has an invalid value."


Thanks.

Lynne
09-28-2009, 02:27 PM
This article should help you out - Create Posts (https://vborg.vbsupport.ru/showthread.php?t=102418&highlight=vB_DataManager_Thread_FirstPost)