From 7bf3db6c785ecda45836678fc5ce758bf3f48657 Mon Sep 17 00:00:00 2001 From: Moc Date: Sat, 26 Jul 2014 11:49:19 +0200 Subject: [PATCH] #716 - Forum post counts in user profile are now showing the correct values --- e107_core/shortcodes/batch/user_shortcodes.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/e107_core/shortcodes/batch/user_shortcodes.php b/e107_core/shortcodes/batch/user_shortcodes.php index b2bf67595..8a18c748a 100644 --- a/e107_core/shortcodes/batch/user_shortcodes.php +++ b/e107_core/shortcodes/batch/user_shortcodes.php @@ -68,7 +68,8 @@ class user_shortcodes extends e_shortcode function sc_user_forumposts($parm) { //return $this->var['user_forums']; //FIXME column not present in v2. Possible fix on next line. - return e107::getDb()->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); + //return e107::getDb()->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); // Does not account for pruned posts? #716. Possible fix on next line. + return e107::getDb()->retrieve('user_extended', 'user_plugin_forum_posts', 'user_extended_id = '.$this->var['user_id']); } @@ -117,13 +118,15 @@ class user_shortcodes extends e_shortcode function sc_user_forumper($parm) { $sql = e107::getDb(); - if(!$forumposts = e107::getRegistry('total_forumposts')) + if(!$total_forumposts = e107::getRegistry('total_forumposts')) { - $forumposts = (e107::isInstalled("forum")) ? intval($sql->count("forum_thread")) : 0; - e107::setRegistry('total_forumposts', $forumposts); - $user_forumposts = $sql->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); + $total_forumposts = (e107::isInstalled("forum")) ? intval($sql->count("forum_post")) : 0; + e107::setRegistry('total_forumposts', $total_forumposts); + //$user_forumposts = $sql->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); + $user_forumposts = e107::getDb()->retrieve('user_extended', 'user_plugin_forum_posts', 'user_extended_id = '.$this->var['user_id']); + } - return ($forumposts > 0) ? round(($user_forumposts/$forumposts) * 100, 2) : 0; + return ($total_forumposts > 0) ? round(($user_forumposts/$total_forumposts) * 100, 2) : 0; }