Parcourir la source

Ticket #5653 - Notifications: Make notifications more accurate.

AntonLV il y a 1 mois
Parent
commit
2152329bb8

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

@@ -59,6 +59,7 @@ class BxNtfsConfig extends BxBaseModNotificationsConfig
             // some params
             'PARAM_QUEUE_ADD_THRESHOLD' => 'bx_notifications_queue_add_threshold',
             'PARAM_QUEUE_ADD_LIMIT' => 'bx_notifications_queue_add_limit',
+            'PARAM_OWN_ACTIONS' => 'bx_notifications_enable_own_actions',
             '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',
@@ -167,7 +168,7 @@ class BxNtfsConfig extends BxBaseModNotificationsConfig
         $this->_iDeliveryTimeout = (int)getParam($sOptionPrefix . 'delivery_timeout');
 
         $this->_bEventsGrouped = getParam($sOptionPrefix . 'enable_group_events') == 'on';
-        $this->_bEventsGroupedDb = false;
+        $this->_bEventsGroupedDb = getParam($sOptionPrefix . 'enable_group_events_db') == 'on';;
 
         $this->_bClickedIndicator = getParam($sOptionPrefix . 'enable_clicked_indicator') == 'on';
 

+ 21 - 6
modules/boonex/notifications/classes/BxNtfsDb.php

@@ -119,7 +119,7 @@ class BxNtfsDb extends BxBaseModNotificationsDb
 
         $sSelectClauseGrouped = $sGroupByClauseGrouped = "";
         if($bEventsGroupedDb) {
-            $sSelectClauseGrouped = ", GROUP_CONCAT(`{$this->_sTable}`.`id` SEPARATOR ',') AS `grouped_by_mac`";
+            $sSelectClauseGrouped =  ", GROUP_CONCAT(`{$this->_sTable}`.`id` ORDER BY `{$this->_sTableHandlers}`.`priority` DESC SEPARATOR ',') AS `subgrouped_by_mac`";
             $sGroupByClauseGrouped = "`{$this->_sTable}`.`source_mac`";
         }
 
@@ -242,7 +242,10 @@ class BxNtfsDb extends BxBaseModNotificationsDb
             'query_pc_ref' => &$sQueryConnections,
         ]);
 
-        $sQuery = "(" . $sQueryOwner . ") UNION (" . $sQueryConnections . ") {order} {limit}";
+        if($bEventsGroupedDb)
+            $sQuery = "SELECT *, GROUP_CONCAT(`subgrouped_by_mac` ORDER BY `priority` DESC SEPARATOR ',') AS `grouped_by_mac` FROM ((" . $sQueryOwner . ") UNION (" . $sQueryConnections . ")) AS `tu` GROUP BY `source_mac` {order} {limit}";
+        else
+            $sQuery = "(" . $sQueryOwner . ") UNION (" . $sQueryConnections . ") {order} {limit}";
         $sQuery = str_replace(['{select}', '{order}', '{limit}'], [$sSelectClause, $sUnionOrderClause, $sUnionLimitClause], $sQuery);
         $aEntries = $this->$sUnionMethod($sQuery);
 
