$postdm = new vB_DataManager_Post($vbulletin, ERRTYPE_STANDARD);
$postthreadid = '4473';
$postusername = 'admin';
// Use $postusername if posting as a guest, use $postuserid if posting as a user
//$postuserid = '1';
$postpagetext = 'Hi mom!';
$postdm->set_info('forum', $foruminfo);
$postdm->set_info('thread', $threadinfo);
$postdm->set('threadid', $postthreadid);
$postdm->set('username', $postusername);
// Use $postusername if posting as a guest, use $postuserid if posting as a user
//$postdm->set('userid', $postuserid);
$postdm->set('pagetext', $postpagetext);
$postdm->set('allowsmilie', 1);
$postdm->set('visible', 1);
$postdm->set('dateline', TIMENOW);
$postdm->save();
unset($postdm);
i wonder if its possible to vote threads with this too?!
i tried this:
PHP Code:
$postdm->set('votetotal', $voted);
but recieved the standard error:
Field votetotal is not defined in $validfields in class vB_DataManager_Post in [path]/includes/class_dm.php
anyone has a clue?
edit:
extending in class_dm.php with this variable works.. no error anymore, but the voting is not transfered. do i really have to write into the DB directly? or is there a way?
This is really offtopic for this thread, but if you want to rate threads, I'd check out class_dm_threadrate.php. If you want to vote in polls, class_dm_pollvote.php probably has what you need.
yeah that's exactly what I am going to do, but it seems wrong when there is an API which supposedly can do all this - but since I do not understand how it works and cannot find a working example or documentation other than the comments in the code itself it doesn;t seem likely that I am going to work it out without a miracle.
There is no miracle needed. The vbulletin code is very well organized and commented.
I guess there must be a way of telling the thread data manager to pre-load itself with the thread. Then change whatever you want to and tell it to save. That should do an update.
Read the data manager class in the includes directory. Or else read any of the default vb scripts which o an update, such as the edit thread function from thread tools dropdown.
It is. You haven't seen the bad stuff. There are a huge number of scripts out there which are not even indented properly and are being sold for $400 and above.
Setting the existing data (if necessary)
If you are using the data managers to insert a new record into the database, you do not need to perform this step. However, if you are updating an existing record (eg, editing a post), this step is mandatory.
To set the existing data, you must call the set_existing method of the data manager object.
set_existing(&$existing)
The $existing is an array of data that is currently stored in the database. It should include all the fields this data manager handles as keys. *snip*
How you could've not checked and/or found that documentation in the first place is seriously beyond me, being the first result on google for vbulletin datamanager and all. It explains everything you could need to know and also has relevant real world examples provided too. So take your ignorant minded "well documented" attack and shove it.