فهرست منبع

Ticket #4523 - Timeline: Actions should be taken from content module.

AntonLV 3 سال پیش
والد
کامیت
b0b35d1b8d

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

@@ -15,6 +15,7 @@
     <string name="_bx_timeline_option_enable_delete"><![CDATA[Разрешить владельцу ленты удалять сообщения]]></string>
     <string name="_bx_timeline_option_enable_show_all"><![CDATA[Показывать все сообщения в 'Общей хронике', включая те, что были написаны в персональных Хрониках]]></string>
     <string name="_bx_timeline_option_enable_count_all_views"><![CDATA[Считать просмотры для всех событий в хронике]]></string>
+    <string name="_bx_timeline_option_enable_content_own_actions"><![CDATA[Событие использует собственные 'действия' контента (просмотры, голосование и тп.)]]></string>
     <string name="_bx_timeline_option_enable_repost_own_actions"><![CDATA[Репост использует собственные действия (просмотры, голосование и тп.)]]></string>
     <string name="_bx_timeline_option_enable_hide_upon_delete"><![CDATA[Деактивировать сообщения при скрывании вместо удаления]]></string>
     <string name="_bx_timeline_option_events_per_page_profile"><![CDATA[Количество элементов в ленте контекста (профиля)]]></string>

+ 7 - 0
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -19,6 +19,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
     protected $_bAllowDelete;
     protected $_bShowAll;
     protected $_bCountAllViews;
+    protected $_bContentOwnActions;
     protected $_bRepostOwnActions;
     protected $_bHideUponDelete;
 
@@ -404,6 +405,7 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         $this->_bAllowDelete = getParam($sOptionPrefix . 'enable_delete') == 'on';
         $this->_bShowAll = getParam($sOptionPrefix . 'enable_show_all') == 'on';
         $this->_bCountAllViews = getParam($sOptionPrefix . 'enable_count_all_views') == 'on';
+        $this->_bContentOwnActions = getParam($sOptionPrefix . 'enable_content_own_actions') == 'on';
         $this->_bRepostOwnActions = getParam($sOptionPrefix . 'enable_repost_own_actions') == 'on';
         $this->_bHideUponDelete = getParam($sOptionPrefix . 'enable_hide_upon_delete') == 'on';
 
@@ -550,6 +552,11 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         return $this->_bCountAllViews;
     }
 
+    public function isContentOwnActions()
+    {
+        return $this->_bContentOwnActions;
+    }
+
     public function isRepostOwnActions()
     {
         return $this->_bRepostOwnActions;

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

@@ -2996,7 +2996,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         if($mixedResult === false)
             return '';
 
-        $this->_preparetDataActions($aEvent, $mixedResult);
+        $this->_preparetDataActions(false, $aEvent, $mixedResult);
         return $mixedResult;
     }
 
@@ -3112,7 +3112,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 break;
         }
 
-        $this->_preparetDataActions($aEvent, $aResult);
+        $this->_preparetDataActions(true, $aEvent, $aResult);
         return $aResult;
     }
 
@@ -3132,17 +3132,18 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         return 0;
     }
 
