gabestah
04-27-2014, 04:45 AM
Hello,
As the title suggests, I am trying to figure out the PHP code needed to create a plugin that generates a second, exact copy of a thread but in a specific forum using a hooked plugin for newthread_post_complete.
I've searched far and wide and the closest information I've found is a a few years old in this thread (https://vborg.vbsupport.ru/showthread.php?t=289033), but more importantly seems to be for a situation where the code is specifying a lot of the information manually (such as 'pagetext', 'userid', etc.)
The closest I've come to a solution is the following snippet of code which unfortunately instead of creating a copy of the thread, actually seems to just move the existing thread into the new forum:
// DESTINATION FORUM ID
$forumid = 2;
$dataman =& datamanager_init('Thread', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$dataman->set_existing($threadinfo);
$dataman->setr('forumid', $forumid);
$dataman->pre_save();
if (count($dataman->errors) > 0)
{
foreach ($errors as $error)
{
$errorss .= $error. "<br />";
}
$errormessage = "Form failed to submit. The following error(s) occured: <br /> ".$errorss;
eval(standard_error($errormessage));
}
else
{
$dataman->save();
$foruminfo = fetch_foruminfo($forumid);
$threadinfo = fetch_threadinfo($newpost['threadid']);
mark_thread_read($threadinfo, $foruminfo, $vbulletin->userinfo['userid'], TIMENOW);
}
My suspicion is the issue lies somewhere in the use of the "set_existing" method, which as described in the documentation (https://www.vbulletin.com/docs/html/data_manager_programming), seems to inform the data manager that we are merely updating an existing record rather than creating a new one.
If anyone has any insight into the code I might need to accomplish this I would truly appreciate any and all assistance.
Thanks!
As the title suggests, I am trying to figure out the PHP code needed to create a plugin that generates a second, exact copy of a thread but in a specific forum using a hooked plugin for newthread_post_complete.
I've searched far and wide and the closest information I've found is a a few years old in this thread (https://vborg.vbsupport.ru/showthread.php?t=289033), but more importantly seems to be for a situation where the code is specifying a lot of the information manually (such as 'pagetext', 'userid', etc.)
The closest I've come to a solution is the following snippet of code which unfortunately instead of creating a copy of the thread, actually seems to just move the existing thread into the new forum:
// DESTINATION FORUM ID
$forumid = 2;
$dataman =& datamanager_init('Thread', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$dataman->set_existing($threadinfo);
$dataman->setr('forumid', $forumid);
$dataman->pre_save();
if (count($dataman->errors) > 0)
{
foreach ($errors as $error)
{
$errorss .= $error. "<br />";
}
$errormessage = "Form failed to submit. The following error(s) occured: <br /> ".$errorss;
eval(standard_error($errormessage));
}
else
{
$dataman->save();
$foruminfo = fetch_foruminfo($forumid);
$threadinfo = fetch_threadinfo($newpost['threadid']);
mark_thread_read($threadinfo, $foruminfo, $vbulletin->userinfo['userid'], TIMENOW);
}
My suspicion is the issue lies somewhere in the use of the "set_existing" method, which as described in the documentation (https://www.vbulletin.com/docs/html/data_manager_programming), seems to inform the data manager that we are merely updating an existing record rather than creating a new one.
If anyone has any insight into the code I might need to accomplish this I would truly appreciate any and all assistance.
Thanks!