1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-18 05:09:05 +01:00

Improved merge pull request #496 from Moc

This commit is contained in:
nlstart 2014-03-04 00:25:57 +01:00
parent e642be3fb8
commit fff2a74aa5

View File

@ -92,11 +92,11 @@ class user_shortcodes extends e_shortcode
$chatposts = 0; // In case plugin not installed $chatposts = 0; // In case plugin not installed
if (e107::isInstalled("chatbox_menu")) if (e107::isInstalled("chatbox_menu"))
{ {
$chatposts = $sql->count("chatbox"); $chatposts = intval($sql->count("chatbox"));
} }
e107::setRegistry('total_chatposts', $chatposts); e107::setRegistry('total_chatposts', $chatposts);
} }
return ($chatposts != 0) ? round(($this->var['user_chats']/$chatposts) * 100, 2) : 0; return ($chatposts > 0) ? round(($this->var['user_chats']/$chatposts) * 100, 2) : 0;
} }
@ -106,10 +106,10 @@ class user_shortcodes extends e_shortcode
$sql = e107::getDb(); $sql = e107::getDb();
if(!$commentposts = e107::getRegistry('total_commentposts')) if(!$commentposts = e107::getRegistry('total_commentposts'))
{ {
$commentposts = $sql->count("comments"); $commentposts = intval($sql->count("comments"));
e107::setRegistry('total_commentposts', $commentposts); e107::setRegistry('total_commentposts', $commentposts);
} }
return ($commentposts != 0) ? round(($this->var['user_comments']/$commentposts) * 100, 2) : 0; return ($commentposts > 0) ? round(($this->var['user_comments']/$commentposts) * 100, 2) : 0;
} }
@ -119,11 +119,11 @@ class user_shortcodes extends e_shortcode
$sql = e107::getDb(); $sql = e107::getDb();
if(!$forumposts = e107::getRegistry('total_forumposts')) if(!$forumposts = e107::getRegistry('total_forumposts'))
{ {
$forumposts = (e107::isInstalled("forum")) ? $sql->count("forum_thread") : 0; $forumposts = (e107::isInstalled("forum")) ? intval($sql->count("forum_thread")) : 0;
e107::setRegistry('total_forumposts', $forumposts); e107::setRegistry('total_forumposts', $forumposts);
$user_forumposts = $sql->count("forum_thread","(*)","where thread_user=".$this->var['user_id']); $user_forumposts = $sql->count("forum_thread","(*)","where thread_user=".$this->var['user_id']);
} }
return ($forumposts != 0) ? round(($user_forumposts/$forumposts) * 100, 2) : 0; return ($forumposts > 0) ? round(($user_forumposts/$forumposts) * 100, 2) : 0;
} }