Kaynağa Gözat

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

AntonLV 3 yıl önce
ebeveyn
işleme
ab666994bc

+ 27 - 0
inc/classes/BxDolCmtsScore.php

@@ -0,0 +1,27 @@
+<?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 BxDolCmtsScore extends BxTemplScore
+{
+    protected 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/BxDolScore.php

@@ -310,7 +310,7 @@ class BxDolScore 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()
@@ -352,6 +352,11 @@ class BxDolScore extends BxDolObject
     /**
      * Internal functions
      */
+    protected function _isAllowedVoteByObject($aObject)
+    {
+        return bx_srv($this->_aSystem['module'], 'check_allowed_view_for_profile', [$aObject]) === CHECK_ACTION_RESULT_ALLOWED;
+    }
+
     protected function _returnVoteDataForSocket($aData, $aMask = [])
     {
         if(empty($aMask) || !is_array($aMask))

+ 1 - 1
install/sql/system.sql

@@ -1499,7 +1499,7 @@ CREATE TABLE `sys_objects_score` (
 );
 
 INSERT INTO `sys_objects_score` (`name`, `module`, `table_main`, `table_track`, `post_timeout`, `is_on`, `trigger_table`, `trigger_field_id`, `trigger_field_author`, `trigger_field_score`, `trigger_field_cup`, `trigger_field_cdown`, `class_name`, `class_file`) VALUES 
-('sys_cmts', 'system', 'sys_cmts_scores', 'sys_cmts_scores_track', '604800', '0', 'sys_cmts_ids', 'id', 'author_id', 'score', 'sc_up', 'sc_down', '', '');
+('sys_cmts', 'system', 'sys_cmts_scores', 'sys_cmts_scores_track', '604800', '0', 'sys_cmts_ids', 'id', 'author_id', 'score', 'sc_up', 'sc_down', 'BxTemplCmtsScore', '');
 
 -- -------------------------------------------------------
 

+ 21 - 0
template/scripts/BxBaseCmtsScore.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 BxDolCmtsScore
+ */
+class BxBaseCmtsScore extends BxDolCmtsScore
+{
+    protected function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */

+ 21 - 0
template/scripts_templ/BxTemplCmtsScore.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 BxDolCmtsScore
+ */
+class BxTemplCmtsScore extends BxBaseCmtsScore
+{
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
+    {
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
+    }
+}
+
+/** @} */