Version: 1.0, by Xenon
Developer Last Online: Oct 2023
Version: 3.5.3
Rating:
Released: 09-19-2005
Last Update: 01-15-2007
Installs: 877
Uses Plugins
No support by the author.
When a User posts into a thread where he already has the lastpost, no new post will be added. The lastpost of him will be edited and the new text is put after his first message.
This will be done until the old post is older than 24 hours (you can change this timespan yourself)
Nothing more to say about that, it's the quite same as my vb3.0 version.
This Mod should run with 3.6 as well
** Please make sure you ENABLE this product after you install it - it is disabled by default. **
I got this to work on my 3.5.3 board (TweakGuides Forums) by using the original code, modifying as provided by Paul M, and also adding one new feature I think is very useful. This code works with AJAX (e.g. Quick Reply) without any problems, it automatically refreshes the page:
PHP Code:
// ########### Xenon Modified Prevent Doublepost Hack #########
$dp_settings = array(
'timespan' => 3600 * 24, // how many seconds after the last post the new post is defined as doublepost (default: 24 hours)
'spacer' => "\n\n [b]Additional Comment:[/b] \n", // What should be between the old post and the new one (default: two empty lines). Note: PersianImmortal has added [b]Additional Comment:[/b] \n to make it clear what is being added each time - can be removed if you wish.
'editedbymsg' => '[Automerged Doublepost]', // If left blank no edited by will appear
);
if ($type != 'thread'
AND $threadinfo['lastpost'] > TIMENOW - $dp_settings['timespan']
AND $threadinfo['lastposter'] == $vbulletin->userinfo['username'])
{
// we are here, so we may have a doublepost -> do more exact checkings
$doublepost = $vbulletin->db->query_first("
SELECT post.*
FROM " . TABLE_PREFIX . "post AS post
LEFT JOIN " . TABLE_PREFIX . "deletionlog AS deletionlog ON(deletionlog.primaryid = post.postid AND type = 'post')
WHERE threadid = $threadinfo[threadid] AND dateline > " . (TIMENOW - $dp_settings['timespan']) . "
AND visible = 1 AND deletionlog.primaryid IS NULL
ORDER BY dateline DESC
LIMIT 1
");
if ($doublepost['userid'] == $vbulletin->userinfo['userid'])
{
// we truely have a doublepost, now check if the merged post still fits the rules!
$dataman2 =& datamanager_init('Post', $vbulletin, ERRTYPE_ARRAY, 'threadpost');
$dataman2->set_existing($doublepost);
$post['message'] = $doublepost['pagetext'] . $dp_settings['spacer'] . $post['message'];
// set info
$dataman2->set_info('preview', $post['preview']);
$dataman2->set_info('parseurl', $post['parseurl']);
$dataman2->set_info('posthash', $post['posthash']);
$dataman2->set_info('forum', $foruminfo);
$dataman2->set_info('thread', $threadinfo);
// set options
$dataman2->setr('showsignature', $post['signature']);
$dataman2->setr('allowsmilie', $post['enablesmilies']);
// set data
$dataman2->setr('pagetext', $post['message']);
$dataman2->setr('iconid', $post['iconid']);
$dataman2->pre_save();
if (!$dataman2->errors)
{
// merged post is ok, so do merging
$isdoublepost = true;
unset($dataman);
$dataman =& $dataman2;
$post['postid'] = $doublepost['postid'];
}
else
{
// merging will produce errors so keep it as a single post..
$isdoublepost = false;
}
}
}
if ($isdoublepost)
{
// Ugly hack added by Paul M to fix ajax merge //
if (!$vbulletin->GPC['ajax'])
{
$id = $doublepost['postid'];
$dataman->save();
if ($dp_settings['editedbymsg'] != '')
{
$vbulletin->db->query_write("
REPLACE INTO " . TABLE_PREFIX . "editlog (postid, userid, username, dateline, reason)
VALUES ($id, " . $vbulletin->userinfo['userid'] . ", '" . addslashes($vbulletin->userinfo['username']) . "', " . TIMENOW . ", '" . addslashes($dp_settings['editedbymsg']) . "')
");
}
}
$vbulletin->url = 'showthread.php?' . $vbulletin->session->vars['sessionurl'] . "p=$post[postid]#post$post[postid]";
eval(print_standard_redirect('redirect_postthanks', true, false));
}
else
{
// no doublepost so save as new post
$post['message'] = $oldmsg;
$id = $dataman->save();
}
In summary the modifications to the original code are firstly the second step provided by Paul M (comment tags show Paul's added code as he provided it) - this is necessary for the AJAX refresh to work properly.
I also added an Additional Comment: heading in the Spacer, so that each automerged reply looks like this:
Additional Comment:
Second post text merged into first post
Additional Comment:
Third post text merged into first post
That way it becomes obvious what's been merged, both to the user and the reader. Also helps prompt the user to use the Edit button to add additional comments next time rather than just post multiple times in a row.
As I said, this now works perfectly on my board, and having tested it with both standard replies, quick replies using full AJAX features enabled, there are no errors or glitches.
Many thanks to Xenon and Paul M for this great mod, very useful and prevents a lot of conflicts and work for mods who get tired of having to merge multiple posts by individuals.
hi PersianImmortal ,I used yours everything is ok.refreshing,quick reply,click reply button...but when I click new thread button and I post ,page says Database errors
Code:
MySQL Error : Duplicate entry '10006' for key 1
Error Number : 1062
the post goes but page says that, I think needs a little arrangement,,what should we do?
I just installed this mod on my vb 3.5.3 but I'm one of those who want the dateline to be updated...
I added
Code:
$dataman2->set('dateline', TIMENOW);
I also tried it with set_info but it doesn't work for me.
The post date doesn't get updated so I don't get a 'new post'...
Do I have to add another code with 3.5.3?
What could be wrong?