AntonLV 7 лет назад
Родитель
Сommit
d318a465aa

+ 26 - 0
inc/classes/BxDolVote.php

@@ -261,6 +261,32 @@ class BxDolVote extends BxDolObject
     {
         return $this->checkActionErrorMsg('vote');
     }
+    
+    public function isAllowedVoteView($isPerformAction = false)
+    {
+        if(isAdmin())
+            return true;
+
+        return $this->checkAction('vote_view', $isPerformAction);
+    }
+    
+    public function msgErrAllowedVoteView()
+    {
+        return $this->checkActionErrorMsg('vote_view');
+    }
+    
+    public function isAllowedVoteViewVoters($isPerformAction = false)
+    {
+        if(isAdmin())
+            return true;
+
+        return $this->checkAction('vote_view_voters', $isPerformAction);
+    }
+
+    public function msgErrAllowedVoteViewVoters()
+    {
+        return $this->checkActionErrorMsg('vote_view_voters');
+    }
 
     /**
      * Internal functions

+ 20 - 0
install/sql/system.sql

@@ -636,6 +636,14 @@ INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`,
 ('system', 'vote', NULL, '_sys_acl_action_vote', '', 1, 0);
 SET @iIdActionVote = LAST_INSERT_ID();
 
+INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
+('system', 'vote_view', NULL, '_sys_acl_action_vote_view', '', 1, 0);
+SET @iIdActionVoteView = LAST_INSERT_ID();
+
+INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
+('system', 'vote_view_voters', NULL, '_sys_acl_action_vote_view_voters', '', 1, 0);
+SET @iIdActionVoteViewVoters = LAST_INSERT_ID();
+
 INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
 ('system', 'report', NULL, '_sys_acl_action_report', '', 1, 0);
 SET @iIdActionReport = LAST_INSERT_ID();
@@ -753,6 +761,18 @@ INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
 (@iAdministrator, @iIdActionVote),
 (@iPremium, @iIdActionVote),
 
+-- vote view
+(@iStandard, @iIdActionVoteView),
+(@iModerator, @iIdActionVoteView),
+(@iAdministrator, @iIdActionVoteView),
+(@iPremium, @iIdActionVoteView),
+
+-- vote view voters
+(@iStandard, @iIdActionVoteViewVoters),
+(@iModerator, @iIdActionVoteViewVoters),
+(@iAdministrator, @iIdActionVoteViewVoters),
+(@iPremium, @iIdActionVoteViewVoters),
+
 -- report 
 (@iStandard, @iIdActionReport),
 (@iModerator, @iIdActionReport),

+ 2 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1658,6 +1658,8 @@
 	<string name="_sys_acl_action_unauthenticated"><![CDATA[Not logged in users can't '{1}'.]]></string>
 	<string name="_sys_acl_action_unconfirmed"><![CDATA[You didn't confirm your profile. Please check your email with profile activation link. Unconfirmed members can't <b>{1}</b>.]]></string>
 	<string name="_sys_acl_action_vote"><![CDATA[Vote]]></string>
+        <string name="_sys_acl_action_vote_view"><![CDATA[View votes]]></string>
+        <string name="_sys_acl_action_vote_view_voters"><![CDATA[View voters]]></string>
 	<string name="_sys_acl_action_report"><![CDATA[Report]]></string>
 	<string name="_sys_acl_action_report_view"><![CDATA[View reports]]></string>
 	<string name="_sys_acl_start"><![CDATA[Start: ]]></string>

+ 2 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1658,6 +1658,8 @@
 	<string name="_sys_acl_action_unauthenticated"><![CDATA[Не вошедшие пользователи не могут '{1}'.]]></string>
 	<string name="_sys_acl_action_unconfirmed"><![CDATA[Вы не подтвердили свой профиль. Пожалуйста, проверьте эл. сообщение со ссылкой на активацию профиля. Неподтверждённые пользователи не могут <b>{1}</b>.]]></string>
 	<string name="_sys_acl_action_vote"><![CDATA[Голосовать]]></string>
+        <string name="_sys_acl_action_vote_view"><![CDATA[Просматривать голоса]]></string>
+        <string name="_sys_acl_action_vote_view_voters"><![CDATA[Просматривать проголосовавших]]></string>
 	<string name="_sys_acl_action_report"><![CDATA[Жаловаться]]></string>
 	<string name="_sys_acl_action_report_view"><![CDATA[Просматривать жалобы]]></string>
 	<string name="_sys_acl_start"><![CDATA[Начало: ]]></string>

+ 30 - 10
template/scripts/BxBaseVote.php

@@ -99,6 +99,7 @@ class BxBaseVote extends BxDolVote
     public function getCounter($aParams = array())
     {
         $bShowEmpty = isset($aParams['show_counter_empty']) && $aParams['show_counter_empty'] == true;
+        $bAllowedViewViewVoters = $this->isAllowedVoteViewVoters();
 
         $sClass = $this->_sStylePrefix . '-counter';
         if(!empty($aParams['class_counter']))
@@ -106,19 +107,37 @@ class BxBaseVote extends BxDolVote
 
         $aTmplVarsAttrs = array(
             array('key' => 'class', 'value' => $sClass),
-            array('key' => 'href', 'value' => 'javascript:void(0)'),
-            array('key' => 'title', 'value' => bx_html_attribute($this->_getTitleDoBy($aParams))),
-            array('key' => 'onclick', 'value' => 'javascript:' . $this->getJsClickCounter($aParams))
         );
 
+        if($bAllowedViewViewVoters)
+            $aTmplVarsAttrs = array_merge($aTmplVarsAttrs, array(
+                array('key' => 'href', 'value' => 'javascript:void(0)'),
+                array('key' => 'title', 'value' => bx_html_attribute($this->_getTitleDoBy($aParams))),
+                array('key' => 'onclick', 'value' => 'javascript:' . $this->getJsClickCounter($aParams))
+            ));
+
         $sHtmlId = isset($aParams['id_counter']) ? $aParams['id_counter'] : $this->_aHtmlIds['counter'];
         if(!empty($sHtmlId))
             $aTmplVarsAttrs[] = array('key' => 'id', 'value' => $sHtmlId);
 
         $aVote = !empty($aParams['vote']) && is_array($aParams['vote']) ? $aParams['vote'] : $this->_getVote();
+        $sContent = $bShowEmpty || (int)$aVote['count'] > 0 ? $this->_getLabelCounter($aVote['count'], $aParams) : '';
+
         return $this->_oTemplate->parseHtmlByContent($this->_getTmplContentCounter(), array(
-            'bx_repeat:attrs' => $aTmplVarsAttrs,
-            'content' => $bShowEmpty || (int)$aVote['count'] > 0 ? $this->_getLabelCounter($aVote['count'], $aParams) : ''
+            'bx_if:show_text' => array(
+                'condition' => !$bAllowedViewViewVoters,
+                'content' => array(
+                    'bx_repeat:attrs' => $aTmplVarsAttrs,
+                    'content' => $sContent
+                )
+            ),
+            'bx_if:show_link' => array(
+                'condition' => $bAllowedViewViewVoters,
+                'content' => array(
+                    'bx_repeat:attrs' => $aTmplVarsAttrs,
+                    'content' => $sContent
+                )
+            )
         ));
     }
 
@@ -171,6 +190,7 @@ class BxBaseVote extends BxDolVote
 
         $bCount = $this->_isCount();
         $isAllowedVote = $this->isAllowedVote();
+        $isAllowedVoteView = $this->isAllowedVoteView();
         $aParams['is_voted'] = $this->isPerformed($iObjectId, $iAuthorId);
         $aParams['track'] = $aParams['is_voted'] ? $this->_getTrack($iObjectId, $iAuthorId) : array();
 
@@ -184,7 +204,7 @@ class BxBaseVote extends BxDolVote
             );
 
         //--- Counter
-        $bTmplVarsCounter = $this->_isShowCounter($aParams, $isAllowedVote, $bCount);
+        $bTmplVarsCounter = $this->_isShowCounter($aParams, $isAllowedVote, $isAllowedVoteView, $bCount);
         $aTmplVarsCounter = array();
         if($bTmplVarsCounter)
             $aTmplVarsCounter = array(
@@ -197,7 +217,7 @@ class BxBaseVote extends BxDolVote
             );
 
         //--- Legend
-        $bTmplVarsLegend = $this->_isShowLegend($aParams, $isAllowedVote, $bCount);
+        $bTmplVarsLegend = $this->_isShowLegend($aParams, $isAllowedVote, $isAllowedVoteView, $bCount);
         $aTmplVarsLegend = array();
         if($bTmplVarsLegend)
             $aTmplVarsLegend = array(
@@ -272,12 +292,12 @@ class BxBaseVote extends BxDolVote
         return !isset($aParams['show_do_vote']) || $aParams['show_do_vote'] == true;
     }
 
-    protected function _isShowCounter($aParams, $isAllowedVote, $bCount)
+    protected function _isShowCounter($aParams, $isAllowedVote, $isAllowedVoteView, $bCount)
     {
-        return isset($aParams['show_counter']) && $aParams['show_counter'] === true && ($isAllowedVote || $bCount);
+        return isset($aParams['show_counter']) && $aParams['show_counter'] === true && $isAllowedVoteView && ($isAllowedVote || $bCount);
     }
 
-    protected function _isShowLegend($aParams, $isAllowedVote, $bCount)
+    protected function _isShowLegend($aParams, $isAllowedVote, $isAllowedVoteView, $bCount)
     {
         return false;
     }

+ 6 - 1
template/vote_counter.html

@@ -1 +1,6 @@
-<a <bx_repeat:attrs>__key__="__value__"</bx_repeat:attrs>>__content__</a>
+<bx_if:show_text>
+    <span <bx_repeat:attrs>__key__="__value__"</bx_repeat:attrs>>__content__</span>
+</bx_if:show_text>
+<bx_if:show_link>
+    <a <bx_repeat:attrs>__key__="__value__"</bx_repeat:attrs>>__content__</a>
+</bx_if:show_link>