2020-04-05, 10:07 AM
so I just found a solution after reading the whole forumdisplay.php source code!!!!!!
it is too bad MyBB has no good documentation for programmers and it's API, anyway support forum still here and hope other people can use this:
First we need to grab the last thread read timestamp of user from database here is the query:
you can add additional line of code if you want to work with guests too and have no empty $lastread variable, something like that:
of course you need to have your thread last post timestamp too! you can use MyBB API in this case and no need to have additional query! here it is:
and at the end, you need to compare these two values and do what you want:
In my case it will add an icon to the beginning of thread title so if the lamp icon was on this means user still not read thread after it's updated cause thread last read timestamp is smaller than thread last post timestamp, and if it's not it means user read thread after it's updated.
at the end you will have a code like this for both groups guests and users:
it is too bad MyBB has no good documentation for programmers and it's API, anyway support forum still here and hope other people can use this:
First we need to grab the last thread read timestamp of user from database here is the query:
$query = $db->query("SELECT dateline FROM ".TABLE_PREFIX."threadsread WHERE tid='$tid' AND uid='$uid'");
$lastread = $db->fetch_field($query,"dateline");
you can add additional line of code if you want to work with guests too and have no empty $lastread variable, something like that:
$lastread = (!empty($lastread)? $lastread: my_get_array_cookie("threadread", $tid));
of course you need to have your thread last post timestamp too! you can use MyBB API in this case and no need to have additional query! here it is:
$thread = get_thread($tid);
$thread_lastpost = $thread['lastpost'];
and at the end, you need to compare these two values and do what you want:
if($thread_lastpost > $lastread )
{
//yourcode
}
else
{
//yourcode
}
In my case it will add an icon to the beginning of thread title so if the lamp icon was on this means user still not read thread after it's updated cause thread last read timestamp is smaller than thread last post timestamp, and if it's not it means user read thread after it's updated.
at the end you will have a code like this for both groups guests and users:
$query = $db->query("SELECT dateline FROM ".TABLE_PREFIX."threadsread WHERE tid='$tid' AND uid='$uid'");
$lastread = $db->fetch_field($query,"dateline");
$lastread = (!empty($lastread)? $lastread: my_get_array_cookie("threadread", $tid));
$thread = get_thread($tid);
$thread_lastpost = $thread['lastpost'];
if($thread_lastpost > $lastread )
{
//yourcode
}
else
{
//yourcode
}