1
0
Эх сурвалжийг харах

Ticket #4835 - Notifications: Add possibility to disable notifications to content author about replies to comments.

AntonLV 1 жил өмнө
parent
commit
3a0e3744fe

+ 1 - 0
inc/classes/BxDolCmts.php

@@ -2170,6 +2170,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
             'comment_id' => $iCmtId, 
             'comment_uniq_id' => $iCmtUniqId,
             'comment_author_id' => $aCmt['cmt_author_id'], 
+            'comment_parent_id' => $aCmt['cmt_parent_id'], 
             'comment_text' => $aCmt['cmt_text'],
 
             'privacy_view' => $iObjAthrPrivacyView,

+ 1 - 0
modules/boonex/notifications/classes/BxNtfsConfig.php

@@ -52,6 +52,7 @@ class BxNtfsConfig extends BxBaseModNotificationsConfig
             // some params
             'PARAM_QUEUE_ADD_THRESHOLD' => 0,
             'PARAM_COMMENT_POST_EXT' => 'bx_notifications_enable_comment_post_ext',
+            'PARAM_REPLY_AS_COMMENT' => 'bx_notifications_enable_reply_as_comment',
             'PARAM_PROCESSED_EVENT' => 'bx_notifications_processed_event',
 
             // objects

+ 18 - 2
modules/boonex/notifications/classes/BxNtfsResponse.php

@@ -59,8 +59,11 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
         switch($aHandler['type']) {
             case BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT:
                 $sMethod = 'getInsertData' . bx_gen_method_name($oAlert->sUnit . '_' . $oAlert->sAction);
-                if(!method_exists($this, $sMethod))
-                    $sMethod = 'getInsertData';
+                if(!method_exists($this, $sMethod)) {
+                    $sMethod = 'getInsertData' . bx_gen_method_name('any_' . $oAlert->sAction);
+                    if(!method_exists($this, $sMethod))
+                        $sMethod = 'getInsertData';
+                }
 
                 $aDataItems = $this->$sMethod($oAlert, $aHandler);
 
@@ -180,6 +183,19 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
         );
     }
 
+    /*
+     * Custom insert data getter for any module -> commentPost alerts. 
+     */
+    protected function getInsertDataAnyCommentPost(&$oAlert, &$aHandler)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if(getParam($CNF['PARAM_REPLY_AS_COMMENT']) != 'on' && isset($oAlert->aExtras['comment_parent_id']) && (int)$oAlert->aExtras['comment_parent_id'] != 0)
+            return [];
+
+        return $this->getInsertData($oAlert, $aHandler);
+    }
+    
     /*
      * Custom insert data getter for comment -> added and deleted alerts. 
      */

+ 1 - 0
modules/boonex/notifications/install/langs/en.xml

@@ -49,6 +49,7 @@
     <string name="_bx_ntfs_option_processed_event"><![CDATA[The last processed event upon notifications sending]]></string>
     <string name="_bx_ntfs_option_clear_interval"><![CDATA[Notification lifetime, in days (0 - no limit)]]></string>
     <string name="_bx_ntfs_option_enable_comment_post_ext"><![CDATA[Notify a user about new comments for a content he's previously commented]]></string>
+    <string name="_bx_ntfs_option_enable_reply_as_comment"><![CDATA[Treat replies as comments in 'New comments' notification.]]></string>
     <string name="_bx_ntfs_option_summary_chars"><![CDATA[Number of characters in auto-cropped summary (applied before saving a notification)]]></string>
     <string name="_bx_ntfs_option_owner_name_chars"><![CDATA[Number of characters in auto-cropped author name in notification text]]></string>
     <string name="_bx_ntfs_option_content_chars"><![CDATA[Number of characters in auto-cropped content title in notification text]]></string>

+ 1 - 0
modules/boonex/notifications/install/sql/enable.sql

@@ -97,6 +97,7 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_notifications_delivery_timeout', '120', @iCategId, '_bx_ntfs_option_delivery_timeout', 'digit', '', '', '', '', 20),
 ('bx_notifications_clear_interval', '90', @iCategId, '_bx_ntfs_option_clear_interval', 'digit', '', '', '', '', 30),
 ('bx_notifications_enable_comment_post_ext', '', @iCategId, '_bx_ntfs_option_enable_comment_post_ext', 'checkbox', '', '', '', '', 40),
+('bx_notifications_enable_reply_as_comment', 'on', @iCategId, '_bx_ntfs_option_enable_reply_as_comment', 'checkbox', '', '', '', '', 42),
 ('bx_notifications_summary_chars', '200', @iCategId, '_bx_ntfs_option_summary_chars', 'digit', '', '', '', '', 50),
 ('bx_notifications_owner_name_chars', '21', @iCategId, '_bx_ntfs_option_owner_name_chars', 'digit', '', '', '', '', 51),
 ('bx_notifications_content_chars', '32', @iCategId, '_bx_ntfs_option_content_chars', 'digit', '', '', '', '', 52),

+ 1 - 0
modules/boonex/russian/data/langs/bx_notifications/ru.xml

@@ -49,6 +49,7 @@
     <string name="_bx_ntfs_option_clear_interval"><![CDATA[Срок жизни уведомления, в днях (0 - без ограничений)]]></string>
     <string name="_bx_ntfs_option_processed_event"><![CDATA[Последнее событие, обработанное в процессе отправки оповещений]]></string>
     <string name="_bx_ntfs_option_enable_comment_post_ext"><![CDATA[Оповещать пользователя о новых комментариях к контенту, котороый он комментировал ранее]]></string>
+    <string name="_bx_ntfs_option_enable_reply_as_comment"><![CDATA[Рассматривать ответы как комментарии в уведомлении 'Новые комментарии'.]]></string>
     <string name="_bx_ntfs_option_summary_chars"><![CDATA[Количество символов в автоматически обрезаемом резюме (применяется перед сохранением уведомления)]]></string>
     <string name="_bx_ntfs_option_owner_name_chars"><![CDATA[Количество символов в автоматически обрезаемом имени автора в тексте уведомления]]></string>
     <string name="_bx_ntfs_option_content_chars"><![CDATA[Количество символов в автоматически обрезаемом заголовке контента в тексте уведомления]]></string>