AntonLV hace 7 años
padre
commit
ee3ecf43f8

+ 18 - 8
modules/base/profile/classes/BxBaseModProfileAlertsResponse.php

@@ -50,15 +50,24 @@ class BxBaseModProfileAlertsResponse extends BxBaseModGeneralAlertsResponse
          * 3. User3 posts something on User2's timeline.
          * Result: User1 would be notifiend when the timeline of following profile (User2) was update by 3d party user.
          */
-        if($oAlert->sUnit == 'bx_timeline' && $oAlert->sAction == 'post_common' && !empty($oAlert->aExtras['object_author_id'])) {
-            $oTimelineOwner = BxDolProfile::getInstance($oAlert->aExtras['object_author_id']);
-            if($oTimelineOwner && $oTimelineOwner->getModule() == $this->_oModule->getName() && $oTimelineOwner->id() != $oAlert->iSender) {
+        /*
+         * The code was commented because it looks like the Retranslation of 
+         * Timeline Common Post is redundant. It's happened after system of Contexts was created.
+         * 
+         * TODO: If nothing happened, remove the code in UNA v.10.
+         * Don't forget to:
+         * 1. Stop listening 'bx_timeline' - 'post_common' alert.
+         * 2. Remove BxBaseModProfileModule::serviceGetNotificationsTimelinePostCommon method
+         * 3. Remove language keys from $CNF['T']['txt_ntfs_timeline_post_common']
+         * 
+        if($oAlert->sUnit == 'bx_timeline' && $oAlert->sAction == 'post_common' && !empty($oAlert->aExtras['owner_id'])) {
+            $iTimelineOwner = (int)$oAlert->aExtras['owner_id'];
+            $oTimelineOwner = BxDolProfile::getInstance($iTimelineOwner);
+            if($oTimelineOwner && $oTimelineOwner->getModule() == $this->_oModule->getName() && $iTimelineOwner != $oAlert->iSender) {
                 $aContentInfo = $this->_oModule->serviceGetContentInfoById($oTimelineOwner->getContentId());
 
-                /*
-                 * Note. Timeline owner profile ID is used as alert sender and also a content (group) owner (author).
-                 */
-                $iSenderId = $iObjectAuthorId = $oTimelineOwner->id(); 
+                //--- Note. Timeline owner profile ID is used as alert sender and also a content (group) owner (author).
+                $iSenderId = $iObjectAuthorId = $iTimelineOwner; 
                 bx_alert($this->_oModule->getName(), 'timeline_post_common', $aContentInfo[$CNF['FIELD_ID']], $iSenderId, array(
                     'object_author_id' => $iObjectAuthorId,
                     'timeline_post_id' => $oAlert->iObject, 
@@ -66,11 +75,12 @@ class BxBaseModProfileAlertsResponse extends BxBaseModGeneralAlertsResponse
 
                     'content' => $aContentInfo,
 
-                    'group_profile' => $oTimelineOwner->id(), 
+                    'group_profile' => $iTimelineOwner, 
                     'profile' => $oAlert->iSender,
                 ));
             }
         }
+        */
 
         if ($this->MODULE != $oAlert->sUnit)
             return;

+ 12 - 1
modules/boonex/notifications/classes/BxNtfsDb.php

@@ -116,9 +116,20 @@ class BxNtfsDb extends BxBaseModNotificationsDb
                     break;
 
                 case BX_NTFS_TYPE_OBJECT_OWNER_AND_CONNECTIONS:
-                    $sWhereClauseObjectOwner = $this->prepareAsString("`{$this->_sTable}`.`owner_id` <> `{$this->_sTable}`.`object_owner_id` AND `{$this->_sTable}`.`object_owner_id`=? ", $aParams['owner_id']);
+                    /**
+                     * 'personal' notifications are taken by: 
+                     * 1. 'owner_id', in case of somebody performed an action in requested profile's context
+                     * 'object_privacy_view' < 0 AND 'owner_id' == ABS('object_privacy_view'))
+                     * Currently it happens when somebody posted a Direct Timeline post in requested profile.
+                     * 2. 'object_owner_id', in case of somebody performed an action with content 
+                     * owned by the requested profile.
+                     */
+                    $sWhereClauseObjectOwner = $this->prepareAsString("`{$this->_sTable}`.`owner_id` <> `{$this->_sTable}`.`object_owner_id` AND ((`{$this->_sTable}`.`owner_id`=? AND `{$this->_sTable}`.`object_privacy_view`<0 AND `{$this->_sTable}`.`owner_id`=ABS(`{$this->_sTable}`.`object_privacy_view`)) OR `{$this->_sTable}`.`object_owner_id`=?) ", $aParams['owner_id'], $aParams['owner_id']);
                     $sWhereClauseObjectOwner .= $this->prepareAsString("AND `{$this->_sTableSettings}`.`type`=?", BX_NTFS_STYPE_PERSONAL);
 
+                    /**
+                     * 'follow' notifications are taken by connection with `owner_id`
+                     */
                     $sWhereClauseConnections = '0';
                     $oConnection = BxDolConnection::getObjectInstance($this->_oConfig->getObject('conn_subscriptions'));
                     $aQueryParts = $oConnection->getConnectedContentAsSQLPartsExt($this->_sTable, 'owner_id', $aParams['owner_id']);

+ 23 - 23
modules/boonex/notifications/classes/BxNtfsTemplate.php

