1
0
Эх сурвалжийг харах

Ticket #4558 - Build-in API support: Stars voting.

AntonLV 2 жил өмнө
parent
commit
1d8fef52eb

+ 1 - 0
inc/classes/BxDolVote.php

@@ -428,6 +428,7 @@ class BxDolVote extends BxDolObject
             'performer_id' => $iAuthorId,
             'is_voted' => $aResult['voted'],
             'is_disabled' => $aResult['disabled'],
+            'value' => $aResult['voted'] ? $aData['value'] : 0,
             'icon' => $aResult['label_emoji'],
             'title' => $aResult['label_title'],
             'counter' => $this->getVote()

+ 12 - 0
inc/classes/BxDolVoteStars.php

@@ -40,8 +40,20 @@ class BxDolVoteStars extends BxTemplVote
      */
     protected function _isDuplicate($iObjectId, $iAuthorId, $iAuthorIp, $bVoted)
     {
+        if($bVoted && $this->isUndo())
+            return false;
+
         return !$this->_oQuery->isPostTimeoutEnded($iObjectId, $iAuthorId, $iAuthorIp);
     }
+
+    protected function _getVote($iObjectId = 0, $bForceGet = false)
+    {
+        $aVote = parent::_getVote($iObjectId, $bForceGet);
+        if(isset($aVote['rate']))
+            $aVote['rate'] = (float)$aVote['rate'];
+
+        return $aVote;
+    }
 }
 
 /** @} */

+ 4 - 0
template/scripts/BxBaseCmtsReviewsForm.php

@@ -22,6 +22,10 @@ class BxBaseCmtsReviewsForm extends BxTemplCmtsForm
 
     protected function genCustomInputCmtMood ($aInput)
     {
+        if(bx_is_api()) {
+            return $aInput;
+        }
+
         $oSystem = $this->_getSystemObject();
 
         $sStylePrefix = $oSystem->getStylePrefix();