Просмотр исходного кода

Ticket #4558 - Build-in API support: Reports do/counter visibility.

AntonLV 2 лет назад
Родитель
Сommit
d2d957a24d
1 измененных файлов с 9 добавлено и 5 удалено
  1. 9 5
      template/scripts/BxBaseReport.php

+ 9 - 5
template/scripts/BxBaseReport.php

@@ -335,7 +335,7 @@ class BxBaseReport extends BxDolReport
         $aParams['track'] = $aParams['is_reported'] ? $this->_getTrack($iObjectId, $iAuthorId) : [];
 
         //--- Do Report
-        $bDoReport = $this->_isShowDoReport($aParams, $isAllowedReport, $bCount);
+        $bDoReport = $this->_isShowDoReport($aParams, $isAllowedReport, $isAllowedReportView, $bCount);
         $aDoReport = $bDoReport ? $this->_getDoReport($aParams, $isAllowedReport) : [];
 
         //--- Counter
@@ -601,14 +601,18 @@ class BxBaseReport extends BxDolReport
         return false;
     }
 
-    protected function _isShowDoReport($aParams, $isAllowedVote, $bCount)
+    protected function _isShowDoReport($aParams, $isAllowedReport, $isAllowedReportView, $bCount)
     {
-        return !isset($aParams['show_do_report']) || (bool)$aParams['show_do_report'] === true;
+        $bShowDoReport = !isset($aParams['show_do_report']) || (bool)$aParams['show_do_report'] === true;
+
+        return $bShowDoReport && ($isAllowedReport || ($isAllowedReportView && $bCount));
     }
 
-    protected function _isShowCounter($aParams, $isAllowedVote, $isAllowedVoteView, $bCount)
+    protected function _isShowCounter($aParams, $isAllowedReport, $isAllowedReportView, $bCount)
     {
-        return isset($aParams['show_counter']) && (bool)$aParams['show_counter'] === true && $isAllowedVoteView && ($isAllowedVote || $bCount);
+        $bShowCounter = isset($aParams['show_counter']) && (bool)$aParams['show_counter'] === true;
+
+        return $bShowCounter && $isAllowedReportView && ($isAllowedReport || $bCount);
     }
 }