-    protected function _preparetDataActions(&$aEvent, &$aResult)
+    protected function _preparetDataActions($bCommon, &$aEvent, &$aResult)
     {
         if(empty($aEvent) || !is_array($aEvent) || empty($aEvent['id']))
             return;
 
         $oModule = $this->getModule();
+        $bUpdateActions = $bCommon || !$this->_oConfig->isContentOwnActions();
 
         $sSystem = $this->_oConfig->getObject('view');
         if(empty($aResult['views'])) {
             $aResult['views'] = array();
-            if($oModule->getViewObject($sSystem, $aEvent['id']) !== false)
+            if($bUpdateActions && $oModule->getViewObject($sSystem, $aEvent['id']) !== false)
                 $aResult['views'] = array(
                     'system' => $sSystem,
                     'object_id' => $aEvent['id'],
@@ -3153,7 +3154,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sSystem = $this->_oConfig->getObject('vote');
         if(empty($aResult['votes'])) {
             $aResult['votes'] = array();
-            if($oModule->getVoteObject($sSystem, $aEvent['id']) !== false)
+            if($bUpdateActions && $oModule->getVoteObject($sSystem, $aEvent['id']) !== false)
                 $aResult['votes'] = array(
                     'system' => $sSystem,
                     'object_id' => $aEvent['id'],
@@ -3164,7 +3165,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sSystem = $this->_oConfig->getObject('reaction');
         if(empty($aResult['reactions'])) {
             $aResult['reactions'] = array();
-            if($oModule->getReactionObject($sSystem, $aEvent['id']) !== false)
+            if($bUpdateActions && $oModule->getReactionObject($sSystem, $aEvent['id']) !== false)
                 $aResult['reactions'] = array(
                     'system' => $sSystem,
                     'object_id' => $aEvent['id'],
@@ -3175,7 +3176,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sSystem = $this->_oConfig->getObject('score');
         if(empty($aResult['scores'])) {
             $aResult['scores'] = array();
-            if($oModule->getScoreObject($sSystem, $aEvent['id']) !== false)
+            if($bUpdateActions && $oModule->getScoreObject($sSystem, $aEvent['id']) !== false)
                 $aResult['scores'] = array(
                     'system' => $sSystem,
                     'object_id' => $aEvent['id'],
@@ -3186,7 +3187,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sSystem = $this->_oConfig->getObject('report');
         if(empty($aResult['reports'])) {
             $aResult['reports'] = array();
-            if($oModule->getReportObject($sSystem, $aEvent['id']) !== false)
+            if($bUpdateActions && $oModule->getReportObject($sSystem, $aEvent['id']) !== false)
                 $aResult['reports'] = array(
                     'system' => $sSystem,
                     'object_id' => $aEvent['id'],
@@ -3197,7 +3198,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sSystem = $this->_oConfig->getObject('comment');
         if(empty($aResult['comments'])) {
             $aResult['comments'] = array();
-            if($oModule->getCmtsObject($sSystem, $aEvent['id']) !== false)
+            if($bUpdateActions && $oModule->getCmtsObject($sSystem, $aEvent['id']) !== false)
                 $aResult['comments'] = array(
                     'system' => $sSystem,
                     'object_id' => $aEvent['id'],

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

@@ -15,6 +15,7 @@
     <string name="_bx_timeline_option_enable_delete"><![CDATA[Allow Timeline owner to remove items]]></string>
     <string name="_bx_timeline_option_enable_show_all"><![CDATA[Show all items in Public Feed including ones which were posted in personal Feeds]]></string>
     <string name="_bx_timeline_option_enable_count_all_views"><![CDATA[Count views for all items in the Feed]]></string>
+    <string name="_bx_timeline_option_enable_content_own_actions"><![CDATA[Event uses content's own actions (views, likes, etc)]]></string>
     <string name="_bx_timeline_option_enable_repost_own_actions"><![CDATA[Repost uses its own actions (views, likes, etc)]]></string>
     <string name="_bx_timeline_option_enable_hide_upon_delete"><![CDATA[Inactivate items upon hiding instead of deletion]]></string>
     <string name="_bx_timeline_option_events_per_page_profile"><![CDATA[Number of items in context (profile) timeline]]></string>

+ 4 - 3
modules/boonex/timeline/install/sql/enable.sql

@@ -300,9 +300,10 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_timeline_enable_edit', 'on', @iCategId, '_bx_timeline_option_enable_edit', 'checkbox', '', '', '', '', 1),
 ('bx_timeline_enable_delete', 'on', @iCategId, '_bx_timeline_option_enable_delete', 'checkbox', '', '', '', '', 2),
 ('bx_timeline_enable_count_all_views', '', @iCategId, '_bx_timeline_option_enable_count_all_views', 'checkbox', '', '', '', '', 3),
-('bx_timeline_enable_repost_own_actions', 'on', @iCategId, '_bx_timeline_option_enable_repost_own_actions', 'checkbox', '', '', '', '', 4),
-('bx_timeline_enable_hide_upon_delete', '', @iCategId, '_bx_timeline_option_enable_hide_upon_delete', 'checkbox', '', '', '', '', 5),
-('bx_timeline_events_hide', CONCAT_WS(',', @iHdrIdComment), @iCategId, '_bx_timeline_option_events_hide', 'rlist', '', '', '', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:21:"get_actions_checklist";}', 6);
+('bx_timeline_enable_content_own_actions', '', @iCategId, '_bx_timeline_option_enable_content_own_actions', 'checkbox', '', '', '', '', 4),
+('bx_timeline_enable_repost_own_actions', 'on', @iCategId, '_bx_timeline_option_enable_repost_own_actions', 'checkbox', '', '', '', '', 5),
+('bx_timeline_enable_hide_upon_delete', '', @iCategId, '_bx_timeline_option_enable_hide_upon_delete', 'checkbox', '', '', '', '', 6),
+('bx_timeline_events_hide', CONCAT_WS(',', @iHdrIdComment), @iCategId, '_bx_timeline_option_events_hide', 'rlist', '', '', '', 'a:2:{s:6:"module";s:11:"bx_timeline";s:6:"method";s:21:"get_actions_checklist";}', 7);
 
 -- Category: Browse
 INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order`)