2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
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();
|
2013-05-05 08:00:31 +00:00
|
|
|
foreach ($Forums as $Forum) {
|
2011-03-28 14:21:28 +00:00
|
|
|
if (!empty($Forum['LastPostTopicID'])) {
|
|
|
|
$TopicIDs[]=$Forum['LastPostTopicID'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Now if we have IDs' we run the query
|
2013-05-05 08:00:31 +00:00
|
|
|
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
|
2011-03-28 14:21:28 +00:00
|
|
|
FROM forums_last_read_topics AS l
|
2013-05-05 08:00:31 +00:00
|
|
|
WHERE TopicID IN(".implode(',',$TopicIDs).")
|
|
|
|
AND UserID='$LoggedUser[ID]'");
|
2011-03-28 14:21:28 +00:00
|
|
|
$LastRead = $DB->to_array('TopicID', MYSQLI_ASSOC);
|
|
|
|
} else {
|
|
|
|
$LastRead = array();
|
|
|
|
}
|
|
|
|
|
2012-10-11 08:00:15 +00:00
|
|
|
View::show_header('Forums');
|
2011-03-28 14:21:28 +00:00
|
|
|
?>
|
|
|
|
<div class="thin">
|
|
|
|
<h2>Forums</h2>
|
2013-02-18 08:00:22 +00:00
|
|
|
<div class="forum_list">
|
2011-03-28 14:21:28 +00:00
|
|
|
<?
|
|
|
|
|
|
|
|
$Row = 'a';
|
2013-05-05 08:00:31 +00:00
|
|
|
$LastCategoryID = 0;
|
2011-03-28 14:21:28 +00:00
|
|
|
$OpenTable = false;
|
|
|
|
$DB->query("SELECT RestrictedForums FROM users_info WHERE UserID = ".$LoggedUser['ID']);
|
|
|
|
list($RestrictedForums) = $DB->next_record();
|
|
|
|
$RestrictedForums = explode(',', $RestrictedForums);
|
2011-10-11 08:00:15 +00:00
|
|
|
$PermittedForums = array_keys($LoggedUser['PermittedForums']);
|
2011-03-28 14:21:28 +00:00
|
|
|
foreach ($Forums as $Forum) {
|
2012-03-28 08:00:20 +00:00
|
|
|
list($ForumID, $CategoryID, $ForumName, $ForumDescription, $MinRead, $MinWrite, $MinCreate, $NumTopics, $NumPosts, $LastPostID, $LastAuthorID, $LastTopicID, $LastTime, $SpecificRules, $LastTopic, $Locked, $Sticky) = array_values($Forum);
|
2013-04-13 08:00:19 +00:00
|
|
|
if ($LoggedUser['CustomForums'][$ForumID] != 1 && ($MinRead > $LoggedUser['Class'] || array_search($ForumID, $RestrictedForums) !== false)) {
|
2011-03-28 14:21:28 +00:00
|
|
|
continue;
|
|
|
|
}
|
2013-06-04 08:00:34 +00:00
|
|
|
$Row = (($Row == 'a') ? 'b' : 'a');
|
2011-03-28 14:21:28 +00:00
|
|
|
$ForumDescription = display_str($ForumDescription);
|
|
|
|
|
2013-04-13 08:00:19 +00:00
|
|
|
if ($CategoryID != $LastCategoryID) {
|
2012-02-13 08:00:23 +00:00
|
|
|
$Row = 'b';
|
2013-04-13 08:00:19 +00:00
|
|
|
$LastCategoryID = $CategoryID;
|
|
|
|
if ($OpenTable) { ?>
|
2011-03-28 14:21:28 +00:00
|
|
|
</table>
|
|
|
|
<? } ?>
|
|
|
|
<h3><?=$ForumCats[$CategoryID]?></h3>
|
|
|
|
<table class="forum_index">
|
|
|
|
<tr class="colhead">
|
2013-04-30 18:18:07 +00:00
|
|
|
<td style="width: 2%;"></td>
|
|
|
|
<td style="width: 25%;">Forum</td>
|
2013-02-18 08:00:22 +00:00
|
|
|
<td>Last post</td>
|
2013-04-30 18:18:07 +00:00
|
|
|
<td style="width: 7%;">Topics</td>
|
|
|
|
<td style="width: 7%;">Posts</td>
|
2011-03-28 14:21:28 +00:00
|
|
|
</tr>
|
|
|
|
<?
|
|
|
|
$OpenTable = true;
|
|
|
|
}
|
|
|
|
|
2013-04-13 08:00:19 +00:00
|
|
|
if ((!$Locked || $Sticky) && $LastPostID != 0 && ((empty($LastRead[$LastTopicID]) || $LastRead[$LastTopicID]['PostID'] < $LastPostID) && strtotime($LastTime) > $LoggedUser['CatchupTime'])) {
|
2011-03-28 14:21:28 +00:00
|
|
|
$Read = 'unread';
|
|
|
|
} else {
|
|
|
|
$Read = 'read';
|
|
|
|
}
|
|
|
|
/* Removed per request, as distracting
|
2013-05-05 08:00:31 +00:00
|
|
|
if ($Locked) {
|
|
|
|
$Read .= "_locked";
|
|
|
|
}
|
|
|
|
if ($Sticky) {
|
|
|
|
$Read .= "_sticky";
|
|
|
|
}
|
2011-03-28 14:21:28 +00:00
|
|
|
*/
|
|
|
|
?>
|
|
|
|
<tr class="row<?=$Row?>">
|
|
|
|
<td class="<?=$Read?>" title="<?=ucfirst($Read)?>"></td>
|
|
|
|
<td>
|
|
|
|
<h4 class="min_padding">
|
|
|
|
<a href="forums.php?action=viewforum&forumid=<?=$ForumID?>" title="<?=display_str($ForumDescription)?>"><?=display_str($ForumName)?></a>
|
|
|
|
</h4>
|
|
|
|
</td>
|
|
|
|
<? if ($NumPosts == 0) { ?>
|
|
|
|
<td colspan="3">
|
2013-06-04 08:00:34 +00:00
|
|
|
There are no topics here.<?=(($MinCreate <= $LoggedUser['Class']) ? ', <a href="forums.php?action=new&forumid='.$ForumID.'">Create one!</a>' : '')?>.
|
2011-03-28 14:21:28 +00:00
|
|
|
</td>
|
|
|
|
<? } else { ?>
|
|
|
|
<td>
|
2013-04-13 08:00:19 +00:00
|
|
|
<span style="float: left;" class="last_topic">
|
2012-10-11 08:00:15 +00:00
|
|
|
<a href="forums.php?action=viewthread&threadid=<?=$LastTopicID?>" title="<?=display_str($LastTopic)?>"><?=display_str(Format::cut_string($LastTopic, 50, 1))?></a>
|
2011-03-28 14:21:28 +00:00
|
|
|
</span>
|
|
|
|
<? if (!empty($LastRead[$LastTopicID])) { ?>
|
|
|
|
<span style="float: left;" class="last_read" title="Jump to last read">
|
|
|
|
<a href="forums.php?action=viewthread&threadid=<?=$LastTopicID?>&page=<?=$LastRead[$LastTopicID]['Page']?>#post<?=$LastRead[$LastTopicID]['PostID']?>"></a>
|
|
|
|
</span>
|
|
|
|
<? } ?>
|
2013-06-04 08:00:34 +00:00
|
|
|
<span style="float: right;" class="last_poster">by <?=Users::format_username($LastAuthorID, false, false, false)?> <?=time_diff($LastTime, 1)?></span>
|
2011-03-28 14:21:28 +00:00
|
|
|
</td>
|
|
|
|
<td><?=number_format($NumTopics)?></td>
|
|
|
|
<td><?=number_format($NumPosts)?></td>
|
|
|
|
<? } ?>
|
|
|
|
</tr>
|
|
|
|
<? } ?>
|
|
|
|
</table>
|
2013-02-18 08:00:22 +00:00
|
|
|
</div>
|
|
|
|
<div class="linkbox"><a href="forums.php?action=catchup&forumid=all&auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Catch up</a></div>
|
2011-03-28 14:21:28 +00:00
|
|
|
</div>
|
2012-10-11 08:00:15 +00:00
|
|
|
<? View::show_footer();
|