AntonLV 8 years ago
parent
commit
e0fe8ebecf

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

@@ -908,8 +908,9 @@ class BxBaseModGeneralModule extends BxDolModule
         $CNF = &$this->_oConfig->CNF;
 
         $iUserId = $this->getUserId();
-        $iAuthorId = $aContentInfo[$CNF['FIELD_AUTHOR']];
-        if($iAuthorId < 0 && abs($iAuthorId) != $iUserId)
+        $iAuthorId = (int)$aContentInfo[$CNF['FIELD_AUTHOR']];
+        $iAuthorIdAbs = abs($iAuthorId);
+        if($iAuthorId < 0 && $iAuthorIdAbs == (int)$aEvent['owner_id'] && $iAuthorIdAbs != $iUserId)
             return false;
 
         //--- Views
@@ -973,17 +974,17 @@ class BxBaseModGeneralModule extends BxDolModule
             $sTitle = $aContentInfo[$CNF['FIELD_TEXT']];
 
         return array(
-            'owner_id' => $aContentInfo[$CNF['FIELD_AUTHOR']],
+            'owner_id' => $iAuthorId,
             'icon' => !empty($CNF['ICON']) ? $CNF['ICON'] : '',
-        	'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
-        	'sample_wo_article' => $CNF['T']['txt_sample_single'],
-    	    'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
+            'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
+            'sample_wo_article' => $CNF['T']['txt_sample_single'],
+            'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
             'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
             'content' => $this->_getContentForTimelinePost($aEvent, $aContentInfo, $aBrowseParams), //a string to display or array to parse default template before displaying.
             'date' => $aContentInfo[$CNF['FIELD_ADDED']],
             'views' => $aViews,
             'votes' => $aVotes,
-        	'scores' => $aScores,
+            'scores' => $aScores,
             'reports' => $aReports,
             'comments' => $aComments,
             'title' => $sTitle, //may be empty.

+ 6 - 9
modules/boonex/channels/classes/BxCnlModule.php

@@ -147,19 +147,16 @@ class BxCnlModule extends BxBaseModGroupsModule
         if(empty($aEvent) || !is_array($aEvent))
             return false;
 
-        $aContentEvent = $this->_oDb->getContentById($aEvent['object_id']);
-        if(empty($aContentEvent) || !is_array($aContentEvent))
+        $aEventContent = $this->_oDb->getContentById($aEvent['object_id']);
+        if(empty($aEventContent) || !is_array($aEventContent))
             return false;
 
-        $oModule = BxDolModule::getInstance($aContentEvent['module_name']);
-        if(empty($oModule))
-            return false;
+        if(!BxDolRequest::serviceExists($aEventContent['module_name'], 'get_timeline_post'))
+            return false;      
 
-        $aTimelinePost = $oModule->serviceGetTimelinePost(array('object_id' => $aContentEvent['content_id']));
-        if($aContentEvent['module_name'] == 'bx_timeline')
-            $aTimelinePost['owner_id'] = $aEvent['owner_id'];
+        $iEventOwnerId = (int)(is_array($aEvent['owner_id']) ? array_shift($aEvent['owner_id']) : $aEvent['owner_id']);
 
-        return $aTimelinePost;
+        return BxDolService::call($aEventContent['module_name'], 'get_timeline_post', array(array('owner_id' => $iEventOwnerId, 'object_id' => $aEventContent['content_id'])));
     }
     
     /**

+ 28 - 23
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -561,7 +561,11 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     public function serviceGetTimelinePost($aEvent, $aBrowseParams = array())
     {
         $CNF = &$this->_oConfig->CNF;
-        $CNF['FIELD_AUTHOR'] = $CNF['FIELD_OWNER_ID'];
+
+        /*
+         * Note. For 'Direct Timeline Posts' FIELD_OBJECT_ID contains post's author profile ID.
+         */
+        $CNF['FIELD_AUTHOR'] = $CNF['FIELD_OBJECT_ID'];
         return parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
     }
 
@@ -1800,7 +1804,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             }
 
             $sTitle = $bText ? $this->_oConfig->getTitle($sText) : $this->_oConfig->getTitleDefault($bLinkIds, $bPhotoIds, $bVideoIds);
