diff options
| author | Joas Schilling <nickvergessen@gmx.de> | 2012-10-21 23:38:55 +0200 |
|---|---|---|
| committer | Joas Schilling <nickvergessen@gmx.de> | 2012-10-21 23:38:55 +0200 |
| commit | 6c39563e9f7fad18f1425292dca652861f5e1cb6 (patch) | |
| tree | dbfd7add9a1efe4d42295170aa88782db74d3de4 /phpBB/includes/content_visibility.php | |
| parent | 2fafa5410770e62daf8ba0ffa46cc9ceeec61608 (diff) | |
| download | forums-6c39563e9f7fad18f1425292dca652861f5e1cb6.tar forums-6c39563e9f7fad18f1425292dca652861f5e1cb6.tar.gz forums-6c39563e9f7fad18f1425292dca652861f5e1cb6.tar.bz2 forums-6c39563e9f7fad18f1425292dca652861f5e1cb6.tar.xz forums-6c39563e9f7fad18f1425292dca652861f5e1cb6.zip | |
[feature/soft-delete] Add a function to calculate the actual post/topic count
PHPBB3-9567
Diffstat (limited to 'phpBB/includes/content_visibility.php')
| -rw-r--r-- | phpBB/includes/content_visibility.php | 20 |
1 files changed, 20 insertions, 0 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. |
