Ver Fonte

Ticket #4482 - Voting for a comment isn't available to common members.

AntonLV há 3 anos atrás
pai
commit
ceefdb93f4

+ 26 - 0
inc/classes/BxDolCmtsVoteLikes.php

@@ -0,0 +1,26 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+class BxDolCmtsVoteLikes extends BxTemplVoteLikes
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+
+    protected function _isAllowedVoteByObject($aObject)
+    {
+        $oCmts = BxDolCmts::getObjectInstanceByUniqId($aObject['id'], true, $this->_oTemplate);
+        if(!$oCmts)
+            return false;
+
+        return $oCmts->isViewAllowed() === CHECK_ACTION_RESULT_ALLOWED;
+    }
+}
+/** @} */

+ 25 - 0
inc/classes/BxDolCmtsVoteReactions.php

@@ -0,0 +1,25 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+class BxDolCmtsVoteReactions extends BxTemplVoteReactions
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+
+    protected function _isAllowedVoteByObject($aObject)
+    {
+        $oCmts = BxDolCmts::getObjectInstanceByUniqId($aObject['id'], true, $this->_oTemplate);
+        if(!$oCmts)
+            return false;
+
+        return $oCmts->isViewAllowed() === CHECK_ACTION_RESULT_ALLOWED;
+    }
+}
+/** @} */

+ 6 - 1
inc/classes/BxDolVote.php

@@ -289,7 +289,7 @@ class BxDolVote extends BxDolObject
         if(empty($aObject) || !is_array($aObject))
             return false;
 
-        return bx_srv($this->_aSystem['module'], 'check_allowed_view_for_profile', [$aObject]) === CHECK_ACTION_RESULT_ALLOWED;
+        return $this->_isAllowedVoteByObject($aObject);
     }
 
     public function msgErrAllowedVote()
@@ -343,6 +343,11 @@ class BxDolVote extends BxDolObject
         return isset($aVote['count']) && (int)$aVote['count'] != 0;
     }
 
+    protected function _isAllowedVoteByObject($aObject)
+    {
+        return bx_srv($this->_aSystem['module'], 'check_allowed_view_for_profile', [$aObject]) === CHECK_ACTION_RESULT_ALLOWED;
+    }
+
     protected function _getVoteData()
     {
         $iValue = bx_get('value');

+ 2 - 2
install/sql/system.sql

@@ -1467,8 +1467,8 @@ CREATE TABLE `sys_objects_vote` (
 );
 
 INSERT INTO `sys_objects_vote` (`Name`, `Module`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
-('sys_cmts', 'system', 'sys_cmts_votes', 'sys_cmts_votes_track', '604800', '1', '1', '0', '1', 'sys_cmts_ids', 'id', 'author_id', 'rate', 'votes', '', ''),
-('sys_cmts_reactions', 'system', 'sys_cmts_reactions', 'sys_cmts_reactions_track', '604800', '1', '1', '1', '1', 'sys_cmts_ids', 'id', 'author_id', 'rrate', 'rvotes', 'BxTemplVoteReactions', ''),
+('sys_cmts', 'system', 'sys_cmts_votes', 'sys_cmts_votes_track', '604800', '1', '1', '0', '1', 'sys_cmts_ids', 'id', 'author_id', 'rate', 'votes', 'BxTemplCmtsVoteLikes', ''),
+('sys_cmts_reactions', 'system', 'sys_cmts_reactions', 'sys_cmts_reactions_track', '604800', '1', '1', '1', '1', 'sys_cmts_ids', 'id', 'author_id', 'rrate', 'rvotes', 'BxTemplCmtsVoteReactions', ''),
 ('sys_form_fields_votes', 'system', 'sys_form_fields_votes', 'sys_form_fields_votes_track', '604800', '1', '1', '0', '1', 'sys_form_fields_ids', 'id', 'author_id', 'rate', 'votes', '', ''),
 ('sys_form_fields_reaction', 'system', 'sys_form_fields_reaction', 'sys_form_fields_reaction_track', '604800', '1', '1', '1', '1', 'sys_form_fields_ids', 'id', 'author_id', 'rrate', 'rvotes', 'BxTemplVoteReactions', '');
 

+ 21 - 0
template/scripts/BxBaseCmtsVoteLikes.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsVoteLikes
+ */
+class BxBaseCmtsVoteLikes extends BxDolCmtsVoteLikes
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
template/scripts/BxBaseCmtsVoteReactions.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaBaseView UNA Base Representation Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsVoteReactions
+ */
+class BxBaseCmtsVoteReactions extends BxDolCmtsVoteReactions
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
template/scripts_templ/BxTemplCmtsVoteLikes.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsVoteLikes
+ */
+class BxTemplCmtsVoteLikes extends BxBaseCmtsVoteLikes
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
template/scripts_templ/BxTemplCmtsVoteReactions.php

@@ -0,0 +1,21 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaTemplate UNA Template Classes
+ * @{
+ */
+
+/**
+ * @see BxDolCmtsVoteReactions
+ */
+class BxTemplCmtsVoteReactions extends BxBaseCmtsVoteReactions
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */