MyBB Community Forums

Full Version: Automerge double posts. [request]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Howdy,
I was wondering if someone could remake the modification that automatically merges two posts if it is the same author posting twice.

There is a version for RC4 here:
http://mods.mybboard.com/view.php?did=73

I did a quick scan of newreply.php and couldn't really find where to start on this one properly and securely.

is it possible to remake as a plugin?
OPEN newreply.php

-----------------------------------------------------------------------------
FIND
-----------------------------------------------------------------------------

	if($updatepost)
	{
$updatedpost = array(
"subject" => addslashes($mybb->input['subject']),
"icon" => intval($mybb->input['icon']),
"username" => addslashes($username),
"dateline" => time(),
"message" => addslashes($mybb->input['message']),
"ipaddress" => getip(),
"includesig" => $postoptions['signature'],
"smilieoff" => $postoptions['disablesmilies'],
"visible" => $visible
);
		$db->update_query(TABLE_PREFIX."posts", $updatedpost, "pid='$pid'");
	}	
	else
	{
		$query = $db->query("SELECT * FROM ".TABLE_PREFIX."posts WHERE tid='$tid' ORDER BY dateline DESC LIMIT 1");
		$lastpost = $db->fetch_array($query);
		if ($lastpost['username'] != $mybb->user['username'])
		{

$newreply = array(
"tid" => intval($tid),
"replyto" => intval($mybb->input['replyto']),
"fid" => $fid,
"subject" => addslashes($mybb->input['subject']),
"icon" => intval($mybb->input['icon']),
"uid" => $mybb->user['uid'],
"username" => addslashes($username),
"dateline" => time(),
"message" => addslashes($mybb->input['message']),
"ipaddress" => getip(),
"includesig" => $postoptions['signature'],
"smilieoff" => $postoptions['disablesmilies'],
"visible" => $visible
);

			$db->insert_query(TABLE_PREFIX."posts", $newreply);
			$pid = $db->insert_id();
			$post_just_edited="no";
		} 
		else
		{
$postid = $lastpost['pid'];
$old_message = $lastpost['message'];
$message = addslashes($mybb->input['message']);
$new_message = $old_message."\n - Post Merged - \n".$message;


		$query = $db->query("UPDATE ".TABLE_PREFIX."posts SET message='$new_message', dateline='".time()."' WHERE pid='$postid'");
		$pid = $db->insert_id();
		$post_just_edited="yes";
		}
	}
-----------------------------------------------------------------------------
REPLACE BY 
-----------------------------------------------------------------------------

	if($updatepost)
	{
		$updatedpost = array(
			"subject" => addslashes($mybb->input['subject']),
			"icon" => intval($mybb->input['icon']),
			"username" => addslashes($username),
			"dateline" => time(),
			"message" => addslashes($mybb->input['message']),
			"ipaddress" => getip(),
			"includesig" => $postoptions['signature'],
			"smilieoff" => $postoptions['disablesmilies'],
			"visible" => $visible
			);
		$db->update_query(TABLE_PREFIX."posts", $updatedpost, "pid='$pid'");
	}
	else
	{
	$query = $db->query("SELECT * FROM ".TABLE_PREFIX."posts WHERE tid='$tid' ORDER BY dateline DESC LIMIT 1");
	$lastpost = $db->fetch_array($query);
	if ($lastpost['username'] != $mybb->user['username'])
	{

		$newreply = array(
			"tid" => intval($tid),
			"replyto" => intval($mybb->input['replyto']),
			"fid" => $fid,
			"subject" => addslashes($mybb->input['subject']),
			"icon" => intval($mybb->input['icon']),
			"uid" => $mybb->user['uid'],
			"username" => addslashes($username),
			"dateline" => time(),
			"message" => addslashes($mybb->input['message']),
			"ipaddress" => getip(),
			"includesig" => $postoptions['signature'],
			"smilieoff" => $postoptions['disablesmilies'],
			"visible" => $visible
			);

		$db->insert_query(TABLE_PREFIX."posts", $newreply);
		$pid = $db->insert_id();
		$post_just_edited="no";
	} 
	else
	{
	$postid = $lastpost['pid'];
	$old_message = $lastpost['message'];
	$message = addslashes($mybb->input['message']);
	$new_message = $old_message."\n - Post Merged - \n".$message;

		
		$query = $db->query("UPDATE ".TABLE_PREFIX."posts SET message='$new_message', dateline='".time()."' WHERE pid='$postid'");
		$pid = $db->insert_id();
		$post_just_edited="yes";
	}
}

-----------------------------------------------------------------------------
FIND
-----------------------------------------------------------------------------

		if($forum['usepostcounts'] != "no")

-----------------------------------------------------------------------------
REPLACE BY
-----------------------------------------------------------------------------

		if(($forum['usepostcounts'] != "no")&&($post_just_edited!="yes"))

It isn't a plugin but it's a re-do of that original. Worked on my earlier board, so should work now also =P
doesn't work in 1.1.7 Just tried it. I would also like this feature.
I've made a mod that works with MyBB 1.2 that does exactly this. It will be released when MyBB 1.2 is out Smile
blackram_air Wrote:doesn't work in 1.1.7  Just tried it. I would also like this feature.

I see why =P There's an } to short in the code to close the
else but that's fixed now , it should work tried it on my 1.1.7 board just before posting this =P
LeX- Wrote:
blackram_air Wrote:doesn't work in 1.1.7 Just tried it. I would also like this feature.

I see why =P There's an } to short in the code to close the
else but that's fixed now , it should work tried it on my 1.1.7 board just before posting this =P

Thank you. How would I go about making the Post Merged a few spaces down from the old message?
Add a few more \n into it ( \n = newline )

So something like this

Open newreply.php

Find


$new_message = $old_message."\n - Post Merged - \n".$message;

Change into for example


$new_message = $old_message."\n\n\n - Post Merged - \n\n\n".$message;

LeX- Wrote:Add a few more \n into it ( \n = newline )

So something like this

Open newreply.php

Find


$new_message = $old_message."\n - Post Merged - \n".$message;

Change into for example


$new_message = $old_message."\n\n\n - Post Merged - \n\n\n".$message;



Thanks

Odd problem it works in all forums but the one I have for just admins and mods.
Thanks LeX- you're a champ!
How to activate doble post in MyBB 1.6.3?