mouth
10-11-2009, 08:19 AM
Hi,
Version = 3.8.4 (PL1)
I am attempting to use the data manager to create a new thread in the forums. A user add an entry to an external calendar and I want to create a new thread in the forums for the external calendar entry.
I have some test code that has vBulletin data manager code only and that works fine. The thread is successfully added to the database ....
<?
// Statements for vBulletin insert
$forums_path = $_SERVER['DOCUMENT_ROOT'] . '/forums';
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
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');
// Statements for vBulletin insert
?>
<html>
<head>
<title>Events Calendar</title>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>
<?
/* --- Insert calendar item into vBulletin forums --- */
// Statements for vBulletin insert - Refer to statements at the top of this page
$userid = 1;
// pick a forum to add the thread to
$forum_id = 82;
$title = "Testing 1-2-3";
$post_text = "Blah Blah Blah Blah";
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$foruminfo = fetch_foruminfo($forum_id);
$threaddm->set_info('forum', $foruminfo);
$threaddm->set('forumid', $foruminfo['forumid']);
$threaddm->set('userid', $userid);
$threaddm->set('title', $title);
$threaddm->set('pagetext', $post_text);
$threaddm->set('allowsmilie', 1);
$threaddm->set('visible', 1);
$threaddm->pre_save();
if (count($threaddm->errors) > 0)
{
// Errors occurred. Do not proceed with the save.
// You may want to loop through $dataman->errors and
// display the results the user.
$errorlist = '';
foreach ($threaddm->errors AS $index => $error)
{
$errorlist .= "<li>$error</li>";
}
echo "<ul>" . $errorlist . "</ul>";
}
else
{
// No errors occurred.
// Proceed with the save (see the next step).
$thread_id = $threaddm->save();
build_forum_counters($forum_id);
echo "<br />thread id: " . $thread_id . "\n";
}
/* --- Insert calendar item into vBulletin forums --- */
?>
</body>
</html>
When I insert this code into my calendar php script, the following fatal error is recorded in the php error log, when the script is run ...
PHP Fatal error: Call to undefined method db::query_first_slave() in [forums path]/includes/class_dm_threadpost.php on line 74
I have ensured that the call to vBulletin's global.php is not inside a function. Here is some of the code from my calendar script ...
<?
error_reporting(E_ALL);
session_start();
require_once($_SERVER['DOCUMENT_ROOT'] . "/include/common.inc");
require_once($_SERVER['DOCUMENT_ROOT'] . "/include/functions.inc");
require_once("include/config.php");
// connect to the database
$conn = mysql_connect($db_host, $db_user, $db_pass, true) or die("Could not connect to database!");
mysql_select_db($db_name, $conn);
// Statements for vBulletin insert
$forums_path = $_SERVER['DOCUMENT_ROOT'] . '/forums';
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
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');
// Statements for vBulletin insert
?>
<html>
<head>
[ ... ]
</head>
<body>
[ ... calendar html and php ...]
[ ... vBulletin test code as per above ... ]
[ ... calendar html and php ...]
</body>
</html>
Can anyone point me to where I can further analyse and resolve this? Or perhaps even can see my problem? Thanks.
Version = 3.8.4 (PL1)
I am attempting to use the data manager to create a new thread in the forums. A user add an entry to an external calendar and I want to create a new thread in the forums for the external calendar entry.
I have some test code that has vBulletin data manager code only and that works fine. The thread is successfully added to the database ....
<?
// Statements for vBulletin insert
$forums_path = $_SERVER['DOCUMENT_ROOT'] . '/forums';
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
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');
// Statements for vBulletin insert
?>
<html>
<head>
<title>Events Calendar</title>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>
<?
/* --- Insert calendar item into vBulletin forums --- */
// Statements for vBulletin insert - Refer to statements at the top of this page
$userid = 1;
// pick a forum to add the thread to
$forum_id = 82;
$title = "Testing 1-2-3";
$post_text = "Blah Blah Blah Blah";
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$foruminfo = fetch_foruminfo($forum_id);
$threaddm->set_info('forum', $foruminfo);
$threaddm->set('forumid', $foruminfo['forumid']);
$threaddm->set('userid', $userid);
$threaddm->set('title', $title);
$threaddm->set('pagetext', $post_text);
$threaddm->set('allowsmilie', 1);
$threaddm->set('visible', 1);
$threaddm->pre_save();
if (count($threaddm->errors) > 0)
{
// Errors occurred. Do not proceed with the save.
// You may want to loop through $dataman->errors and
// display the results the user.
$errorlist = '';
foreach ($threaddm->errors AS $index => $error)
{
$errorlist .= "<li>$error</li>";
}
echo "<ul>" . $errorlist . "</ul>";
}
else
{
// No errors occurred.
// Proceed with the save (see the next step).
$thread_id = $threaddm->save();
build_forum_counters($forum_id);
echo "<br />thread id: " . $thread_id . "\n";
}
/* --- Insert calendar item into vBulletin forums --- */
?>
</body>
</html>
When I insert this code into my calendar php script, the following fatal error is recorded in the php error log, when the script is run ...
PHP Fatal error: Call to undefined method db::query_first_slave() in [forums path]/includes/class_dm_threadpost.php on line 74
I have ensured that the call to vBulletin's global.php is not inside a function. Here is some of the code from my calendar script ...
<?
error_reporting(E_ALL);
session_start();
require_once($_SERVER['DOCUMENT_ROOT'] . "/include/common.inc");
require_once($_SERVER['DOCUMENT_ROOT'] . "/include/functions.inc");
require_once("include/config.php");
// connect to the database
$conn = mysql_connect($db_host, $db_user, $db_pass, true) or die("Could not connect to database!");
mysql_select_db($db_name, $conn);
// Statements for vBulletin insert
$forums_path = $_SERVER['DOCUMENT_ROOT'] . '/forums';
define('VB_AREA', 'External');
define('SKIP_SESSIONCREATE', 1);
define('SKIP_USERINFO', 1);
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');
// Statements for vBulletin insert
?>
<html>
<head>
[ ... ]
</head>
<body>
[ ... calendar html and php ...]
[ ... vBulletin test code as per above ... ]
[ ... calendar html and php ...]
</body>
</html>
Can anyone point me to where I can further analyse and resolve this? Or perhaps even can see my problem? Thanks.