Exemple #1
0
 public 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);
     }
     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;
     }
     return $iNumUserPoints;
 }