get_value("forums_$ForumID");
}
if (!isset($Forum) || !is_array($Forum)) {
$DB->query("
SELECT
t.ID,
t.Title,
t.AuthorID,
t.IsLocked,
t.IsSticky,
t.NumPosts,
t.LastPostID,
t.LastPostTime,
t.LastPostAuthorID
FROM forums_topics AS t
WHERE t.ForumID = '$ForumID'
ORDER BY t.Ranking = 0, t.Ranking ASC, t.IsSticky DESC, t.LastPostTime DESC
LIMIT $Limit"); // Can be cached until someone makes a new post
$Forum = $DB->to_array('ID', MYSQLI_ASSOC, false);
if ($Page == 1) {
$DB->query("
SELECT COUNT(ID)
FROM forums_topics
WHERE ForumID = '$ForumID'
AND IsSticky = '1'");
list($Stickies) = $DB->next_record();
$Cache->cache_value("forums_$ForumID", array($Forum, '', 0, $Stickies), 0);
}
}
if (!isset($Forums[$ForumID])) {
error(404);
}
// Make sure they're allowed to look at the page
if (!check_perms('site_moderate_forums')) {
if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) {
error(403);
}
}
$ForumName = display_str($Forums[$ForumID]['Name']);
if ($LoggedUser['CustomForums'][$ForumID] != 1 && $Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class']) {
error(403);
}
// Start printing
View::show_header('Forums > '. $Forums[$ForumID]['Name']);
?>
Forums > =$ForumName?>
if (check_forumperm($ForumID, 'Write') && check_forumperm($ForumID, 'Create')) { ?>
New thread
} ?>
Search this forum
/*
if (check_perms('users_mod')) {
$DB->query("
SELECT ForumID
FROM subscribed_forums
WHERE ForumID='$ForumID'
AND SubscriberID='$LoggedUser[ID]'");
if (!$DB->has_results()) { ?>
Subscribe to forum
} else { ?>
Unsubscribe from forum
}
}
*/
?>
if (check_perms('site_moderate_forums')) { ?>
} ?>
if (!empty($Forums[$ForumID]['SpecificRules'])) { ?>
Forum Specific Rules
foreach ($Forums[$ForumID]['SpecificRules'] as $ThreadIDs) {
$Thread = get_thread_info($ThreadIDs);
?>
=display_str($Thread['Title'])?>
} ?>
} ?>
|
Latest |
Replies |
Author |
// Check that we have content to process
if (count($Forum) === 0) {
?>
No threads to display in this forum!
|
} else {
// forums_last_read_topics is a record of the last post a user read in a topic, and what page that was on
$DB->query("
SELECT
l.TopicID,
l.PostID,
CEIL((
SELECT COUNT(ID)
FROM forums_posts
WHERE forums_posts.TopicID = l.TopicID
AND forums_posts.ID <= l.PostID
) / $PerPage
) AS Page
FROM forums_last_read_topics AS l
WHERE TopicID IN(".implode(', ', array_keys($Forum)).')
AND UserID = \''.$LoggedUser['ID'].'\'');
// Turns the result set into a multi-dimensional array, with
// forums_last_read_topics.TopicID as the key.
// This is done here so we get the benefit of the caching, and we
// don't have to make a database query for each topic on the page
$LastRead = $DB->to_array('TopicID');
//---------- Begin printing
$Row = 'a';
foreach ($Forum as $Topic) {
list($TopicID, $Title, $AuthorID, $Locked, $Sticky, $PostCount, $LastID, $LastTime, $LastAuthorID) = array_values($Topic);
$Row = $Row === 'a' ? 'b' : 'a';
// Build list of page links
// Only do this if there is more than one page
$PageLinks = array();
$ShownEllipses = false;
$PagesText = '';
$TopicPages = ceil($PostCount / $PerPage);
if ($TopicPages > 1) {
$PagesText = ' (';
for ($i = 1; $i <= $TopicPages; $i++) {
if ($TopicPages > 4 && ($i > 2 && $i <= $TopicPages - 2)) {
if (!$ShownEllipses) {
$PageLinks[] = '-';
$ShownEllipses = true;
}
continue;
}
$PageLinks[] = "$i";
}
$PagesText .= implode(' ', $PageLinks);
$PagesText .= ')';
}
// handle read/unread posts - the reason we can't cache the whole page
if ((!$Locked || $Sticky) && ((empty($LastRead[$TopicID]) || $LastRead[$TopicID]['PostID'] < $LastID) && strtotime($LastTime) > $LoggedUser['CatchupTime'])) {
$Read = 'unread';
} else {
$Read = 'read';
}
if ($Locked) {
$Read .= '_locked';
}
if ($Sticky) {
$Read .= '_sticky';
}
?>
|
$TopicLength = 75 - (2 * count($PageLinks));
unset($PageLinks);
$Title = display_str($Title);
$DisplayTitle = $Title;
?>
=Format::cut_string($DisplayTitle, $TopicLength) ?>
=$PagesText?>
if (!empty($LastRead[$TopicID])) { ?>
} ?>
by =Users::format_username($LastAuthorID, false, false, false)?> =time_diff($LastTime, 1)?>
|
=number_format($PostCount - 1)?> |
=Users::format_username($AuthorID, false, false, false)?> |
}
} ?>
View::show_footer(); ?>