Quote:
Originally Posted by Opserty
|
hi - thanks for that!
in the example you referenced there is a variable $vbulletin which is passed as a parameter to the datamanager_init function. How is that variable created?
Also wondering which php files I need to
require for
datamanager_init to work.
PHP Code:
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$forumid = $vbulletin->GPC['fid']; // can also be a number ;) $forumdid= 12;
$foruminfo = fetch_foruminfo($forumid);
$threaddm->set_info('forum', $foruminfo);
$threaddm->set('forumid', $foruminfo['forumid']);
$threaddm->set('userid', 1234);
$threaddm->set('title', 'Testtitle');
$threaddm->set('pagetext', 'a little test');
$threaddm->set('allowsmilie', 1);
$threaddm->set('visible', 1);
$threaddm->set('dateline', TIMENOW);
$threaddm->save();
--------------- Added [DATE]1213523643[/DATE] at [TIME]1213523643[/TIME] ---------------
Quote:
Originally Posted by Opserty
Check the thread datamanager files in the include directory. class_dm_thread*.php
TYPE_xxx defines their type and requirements.
--------------- Added [DATE]1213523255[/DATE] at [TIME]1213523255[/TIME] ---------------
Maybe of interest: Data Managers
|
OK - i will start reading the manual.
--------------- Added [DATE]1213524531[/DATE] at [TIME]1213524531[/TIME] ---------------
PHP Code:
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
In the manual it says (in regard to the 2nd param):
Quote:
$registry - the main registry object used by vBulletin to hold application-level data. In most cases, this will be the variable $vbulletin.
|
Do I need to use this? If so, how do I construct the object ($vbulletin)?
I am guessing that maybe I don't need it because in the sample code it is only used to fetch an id - but in my case I will be passing that as a separate param:
PHP Code:
$forumid = $vbulletin->GPC['fid'];
So can I get away with passing an empty string as "the main registry object" or will this cause the function to fail?
--------------- Added [DATE]1213525869[/DATE] at [TIME]1213525869[/TIME] ---------------
OK, small question:
where does the function
datamanager_init live?
This seems to be the key to it all. it would be nice if there was a working sample that showed what needs to be in the required path etc..
--------------- Added [DATE]1213526137[/DATE] at [TIME]1213526137[/TIME] ---------------
OK I found it in functions.php
so i guess I need to start with something like:
PHP Code:
require $root_path/functions.php;
--------------- Added [DATE]1213526419[/DATE] at [TIME]1213526419[/TIME] ---------------
In the comments for
datamanager_init we see:
PHP Code:
/*
* Class factory. This is used for instantiating the extended classes.
*
* @param string The type of the class to be called (user, forum etc.)
* @param vB_Registry An instance of the vB_Registry object.
* @param integer One of the ERRTYPE_x constants
* @param string Option to force loading a class from a specific file; no extension
*
* @return vB_DataManager An instance of the desired class
*/
question: How do I construct the vB_Registry object?
--------------- Added [DATE]1213527347[/DATE] at [TIME]1213527347[/TIME] ---------------
OK, looks like I need something like the following:
PHP Code:
<?php
require $root_path/includes/class_core.php;
require $root_path/functions.php;
$vbulletin = new vB_Registry();
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$forumid = $vbulletin->GPC['fid']; // can also be a number ;) $forumdid= 12;
$foruminfo = fetch_foruminfo($forumid);
$threaddm->set_info('forum', $foruminfo);
$threaddm->set('forumid', $foruminfo['forumid']);
$threaddm->set('userid', 1234);
$threaddm->set('title', 'Testtitle');
$threaddm->set('pagetext', 'a little test');
$threaddm->set('allowsmilie', 1);
$threaddm->set('visible', 1);
$threaddm->set('dateline', TIMENOW);
$threaddm->save();
?>
--------------- Added [DATE]1213529047[/DATE] at [TIME]1213529047[/TIME] ---------------
OK, I have no confirmed that the above DOES NOT WORK.
Can anyone tell me what is wrong with the code or should I just give up?
--------------- Added [DATE]1213531637[/DATE] at [TIME]1213531637[/TIME] ---------------
The following is tested and WORKS:
PHP Code:
<?php
define('VB_AREA', 'Forum');
define('CWD', (($getcwd = getcwd()) ? $getcwd : '.'));
require_once("./includes/init.php");
define('DIR', CWD);
require_once "./includes/functions.php";
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$forumid = 30; //$vbulletin->GPC['fid']; // can also be a number ;) $forumdid= 12;
$foruminfo = fetch_foruminfo($forumid);
$threaddm->set_info('forum', $foruminfo);
$threaddm->set('forumid', $foruminfo['forumid']);
$threaddm->set('userid', 1);
$threaddm->set('title', 'Testtitle');
$threaddm->set('pagetext', 'a little test');
$threaddm->set('allowsmilie', 1);
$threaddm->set('visible', 1);
$threaddm->set('dateline', TIMENOW);
$threaddm->save();
print "The action was performed.";
?>
--------------- Added [DATE]1213531734[/DATE] at [TIME]1213531734[/TIME] ---------------
NOTE: The file needs to be placed
at the root level of your vbulletin installation.