AntonLV пре 6 година
родитељ
комит
b55a0e51d0
2 измењених фајлова са 20 додато и 6 уклоњено
  1. 19 5
      inc/classes/BxDolVoteQuery.php
  2. 1 1
      inc/classes/BxDolVoteStars.php

+ 19 - 5
inc/classes/BxDolVoteQuery.php

@@ -28,15 +28,29 @@ class BxDolVoteQuery extends BxDolObjectQuery
         $this->_sMethodGetEntry = 'getVote';
     }
 
-    public function isPostTimeoutEnded($iObjectId, $sAuthorIp)
+    public function isPostTimeoutEnded($iObjectId, $iAuthorId, $sAuthorIp)
     {
         if($this->_iPostTimeout == 0)
             return true;
 
-        $iDate = time() - $this->_iPostTimeout;
-        $iAuthorNip = ip2long($sAuthorIp);
-        $sQuery = $this->prepare("SELECT `object_id` FROM `{$this->_sTableTrack}` WHERE `object_id` = ? AND `author_nip` = ? AND `date` > ?", $iObjectId, $iAuthorNip, $iDate);
-        return (int)$this->getOne($sQuery) == 0;
+        $aBindings = array(
+            'object_id' => $iObjectId,
+            'date' => time() - $this->_iPostTimeout
+        );
+        $sWhereClause = " AND `object_id` = :object_id AND `date` > :date";
+
+        if(!empty($iAuthorId)) {
+            $aBindings['author_id'] = $iAuthorId;
+
+            $sWhereClause .= " AND `author_id` = :author_id";
+        }
+        else {
+            $aBindings['author_nip'] = ip2long($sAuthorIp);
+
+            $sWhereClause .= " AND `author_nip` = :author_nip";
+        }
+
+        return (int)$this->getOne("SELECT `object_id` FROM `" . $this->_sTableTrack . "` WHERE 1" . $sWhereClause, $aBindings) == 0;
     }
 
     public function getVote($iObjectId)

+ 1 - 1
inc/classes/BxDolVoteStars.php

@@ -25,7 +25,7 @@ class BxDolVoteStars extends BxTemplVote
      */
     protected function _isDuplicate($iObjectId, $iAuthorId, $iAuthorIp, $bVoted)
     {
-        return !$this->_oQuery->isPostTimeoutEnded($iObjectId, $iAuthorIp);
+        return !$this->_oQuery->isPostTimeoutEnded($iObjectId, $iAuthorId, $iAuthorIp);
     }
 }