예제 #1
0
파일: thread.php 프로젝트: mohirt/Gazelle
$LastPost = $LastPost['ID'];
$FirstPost = reset($Thread);
$FirstPost = $FirstPost['ID'];
if ($ThreadInfo['Posts'] <= $PerPage * $Page && $ThreadInfo['StickyPostID'] > $LastPost) {
    $LastPost = $ThreadInfo['StickyPostID'];
}
//Handle last read
if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) {
    $DB->query("\n\t\tSELECT PostID\n\t\tFROM forums_last_read_topics\n\t\tWHERE UserID = '{$LoggedUser['ID']}'\n\t\t\tAND TopicID = '{$ThreadID}'");
    list($LastRead) = $DB->next_record();
    if ($LastRead < $LastPost) {
        $DB->query("\n\t\t\tINSERT INTO forums_last_read_topics\n\t\t\t\t(UserID, TopicID, PostID)\n\t\t\tVALUES\n\t\t\t\t('{$LoggedUser['ID']}', '{$ThreadID}', '" . db_string($LastPost) . "')\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\tPostID = '{$LastPost}'");
    }
}
//Handle subscriptions
$UserSubscriptions = Subscriptions::get_subscriptions();
if (empty($UserSubscriptions)) {
    $UserSubscriptions = array();
}
if (in_array($ThreadID, $UserSubscriptions)) {
    $Cache->delete_value('subscriptions_user_new_' . $LoggedUser['ID']);
}
$QuoteNotificationsCount = $Cache->get_value('notify_quoted_' . $LoggedUser['ID']);
if ($QuoteNotificationsCount === false || $QuoteNotificationsCount > 0) {
    $DB->query("\n\t\tUPDATE users_notify_quoted\n\t\tSET UnRead = false\n\t\tWHERE UserID = '{$LoggedUser['ID']}'\n\t\t\tAND Page = 'forums'\n\t\t\tAND PageID = '{$ThreadID}'\n\t\t\tAND PostID >= '{$FirstPost}'\n\t\t\tAND PostID <= '{$LastPost}'");
    $Cache->delete_value('notify_quoted_' . $LoggedUser['ID']);
}
// Start printing
View::show_header($ThreadInfo['Title'] . ' &lt; ' . $Forums[$ForumID]['Name'] . ' &lt; Forums', 'comments,subscriptions,bbcode', $IsDonorForum ? 'donor' : '');
?>
<div class="thin">