View Single Post
  #5  
Old 06-15-2008, 08:50 AM
Hereward Hereward is offline
 
Join Date: Jun 2008
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
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'$vbulletinERRTYPE_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 View Post
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'$vbulletinERRTYPE_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'$vbulletinERRTYPE_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'$vbulletinERRTYPE_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.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01397 seconds
  • Memory Usage 1,850KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete