Hi Xia,
(Hope is not too late.. well, it will serve someone else if it's too late for you
)
Here's the code to get an instance of vbulletins' registry object (a.k.a $vbulletin).
I've placed toghether a couple pieces from various threads here in vb.org (including some of them from this same one, and from
https://vborg.vbsupport.ru/showthread.php?t=112388)
You can place the function as a method in your class and call it statically like:
PHP Code:
$vbInstance = &yourClass::_getVbulletinRegistryInstance()
(remember to use '=&', not just '=' here
)
I've successfully tested this and used a datamanager, and it worked perfectly (created thread and post correctly :-D)
This follows a singleton pattern, so you'll never overwrite the instance, even if the instance was created by vB itself.
PHP Code:
function &_getVbulletinRegistryInstance() {
define('SKIP_SESSIONCREATE', 1);
define('DIE_QUIETLY', 1);
define('THIS_SCRIPT', 'vbSupport');
$GLOBALS['phrasegroups'] = array();
$GLOBALS['specialtemplates'] = array();
$GLOBALS['globaltemplates'] = array();
$GLOBALS['actiontemplates'] = array();
$cwd = getcwd();
chdir($_SERVER['DOCUMENT_ROOT'].'/forum');
if (!isset($GLOBALS['vbulletin'])) {
include_once('./includes/init.php');
$GLOBALS['vbulletin'] = &$vbulletin;
}
chdir($cwd);
return $GLOBALS['vbulletin'];
}
regards!
Markus