aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/content_visibility.php20
-rw-r--r--phpBB/includes/functions_display.php5
-rw-r--r--phpBB/viewforum.php11
3 files changed, 29 insertions, 7 deletions
diff --git a/phpBB/includes/content_visibility.php b/phpBB/includes/content_visibility.php
index 8bfdfd2917..2a0cc3c850 100644
--- a/phpBB/includes/content_visibility.php
+++ b/phpBB/includes/content_visibility.php
@@ -47,6 +47,26 @@ class phpbb_content_visibility
}
/**
+ * Get the topics post count or the forums post/topic count based on permissions
+ *
+ * @param $mode string One of topic_posts, forum_posts or forum_topics
+ * @param $data array Array with the topic/forum data to calculate from
+ * @param $forum_id int The forum id is used for permission checks
+ * @return int Number of posts/topics the user can see in the topic/forum
+ */
+ static public function get_count($mode, $data, $forum_id)
+ {
+ global $auth;
+
+ if (!$auth->acl_get('m_approve', $forum_id))
+ {
+ return (int) $data[$mode];
+ }
+
+ return (int) $data[$mode] + (int) $data[$mode . '_unapproved'] + (int) $data[$mode . '_softdeleted'];
+ }
+
+ /**
* Create topic/post visibility SQL for a given forum ID
*
* Note: Read permissions are not checked.
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 10f07bfbf1..ed91d9ad1c 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -200,8 +200,9 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}
// Count the difference of real to public topics, so we can display an information to moderators
- $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && ($row['forum_topics_real'] != $row['forum_topics'])) ? $forum_id : 0;
- $row['forum_topics'] = ($auth->acl_get('m_approve', $forum_id)) ? $row['forum_topics_real'] : $row['forum_topics'];
+ $row['forum_id_unapproved_topics'] = ($auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved']) ? $forum_id : 0;
+ $row['forum_posts'] = phpbb_content_visibility::get_count('forum_posts', $row, $forum_id);
+ $row['forum_topics'] = phpbb_content_visibility::get_count('forum_topics', $row, $forum_id);
// Display active topics from this forum?
if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && ($row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS))
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 40ef255004..c1d3b2c03c 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -258,7 +258,7 @@ if ($sort_days)
}
else
{
- $topics_count = ($auth->acl_get('m_approve', $forum_id)) ? $forum_data['forum_topics_real'] : $forum_data['forum_topics'];
+ $topics_count = phpbb_content_visibility::get_count('forum_topics', $forum_data, $forum_id);
$sql_limit_time = '';
}
@@ -668,7 +668,7 @@ if (sizeof($topic_list))
$s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
// Replies
- $replies = ($auth->acl_get('m_approve', $topic_forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
+ $replies = phpbb_content_visibility::get_count('topic_posts', $row, $topic_forum_id) - 1;
if ($row['topic_status'] == ITEM_MOVED)
{
@@ -689,11 +689,12 @@ if (sizeof($topic_list))
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params);
$topic_unapproved = ($row['topic_visibility'] == ITEM_UNAPPROVED && $auth->acl_get('m_approve', $row['forum_id']));
- $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id']));
- // @TODO: Make this work for cases where some posts within a topic are deleted.
+ $posts_unapproved = ($row['topic_visibility'] == ITEM_APPROVED && $row['topic_posts_unapproved'] && $auth->acl_get('m_approve', $row['forum_id']));
$topic_deleted = ($row['topic_visibility'] == ITEM_DELETED);
+ $posts_deleted = ($row['topic_visibility'] == ITEM_DELETED && $row['topic_posts_softdeleted'] && $auth->acl_get('m_approve', $row['forum_id']));
+ //@todo: this is still some kind of wrong!
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$topic_id", true, $user->session_id) : '';
- $u_mcp_queue = (!$u_mcp_queue && $topic_deleted) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=deleted_posts&amp;t=' . $topic_id, true, $user->session_id) : $u_mcp_queue;
+ $u_mcp_queue = (!$u_mcp_queue && ($topic_deleted || $posts_deleted)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=deleted_posts&amp;t=' . $topic_id, true, $user->session_id) : $u_mcp_queue;
// Send vars to template
$topic_row = array(