The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Copy a thread with Datamanager
Is it possible to copy an existing thread to another forum without moving it using the datamanager? I know how to change the values of a thread but I'm clueless as to how to just make an exact copy elsewhere. Any help is appreciated.
|
#2
|
|||
|
|||
I think you'd have to query the database for the thread record and all post records, then use the datamanager(s) to add the thread and posts just like it was a new thread, using data from your queries. (If I remember correctly it's a 'Thread_FirstPost' datamanager for the thread and first post combined, and 'Post' datamanagers for each post after that).
|
#3
|
|||
|
|||
I'm using build_thread_counters and build_forum_counters to get all that information up to date. Do you know how to update the posting user's post count? It doesn't get increased with a manual post add.
|
#4
|
|||
|
|||
If you used the datamanager to save the posts then everything should be taken care of (including updating counts). If you didn't use the dm then you might want to look in includes/class_dm_threadpost.php and see what happens when posts are saved (I think you want functionfunction post_save_each_post() which starts around line 502).
ETA: there's probably a function called in the admincp code that recalculates the count for all users, so I suppose that's another option although that's a lot of work to do if you have a big forum. |
#5
|
|||
|
|||
Thanks for the response.
I'm using the post datamanager to add the post. Here's my code: Code:
$tdm =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); $tdm->set('userid', $userid); $tdm->set('pagetext', $text); $tdm->set('allowsmilie', 1); $tdm->set('visible', 1); $tdm->set('threadid', $threadid); $tdm->set('dateline', $date); require_once(DIR . '/includes/functions_databuild.php'); $tdm->save(); build_thread_counters($threadid); build_forum_counters(19); Does it look like something's missing in the code I'm using? |
#6
|
|||
|
|||
Hmm...try adding this:
Code:
$userinfo = fetch_userinfo($userid); $tdm->set_info('user', $userinfo); |
#7
|
|||
|
|||
Still a no go, using the following:
Code:
$tdm =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); $userinfo = fetch_userinfo($userid); $tdm->set_info('user', $userinfo); $tdm->set('userid', $userid); $tdm->set('pagetext', $text); $tdm->set('allowsmilie', 1); $tdm->set('visible', 1); $tdm->set('threadid', $threadid); $tdm->set('dateline', $date); $tdm->save(); |
#8
|
|||
|
|||
OK, try adding this:
Once at the start: Code:
$threadinfo = verify_id('thread', $threadid, 0, 1); $foruminfo = fetch_foruminfo($threadinfo['forumid']); Then for each post: Code:
$tdm->set_info('forum', $foruminfo); $tdm->set_info('thread', $threadinfo); BTW, I'm looking in includes/functions_newpost.php at function build_new_post() as well as class_dm_threadpost.php. |
#9
|
|||
|
|||
You, sir, are a gentleman and a scholar. This worked beautifully:
Code:
$tdm =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost'); $threadinfo = verify_id('thread', $threadid, 0, 1); $foruminfo = fetch_foruminfo($threadinfo['forumid']); $userinfo = fetch_userinfo($userid); $tdm->set_info('user', $userinfo); $tdm->set_info('forum', $foruminfo); $tdm->set_info('thread', $threadinfo); $tdm->set('userid', $userid); $tdm->set('pagetext', $text); $tdm->set('allowsmilie', 1); $tdm->set('visible', 1); $tdm->set('threadid', $threadid); $tdm->set('dateline', $date); $tdm->save(); require_once(DIR . '/includes/functions_databuild.php'); build_thread_counters($threadid); build_forum_counters(19); |
#10
|
||||
|
||||
great ,but how do we also add tags to a thread using the datamanager method
i tried with do_set('taglist','tag1,tag2') and it shows the tags under the post but when clicked it says invalid tags . seems some "rebuild/reindex" problem |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|