-            $sDescription = _t('_bx_timeline_txt_user_added_sample', $sUserName, _t('_bx_timeline_txt_sample_with_article'));
+            $sDescription = _t('_bx_timeline_txt_user_added_sample', '{profile_name}', _t('_bx_timeline_txt_sample_with_article'));
 
             //--- Process Date ---//
             $iDate = 0;
@@ -2700,30 +2704,31 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
     	$sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
 
-    	//--- Text
-        $sText = isset($CNF['FIELD_TEXT']) && isset($aContentInfo[$CNF['FIELD_TEXT']]) ? $aContentInfo[$CNF['FIELD_TEXT']] : '';
-        if(!empty($CNF['OBJECT_METATAGS']) && is_string($sText)) {
-        	$oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
-        	$sText = $oMetatags->metaParse($aContentInfo[$CNF['FIELD_ID']], $sText);
-        }
-        
-        $sTextForTimeline = ""; 
-        if (isset($aContentInfo['content'])){
+        $sText = ''; 
+        if(isset($aContentInfo['content'])){
             $aTmp = unserialize($aContentInfo['content']);
-            if (isset($aTmp['text']))
-                $sTextForTimeline = $aTmp['text'];
+            if(isset($aTmp['text']))
+                $sText = $aTmp['text'];
         }
-        
-    	return array(
-    		'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
-    		'sample_wo_article' => $CNF['T']['txt_sample_single'],
-    	    'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
-			'url' => $sUrl,
-			'title' => $sText,
-			'text' => $sTextForTimeline,
-			'images' => array(),
+
+        if(empty($sText) && !empty($aContentInfo[$CNF['FIELD_TITLE']]))
+            $sText = $aContentInfo[$CNF['FIELD_TITLE']];
+
+        if(!empty($CNF['OBJECT_METATAGS']) && !empty($sText)) {
+            $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
+            $sText = $oMetatags->metaParse($aContentInfo[$CNF['FIELD_ID']], $sText);
+        }
+
+        return array(
+            'sample' => isset($CNF['T']['txt_sample_single_with_article']) ? $CNF['T']['txt_sample_single_with_article'] : $CNF['T']['txt_sample_single'],
+            'sample_wo_article' => $CNF['T']['txt_sample_single'],
+            'sample_action' => isset($CNF['T']['txt_sample_action']) ? $CNF['T']['txt_sample_action'] : '',
+            'url' => $sUrl,
+            'title' => '',
+            'text' => $sText,
+            'images' => array(),
             'videos' => array()
-		);
+        );
     }
 
 	protected function _isAllowedPin($aEvent, $bPerform = false)

+ 9 - 5
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -1596,17 +1596,19 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sPrefix = $this->_oConfig->getPrefix('common_post');
         $sType = str_replace($sPrefix, '', $aEvent['type']);
 
+        $oOwner = BxDolProfile::getInstanceMagic($aEvent['object_id']);
+
         $aResult = array(
             'owner_id' => $aEvent['object_id'],
             'icon' => $CNF['ICON'],
-        	'sample' => '_bx_timeline_txt_sample_with_article',
+            'sample' => '_bx_timeline_txt_sample_with_article',
             'sample_wo_article' => '_bx_timeline_txt_sample',
-        	'sample_action' => '_bx_timeline_txt_added_sample',
+            'sample_action' => '_bx_timeline_txt_added_sample',
             'content_type' => $sType,
             'content' => array(
                 'sample' => '_bx_timeline_txt_sample_with_article',
-        		'sample_wo_article' => '_bx_timeline_txt_sample',
-        		'sample_action' => '_bx_timeline_txt_added_sample',
+                'sample_wo_article' => '_bx_timeline_txt_sample',
+                'sample_action' => '_bx_timeline_txt_added_sample',
                 'url' => $this->_oConfig->getItemViewUrl($aEvent)
             ), //a string to display or array to parse default template before displaying.
             'views' => '',
@@ -1615,7 +1617,9 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'reports' => '',
             'comments' => '',
             'title' => $aEvent['title'], //may be empty.
-            'description' => $aEvent['description'] //may be empty.
+            'description' => bx_replace_markers($aEvent['description'], array(
+                'profile_name' => $oOwner->getDisplayName()
+            )) //may be empty.
         );
 
         switch($sType) {