AntonLV %!s(int64=7) %!d(string=hai) anos
pai
achega
f0d1ac1f3d

+ 12 - 7
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -88,6 +88,11 @@ class BxBaseModGeneralModule extends BxDolModule
         return $mixedResult !== false ? (int)$mixedResult : 0; 
     }
 
+    public function serviceGetPrivacyView ($iContentId)
+    {
+        return $this->_getFieldValue('FIELD_ALLOW_VIEW_TO', $iContentId);
+    }
+
     public function serviceGetDateAdded ($iContentId)
     {
         $mixedResult = $this->_getFieldValue('FIELD_ADDED', $iContentId);
@@ -1105,7 +1110,7 @@ class BxBaseModGeneralModule extends BxDolModule
             return false;
 
         //--- Views
-        $oViews = isset($CNF['OBJECT_VIEWS']) ? BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $aEvent['object_id']) : null;
+        $oViews = isset($CNF['OBJECT_VIEWS']) ? BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $aContentInfo[$CNF['FIELD_ID']]) : null;
 
         $aViews = array();
         if ($oViews && $oViews->isEnabled())
@@ -1116,7 +1121,7 @@ class BxBaseModGeneralModule extends BxDolModule
             );
 
         //--- Votes
-        $oVotes = isset($CNF['OBJECT_VOTES']) ? BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aEvent['object_id']) : null;
+        $oVotes = isset($CNF['OBJECT_VOTES']) ? BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aContentInfo[$CNF['FIELD_ID']]) : null;
 
         $aVotes = array();
         if ($oVotes && $oVotes->isEnabled())
@@ -1127,7 +1132,7 @@ class BxBaseModGeneralModule extends BxDolModule
             );
         
         //--- Reactions
-        $oReactions = isset($CNF['OBJECT_REACTIONS']) ? BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $aEvent['object_id']) : null;
+        $oReactions = isset($CNF['OBJECT_REACTIONS']) ? BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $aContentInfo[$CNF['FIELD_ID']]) : null;
 
         $aReactions = array();
         if ($oReactions && $oReactions->isEnabled())
@@ -1138,7 +1143,7 @@ class BxBaseModGeneralModule extends BxDolModule
             );
 
         //--- Scores
-        $oScores = isset($CNF['OBJECT_SCORES']) ? BxDolScore::getObjectInstance($CNF['OBJECT_SCORES'], $aEvent['object_id']) : null;
+        $oScores = isset($CNF['OBJECT_SCORES']) ? BxDolScore::getObjectInstance($CNF['OBJECT_SCORES'], $aContentInfo[$CNF['FIELD_ID']]) : null;
 
         $aScores = array();
         if ($oScores && $oScores->isEnabled())
@@ -1148,8 +1153,8 @@ class BxBaseModGeneralModule extends BxDolModule
                 'score' => $aContentInfo['score']
             );
 
-		//--- Reports
-        $oReports = isset($CNF['OBJECT_REPORTS']) ? BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $aEvent['object_id']) : null;
+        //--- Reports
+        $oReports = isset($CNF['OBJECT_REPORTS']) ? BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $aContentInfo[$CNF['FIELD_ID']]) : null;
 
         $aReports = array();
         if ($oReports && $oReports->isEnabled())
@@ -1160,7 +1165,7 @@ class BxBaseModGeneralModule extends BxDolModule
             );
 
         //--- Comments
-        $oCmts = isset($CNF['OBJECT_COMMENTS']) ? BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aEvent['object_id']) : null;
+        $oCmts = isset($CNF['OBJECT_COMMENTS']) ? BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aContentInfo[$CNF['FIELD_ID']]) : null;
 
         $aComments = array();
         if($oCmts && $oCmts->isEnabled())

+ 35 - 10
modules/boonex/channels/classes/BxCnlModule.php

@@ -233,16 +233,41 @@ class BxCnlModule extends BxBaseModGroupsModule
         if(empty($aEventContent) || !is_array($aEventContent))
             return false;
 
-        if(!BxDolRequest::serviceExists($aEventContent['module_name'], 'get_timeline_post'))
-            return false;      
-
-        return BxDolService::call($aEventContent['module_name'], 'get_timeline_post', array(
-            array(
-                'id' => $aEvent['id'], 
-                'owner_id' => $aEventContent['author_id'], 
-                'object_id' => $aEventContent['content_id']
-            ), 
-            $aBrowseParams
+        $sModule = $aEventContent['module_name'];
+        if(!BxDolRequest::serviceExists($sModule, 'get_timeline_post'))
+            return false;
+
+        /**
+         * Prepare fake event array (only mandatory parameters) to get
+         * necessary data (related to an 'original' event with hashtag/label) 
+         * from associated content module.
+         */
+        $iOwnerId = (int)$aEventContent['author_id'];
+        $iContentId = (int)$aEventContent['content_id'];
+        $mixedObjectPrivacyView = BX_DOL_PG_ALL;
+        if(BxDolRequest::serviceExists($sModule, 'get_privacy_view')) {
+            $mixedAllowViewTo = BxDolService::call($sModule, 'get_privacy_view', array($iContentId));
+            if($mixedAllowViewTo !== false)
+                $mixedObjectPrivacyView = $mixedAllowViewTo;
+            if(is_numeric($mixedAllowViewTo) && (int)$mixedAllowViewTo < 0)
+                $iOwnerId = abs($mixedAllowViewTo);
+        }
+
+        $aResult = BxDolService::call($sModule, 'get_timeline_post', array(array(
+            'owner_id' => $iOwnerId,
+            'object_id' => $iContentId,
+            'object_privacy_view' => $mixedObjectPrivacyView
+        ), $aBrowseParams));
+
+        if(empty($aResult) || !is_array($aResult))
+            return $aResult;
+
+        /**
+         * Note. The context shouldn't be changed therefore 
+         * use input event's context (owner_id) in returned results.
+         */
+        return array_merge($aResult, array(
+            'owner_id' => $aEvent['owner_id']
         ));
     }
     

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

@@ -628,12 +628,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
     {
-        $CNF = &$this->_oConfig->CNF;
+        $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
+        if(empty($aContentInfo) || !is_array($aContentInfo))
+            return false;
+
+        $aEvent = array_merge($aEvent, array(
+            'owner_id' => $aContentInfo['owner_id'],
+            'object_privacy_view' => $aContentInfo['object_privacy_view']
+        ));
 
         /*
          * Note. For 'Direct Timeline Posts' FIELD_OBJECT_ID contains post's author profile ID.
          */
-        $CNF['FIELD_AUTHOR'] = $CNF['FIELD_OBJECT_ID'];
+        $this->_oConfig->CNF['FIELD_AUTHOR'] = $this->_oConfig->CNF['FIELD_OBJECT_ID'];
         return parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
     }