• Модуль: forum
  • Путь к файлу: ~/bitrix/modules/forum/classes/general/user.php
  • Класс: CAllForumUser
  • Вызов: CAllForumUser::CountUserPoints
static function CountUserPoints($USER_ID = 0, $iCnt = false)
{
	$USER_ID = intval($USER_ID);
	$iNumUserPosts = intval($iCnt);
	$iNumUserPoints = 0;
	$fPointsPerPost = 0.0;
	if ($USER_ID <= 0) return 0;

	if ($iCnt === false):
		$iNumUserPoints = CForumUser::GetUserPoints($USER_ID);
	endif;

	if ($iNumUserPoints === false || $iCnt != false):
		$iNumUserPosts = CForumMessage::GetList(array(), array("AUTHOR_ID" => $USER_ID, "APPROVED" => "Y"), true);
		$db_res = CForumPoints2Post::GetList(array("MIN_NUM_POSTS" => "DESC"), array("<=MIN_NUM_POSTS" => $iNumUserPosts));
		if ($ar_res = $db_res->Fetch())
			$fPointsPerPost = DoubleVal($ar_res["POINTS_PER_POST"]);
		$iNumUserPoints = floor($fPointsPerPost*$iNumUserPosts);
		$iCnt = CForumUserPoints::CountSumPoints($USER_ID);
		$iNumUserPoints += $iCnt;
	endif;
	return $iNumUserPoints;
}