fix last_post_information for moderated topics

git-svn-id: file:///svn/phpbb/trunk@5088 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2005-01-29 14:46:16 +00:00
parent 261e79c920
commit 0aacc24526
2 changed files with 11 additions and 20 deletions

View file

@ -97,14 +97,17 @@ function update_last_post_information($type, $id)
$update_sql = array(); $update_sql = array();
$sql = 'SELECT MAX(post_id) as last_post_id $sql = 'SELECT MAX(p.post_id) as last_post_id
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . " t
WHERE post_approved = 1 WHERE p.topic_id = t.topic_id
AND {$type}_id = $id"; AND p.post_approved = 1
AND t.topic_approved = 1
AND p.{$type}_id = $id";
$result = $db->sql_query($sql); $result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result); $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 $sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u

View file

@ -1258,7 +1258,7 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, &$data)
$sql = 'SELECT MAX(post_id) as last_post_id $sql = 'SELECT MAX(post_id) as last_post_id
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE topic_id = $topic_id " . 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); $result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result); $row = $db->sql_fetchrow($result);
$db->sql_freeresult($result); $db->sql_freeresult($result);
@ -1271,7 +1271,7 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, &$data)
$sql = 'SELECT post_id $sql = 'SELECT post_id
FROM ' . POSTS_TABLE . " FROM ' . POSTS_TABLE . "
WHERE topic_id = $topic_id " . 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'] . ' AND post_time > ' . $data['post_time'] . '
ORDER BY post_time ASC'; ORDER BY post_time ASC';
$result = $db->sql_query_limit($sql, 1); $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) 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 $sql_data[FORUMS_TABLE]['stat'][] = implode(', ', update_last_post_information('forum', $data['forum_id']));
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;
}
} }
$update = update_last_post_information('topic', $data['topic_id']); $update = update_last_post_information('topic', $data['topic_id']);