AntonLV há 8 anos atrás
pai
commit
9edc94bad6

+ 29 - 0
inc/classes/BxDolCmts.php

@@ -297,6 +297,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
                     `RootStylePrefix` AS `root_style_prefix`,
                     `BaseUrl` AS `base_url`,
                     `ObjectVote` AS `object_vote`,
+                    `ObjectReport` AS `object_report`,
                     `TriggerTable` AS `trigger_table`,
                     `TriggerFieldId` AS `trigger_field_id`,
                     `TriggerFieldAuthor` AS `trigger_field_author`,
@@ -443,6 +444,18 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         return $oVote;
     }
 
+    public function getReportObject($iId)
+    {
+        if(empty($this->_aSystem['object_report']))
+        	$this->_aSystem['object_report'] = 'sys_cmts';
+
+        $oReport = BxDolReport::getObjectInstance($this->_aSystem['object_report'], $iId, true, $this->_oTemplate);
+        if(!$oReport || !$oReport->isEnabled())
+            return false;
+
+        return $oReport;
+    }
+
 	public function getNotificationId()
 	{
 		return 'cmts-notification-' . $this->_sSystem . '-' . $this->_iId;
@@ -703,6 +716,22 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         return $oVote->isAllowedVote($isPerformAction);
     }
 
