MyBB Community Forums

Full Version: Unread post on portal page (last threads)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

I posted already a question in the plugin forum (https://community.mybb.com/thread-71986-...pid1283361) but I think it is a more common question.

I want to show the read/unread status and the link to the last read post on the portal page (box lastthreads)
Tried to add some queries in the portal.php and also embed the forumdisplay_thread_gotounread template.

Maybe someone here have a solution.

Many many thanks
Martin


// Last Read threads
 if($mybb->user['uid'] && $mybb->settings['threadreadcut'] > 0 && !empty($threadcache))
{
$query = $db->simple_select("threadsread", "*", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})");
while($readthread = $db->fetch_array($query))
{
if(!empty($moved_threads[$readthread['tid']]))
{
$readthread['tid'] = $moved_threads[$readthread['tid']];
}
if($threadcache[$readthread['tid']])
{
$threadcache[$readthread['tid']]['lastread'] = $readthread['dateline'];
}
}
} 

// LAST READ EDITED MD
if($mybb->settings['threadreadcut'] > 0)
{
$forum_read = $readforums[$thread['fid']];

$read_cutoff = TIME_NOW-$mybb->settings['threadreadcut']*60*60*24;
if($forum_read == 0 || $forum_read < $read_cutoff)
{
$forum_read = $read_cutoff;
}
} 


if($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forum_read)
{
if(!empty($thread['lastread']))
{
$last_read = $thread['lastread'];
}
else
{
$last_read = $read_cutoff;
}
}
else
{
$last_read = my_get_array_cookie("threadread", $thread['tid']);
}

if($thread['lastpost'] > $last_read && $moved[0] != "moved")
{
$folder .= "new";
$folder_label .= $lang->icon_new;
$new_class = "subject_new";
$thread['newpostlink'] = get_thread_link($thread['tid'], 0, "newpost");
eval("\$gotounread = \"".$templates->get("forumdisplay_thread_gotounread")."\";");
$unreadpost = 1;
}
else
{
$folder_label .= $lang->icon_no_new;
$new_class = "subject_old";
$thread['newpostlink'] = "";
}