Ver código fonte

Ticket #4844 - Reputation module.

AntonLV 1 ano atrás
pai
commit
3c48acc998

+ 17 - 11
modules/boonex/reputation/classes/BxReputationModule.php

@@ -90,10 +90,7 @@ class BxReputationModule extends BxBaseModNotificationsModule
         $mixedResult = $this->_oTemplate->getBlockSummary($iProfileId, $iContextId);
         $mixedResult = $this->_oTemplate->getBlockSummary($iProfileId, $iContextId);
 
 
         return !$this->_bIsApi ? $mixedResult : [
         return !$this->_bIsApi ? $mixedResult : [
-            bx_api_get_block('reputation_summary', array_merge($mixedResult, [
-                'actions_list' => $this->_oTemplate->getBlockActions(),
-                'levels_list' => $this->_oTemplate->getBlockLevels()
-            ]))
+            bx_api_get_block('reputation_summary', $mixedResult)
         ];
         ];
     }
     }
 
 
@@ -131,16 +128,25 @@ class BxReputationModule extends BxBaseModNotificationsModule
         $sLangKey = '_bx_reputation_page_block_title_';
         $sLangKey = '_bx_reputation_page_block_title_';
 
 
         $sParamProfile = '&params[]=' . $iProfileId;
         $sParamProfile = '&params[]=' . $iProfileId;
-        $sParamContext = ($iContextId = (int)$iContextId) ? '&params[]=' . $iContextId : '';
+        $sParamContext = '&params[]=' . $iContextId;
 
 
         return [
         return [
             bx_api_get_block('reputation_widget', [
             bx_api_get_block('reputation_widget', [
-                'tabs'=> [
-                    ['url' => '/api.php?r=' . $sModule . '/get_block_summary' . $sParamProfile . $sParamContext, 'title' => _t($sLangKey . 'summary')],
-                    ['url' => '/api.php?r=' . $sModule . '/get_block_leaderboard' . $sParamContext . '&params[]=7', 'title' => _t($sLangKey . 'leaderboard_week')],
-                    ['url' => '/api.php?r=' . $sModule . '/get_block_leaderboard' . $sParamContext . '&params[]=30', 'title' => _t($sLangKey . 'leaderboard_month')],
-                    ['url' => '/api.php?r=' . $sModule . '/get_block_leaderboard' . $sParamContext . '', 'title' => _t($sLangKey . 'leaderboard_all_time')]
-                ]
+                'tabs'=> [[
+                    'url' => '/api.php?r=' . $sModule . '/get_block_summary' . $sParamProfile . $sParamContext, 
+                    'title' => _t($sLangKey . 'summary'),
+                    'data' => $this->_oTemplate->getBlockSummary($iProfileId, (int)$iContextId),
+                    'selected' => true,  
+                ], [
+                    'url' => '/api.php?r=' . $sModule . '/get_block_leaderboard' . $sParamContext . '&params[]=7', 
+                    'title' => _t($sLangKey . 'leaderboard_week')
+                ], [
+                    'url' => '/api.php?r=' . $sModule . '/get_block_leaderboard' . $sParamContext . '&params[]=30', 
+                    'title' => _t($sLangKey . 'leaderboard_month')
+                ], [
+                    'url' => '/api.php?r=' . $sModule . '/get_block_leaderboard' . $sParamContext . '', 
+                    'title' => _t($sLangKey . 'leaderboard_all_time')
+                ]]
             ])
             ])
         ];
         ];
     }
     }

+ 2 - 0
modules/boonex/reputation/classes/BxReputationTemplate.php

@@ -176,6 +176,8 @@ class BxReputationTemplate extends BxBaseModNotificationsTemplate
                 'author_data' => BxDolProfile::getData($iProfileId),
                 'author_data' => BxDolProfile::getData($iProfileId),
                 'points' => $iProfilePoints,
                 'points' => $iProfilePoints,
                 'levels' => $aTmplVarsLevels,
                 'levels' => $aTmplVarsLevels,
