$topics =
[];
$first_new_found = FALSE;
foreach ($result as $topic) { if ($account->
isAuthenticated()) { // A forum is new if the topic is new, or if there are new comments since
// the user's last visit.
if ($topic->forum_tid !=
$tid) { $topic->new = 0;
} else { $history =
$this->
lastVisit($topic->
id(),
$account);
$topic->new_replies =
$this->commentManager->
getCountNewComments($topic, 'comment_forum',
$history);
$topic->new =
$topic->new_replies
|| ($topic->last_comment_timestamp >
$history);
} } else { // Do not track "new replies" status for topics if the user is anonymous.
$topic->new_replies = 0;
$topic->new = 0;
} // Make sure only one topic is indicated as the first new topic.
$topic->first_new = FALSE;