diff options
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/includes/functions_posting.php | 13 | ||||
-rw-r--r-- | phpBB/posting.php | 18 |
2 files changed, 11 insertions, 20 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 7aba451285..8e3851e86c 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -97,14 +97,17 @@ function update_last_post_information($type, $id) $update_sql = array(); - $sql = 'SELECT MAX(post_id) as last_post_id - FROM ' . POSTS_TABLE . " - WHERE post_approved = 1 - AND {$type}_id = $id"; + $sql = 'SELECT MAX(p.post_id) as last_post_id + FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t + WHERE p.topic_id = t.topic_id + AND p.post_approved = 1 + AND t.topic_approved = 1 + AND p.{$type}_id = $id"; + $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); - if ($row['last_post_id']) + if ((int) $row['last_post_id']) { $sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u diff --git a/phpBB/posting.php b/phpBB/posting.php index a7ba19488a..3933cc22a5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1258,7 +1258,7 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, &$data) $sql = 'SELECT MAX(post_id) as last_post_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id " . - (($auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : ''); + ((!$auth->acl_get('m_approve')) ? 'AND post_approved = 1' : ''); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1271,7 +1271,7 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, &$data) $sql = 'SELECT post_id FROM ' . POSTS_TABLE . " WHERE topic_id = $topic_id " . - (($auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '') . ' + ((!$auth->acl_get('m_approve')) ? 'AND post_approved = 1' : '') . ' AND post_time > ' . $data['post_time'] . ' ORDER BY post_time ASC'; $result = $db->sql_query_limit($sql, 1); @@ -1721,19 +1721,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { if ($topic_type != POST_GLOBAL) { - // We get the last post information not for posting or replying, we can assume the correct params here, which is much faster - if ($post_mode == 'edit_last_post') - { - $sql_data[FORUMS_TABLE]['stat'][] = implode(', ', update_last_post_information('forum', $data['forum_id'])); - } - else if (!$auth->acl_get('f_moderate', $data['forum_id']) || $auth->acl_get('m_approve')) - { - $update_sql = 'forum_last_post_id = ' . $data['post_id']; - $update_sql .= ", forum_last_post_time = $current_time"; - $update_sql .= ', forum_last_poster_id = ' . $user->data['user_id']; - $update_sql .= ", forum_last_poster_name = '" . (($user->data['user_id'] == ANONYMOUS) ? $db->sql_escape(stripslashes($username)) : $db->sql_escape($user->data['username'])) . "'"; - $sql_data[FORUMS_TABLE]['stat'][] = $update_sql; - } + $sql_data[FORUMS_TABLE]['stat'][] = implode(', ', update_last_post_information('forum', $data['forum_id'])); } $update = update_last_post_information('topic', $data['topic_id']); |