From f8a3f05afdb470ec4d78d393c8e03c9ee08cd114 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 18 Jan 2006 18:06:40 +0000 Subject: [PATCH] - fix two very annoying bugs (1) mark topic read behaving incorrectly if editing posts (the topic gets marked unread) (2) jump to wrong page number (viewtopic with post id) if descending post ordering is set git-svn-id: file:///svn/phpbb/trunk@5471 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 3 ++- phpBB/viewtopic.php | 14 +++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 276db4355d..c5a36421a9 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1867,7 +1867,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Mark this topic as read - markread('topic', $data['forum_id'], $data['topic_id'], $data['post_time']); + // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) + markread('topic', $data['forum_id'], $data['topic_id'], time()); // Send Notifications if ($mode != 'edit' && $mode != 'delete' && (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve'))) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 62d8ef9a94..51e29b388f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -154,17 +154,13 @@ if (!$post_id) } else { - if ($auth->acl_get('m_approve', $forum_id)) - { - $join_sql = (!$post_id) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id"; - } - else - { - $join_sql = (!$post_id) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND p.post_approved = 1 AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = 1 AND p2.post_id <= $post_id"; - } + $join_sql = (!$post_id) ? "t.topic_id = $topic_id" : "p.post_id = $post_id" . ((!$auth->acl_get('m_approve', $forum_id)) ? ' AND p.post_approved = 1' : '') . ' AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_approved = 1'; + + // This is for determining where we are (page) + $join_sql .= ($sort_dir == 'd') ? " AND p2.post_id >= $post_id" : " AND p2.post_id <= $post_id"; } $extra_fields = (!$post_id) ? '' : ', COUNT(p2.post_id) AS prev_posts'; -$order_sql = (!$post_id) ? '' : 'GROUP BY p.post_id, ' . $select_sql . ' ORDER BY p.post_id ASC'; +$order_sql = (!$post_id) ? '' : 'GROUP BY p.post_id, ' . $select_sql . ' ORDER BY p.post_id ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); if ($user->data['is_registered']) {