aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2007-03-14 21:40:52 +0000
committerNils Adermann <naderman@naderman.de>2007-03-14 21:40:52 +0000
commit73ae6011588d533474005818a3db2a11b5b9d784 (patch)
tree824acae779eeea1aa32bea46e95022aa9d1bc555 /phpBB
parent59231a0024a05d20cc85c0a67defb04967548759 (diff)
downloadforums-73ae6011588d533474005818a3db2a11b5b9d784.tar
forums-73ae6011588d533474005818a3db2a11b5b9d784.tar.gz
forums-73ae6011588d533474005818a3db2a11b5b9d784.tar.bz2
forums-73ae6011588d533474005818a3db2a11b5b9d784.tar.xz
forums-73ae6011588d533474005818a3db2a11b5b9d784.zip
- sync now correctly handles approved posts in unapproved topics (last_post info)
git-svn-id: file:///svn/phpbb/trunk@7191 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_admin.php22
-rw-r--r--phpBB/includes/functions_posting.php31
2 files changed, 35 insertions, 18 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 62a025da97..fcdbd452a4 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -1481,18 +1481,22 @@ function sync($mode, $where_type = '', $where_ids = '', $resync_parents = false,
// 3: Get post count and last_post_id for each forum
if (sizeof($forum_ids) == 1)
{
- $sql = 'SELECT COUNT(post_id) AS forum_posts, MAX(post_id) AS last_post_id
- FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . '
- AND post_approved = 1';
+ $sql = 'SELECT COUNT(p.post_id) AS forum_posts, MAX(p.post_id) AS last_post_id
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
+ WHERE ' . $db->sql_in_set('p.forum_id', $forum_ids) . '
+ AND p.topic_id = t.topic_id
+ AND t.topic_approved = 1
+ AND p.post_approved = 1';
}
else
{
- $sql = 'SELECT forum_id, COUNT(post_id) AS forum_posts, MAX(post_id) AS last_post_id
- FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_ids) . '
- AND post_approved = 1
- GROUP BY forum_id';
+ $sql = 'SELECT forum_id, COUNT(p.post_id) AS forum_posts, MAX(p.post_id) AS last_post_id
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
+ WHERE ' . $db->sql_in_set('p.forum_id', $forum_ids) . '
+ AND p.topic_id = t.topic_id
+ AND t.topic_approved = 1
+ AND p.post_approved = 1
+ GROUP BY p.forum_id';
}
$result = $db->sql_query($sql);
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 020d437b14..67aedc2f25 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -113,20 +113,33 @@ function update_post_information($type, $ids, $return_update_sql = false)
$update_sql = $empty_forums = $not_empty_forums = array();
+ if ($type != 'topic')
+ {
+ $topic_join = ', ' . TOPICS_TABLE . ' t';
+ $topic_condition = 'AND t.topic_id = p.topic_id AND t.topic_approved = 1';
+ }
+ else
+ {
+ $topic_join = '';
+ $topic_condition = '';
+ }
+
if (sizeof($ids) == 1)
{
- $sql = 'SELECT MAX(post_id) as last_post_id
- FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set($type . '_id', $ids) . '
- AND post_approved = 1';
+ $sql = 'SELECT MAX(p.post_id) as last_post_id
+ FROM ' . POSTS_TABLE . " p $topic_join
+ WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
+ $topic_condition
+ AND p.post_approved = 1";
}
else
{
- $sql = 'SELECT ' . $type . '_id, MAX(post_id) as last_post_id
- FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set($type . '_id', $ids) . "
- AND post_approved = 1
- GROUP BY {$type}_id";
+ $sql = 'SELECT p.' . $type . '_id, MAX(p.post_id) as last_post_id
+ FROM ' . POSTS_TABLE . " p $topic_join
+ WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
+ $topic_condition
+ AND p.post_approved = 1
+ GROUP BY p.{$type}_id";
}
$result = $db->sql_query($sql);