View Full Version : How to attach files with new thread (using data manager) ?
ULFSoft
06-03-2009, 04:00 PM
How can i attach files when i want to create a thread with data manager?
i think that i must use class_dm_attachment.php but how?
can anyone help me?
(i am new to vb programming!)
Dismounted
06-04-2009, 05:46 AM
Have you tried looking at how vBulletin does it? Look at the forms, then looks at the processing behind them.
ULFSoft
06-04-2009, 09:07 PM
Have you tried looking at how vBulletin does it? Look at the forms, then looks at the processing behind them.
Yes,
when we want to create a new thread, there is a variable named posthash that in the processing point to the first post of thread!
but when we use data manager, posthash doesn't exist!
(sorry for my bad grammer!)
Dismounted
06-05-2009, 05:26 AM
When you call the "save" method of the Post DM, you will receive that post's ID.
ULFSoft
06-05-2009, 08:44 AM
When you call the "save" method of the Post DM, you will receive that post's ID.
require_once('global.php');
require_once('includes/class_dm.php');
require_once('includes/class_dm_threadpost.php');
require_once('includes/functions_databuild.php');
$threaddm =& datamanager_init('Thread_FirstPost', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$forumid = 12;
$title = $charNames . $txtttl . $charClass;
$pagetext = $txtbody;
$foruminfo = fetch_foruminfo($forumid);
$threaddm->set_info('forum', $foruminfo);
$forum_id = (int)$forum_id;
$pagetext = (string)strip_tags($pagetext);
$title = (string)strip_tags($title);
$threaddm->set('forumid', $foruminfo['forumid']);
$threaddm->set('userid', 1096);
$threaddm->set('title', $title);
$threaddm->set('pagetext', $pagetext);
$threaddm->set('allowsmilie', 1);
$threaddm->set('visible', 1);
$threaddm->set('dateline', TIMENOW);
$threaddm->pre_save();
if (count($threaddm->errors) > 0) {
print_r($threaddm->errors);
}
else {
$threaddm->save();
build_forum_counters($forum_id);
}
I used above code to create new thread.
Did you mean attach files after posting thread?!
But if i want to make links to attached files in the thread, i need to attach files before posting thread, or edit thread after attaching files !!!
Andreas
06-05-2009, 05:03 PM
Create a posthash, create attachments for the posthash, pass the hash to the threadfp dm - just like vBulletin does it :)
ULFSoft
06-05-2009, 05:26 PM
Create a posthash, create attachments for the posthash, pass the hash to the threadfp dm - just like vBulletin does it :)
thank you :-*,
I will try this.
ULFSoft
06-08-2009, 03:10 AM
pass the hash to the threadfp dm
Can you explain deeper? (how?)
Andreas
06-09-2009, 08:12 AM
Take a look at build_new_post() in includes/functions_newpost.php, read and learn how vBulletin does stuff :-)
$dataman->set_info('posthash', $post['posthash']);
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.