+    public function isReportAllowed ($aCmt, $isPerformAction = false)
+    {
+        $oReport = $this->getReportObject($aCmt['cmt_id']);
+        if($oReport === false)
+            return false;
+
+        $iUserId = (int)$this->_getAuthorId();
+        if($iUserId == 0)
+            return false;
+
+        if(isAdmin())
+            return true;
+
+        return $oReport->isAllowedReport($isPerformAction);
+    }
+
     public function isPostReplyAllowed ($isPerformAction = false)
     {
         $mixedResult = BxDolService::call($this->_aSystem['module'], 'check_allowed_comments_post', array($this->getId(), $this->getSystemName()));

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
install/sql/system.sql


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

@@ -2136,8 +2136,8 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_item_title_cart"><![CDATA[Shopping Cart]]></string>
 	<string name="_sys_menu_item_title_cmts_item_delete"><![CDATA[Delete]]></string>
 	<string name="_sys_menu_item_title_cmts_item_edit"><![CDATA[Edit]]></string>
-	<string name="_sys_menu_item_title_cmts_item_reply"><![CDATA[Reply]]></string>
-	<string name="_sys_menu_item_title_cmts_item_vote"><![CDATA[Vote]]></string>
+	<string name="_sys_menu_item_title_cmts_item_reply"><![CDATA[]]></string>
+	<string name="_sys_menu_item_title_cmts_item_vote"><![CDATA[]]></string>
 	<string name="_sys_menu_item_title_dashboard"><![CDATA[Dash]]></string>
 	<string name="_sys_menu_item_title_home"><![CDATA[Home]]></string>
 	<string name="_sys_menu_item_title_logout"><![CDATA[Sign out]]></string>
@@ -2195,6 +2195,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_item_title_system_cmts_item_delete"><![CDATA[Delete]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_edit"><![CDATA[Edit]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_reply"><![CDATA[Reply]]></string>
+	<string name="_sys_menu_item_title_system_cmts_item_report"><![CDATA[Report]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_vote"><![CDATA[Plus]]></string>
 	<string name="_sys_menu_item_title_system_dashboard"><![CDATA[Dashboard]]></string>
 	<string name="_sys_menu_item_title_system_home"><![CDATA[Home]]></string>

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

@@ -2135,8 +2135,8 @@
 	<string name="_sys_menu_item_title_cart"><![CDATA[Корзина]]></string>
 	<string name="_sys_menu_item_title_cmts_item_delete"><![CDATA[Удалить]]></string>
 	<string name="_sys_menu_item_title_cmts_item_edit"><![CDATA[Редактировать]]></string>
-	<string name="_sys_menu_item_title_cmts_item_reply"><![CDATA[Ответить]]></string>
-	<string name="_sys_menu_item_title_cmts_item_vote"><![CDATA[Голосовать]]></string>
+	<string name="_sys_menu_item_title_cmts_item_reply"><![CDATA[]]></string>
+	<string name="_sys_menu_item_title_cmts_item_vote"><![CDATA[]]></string>
 	<string name="_sys_menu_item_title_dashboard"><![CDATA[Панель]]></string>
 	<string name="_sys_menu_item_title_home"><![CDATA[Домой]]></string>
 	<string name="_sys_menu_item_title_logout"><![CDATA[Выйти]]></string>
@@ -2194,6 +2194,7 @@
 	<string name="_sys_menu_item_title_system_cmts_item_delete"><![CDATA[Удалить]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_edit"><![CDATA[Редактировать]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_reply"><![CDATA[Ответить]]></string>
+	<string name="_sys_menu_item_title_system_cmts_item_report"><![CDATA[Пожаловаться]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_vote"><![CDATA[Плюс]]></string>
 	<string name="_sys_menu_item_title_system_dashboard"><![CDATA[Панель]]></string>
 	<string name="_sys_menu_item_title_system_home"><![CDATA[Домой]]></string>

+ 1 - 0
template/menu_custom_item.html

@@ -2,6 +2,7 @@
     <a href="__link__" target="__target__" onclick="__onclick__" title="__title_attr__">
         <bx_if:icon><i class="sys-icon __icon__"></i></bx_if:icon>
         <bx_if:image><img style="background-image:url(__icon_url__)" src="<bx_icon_url:spacer.gif />" /></bx_if:image>
+        <bx_if:title><span class="bx-def-margin-sec-left-auto">__title__</span></bx_if:title>
     </a>
     <bx_if:addon>__addon__</bx_if:addon>
 </span>

+ 42 - 3
template/scripts/BxBaseCmtsMenuActions.php

@@ -16,9 +16,13 @@ class BxBaseCmtsMenuActions extends BxTemplMenuCustom
     protected $_oCmts;
     protected $_aCmt;
 
+    protected $_bShowTitles;
+
     public function __construct ($aObject, $oTemplate)
     {
         parent::__construct ($aObject, $oTemplate);
+
+        $this->_bShowTitles = false;
     }
 
     public function setCmtsData($oCmts, $iCmtId)
@@ -45,7 +49,24 @@ class BxBaseCmtsMenuActions extends BxTemplMenuCustom
         if(!$oVote)
         	return false;
 
-    	return $oVote->getElementInline(array('dynamic_mode' => $this->_bDynamicMode));
+        $aVotesParams = array('dynamic_mode' => $this->_bDynamicMode);
+        if($this->_bShowTitles)
+		    $aVotesParams['show_do_vote_label'] = true;
+
+    	return $oVote->getElementInline($aVotesParams);
+    }
+
+	protected function _getMenuItemItemReport($aItem)
+    {
+        $oReport = $this->_oCmts->getReportObject($this->_aCmt['cmt_unique_id']);
+        if(!$oReport)
+        	return false;
+
+        $aReportParams = array('dynamic_mode' => $this->_bDynamicMode);
+        if($this->_bShowTitles)
+		    $aReportParams['show_do_report_label'] = true;
+
+    	return $oReport->getElementInline($aReportParams);
     }
 
     /**
@@ -61,14 +82,32 @@ class BxBaseCmtsMenuActions extends BxTemplMenuCustom
         $sCheckFuncName = '';
         $aCheckFuncParams = array();
         switch ($a['name']) {
+            case 'item-reply':
+                $sCheckFuncName = 'isPostReplyAllowed';
+                break;
+
             case 'item-vote':
                 $sCheckFuncName = 'isVoteAllowed';
                 if(!empty($this->_aCmt))
                     $aCheckFuncParams = array($this->_aCmt);
                 break;
 
-            case 'item-reply':
-                $sCheckFuncName = 'isPostReplyAllowed';
+            case 'item-report':
+                $sCheckFuncName = 'isReportAllowed';
+                if(!empty($this->_aCmt))
+                    $aCheckFuncParams = array($this->_aCmt);
+                break;
+
+            case 'item-edit':
+                $sCheckFuncName = 'isEditAllowed';
+                if(!empty($this->_aCmt))
+                    $aCheckFuncParams = array($this->_aCmt);
+                break;
+
+            case 'item-delete':
+                $sCheckFuncName = 'isRemoveAllowed';
+                if(!empty($this->_aCmt))
+                    $aCheckFuncParams = array($this->_aCmt);
                 break;
         }
 

+ 2 - 49
template/scripts/BxBaseCmtsMenuManage.php

@@ -11,60 +11,13 @@
  * Menu representation.
  * @see BxDolMenu
  */
-class BxBaseCmtsMenuManage extends BxTemplMenu
+class BxBaseCmtsMenuManage extends BxTemplCmtsMenuActions
 {
-    protected $_oCmts;
-    protected $_aCmt;
-
     public function __construct ($aObject, $oTemplate)
     {
         parent::__construct ($aObject, $oTemplate);
-    }
-
-    public function setCmtsData($oCmts, $iCmtId)
-    {
-        if(empty($oCmts) || empty($iCmtId))
-            return;
-
-        $this->_oCmts = $oCmts;
-        $this->_aCmt = $oCmts->getCommentRow($iCmtId);
-
-        $this->addMarkers(array(
-            'js_object' => $oCmts->getJsObjectName(),
-            'content_id' => $iCmtId,
-        ));
-    }
-
-    /**
-     * Check if menu items is visible.
-     * @param $a menu item array
-     * @return boolean
-     */
-    protected function _isVisible ($a)
-    {
-        if(!parent::_isVisible($a))
-            return false;
-
-        $sCheckFuncName = '';
-        $aCheckFuncParams = array();
-        switch ($a['name']) {
-            case 'item-edit':
-                $sCheckFuncName = 'isEditAllowed';
-                if(!empty($this->_aCmt))
-                    $aCheckFuncParams = array($this->_aCmt);
-                break;
-
-            case 'item-delete':
-                $sCheckFuncName = 'isRemoveAllowed';
-                if(!empty($this->_aCmt))
-                    $aCheckFuncParams = array($this->_aCmt);
-                break;
-        }
-
-        if(!$sCheckFuncName || !method_exists($this->_oCmts, $sCheckFuncName))
-            return true;
 
-        return call_user_func_array(array($this->_oCmts, $sCheckFuncName), $aCheckFuncParams);
+        $this->_bShowTitles = true;
     }
 }
 

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff