MyBB Community Forums

Full Version: Check for new Posts in thread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,

Im trying to add some custom functionality to the index page of MyBB. What I am trying to do is have a list of the 10 most recent posts on the index page. Here is an example of what I'm talking about

http://dwforums.net

On the index page it lists all the threads which have had new posts made in them. I have something similar working in mybb but the issue im having is with the new post image indicator on the very left. So can someone suggest some php coding to check to see if a thread has any new posts in it since last visit?
OK so far I have managed to get it working for .. the guest users only. It doesn't seem to work very well for the users who are logged in. The status will remain unread/read.

Is there a way to use the get_forum_lightbulb function to check for unread posts in threads?

Here is my code so far
		$myuser = $mybb->user['uid'];
		$truser = $thread['uid'];
		$fid = $thread['fid'];
$cutoff = TIME_NOW-$mybb->settings['threadreadcut']*60*60*24;

if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'])
{
	$status_query = $db->simple_select("forumsread", "dateline", "fid='{$fid}' AND uid='{$truser}'");
	$forum_read = $db->fetch_field($status_query, "dateline");

	$read_cutoff = TIME_NOW-$mybb->settings['threadreadcut']*60*60*24;
	if($forum_read == 0 || $forum_read < $read_cutoff)
	{
		$forum_read = $read_cutoff;
	}
}
else
{
	$forum_read = my_get_array_cookie("forumread", $fid);
}
	
	
	
	if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forum_read)
		{
			if($thread['lastread'])
			{
				$last_read = $thread['lastread'];
			}
			else
			{
				$last_read = $read_cutoff;
			}
		}
		else
		{
			$last_read = my_get_array_cookie("threadread", $thread['tid']);
		}

		if($forum_read > $last_read)
		{
			$last_read = $forum_read;
		}

		if($thread['lastpost'] > $last_read && $moved[0] != "moved")
		{
			$new = "unread";
		}
		else
		{
			$new="read";
		}