1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 16:56:44 +02:00

[feature/soft-delete] Add a function to calculate the actual post/topic count

PHPBB3-9567
This commit is contained in:
Joas Schilling
2012-10-21 23:38:55 +02:00
parent 2fafa54107
commit 6c39563e9f
3 changed files with 29 additions and 7 deletions

View File

@@ -46,6 +46,26 @@ class phpbb_content_visibility
return false;
}
/**
* 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
*

View File

@@ -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))