PDA

View Full Version : How can I edit two posts at the same time?


DivinoZarathos
05-14-2012, 08:13 PM
I'm building a vB modification that allows moderators to duplicate a post and insert it in another existing thread only once. I added a column to the post sql table that keeps track of the "link" between the two posts.
I can already delete both posts if one of them is deleted, but now I would like to create a specular post editing system so that if one of the two posts is edited, the other reflects the same changes.
Let's say I have a post with ID=10. It is duplicated by a mod and inserted into another thread: the duplicated post has ID=11. Now in my database post ID=10 will have LINKID=11 and post ID=11 will have LINKID=10.
How can I hook into editpost.php so that if I edit post ID=10, post ID=11 also get edited and vice-versa?

Many thanks.

kh99
05-14-2012, 09:34 PM
What you might want to do is look at includes/class_dm_threadpost.php and find the place where an edited post is actually updated. Then you might be able to find a place to check your link field and modify the other post in the same way.

DivinoZarathos
05-14-2012, 09:51 PM
I found this:

$dataman =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$dataman->set_existing($postinfo);

($hook = vBulletinHook::fetch_hook('editpost_update_process ')) ? eval($hook) : false;

$dataman->set_info('parseurl', (($vbulletin->options['allowedbbcodes'] & ALLOW_BBCODE_URL) AND $foruminfo['allowbbcode'] AND $edit['parseurl']));
$dataman->set_info('posthash', $posthash);
$dataman->set_info('forum', $foruminfo);
...

But I don't know how to duplicate the dataman, set it up to a different existing like:
$linkdataman->set_existing(fetch_postinfo($postinfo['linkid']))
And then make $dataman functions reflect $linkdataman ones... seems quite difficult...

kh99
05-14-2012, 09:57 PM
Sounds like you've pretty much got it figured out. Why not just make the same datamanager calls that are being made on the other datamanager? If you're only interested in having the text of the linked post update, then you probably only need to set_existing, set('message'...), then save().

Edit: sorry, that second one would actually be setr('pagetext', $edit['message']). And you wouldn't want to duplicate all the calls made on the other post because you don't want to be changing the threadid or forumid, for instance.