if (isset($LoggedUser['PostsPerPage'])) {
$PerPage = $LoggedUser['PostsPerPage'];
} else {
$PerPage = POSTS_PER_PAGE;
}
//We have to iterate here because if one is empty it breaks the query
$TopicIDs = array();
foreach($Forums as $Forum) {
if (!empty($Forum['LastPostTopicID'])) {
$TopicIDs[]=$Forum['LastPostTopicID'];
}
}
//Now if we have IDs' we run the query
if(!empty($TopicIDs)) {
$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(',',$TopicIDs).") AND
UserID='$LoggedUser[ID]'");
$LastRead = $DB->to_array('TopicID', MYSQLI_ASSOC);
} else {
$LastRead = array();
}
show_header('Forums');
?>
Forums
$Row = 'a';
$LastCategoryID=0;
$OpenTable = false;
$DB->query("SELECT RestrictedForums FROM users_info WHERE UserID = ".$LoggedUser['ID']);
list($RestrictedForums) = $DB->next_record();
$RestrictedForums = explode(',', $RestrictedForums);
$PermittedForums = array_keys($LoggedUser['PermittedForums']);
foreach ($Forums as $Forum) {
list($ForumID, $CategoryID, $ForumName, $ForumDescription, $MinRead, $MinWrite, $MinCreate, $NumTopics, $NumPosts, $LastPostID, $LastAuthorID, $LastPostAuthorName, $LastTopicID, $LastTime, $SpecificRules, $LastTopic, $Locked, $Sticky) = array_values($Forum);
if ($LoggedUser['CustomForums'][$ForumID] != 1 && ($MinRead>$LoggedUser['Class'] || array_search($ForumID, $RestrictedForums) !== FALSE)) {
continue;
}
$Row = ($Row == 'a') ? 'b' : 'a';
$ForumDescription = display_str($ForumDescription);
if($CategoryID!=$LastCategoryID) {
$LastCategoryID=$CategoryID;
if($OpenTable) { ?>
} ?>
=$ForumCats[$CategoryID]?>
|
Forum |
Last Post |
Topics |
Posts |
$OpenTable = true;
}
if((!$Locked || $Sticky) && $LastPostID != 0 && ((empty($LastRead[$LastTopicID]) || $LastRead[$LastTopicID]['PostID'] < $LastPostID) && strtotime($LastTime)>$LoggedUser['CatchupTime'])) {
$Read = 'unread';
} else {
$Read = 'read';
}
/* Removed per request, as distracting
if($Locked) { $Read .= "_locked"; }
if($Sticky) { $Read .= "_sticky"; }
*/
?>
|
|
if ($NumPosts == 0) { ?>
There are no topics here=($MinCreate<=$LoggedUser['Class']) ? ', '.'create one'.'' : ''?>.
|
} else { ?>
=display_str(cut_string($LastTopic, 50, 1))?>
if (!empty($LastRead[$LastTopicID])) { ?>
} ?>
by =format_username($LastAuthorID, $LastPostAuthorName)?> =time_diff($LastTime,1)?>
|
=number_format($NumTopics)?> |
=number_format($NumPosts)?> |
} ?>
} ?>
show_footer();