Просмотр исходного кода

Ticket #4491 - Anonymous post with hashtag should be seen on channel's timeline.

AntonLV 3 лет назад
Родитель
Сommit
b16e92ed3c

+ 5 - 1
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -2264,7 +2264,11 @@ class BxBaseModGeneralModule extends BxDolModule
         $iUserId = $this->getUserId();
         $iAuthorId = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
         $iAuthorIdAbs = abs($iAuthorId);
-        if($iAuthorId < 0 && ((is_numeric($aEvent['owner_id']) && $iAuthorIdAbs == (int)$aEvent['owner_id']) || (is_array($aEvent['owner_id']) && in_array($iAuthorIdAbs, $aEvent['owner_id']))) && $iAuthorIdAbs != $iUserId)
+
+        /**
+         * Don't show anonymous posts on the post's owner timeline.
+         */
+        if($iAuthorId < 0 && $iAuthorIdAbs != $iUserId && ((is_numeric($aEvent['owner_id']) && $iAuthorIdAbs == (int)$aEvent['owner_id']) || (is_array($aEvent['owner_id']) && in_array($iAuthorIdAbs, $aEvent['owner_id']))))
             return false;
 
         //--- Views

+ 28 - 18
modules/boonex/channels/classes/BxCnlModule.php

@@ -309,44 +309,54 @@ class BxCnlModule extends BxBaseModGroupsModule
         return BxDolService::call($aEventContent['module_name'], 'get_timeline_post_allowed_view', array(array('id' => $aEvent['id'], 'owner_id' => $aEventContent['author_id'], 'object_id' => $aEventContent['content_id'])));
     }
 
-    public function serviceGetTimelinePostHashtag($aEvent, $aBrowseParams = array())
+    public function serviceGetTimelinePostHashtag($aEvent, $aBrowseParams = [])
     {
         if(empty($aEvent) || !is_array($aEvent))
             return false;
-        
+
         $aEventContent = $this->_oDb->getContentById($aEvent['object_id']);
         if(empty($aEventContent) || !is_array($aEventContent))
             return false;
-       
+
         $sModule = $aEventContent['module_name'];
         $sClass = 'Module';
-        if($sModule == 'sys_cmts'){
-            $sClass = 'TemplCmtsServices';
+        if($sModule == 'sys_cmts') {
             $sModule = 'system';
+            $sClass = 'TemplCmtsServices';
         }
-        
+
         if(!BxDolRequest::serviceExists($sModule, 'get_timeline_post', $sClass))
             return false;
+
+        $iContentId = (int)$aEventContent['content_id'];
+        $iContentAuthor = 0;
+        if(bx_is_srv($sModule, 'get_author', $sClass))
+            $iContentAuthor = bx_srv($sModule, 'get_author', [$iContentId], $sClass);
+
         /**
          * 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'];
+        $iOwnerId = $aEvent['owner_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);
+        if($iContentAuthor > 0) {
+            $iOwnerId = (int)$aEventContent['author_id'];
+            if(bx_is_srv($sModule, 'get_privacy_view', $sClass)) {
+                $mixedAllowViewTo = bx_srv($sModule, 'get_privacy_view', [$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(
+
+        $aResult = bx_srv($sModule, 'get_timeline_post', [[
             'owner_id' => $iOwnerId,
             'object_id' => $iContentId,
             'object_privacy_view' => $mixedObjectPrivacyView
-        ), $aBrowseParams), $sClass);
+        ], $aBrowseParams], $sClass);
 
         if(empty($aResult) || !is_array($aResult))
             return $aResult;
@@ -355,9 +365,9 @@ class BxCnlModule extends BxBaseModGroupsModule
          * Note. The context shouldn't be changed therefore 
          * use input event's context (owner_id) in returned results.
          */
-        return array_merge($aResult, array(
+        return array_merge($aResult, [
             'owner_id' => $aEvent['owner_id']
-        ));
+        ]);
     }
     
     /**

+ 26 - 0
template/scripts/BxBaseCmtsServices.php

@@ -17,6 +17,32 @@ class BxBaseCmtsServices extends BxDol
         parent::__construct();
     }
 
+    public function serviceGetAuthor($iCmtUniqId)
+    {
+        $oCmts = BxDolCmts::getObjectInstanceByUniqId($iCmtUniqId);
+        if(!$oCmts)
+            return [];
+
+        $aCmt = BxDolCmtsQuery::getCommentExtendedByUniqId($iCmtUniqId);
+        if(empty($aCmt) || !is_array($aCmt))
+            return [];
+
+        return $oCmts->serviceGetAuthor((int)$aCmt['cmt_id']);
+    }
+
+    public function serviceGetInfo($iCmtUniqId, $bSearchableFieldsOnly = true)
+    {
+        $oCmts = BxDolCmts::getObjectInstanceByUniqId($iCmtUniqId);
+        if(!$oCmts)
+            return [];
+
+        $aCmt = BxDolCmtsQuery::getCommentExtendedByUniqId($iCmtUniqId);
+        if(empty($aCmt) || !is_array($aCmt))
+            return [];
+
+        return $oCmts->serviceGetInfo((int)$aCmt['cmt_id'], $bSearchableFieldsOnly);
+    }
+
     public function serviceGetBlockView($sSystem = '', $iObjectId = 0, $iCommentId = 0)
     {
         if(empty($sSystem) && ($sSystem = bx_get('sys')) !== false)