Przeglądaj źródła

#24 - Show action buttons (Votes) for visitors.

AntonLV 11 lat temu
rodzic
commit
b9f2bcb5f6

+ 1 - 5
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -654,14 +654,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule
         $oVote = $this->getVoteObject($sSystem, $iObjectId);
         $oVote->addCssJs();
 
-        $iUserId = (int)$this->getUserId();
-        if($iUserId == 0)
-            return false;
-
         if(isAdmin())
             return true;
 
-        return $oVote->isAllowedVote($bPerform);
+        return true;
     }
 
     public function isAllowedShare($aEvent, $bPerform = false)

+ 8 - 4
template/scripts/BxBaseVote.php

@@ -132,9 +132,6 @@ class BxBaseVote extends BxDolVote
 
     public function getElement($aParams = array())
     {
-        if(!$this->isAllowedVote())
-            return '';
-
         $bLike =  $this->isLikeMode();
         $sType = $bLike ? BX_DOL_VOTE_TYPE_LIKES : BX_DOL_VOTE_TYPE_STARS;
 
@@ -149,6 +146,9 @@ class BxBaseVote extends BxDolVote
 		$iAuthorId = $this->_getAuthorId();
         $aVote = $this->_oQuery->getVote($iObjectId);
 
+        if(!$this->isAllowedVote() && (int)$aVote['count'] == 0)
+            return '';
+
         $aParams = array_merge($this->_aElementDefaults[$sType], $aParams);
         $aParams['is_voted'] = $this->_oQuery->isVoted($iObjectId, $iAuthorId) ? true : false;
 
@@ -177,6 +177,10 @@ class BxBaseVote extends BxDolVote
 
     protected function _getDoVoteStars($aParams = array())
     {
+    	//TODO: Add 'disabled' appearance for this type of votes.
+    	if(!$this->isAllowedVote())
+            return '';
+
         $sJsObject = $this->getJsObjectName();
         $iMinValue = $this->getMinValue();
         $iMaxValue = $this->getMaxValue();
@@ -224,7 +228,7 @@ class BxBaseVote extends BxDolVote
     	$bVoted = isset($aParams['is_voted']) && $aParams['is_voted'] === true;
         $bShowDoVoteAsButtonSmall = isset($aParams['show_do_vote_as_button_small']) && $aParams['show_do_vote_as_button_small'] == true;
         $bShowDoVoteAsButton = !$bShowDoVoteAsButtonSmall && isset($aParams['show_do_vote_as_button']) && $aParams['show_do_vote_as_button'] == true;
-		$bDisabled = $bVoted && !$this->isUndo();
+		$bDisabled = !$this->isAllowedVote() || ($bVoted && !$this->isUndo());
 
         $sClass = '';
 		if($bShowDoVoteAsButton)