$forumList) {
$seen = 0;
foreach ($forumList as $f) {
$forum = new Gazelle\Forum($f['ID']);
if (!$Viewer->readAccess($forum)) {
continue;
}
if ($f['ID'] == DONOR_FORUM) {
$f['Description'] = donorForumDescription();
}
$userLastRead = $forum->userLastRead($Viewer->id(), $Viewer->postsPerPage());
if (isset($userLastRead[$f['LastPostTopicID']])) {
$lastReadPage = (int)$userLastRead[$f['LastPostTopicID']]['Page'];
$lastReadPost = $userLastRead[$f['LastPostTopicID']]['PostID'];
$catchup = $userLastRead[$f['LastPostTopicID']]['PostID'] >= $f['LastPostID']
|| $Viewer->forumCatchupEpoch() >= strtotime($f['LastPostTime']);
$isRead = true;
} else {
$lastReadPage = null;
$lastReadPost = null;
$catchup = $f['LastPostTime'] ? $Viewer->forumCatchupEpoch() >= strtotime($f['LastPostTime']) : false;
$isRead = false;
}
$iconClass = (($f['IsLocked'] && !$f['IsSticky']) || $catchup ? 'read' : 'unread')
. ($f['IsLocked'] ? '_locked' : '')
. ($f['IsSticky'] ? '_sticky' : '');
echo $Twig->render('forum/main.twig', [
'creator' => $f['MinClassCreate'] <= $Viewer->classLevel(),
'category' => $category,
'category_id' => $f['categoryId'],
'cut_title' => shortenString($f['Title'] ?? '', 50, true),
'description' => $f['Description'],
'forum_id' => $f['ID'],
'icon_class' => $iconClass,
'id' => $f['LastPostTopicID'],
'is_read' => $isRead,
'last_post_time' => $f['LastPostTime'],
'last_post_user' => $f['LastPostAuthorID'],
'last_read_page' => $lastReadPage,
'last_read_post' => $lastReadPost,
'name' => $f['Name'],
'num_posts' => $f['NumPosts'],
'num_topics' => $f['NumTopics'],
'seen' => ++$seen, // $seen == 1 implies
needs to be emitted
'threads' => $f['NumPosts'] > 0,
'title' => $f['Title'],
'tooltip' => $f['ID'] == DONOR_FORUM ? 'tooltip_gold' : 'tooltip',
]);
}
/* close the opened in first call to render() above */
if ($seen) { ?>