mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-26 05:08:52 +00:00
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:
parent
261e79c920
commit
0aacc24526
2 changed files with 11 additions and 20 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
@ -1720,21 +1720,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
|
|||
if ($post_mode == 'post' || $post_mode == 'reply' || $post_mode == 'edit_last_post')
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$update = update_last_post_information('topic', $data['topic_id']);
|
||||
if (sizeof($update))
|
||||
|
|
Loading…
Add table
Reference in a new issue