+                'actions_list' => $this->getBlockActions(),
+                'levels_list' => $this->getBlockLevels()
             ];
             ];
 
 
         return $this->parseHtmlByName('block_summary.html', [
         return $this->parseHtmlByName('block_summary.html', [

+ 2 - 0
modules/boonex/reputation/install/langs/en.xml

@@ -63,6 +63,8 @@
     <string name="_bx_reputation_page_title_sys_history"><![CDATA[Points history]]></string>
     <string name="_bx_reputation_page_title_sys_history"><![CDATA[Points history]]></string>
     <string name="_bx_reputation_page_title_history"><![CDATA[History]]></string>
     <string name="_bx_reputation_page_title_history"><![CDATA[History]]></string>
     <string name="_bx_reputation_page_block_title_history"><![CDATA[History]]></string>
     <string name="_bx_reputation_page_block_title_history"><![CDATA[History]]></string>
+    <string name="_bx_reputation_page_block_title_system_widget"><![CDATA[Widget (for API only)]]></string>
+    <string name="_bx_reputation_page_block_title_widget"><![CDATA[Widget]]></string>
 
 
     <!-- Menus -->
     <!-- Menus -->
     <string name="_bx_reputation_menu_item_title_system_leaderboard"><![CDATA[Leaderboard]]></string>
     <string name="_bx_reputation_menu_item_title_system_leaderboard"><![CDATA[Leaderboard]]></string>

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

@@ -48,9 +48,10 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title_system`, `
 
 
 -- PAGE: service blocks
 -- PAGE: service blocks
 SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = '' AND `cell_id` = 0 ORDER BY `order` DESC LIMIT 1);
 SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = '' AND `cell_id` = 0 ORDER BY `order` DESC LIMIT 1);
-INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
-('', 0, @sName, '', '_bx_reputation_page_block_title_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:17:"get_block_actions";}', 0, 1, IFNULL(@iBlockOrder, 0) + 1),
-('', 0, @sName, '', '_bx_reputation_page_block_title_levels', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:16:"get_block_levels";}', 0, 1, IFNULL(@iBlockOrder, 0) + 2);
+INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `active_api`, `order`) VALUES 
+('', 0, @sName, '', '_bx_reputation_page_block_title_actions', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:17:"get_block_actions";}', 0, 1, 1, 0, IFNULL(@iBlockOrder, 0) + 1),
+('', 0, @sName, '', '_bx_reputation_page_block_title_levels', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:16:"get_block_levels";}', 0, 1, 1, 0, IFNULL(@iBlockOrder, 0) + 2),
+('', 0, @sName, '_bx_reputation_page_block_title_system_widget', '_bx_reputation_page_block_title_widget', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:13:"bx_reputation";s:6:"method";s:16:"get_block_levels";}', 0, 1, 0, 1, IFNULL(@iBlockOrder, 0) + 3);
 
 
 
 
 -- MENU: add to site menu
 -- MENU: add to site menu

+ 2 - 0
modules/boonex/russian/data/langs/bx_reputation/ru.xml

@@ -60,6 +60,8 @@
     <string name="_bx_reputation_page_title_sys_history"><![CDATA[История баллов]]></string>
     <string name="_bx_reputation_page_title_sys_history"><![CDATA[История баллов]]></string>
     <string name="_bx_reputation_page_title_history"><![CDATA[История]]></string>
     <string name="_bx_reputation_page_title_history"><![CDATA[История]]></string>
     <string name="_bx_reputation_page_block_title_history"><![CDATA[История]]></string>
     <string name="_bx_reputation_page_block_title_history"><![CDATA[История]]></string>
+    <string name="_bx_reputation_page_block_title_system_widget"><![CDATA[Виджет (только для API)]]></string>
+    <string name="_bx_reputation_page_block_title_widget"><![CDATA[Виджет]]></string>
 
 
     <!-- Menus -->
     <!-- Menus -->
     <string name="_bx_reputation_menu_item_title_system_leaderboard"><![CDATA[Таблица лидеров]]></string>
     <string name="_bx_reputation_menu_item_title_system_leaderboard"><![CDATA[Таблица лидеров]]></string>