AntonLV 8 yıl önce
ebeveyn
işleme
6583792028

+ 31 - 21
modules/base/profile/classes/BxBaseModProfileAlertsResponse.php

@@ -42,24 +42,34 @@ class BxBaseModProfileAlertsResponse extends BxBaseModGeneralAlertsResponse
                 $this->sendMailFriendRequest($oAlert);
         }
 
-        // re-translate timeline alert for timeline in this module for posts made by other profiles
-        if ('bx_timeline' == $oAlert->sUnit && 'post_common' == $oAlert->sAction && ($oGroupProfile = BxDolProfile::getInstance($oAlert->aExtras['object_author_id'])) && $oGroupProfile->getModule() == $this->_oModule->getName() && $oGroupProfile->id() != $oAlert->iSender) {            
-            $aContentInfo = $this->_oModule->serviceGetContentInfoById($oGroupProfile->getContentId());
-
-            /*
-             * Note. Group Profile ID is used as alert sender and also a content (group) owner (author).
-             */
-            $iSenderId = $iObjectAuthorId = $oGroupProfile->id(); 
-            bx_alert($this->_oModule->getName(), 'timeline_post_common', $aContentInfo[$CNF['FIELD_ID']], $iSenderId, array(
-            	'object_author_id' => $iObjectAuthorId,
-            	'timeline_post_id' => $oAlert->iObject, 
-                'timeline_post_author_id' => $oAlert->iSender,
-
-            	'content' => $aContentInfo,
-
-            	'group_profile' => $oGroupProfile->id(), 
-            	'profile' => $oAlert->iSender,
-            ));
+        /*
+         * Re-translate timeline alert for timeline posts made by other profiles.
+         * It's used with Notifications module in the following circumstances:
+         * 1. User1 follow User2.
+         * 2. User1 doesn't follow User3.
+         * 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') {
+            $oTimelineOwner = BxDolProfile::getInstance($oAlert->aExtras['object_author_id']);
+            if($oTimelineOwner && $oTimelineOwner->getModule() == $this->_oModule->getName() && $oTimelineOwner->id() != $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(); 
+                bx_alert($this->_oModule->getName(), 'timeline_post_common', $aContentInfo[$CNF['FIELD_ID']], $iSenderId, array(
+                    'object_author_id' => $iObjectAuthorId,
+                    'timeline_post_id' => $oAlert->iObject, 
+                    'timeline_post_author_id' => $oAlert->iSender,
+
+                    'content' => $aContentInfo,
+
+                    'group_profile' => $oTimelineOwner->id(), 
+                    'profile' => $oAlert->iSender,
+                ));
+            }
         }
 
         if ($this->MODULE != $oAlert->sUnit)
@@ -85,8 +95,8 @@ class BxBaseModProfileAlertsResponse extends BxBaseModGeneralAlertsResponse
             $this->processTimelineEventsCheckResult($oAlert, $oAlert->iObject, 'checkAllowedEdit');
             break;
 
-        case 'timeline_share':
-            $this->processTimelineShare($oAlert, $oAlert->iObject);
+        case 'timeline_repost':
+            $this->processTimelineRepost($oAlert, $oAlert->iObject);
             break;
         }
 
@@ -165,7 +175,7 @@ class BxBaseModProfileAlertsResponse extends BxBaseModGeneralAlertsResponse
         $oAlert->aExtras['result'] = (CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->$sFunc($aContentInfo)) ? true : false;
     }
 
-    protected function processTimelineShare ($oAlert, $iGroupProfileId)
+    protected function processTimelineRepost ($oAlert, $iGroupProfileId)
     {
         if ($oAlert->aExtras['check_result'][CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
             return;

+ 38 - 47
modules/boonex/notifications/classes/BxNtfsDb.php

@@ -85,64 +85,55 @@ class BxNtfsDb extends BxBaseModNotificationsDb
         if(!empty($aParams['new']) && !empty($aParams['owner_id']))
             $sWhereClause .= $this->prepareAsString("AND `{$this->_sTable}`.`id`>? ", $this->getLastRead((int)$aParams['owner_id']));
 
-        //--- Apply privacy filter
-        $aPrivacy = array(BX_DOL_PG_ALL);
-        if(isLogged())
-            $aPrivacy[] = BX_DOL_PG_MEMBERS;
-
-        $oPrivacy = BxDolPrivacy::getObjectInstance($this->_oConfig->getObject('privacy_view'));
-        $aQueryParts = $oPrivacy->getContentByGroupAsSQLPart($aPrivacy);
-        $sWhereClause .= $aQueryParts['where'] . " ";
-
         //--- Check type
         if(!empty($aParams['owner_id']))
-                switch($aParams['type']) {
-                    case BX_BASE_MOD_NTFS_TYPE_OWNER:
-                        $sWhereClause .= $this->prepareAsString("AND `{$this->_sTable}`.`owner_id`=? ", $aParams['owner_id']);
+            switch($aParams['type']) {
+                case BX_BASE_MOD_NTFS_TYPE_OWNER:
+                    $sWhereClause .= $this->prepareAsString("AND `{$this->_sTable}`.`owner_id`=? ", $aParams['owner_id']);
+                    break;
+
+                case BX_BASE_MOD_NTFS_TYPE_OBJECT_OWNER:
+                    $sWhereClause .= $this->prepareAsString("AND `{$this->_sTable}`.`owner_id`<>`{$this->_sTable}`.`object_owner_id` AND `{$this->_sTable}`.`object_owner_id`=? ", $aParams['owner_id']);
+                    $sWhereClause .= $this->prepareAsString("AND `{$this->_sTableSettings}`.`type`=? AND `{$this->_sTableSettings}`.`active`='1' AND (ISNULL(`{$this->_sTableSettings2Users}`.`active`) OR `{$this->_sTableSettings2Users}`.`active`='1') ", BX_NTFS_STYPE_PERSONAL);
+                    break;
+
+                case BX_BASE_MOD_NTFS_TYPE_CONNECTIONS:
+                    $oConnection = BxDolConnection::getObjectInstance($this->_oConfig->getObject('conn_subscriptions'));
+                    $aQueryParts = $oConnection->getConnectedContentAsSQLParts($this->_sPrefix . "events", 'owner_id', $aParams['owner_id']);
+                    if(empty($aQueryParts) || !is_array($aQueryParts) || empty($aQueryParts['join']))
                         break;
 
-                    case BX_BASE_MOD_NTFS_TYPE_OBJECT_OWNER:
-                        $sWhereClause .= $this->prepareAsString("AND `{$this->_sTable}`.`owner_id`<>`{$this->_sTable}`.`object_owner_id` AND `{$this->_sTable}`.`object_owner_id`=? ", $aParams['owner_id']);
-                        $this->prepareAsString("AND `{$this->_sTableSettings}`.`type`=? AND `{$this->_sTableSettings}`.`active`='1' AND (ISNULL(`{$this->_sTableSettings2Users}`.`active`) OR `{$this->_sTableSettings2Users}`.`active`='1') ", BX_NTFS_STYPE_PERSONAL);
-                        break;
+                    $sJoinClause .= " LEFT JOIN `sys_profiles` AS `tsp` ON `{$this->_sTable}`.`owner_id`=`tsp`.`id` " . $aQueryParts['join'];
 
-                    case BX_BASE_MOD_NTFS_TYPE_CONNECTIONS:
-                        $oConnection = BxDolConnection::getObjectInstance($this->_oConfig->getObject('conn_subscriptions'));
-                        $aQueryParts = $oConnection->getConnectedContentAsSQLParts($this->_sPrefix . "events", 'owner_id', $aParams['owner_id']);
-                        if(empty($aQueryParts) || !is_array($aQueryParts) || empty($aQueryParts['join']))
-                            break;
+                    if(!empty($aQueryParts['fields']['added']))
+                        $sWhereClause .= "AND `{$this->_sTable}`.`date` > " . $aQueryParts['fields']['added'];
 
-                        $sJoinClause .= " LEFT JOIN `sys_profiles` AS `tsp` ON `{$this->_sTable}`.`owner_id`=`tsp`.`id` " . $aQueryParts['join'];
+                    list($aModulesProfiles, $aModulesContexts) = $this->_oConfig->getProfileBasedModules();
+                    $sWhereClause .= $this->prepareAsString("AND ((`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesProfiles) . ")) || (`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesContexts) . "))) ", BX_NTFS_STYPE_FOLLOW_MEMBER, BX_NTFS_STYPE_FOLLOW_CONTEXT);
+                    break;
 
-                        if(!empty($aQueryParts['fields']['added']))
-                            $sWhereClause .= "AND `{$this->_sTable}`.`date` > " . $aQueryParts['fields']['added'];
+                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']);
+                    $sWhereClauseObjectOwner .= $this->prepareAsString("AND `{$this->_sTableSettings}`.`type`=?", BX_NTFS_STYPE_PERSONAL);
 
-                        list($aModulesProfiles, $aModulesContexts) = $this->_oConfig->getProfileBasedModules();
-                        $sWhereClause .= $this->prepareAsString("AND ((`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesProfiles) . ")) || (`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesContexts) . "))) ", BX_NTFS_STYPE_FOLLOW_MEMBER, BX_NTFS_STYPE_FOLLOW_CONTEXT);
-                        break;
+                    $sWhereClauseConnections = '0';
+                    $oConnection = BxDolConnection::getObjectInstance($this->_oConfig->getObject('conn_subscriptions'));
+                    $aQueryParts = $oConnection->getConnectedContentAsSQLPartsExt($this->_sTable, 'owner_id', $aParams['owner_id']);
+                    if(!empty($aQueryParts) && is_array($aQueryParts) && !empty($aQueryParts['join'])) {
+                        $sJoinClause .= " LEFT JOIN `sys_profiles` AS `tsp` ON `{$this->_sTable}`.`owner_id`=`tsp`.`id`";
+                        $sJoinClause .= " LEFT JOIN `" . $aQueryParts['join']['table'] . "` AS `" . $aQueryParts['join']['table_alias'] . "` ON (" . $aQueryParts['join']['condition'] . ")";
 
-                    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']);
-                        $sWhereClauseObjectOwner .= $this->prepareAsString("AND `{$this->_sTableSettings}`.`type`=?", BX_NTFS_STYPE_PERSONAL);
-
-                        $sWhereClauseConnections = '0';
-                        $oConnection = BxDolConnection::getObjectInstance($this->_oConfig->getObject('conn_subscriptions'));
-                        $aQueryParts = $oConnection->getConnectedContentAsSQLPartsExt($this->_sTable, 'owner_id', $aParams['owner_id']);
-                        if(!empty($aQueryParts) && is_array($aQueryParts) && !empty($aQueryParts['join'])) {
-                            $sJoinClause .= " LEFT JOIN `sys_profiles` AS `tsp` ON `{$this->_sTable}`.`owner_id`=`tsp`.`id`";
-                            $sJoinClause .= " LEFT JOIN `" . $aQueryParts['join']['table'] . "` AS `" . $aQueryParts['join']['table_alias'] . "` ON (" . $aQueryParts['join']['condition'] . ")";
-
-                            $sWhereClauseConnections = "NOT ISNULL(`c`.`content`) ";
-                            if(!empty($aQueryParts['fields']['added']))
-                                $sWhereClauseConnections .= "AND `{$this->_sTable}`.`date` > `" . $aQueryParts['fields']['added']['table_alias'] . "`.`" . $aQueryParts['fields']['added']['name'] . "` ";
+                        $sWhereClauseConnections = "NOT ISNULL(`c`.`content`) ";
+                        if(!empty($aQueryParts['fields']['added']))
+                            $sWhereClauseConnections .= "AND `{$this->_sTable}`.`date` > `" . $aQueryParts['fields']['added']['table_alias'] . "`.`" . $aQueryParts['fields']['added']['name'] . "` ";
 
-                            list($aModulesProfiles, $aModulesContexts) = $this->_oConfig->getProfileBasedModules();
-                            $sWhereClauseConnections .= $this->prepareAsString("AND ((`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesProfiles) . ")) || (`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesContexts) . "))) ", BX_NTFS_STYPE_FOLLOW_MEMBER, BX_NTFS_STYPE_FOLLOW_CONTEXT);
-                        }
+                        list($aModulesProfiles, $aModulesContexts) = $this->_oConfig->getProfileBasedModules();
+                        $sWhereClauseConnections .= $this->prepareAsString("AND ((`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesProfiles) . ")) || (`{$this->_sTableSettings}`.`type`=? AND `tsp`.`type` IN (" . $this->implode_escape($aModulesContexts) . "))) ", BX_NTFS_STYPE_FOLLOW_MEMBER, BX_NTFS_STYPE_FOLLOW_CONTEXT);
+                    }
 
-                        $sWhereClause .= "AND ((" . $sWhereClauseObjectOwner . ") || (" . $sWhereClauseConnections . ")) AND `{$this->_sTableSettings}`.`active`='1' AND (ISNULL(`{$this->_sTableSettings2Users}`.`active`) OR `{$this->_sTableSettings2Users}`.`active`='1') ";
-                        break;
-                }
+                    $sWhereClause .= "AND ((" . $sWhereClauseObjectOwner . ") || (" . $sWhereClauseConnections . ")) AND `{$this->_sTableSettings}`.`active`='1' AND (ISNULL(`{$this->_sTableSettings2Users}`.`active`) OR `{$this->_sTableSettings2Users}`.`active`='1') ";
+                    break;
+            }
 
         return array($sJoinClause, $sWhereClause);
     }

+ 8 - 4
modules/boonex/notifications/classes/BxNtfsTemplate.php

@@ -115,13 +115,17 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
     	$oModule = $this->getModule();
 
     	if((int)$aEvent['processed'] == 0)
-    		$this->_processContent($aEvent);
+            $this->_processContent($aEvent);
 
         $aEvent['content'] = unserialize($aEvent['content']);
 
-    	$oPrivacy = $oModule->_oConfig->getPrivacyObject($aEvent['type'] . '_' . $aEvent['action']);
-    	if($oPrivacy !== false && !$oPrivacy->check($aEvent['id'])) 
-    		return '';
+        $oPrivacyInt = BxDolPrivacy::getObjectInstance($this->_oConfig->getObject('privacy_view'));
+        if(!$oPrivacyInt->check($aEvent['id']))
+            return '';
+
+    	$oPrivacyExt = $oModule->_oConfig->getPrivacyObject($aEvent['type'] . '_' . $aEvent['action']);
+    	if($oPrivacyExt !== false && !$oPrivacyExt->check($aEvent['id']))
+            return '';
 
         $sService = 'check_allowed_with_content';
         if(BxDolRequest::serviceExists($aEvent['type'], $sService) && BxDolService::call($aEvent['type'], $sService, array('view', $this->_getContentObjectId($aEvent))) !== CHECK_ACTION_RESULT_ALLOWED)

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

@@ -194,6 +194,7 @@
     <string name="_bx_timeline_alert_action_added"><![CDATA[добавить]]></string>
     <string name="_bx_timeline_alert_action_post_common"><![CDATA[добавить сообщение]]></string>
     <string name="_bx_timeline_alert_action_repost"><![CDATA[добавить репост]]></string>
+    <string name="_bx_timeline_alert_action_post_common_personal"><![CDATA[Новый контент]]></string>
     <string name="_bx_timeline_alert_action_post_common_follow_member"><![CDATA[Новый контент]]></string>
     <string name="_bx_timeline_alert_action_post_common_follow_context"><![CDATA[Новый контент]]></string>
     <string name="_bx_timeline_alert_action_repost_follow_member"><![CDATA[Новый репост контента]]></string>

+ 1 - 1
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -1231,7 +1231,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
             ),
             'settings' => array(
-                array('group' => 'content', 'unit' => $sModule, 'action' => 'post_common', 'types' => array('follow_member', 'follow_context')),
+                array('group' => 'content', 'unit' => $sModule, 'action' => 'post_common', 'types' => array('personal', 'follow_member', 'follow_context')),
                 array('group' => 'content', 'unit' => $sModule, 'action' => 'repost', 'types' => array('follow_member', 'follow_context')),
                 array('group' => 'comment', 'unit' => $sModule, 'action' => 'commentPost', 'types' => array('personal', 'follow_member', 'follow_context')),
                 array('group' => 'vote', 'unit' => $sModule, 'action' => 'doVote', 'types' => array('personal', 'follow_member', 'follow_context'))

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

@@ -193,6 +193,7 @@
     <string name="_bx_timeline_alert_action_added"><![CDATA[add]]></string>
     <string name="_bx_timeline_alert_action_post_common"><![CDATA[add post]]></string>
     <string name="_bx_timeline_alert_action_repost"><![CDATA[repost]]></string>
+    <string name="_bx_timeline_alert_action_post_common_personal"><![CDATA[New content]]></string>
     <string name="_bx_timeline_alert_action_post_common_follow_member"><![CDATA[New content]]></string>
     <string name="_bx_timeline_alert_action_post_common_follow_context"><![CDATA[New content]]></string>
     <string name="_bx_timeline_alert_action_repost_follow_member"><![CDATA[New content repost]]></string>