@@ -246,29 +246,29 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
     protected function _processContent(&$aEvent)
     {
     	$aContent = $this->_getContent($aEvent);
-		if(empty($aContent) || !is_array($aContent)) 
-			return;
-
-		$aSet = array();
-		if(!empty($aContent['entry_author'])) {
-			$aSet['object_owner_id'] = (int)$aContent['entry_author'];
-			unset($aContent['entry_author']);
-		}
-
-		if(!empty($aContent['entry_privacy'])) {
-			$aSet['allow_view_event_to'] = $aContent['entry_privacy'];
-			$aEvent['allow_view_event_to'] = $aContent['entry_privacy'];
-			unset($aContent['entry_privacy']);
-		}
-
-		$aEvent['content'] = serialize($aContent);
-		$aSet = array_merge($aSet, array(
-			'content' => $aEvent['content'], 
-			'processed' => 1
-		));
-
-		$this->_oDb->updateEvent($aSet, array('id' => $aEvent['id']));
-		return;
+        if(empty($aContent) || !is_array($aContent)) 
+            return;
+
+        $aSet = array();
+        if(!empty($aContent['entry_author'])) {
+            $aSet['object_owner_id'] = (int)$aContent['entry_author'];
+            unset($aContent['entry_author']);
+        }
+
+        if(!empty($aContent['entry_privacy'])) {
+            $aSet['allow_view_event_to'] = $aContent['entry_privacy'];
+            $aEvent['allow_view_event_to'] = $aContent['entry_privacy'];
+            unset($aContent['entry_privacy']);
+        }
+
+        $aEvent['content'] = serialize($aContent);
+        $aSet = array_merge($aSet, array(
+            'content' => $aEvent['content'], 
+            'processed' => 1
+        ));
+
+        $this->_oDb->updateEvent($aSet, array('id' => $aEvent['id']));
+        return;
     }
 
     protected function _getContent(&$aEvent)

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

@@ -232,7 +232,6 @@
     <string name="_bx_timeline_txt_sample_with_image"><![CDATA[с изображением]]></string>
     <string name="_bx_timeline_txt_sample_with_video"><![CDATA[с видео]]></string>
     <string name="_bx_timeline_txt_sample_with_media"><![CDATA[с медиа]]></string>
-    <string name="_bx_timeline_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_timeline_txt_today"><![CDATA[Сегодня]]></string>
     <string name="_bx_timeline_txt_some_text_here"><![CDATA[Поделитесь своими мыслями]]></string>
     <string name="_bx_timeline_txt_show"><![CDATA[Показать]]></string>

+ 15 - 9
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -1431,14 +1431,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if(empty($aContent) || !is_array($aContent))
             return array();
 
+        if($this->_oConfig->isSystem($aContent['type'], $aContent['action']))
+            $iEntryAuthor = (int)$aContent['owner_id'];
+        else
+            $iEntryAuthor = (int)$aContent['object_id'];
+
         $sEntryCaption = !empty($aContent['title']) ? $aContent['title'] : $this->_oConfig->getTitle($aContent['description'], $aContent['object_id']);
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single_ext'],
             'entry_url' => $this->_oConfig->getItemViewUrl($aContent),
             'entry_caption' => $sEntryCaption,
-            'entry_author' => $aContent['owner_id'],
-            'lang_key' => '_bx_timeline_ntfs_txt_object_added', //may be empty or not specified. In this case the default one from Notification module will be used.
+            'entry_author' => $iEntryAuthor,
+            'lang_key' => '' //may be empty or not specified. In this case the default one from Notification module will be used.
         );
     }
 
@@ -2674,18 +2679,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             $this->_oTemplate->getData($aEvent);
 
             $sPostType = 'system';
-            $iSenderId = $aEvent['owner_id'];
-        } else {
+            $iSenderId = $iObjectAuthorId = (int)$aEvent['owner_id'];
+        } 
+        else {
             $sPostType = 'common';
-            $iSenderId = $aEvent['object_id'];
+            $iSenderId = $iObjectAuthorId = (int)$aEvent['object_id'];
         }
 
         //--- Event -> Post for Alerts Engine ---//
-        $oAlert = new BxDolAlerts($this->_oConfig->getObject('alert'), 'post_' . $sPostType, $iId, $iSenderId, array(
-        	'privacy_view' => $aEvent['object_privacy_view'],
-        	'object_author_id' => $aEvent['owner_id'],
+        bx_alert($this->_oConfig->getObject('alert'), 'post_' . $sPostType, $iId, $iSenderId, array(
+            'owner_id' => $aEvent['owner_id'],
+            'object_author_id' => $iObjectAuthorId,
+            'privacy_view' => $aEvent['object_privacy_view'],
         ));
-        $oAlert->alert();
         //--- Event -> Post for Alerts Engine ---//
     }
 

+ 1 - 2
modules/boonex/timeline/install/langs/en.xml

@@ -231,8 +231,7 @@
     <string name="_bx_timeline_txt_sample_with_link"><![CDATA[with link]]></string>
     <string name="_bx_timeline_txt_sample_with_image"><![CDATA[with image]]></string>
     <string name="_bx_timeline_txt_sample_with_video"><![CDATA[with video]]></string>
-    <string name="_bx_timeline_txt_sample_with_media"><![CDATA[with media]]></string>    
-    <string name="_bx_timeline_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_timeline_txt_sample_with_media"><![CDATA[with media]]></string>
     <string name="_bx_timeline_txt_today"><![CDATA[Today]]></string>
     <string name="_bx_timeline_txt_some_text_here"><![CDATA[Share your thoughts, location, photos or video]]></string>
     <string name="_bx_timeline_txt_show"><![CDATA[Show]]></string>