@@ -296,6 +299,8 @@ class BxNtfsDb extends BxBaseModNotificationsDb
 
     protected function _getSqlPartsEventsList($aParams)
     {
+        $CNF = &$this->_oConfig->CNF;
+
         $sJoinClause = $sWhereClause = "";
 
         //--- Apply 'start from'  filter
@@ -357,8 +362,13 @@ class BxNtfsDb extends BxBaseModNotificationsDb
                     $sJoinClause .= " LEFT JOIN `sys_profiles` AS `tsp` ON `{$this->_sTable}`.`owner_id`=`tsp`.`id` " . $aQueryParts['join'];
 
                     $sWhereClauseType = '';
-                    //--- Don't show notifications about own posts to connected contexts
-                    $sWhereClauseType .= $this->prepareAsString("AND `{$this->_sTable}`.`object_owner_id` <> ? ", $aParams['owner_id']);
+                    if(getParam($CNF['PARAM_OWN_ACTIONS']) != 'on') {
+                        //--- Don't show notifications about own posts to connected contexts
+                        $sWhereClauseType .= $this->prepareAsString("AND `{$this->_sTable}`.`object_owner_id` <> ? ", $aParams['owner_id']);
+
+                        //--- Don't show notifications about the other own actions performed in connected contexts
+                        $sWhereClauseType .= $this->prepareAsString("AND `{$this->_sTable}`.`author_id` <> ? ", $aParams['owner_id']);
+                    }
                     //--- Don't show notifications about posts created before the connection was established
                     if(!empty($aQueryParts['fields']['added']))
                         $sWhereClauseType .= "AND `{$this->_sTable}`.`date` >= " . $aQueryParts['fields']['added'];
@@ -397,8 +407,13 @@ class BxNtfsDb extends BxBaseModNotificationsDb
 
                         //--- Show notifications from connected contexts
                         $sWhereClauseConnections = "NOT ISNULL(`c`.`content`) ";
-                        //--- Don't show notifications about own posts to connected contexts
-                        $sWhereClauseConnections .= $this->prepareAsString("AND `{$this->_sTable}`.`object_owner_id` <> ? ", $aParams['owner_id']);
+                        if(getParam($CNF['PARAM_OWN_ACTIONS']) != 'on') {
+                            //--- Don't show notifications about own posts to connected contexts
+                            $sWhereClauseConnections .= $this->prepareAsString("AND `{$this->_sTable}`.`object_owner_id` <> ? ", $aParams['owner_id']);
+
+                            //--- Don't show notifications about the other own actions performed in connected contexts
+                            $sWhereClauseType .= $this->prepareAsString("AND `{$this->_sTable}`.`author_id` <> ? ", $aParams['owner_id']);
+                        }
                         //--- Don't show notifications about posts created before the connection was established
                         if(!empty($aQueryParts['fields']['added']))
                             $sWhereClauseConnections .= "AND `{$this->_sTable}`.`date` >= `" . $aQueryParts['fields']['added']['table_alias'] . "`.`" . $aQueryParts['fields']['added']['name'] . "` ";

+ 52 - 56
modules/boonex/notifications/classes/BxNtfsResponse.php

@@ -135,6 +135,7 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
         $aResult = array();
         foreach($mixedSubobjectId as $iSubobjectId)
             $aResult[] = array(
+                'author_id' => $oAlert->iSender,
                 'owner_id' => $iOwnerId,
                 'type' => $oAlert->sUnit,
                 'action' => $oAlert->sAction,
@@ -226,6 +227,7 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
                 continue;
 
             $aResults[] = [
+                'author_id' => $oAlert->iSender,
                 'owner_id' => $iOwnerId,
                 'type' => $oAlert->sUnit,
                 'action' => $oAlert->sAction,
@@ -254,24 +256,23 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
         $iObjectPrivacyView = $this->_getObjectPrivacyView($oAlert->aExtras);
         $iPrivacyView = $this->_oModule->_oConfig->getPrivacyViewDefault('event');
 
-    	return array(
-    	    array(
-                'owner_id' => $oAlert->aExtras['initiator'],
-                'type' => $oAlert->sUnit,
-                'action' => $oAlert->sAction,
-                'object_id' => $oAlert->aExtras['content'],
-                'object_owner_id' => $oAlert->aExtras['content'],
-                'object_privacy_view' => $iObjectPrivacyView,
-                'subobject_id' => 0,
-                'content' => $this->_getContent($oAlert->aExtras, array(
-                    'request' => empty($oAlert->aExtras['mutual']) ? 1 : 0
-                )),
-                'source' => $this->_getSource($oAlert->aExtras),
-                'source_mac' => $this->_getSourceMac($oAlert->aExtras),
-                'allow_view_event_to' => $iPrivacyView,
-                'processed' => 0
-    	    )
-        );
+    	return [[
+            'author_id' => $oAlert->iSender,
+            'owner_id' => $oAlert->aExtras['initiator'],
+            'type' => $oAlert->sUnit,
+            'action' => $oAlert->sAction,
+            'object_id' => $oAlert->aExtras['content'],
+            'object_owner_id' => $oAlert->aExtras['content'],
+            'object_privacy_view' => $iObjectPrivacyView,
+            'subobject_id' => 0,
+            'content' => $this->_getContent($oAlert->aExtras, array(
+                'request' => empty($oAlert->aExtras['mutual']) ? 1 : 0
+            )),
+            'source' => $this->_getSource($oAlert->aExtras),
+            'source_mac' => $this->_getSourceMac($oAlert->aExtras),
+            'allow_view_event_to' => $iPrivacyView,
+            'processed' => 0
+        ]];
     }
     
     protected function getInsertDataMetaMentionAdded(&$oAlert, &$aHandler)
@@ -283,6 +284,7 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
             $iOwnerId = abs($iObjectPrivacyView);
         
          $aResult = [[
+            'author_id' => $oAlert->iSender,
             'owner_id' => $iOwnerId,
             'type' => $oAlert->sUnit,
             'action' => $oAlert->sAction,
@@ -308,20 +310,17 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
         $aHandlers = $this->_oModule->_oDb->getHandlers(array('type' => 'by_group_key_type', 'group' => $aHandler['group']));
 
         $sAction = $aHandlers[BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT]['alert_action'];
-    	return array(
-    	    array(
-    	        'owner_id' => $oAlert->aExtras['initiator'],
-            	'type' => $oAlert->sUnit, 
-            	'action' => $sAction, 
-            	'object_id' => $oAlert->aExtras['content']
-            ),
-            array(
-            	'owner_id' => $oAlert->aExtras['content'],
-            	'type' => $oAlert->sUnit, 
-            	'action' => $sAction, 
-            	'object_id' => $oAlert->aExtras['initiator']
-            )
-        );
+    	return [[
+            'owner_id' => $oAlert->aExtras['initiator'],
+            'type' => $oAlert->sUnit, 
+            'action' => $sAction, 
+            'object_id' => $oAlert->aExtras['content']
+        ], [
+            'owner_id' => $oAlert->aExtras['content'],
+            'type' => $oAlert->sUnit, 
+            'action' => $sAction, 
+            'object_id' => $oAlert->aExtras['initiator']
+        ]];
     }
 
     /**
@@ -329,36 +328,33 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
      */
     protected function getInsertDataSysProfilesSubscriptionsConnectionAdded(&$oAlert, &$aHandler)
     {
-    	return array(
-    	    array(
-                'owner_id' => $oAlert->aExtras['initiator'],
-                'type' => $oAlert->sUnit,
-                'action' => $oAlert->sAction,
-                'object_id' => $oAlert->aExtras['content'],
-                'object_owner_id' => $oAlert->aExtras['content'],
-                'object_privacy_view' => $this->_getObjectPrivacyView($oAlert->aExtras),
-                'subobject_id' => 0,
-                'content' => $this->_getContent($oAlert->aExtras),
-                'source' => $this->_getSource($oAlert->aExtras),
-                'source_mac' => $this->_getSourceMac($oAlert->aExtras),                
-                'allow_view_event_to' => $this->_oModule->_oConfig->getPrivacyViewDefault('event'),
-                'processed' => 0
-    	    )
-        );
+    	return [[
+            'author_id' => $oAlert->iSender,
+            'owner_id' => $oAlert->aExtras['initiator'],
+            'type' => $oAlert->sUnit,
+            'action' => $oAlert->sAction,
+            'object_id' => $oAlert->aExtras['content'],
+            'object_owner_id' => $oAlert->aExtras['content'],
+            'object_privacy_view' => $this->_getObjectPrivacyView($oAlert->aExtras),
+            'subobject_id' => 0,
+            'content' => $this->_getContent($oAlert->aExtras),
+            'source' => $this->_getSource($oAlert->aExtras),
+            'source_mac' => $this->_getSourceMac($oAlert->aExtras),                
+            'allow_view_event_to' => $this->_oModule->_oConfig->getPrivacyViewDefault('event'),
+            'processed' => 0
+        ]];
     }
 
     protected function getDeleteDataSysProfilesSubscriptionsConnectionRemoved(&$oAlert, &$aHandler)
     {
         $aHandlers = $this->_oModule->_oDb->getHandlers(array('type' => 'by_group_key_type', 'group' => $aHandler['group']));
 
-    	return array(
-    	    array(
-    	        'owner_id' => $oAlert->aExtras['initiator'],
-            	'type' => $oAlert->sUnit, 
-            	'action' => $aHandlers[BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT]['alert_action'], 
-            	'object_id' => $oAlert->aExtras['content']
-            )
-        );
+    	return [[
+            'owner_id' => $oAlert->aExtras['initiator'],
+            'type' => $oAlert->sUnit, 
+            'action' => $aHandlers[BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT]['alert_action'], 
+            'object_id' => $oAlert->aExtras['content']
+        ]];
     }
 
     protected function _getObjectOwnerId($aExtras)

+ 48 - 24
modules/boonex/notifications/classes/BxNtfsTemplate.php

@@ -94,12 +94,8 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
             if(empty($sEvent))
                 continue;
 
-            if($this->_bIsApi){
-                if(!isset($sEvent['author_data']))
-                    $sEvent['author_data'] = BxDolProfile::getData($sEvent['owner_id']);
-
+            if($this->_bIsApi)
                 $aTmplVarsEvents[] = $sEvent;
-            }
             else
                 $aTmplVarsEvents[] = ['event' => $sEvent];
 
@@ -110,19 +106,19 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
         if($this->_bIsApi)
             return $aTmplVarsEvents;
 
-        $oPaginate = new BxTemplPaginate(array(
+        $oPaginate = new BxTemplPaginate([
             'start' => $aParams['start'],
             'per_page' => $aParams['per_page'],
             'page_url' => $this->_oConfig->getViewUrl(),
             'on_change_page' => $sJsObject . ".changePage(this, {start}, {per_page})"
-        ));
+        ]);
         $oPaginate->setNumFromDataArray($aTmplVarsEvents);
 
-        return $this->parseHtmlByName('events.html', array(
+        return $this->parseHtmlByName('events.html', [
             'style_prefix' => $this->_oConfig->getPrefix('style'),
             'bx_repeat:events' => $aTmplVarsEvents,
             'paginate' => $oPaginate->getSimplePaginate()
-        ));
+        ]);
     }
 
     /**
@@ -167,6 +163,14 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
 
         $bShowRealProfile = !isset($aBrowseParams['show_real_profile']) || $aBrowseParams['show_real_profile'] === true;
 
+        $oAuthor = $oModule->getObjectUser($aEvent['author_id'] ?? 0);
+        if(!$bShowRealProfile && $oAuthor instanceof BxDolProfileAnonymous)
+            $oAuthor->setShowRealProfile($bShowRealProfile);
+
+        $aEvent['content']['author_name'] = strmaxtextlen($oAuthor->getDisplayName(), $this->_oConfig->getOwnerNameMaxLen());
+        $aEvent['content']['author_link'] = $oAuthor->getUrl();
+        $aEvent['content']['author_icon'] = $oAuthor->getThumb();
+
         $oOwner = $oModule->getObjectUser($aEvent['owner_id']);
         if(!$bShowRealProfile && $oOwner instanceof BxDolProfileAnonymous)
             $oOwner->setShowRealProfile($bShowRealProfile);
@@ -216,11 +220,13 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
             $aEvent['content'][$sKey] = call_user_func_array('_t', $aCallParams);
         }
 
-        $sOwnerUnit = $oOwner->getUnit(0, ['template' => 'unit_wo_info_links']);
+        $sAuthorUnit = '';
+        if(($o = !($oAuthor instanceof BxDolProfileUndefined) ? $oAuthor : $oOwner) !== false)
+            $sAuthorUnit = $o->getUnit(0, ['template' => 'unit_wo_info_links']);
 
         $bEventParsed = false;
         $bEventCanceled = false;
-        
+
         /**
          * @hooks
          * @hookdef hook-bx_notifications-get_notification 'bx_notifications', 'get_notification' - hook to override notification or even cancel it
@@ -243,17 +249,19 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
             'event' => &$aEvent, 
             'event_parsed' => &$bEventParsed, 
             'event_canceled' => &$bEventCanceled,
+            'author' => &$oAuthor, 
             'owner' => &$oOwner, 
-            'owner_unit' => &$sOwnerUnit,
+            'owner_unit' => &$sAuthorUnit,
 
             'event_ref' => &$aEvent, 
             'event_parsed_ref' => &$bEventParsed, 
             'event_canceled_ref' => &$bEventCanceled,
-            'owner_ref' => &$oOwner, 
-            'owner_unit_ref' => &$sOwnerUnit,
+            'author_ref' => &$oAuthor,
+            'owner_ref' => &$oOwner,
+            'owner_unit_ref' => &$sAuthorUnit,
         ]);
-        
-        if ($bEventCanceled)
+
+        if($bEventCanceled)
             return '';
 
         if(($sGroupedByMac = $aEvent['grouped_by_mac'] ?? false)) {
@@ -265,10 +273,15 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
                 if(!$aSubEvent || !is_array($aSubEvent))
                     continue;
 
+                if($sContentParsed && ($sK = 'content') && ($sEc = $aSubEvent[$sK] ?? '') && is_string($sEc)) {
+                    $aSubEvent[$sK] = unserialize($sEc);
+                    $aSubEvent[$sK]['author_name_wrapped'] = _t('_bx_ntfs_txt_and');
+                }
+
                 $this->getPost($aSubEvent);
 
                 if(($sCp = $aSubEvent['content_parsed'] ?? false))
-                    $sContentParsed .= $sCp . '<br />';
+                    $sContentParsed .= ' ' . $sCp;
             }
 
             if($sContentParsed) {
@@ -303,7 +316,10 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
         $sJsObject = $this->_oConfig->getJsObject('view');
 
         if($this->_bIsApi) {
+            $aEvent['author_data'] = BxDolProfile::getData($aEvent['author_id']);
+
             $aLinks = [
+                'author_link' => $aEvent['content']['author_link'],
                 'owner_link' => $aEvent['content']['owner_link'],
                 'object_owner_link' => $aEvent['content']['object_owner_link']
             ];
@@ -339,7 +355,7 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
                 $aEvent[$sKey] = html_entity_decode($aEvent[$sKey]);
 
             return array_intersect_key($aEvent, array_flip([
-                'id', 'owner_id', 'module', 'type', 'content', 'content_parsed', 'date', 'author_data'
+                'id', 'author_id', 'author_data', 'owner_id', 'module', 'type', 'content', 'content_parsed', 'date'
             ]));
         }
 
@@ -349,7 +365,7 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
             'js_object' => $sJsObject,
             'class' => !empty($aBrowseParams['last_read']) && $aEvent['id'] > $aBrowseParams['last_read'] ? ' bx-def-color-bg-box-active' : '', 
             'id' => $aEvent['id'],
-            'author_unit' => $sOwnerUnit,
+            'author_unit' => $sAuthorUnit,
             'link' => $this->_getContentLink($aEvent),
             'content' => is_array($aEvent['content_parsed']) && isset($aEvent['content_parsed']['site']) ? $aEvent['content_parsed']['site'] : $aEvent['content_parsed'],
             'date' => bx_time_js($aEvent['date']),
@@ -621,12 +637,20 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
 
     protected function _parseContentLangKey($sLangKey, &$aEvent)
     {
-        $aExclude = array(
-            'lang_key' => 1,
-            'settings' => 1
-        );
+        $aMarkers = array_diff_key($aEvent['content'], array_flip([
+            'lang_key', 'settings'
+        ]));
+
+        $aPreparsed = [];
+        if(($sK = 'author_name_wrapped') && !isset($aMarkers[$sK]))
+            $aPreparsed[$sK] = _t('_bx_ntfs_txt_author_name_wrapped');
+        if(($sK = 'owner_name_wrapped') && !isset($aMarkers[$sK]))
+            $aPreparsed[$sK] = _t('_bx_ntfs_txt_owner_name_wrapped');
+
+        if($aPreparsed)
+            $aMarkers = array_merge($aMarkers, bx_replace_markers($aPreparsed, $aMarkers));
 
-        return $this->parseHtmlByContent(_t($sLangKey), array_diff_key($aEvent['content'], $aExclude), array('{', '}'));
+        return bx_replace_markers(_t($sLangKey), $aMarkers);
     }
 
     protected function _getContentLink($aEvent, $bForApi = false)

+ 16 - 10
modules/boonex/notifications/install/langs/en.xml

@@ -65,6 +65,7 @@
     <string name="_bx_ntfs_option_events_hide_push"><![CDATA[Push notifications]]></string>
     <string name="_bx_ntfs_option_enable_group_settings"><![CDATA[Group settings by category]]></string>
     <string name="_bx_ntfs_option_enable_group_events"><![CDATA[Group notifications by event]]></string>
+    <string name="_bx_ntfs_option_enable_group_events_db"><![CDATA[Group notifications by event (on DB level, experimental)]]></string>
     <string name="_bx_ntfs_option_enable_clicked_indicator"><![CDATA[Enable 'clicked' indicator]]></string>
     <string name="_bx_ntfs_option_delivery_timeout"><![CDATA[Delay before sending Email and/or Push notifications (in seconds)]]></string>
     <string name="_bx_ntfs_option_delivery_timeout_inf"><![CDATA[Positive value other than '0' means that notifications will be send via Internal queue.]]></string>
@@ -74,6 +75,7 @@
     <string name="_bx_ntfs_option_queue_add_limit_inf"><![CDATA['0' means that all available notifications will be processed at once.]]></string>
     <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_own_actions"><![CDATA[Notify a user about his own actions]]></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>
@@ -176,18 +178,22 @@
     <string name="_bx_ntfs_txt_msg_no_results"><![CDATA[Empty]]></string>
     <string name="_bx_ntfs_txt_err_nothing_changed"><![CDATA[Nothing was changed.]]></string>
     <string name="_bx_ntfs_txt_err_cannot_perform"><![CDATA[Cannot perform the action.]]></string>
-    <string name="_bx_ntfs_txt_object_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_added_in_context"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> has got a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> added by <b class="bx-ntfs-content-profile">{object_owner_name}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_post_common"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_post_common_in_context"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> has got a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> added by <b class="bx-ntfs-content-profile">{object_owner_name}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_approved"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> approved {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_approved_in_context"><![CDATA[<b class="bx-ntfs-content-entry">{entry_caption}</b> {entry_sample} was approved in <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
+
+    <string name="_bx_ntfs_txt_and"><![CDATA[and]]></string>
+    <string name="_bx_ntfs_txt_author_name_wrapped"><![CDATA[<b class="bx-ntfs-content-profile">{author_name}</b>]]></string>
+    <string name="_bx_ntfs_txt_owner_name_wrapped"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_added"><![CDATA[{author_name_wrapped} added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_added_in_context"><![CDATA[{author_name_wrapped} added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_post_common"><![CDATA[{author_name_wrapped} added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_post_common_in_context"><![CDATA[{author_name_wrapped} added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_approved"><![CDATA[{author_name_wrapped} approved {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_approved_in_context"><![CDATA[{author_name_wrapped} approved <b class="bx-ntfs-content-entry">{entry_caption}</b> {entry_sample} in <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
     <string name="_bx_ntfs_txt_object_publish_failed"><![CDATA[Failed to publish your {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
     <string name="_bx_ntfs_txt_object_publish_succeeded"><![CDATA[Your {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> was published successfully]]></string>
-    <string name="_bx_ntfs_txt_object_pending_approval"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> added a pending approval {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_reported_content"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> reported a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_subobject_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> added a {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_subobject_added_in_context"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> has got a {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_pending_approval"><![CDATA[{author_name_wrapped} added a pending approval {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_reported_content"><![CDATA[{author_name_wrapped} reported a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_subobject_added"><![CDATA[{author_name_wrapped} added a {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_subobject_added_in_context"><![CDATA[{author_name_wrapped} added a {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
     <string name="_bx_ntfs_txt_new_event_subject"><![CDATA[New on "{0}"]]></string>
     <string name="_bx_ntfs_txt_et_preview_subject"><![CDATA[Subject:]]></string>
     <string name="_bx_ntfs_txt_et_preview_body"><![CDATA[Body:]]></string>

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

@@ -98,12 +98,14 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `info`, `t
 ('bx_notifications_events_per_preview', '5', @iCategId, '_bx_ntfs_option_events_per_preview', '', 'digit', '', '', '', '', 5),
 ('bx_notifications_enable_group_settings', 'on', @iCategId, '_bx_ntfs_option_enable_group_settings', '', 'checkbox', '', '', '', '', 10), 
 ('bx_notifications_enable_group_events', 'on', @iCategId, '_bx_ntfs_option_enable_group_events', '', 'checkbox', '', '', '', '', 11), 
+('bx_notifications_enable_group_events_db', '', @iCategId, '_bx_ntfs_option_enable_group_events_db', '', 'checkbox', '', '', '', '', 13), 
 ('bx_notifications_enable_clicked_indicator', '', @iCategId, '_bx_ntfs_option_enable_clicked_indicator', '', 'checkbox', '', '', '', '', 15),
 ('bx_notifications_delivery_timeout', '120', @iCategId, '_bx_ntfs_option_delivery_timeout', '_bx_ntfs_option_delivery_timeout_inf', 'digit', '', '', '', '', 20),
 ('bx_notifications_queue_add_threshold', '0', @iCategId, '_bx_ntfs_option_queue_add_threshold', '_bx_ntfs_option_queue_add_threshold_inf', 'digit', '', '', '', '', 21),
 ('bx_notifications_queue_add_limit', '200', @iCategId, '_bx_ntfs_option_queue_add_limit', '_bx_ntfs_option_queue_add_limit_inf', 'digit', '', '', '', '', 22),
 ('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_own_actions', '', @iCategId, '_bx_ntfs_option_enable_own_actions', '', 'checkbox', '', '', '', '', 40),
+('bx_notifications_enable_comment_post_ext', '', @iCategId, '_bx_ntfs_option_enable_comment_post_ext', '', 'checkbox', '', '', '', '', 41),
 ('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),

+ 2 - 1
modules/boonex/notifications/install/sql/install.sql

@@ -4,6 +4,7 @@ SET @sName = 'bx_notifications';
 -- TABLES
 CREATE TABLE IF NOT EXISTS `bx_notifications_events` (
   `id` int(11) NOT NULL auto_increment,
+  `author_id` int(11) NOT NULL default '0',
   `owner_id` int(11) NOT NULL default '0',
   `type` varchar(255) NOT NULL,
   `action` varchar(255) NOT NULL,
@@ -80,7 +81,7 @@ INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_ac
 
 -- Mentions
 INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`, `privacy`, `priority`) VALUES 
-('mention', 'insert', 'meta_mention', 'added', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:30:"get_notifications_post_mention";s:12:"module_class";s:20:"TemplServiceMetatags";}', '', 1);
+('mention', 'insert', 'meta_mention', 'added', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:30:"get_notifications_post_mention";s:12:"module_class";s:20:"TemplServiceMetatags";}', '', 0);
 SET @iHandlerId = LAST_INSERT_ID();
 
 INSERT INTO `bx_notifications_settings`(`group`, `handler_id`, `delivery`, `type`, `title`, `order`) VALUES

+ 14 - 10
modules/boonex/russian/data/langs/bx_notifications/ru.xml

@@ -65,6 +65,7 @@
     <string name="_bx_ntfs_option_events_hide_push"><![CDATA[Push-уведомления]]></string>
     <string name="_bx_ntfs_option_enable_group_settings"><![CDATA[Сгруппировать настройки по категориям]]></string>
     <string name="_bx_ntfs_option_enable_group_events"><![CDATA[Сгруппировать оповещения по принадлежности к событию]]></string>
+    <string name="_bx_ntfs_option_enable_group_events"><![CDATA[Сгруппировать оповещения по принадлежности к событию (на уровне БД, экспериментально)]]></string>
     <string name="_bx_ntfs_option_enable_clicked_indicator"><![CDATA[Включить индикатор перехода по ссылке уведомления]]></string>
     <string name="_bx_ntfs_option_delivery_timeout"><![CDATA[Задержка перед отправкой Email и/или Push уведомлений (в секундах)]]></string>
     <string name="_bx_ntfs_option_delivery_timeout_inf"><![CDATA[Положительное значение, отличное от '0', означает, что уведомления будут отправляться через Внутреннюю очередь.]]></string>
@@ -74,6 +75,7 @@
     <string name="_bx_ntfs_option_queue_add_limit_inf"><![CDATA['0' означает, что все доступные уведомления будут обработаны одновременно.]]></string>
     <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_own_actions"><![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>
@@ -176,18 +178,20 @@
     <string name="_bx_ntfs_txt_msg_no_results"><![CDATA[Пусто]]></string>
     <string name="_bx_ntfs_txt_err_nothing_changed"><![CDATA[Ничего не изменилось.]]></string>
     <string name="_bx_ntfs_txt_err_cannot_perform"><![CDATA[Невозможно выполнить действие.]]></string>
-    <string name="_bx_ntfs_txt_object_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_added_in_context"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> от <b class="bx-ntfs-content-profile">{object_owner_name}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_post_common"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_post_common_in_context"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> от <b class="bx-ntfs-content-profile">{object_owner_name}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_approved"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - одобрение <b class="bx-ntfs-content-entry">{entry_caption}</b> ({entry_sample})]]></string>
-    <string name="_bx_ntfs_txt_object_approved_in_context"><![CDATA[<b class="bx-ntfs-content-entry">{entry_caption}</b> {entry_sample} - одобрение в <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
+
+    <string name="_bx_ntfs_txt_and"><![CDATA[и]]></string>
+    <string name="_bx_ntfs_txt_object_added"><![CDATA[{author_name_wrapped} - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_added_in_context"><![CDATA[{author_name_wrapped} - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> в <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_post_common"><![CDATA[{author_name_wrapped} - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_post_common_in_context"><![CDATA[{author_name_wrapped} - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> в <b class="bx-ntfs-content-profile">{object_owner_name}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_approved"><![CDATA[{author_name_wrapped} - одобрение <b class="bx-ntfs-content-entry">{entry_caption}</b> ({entry_sample})]]></string>
+    <string name="_bx_ntfs_txt_object_approved_in_context"><![CDATA[{author_name_wrapped} - одобрение <b class="bx-ntfs-content-entry">{entry_caption}</b> ({entry_sample}) в <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
     <string name="_bx_ntfs_txt_object_publish_failed"><![CDATA[Ошибка при публикации: {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
     <string name="_bx_ntfs_txt_object_publish_succeeded"><![CDATA[Успешная публикация: {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_object_pending_approval"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> ожидает одобрения]]></string>
-    <string name="_bx_ntfs_txt_object_reported_content"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - новая жалоба: {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_subobject_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
-    <string name="_bx_ntfs_txt_subobject_added_in_context"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_object_pending_approval"><![CDATA[{author_name_wrapped} - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> ожидает одобрения]]></string>
+    <string name="_bx_ntfs_txt_object_reported_content"><![CDATA[{author_name_wrapped} - новая жалоба: {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_subobject_added"><![CDATA[{author_name_wrapped} - {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
+    <string name="_bx_ntfs_txt_subobject_added_in_context"><![CDATA[{author_name_wrapped} - {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b> в <b class="bx-ntfs-content-profile">{owner_name}</b>]]></string>
     <string name="_bx_ntfs_txt_new_event_subject"><![CDATA[Новое на сайте "{0}"]]></string>
     <string name="_bx_ntfs_txt_et_preview_subject"><![CDATA[Тема:]]></string>
     <string name="_bx_ntfs_txt_et_preview_body"><![CDATA[Текст:]]></string>