Gazelle/sections/forums/main.php

114 lines
3.9 KiB
PHP
Raw Normal View History

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();
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();
}
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';
$LastCategoryID=0;
$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);
2011-10-11 08:00:15 +00:00
if ($LoggedUser['CustomForums'][$ForumID] != 1 && ($MinRead>$LoggedUser['Class'] || array_search($ForumID, $RestrictedForums) !== FALSE)) {
2011-03-28 14:21:28 +00:00
continue;
}
$Row = ($Row == 'a') ? 'b' : 'a';
$ForumDescription = display_str($ForumDescription);
if($CategoryID!=$LastCategoryID) {
2012-02-13 08:00:23 +00:00
$Row = 'b';
2011-03-28 14:21:28 +00:00
$LastCategoryID=$CategoryID;
if($OpenTable) { ?>
</table>
<? } ?>
<h3><?=$ForumCats[$CategoryID]?></h3>
<table class="forum_index">
<tr class="colhead">
<td style="width:2%;"></td>
<td style="width:25%;">Forum</td>
2013-02-18 08:00:22 +00:00
<td>Last post</td>
2011-03-28 14:21:28 +00:00
<td style="width:7%;">Topics</td>
<td style="width:7%;">Posts</td>
</tr>
<?
$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"; }
*/
?>
<tr class="row<?=$Row?>">
<td class="<?=$Read?>" title="<?=ucfirst($Read)?>"></td>
<td>
<h4 class="min_padding">
<a href="forums.php?action=viewforum&amp;forumid=<?=$ForumID?>" title="<?=display_str($ForumDescription)?>"><?=display_str($ForumName)?></a>
</h4>
</td>
<? if ($NumPosts == 0) { ?>
<td colspan="3">
There are no topics here<?=($MinCreate<=$LoggedUser['Class']) ? ', <a href="forums.php?action=new&amp;forumid='.$ForumID.'">'.'create one'.'</a>' : ''?>.
</td>
<? } else { ?>
<td>
<span style="float:left;" class="last_topic">
2012-10-11 08:00:15 +00:00
<a href="forums.php?action=viewthread&amp;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&amp;threadid=<?=$LastTopicID?>&amp;page=<?=$LastRead[$LastTopicID]['Page']?>#post<?=$LastRead[$LastTopicID]['PostID']?>"></a>
</span>
<? } ?>
2012-10-11 08:00:15 +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&amp;forumid=all&amp;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();