AntonLV 2 лет назад
Родитель
Сommit
5ace1be47b

+ 2 - 2
modules/base/general/classes/BxBaseModGeneralFormsEntryHelper.php

@@ -351,8 +351,8 @@ class BxBaseModGeneralFormsEntryHelper extends BxDolProfileForms
             'override_result' => &$sUrl,
         ]);
 
-        if (bx_is_api())
-            return [bx_api_get_block('redirect', ['uri' => BxDolPermalinks::getInstance()->permalink($sUrl), 'timeout' => 1000])];
+        if($this->_bIsApi)
+            return !empty($sUrl) ? [bx_api_get_block('redirect', ['uri' => BxDolPermalinks::getInstance()->permalink($sUrl), 'timeout' => 1000])] : [];
         
         if($this->_bAjaxMode) {
             echoJson($this->prepareResponse($sUrl, $this->_bAjaxMode, 'redirect'));

+ 1 - 0
modules/boonex/courses/classes/BxCoursesConfig.php

@@ -59,6 +59,7 @@ class BxCoursesConfig extends BxBaseModGroupsConfig
             'FIELD_CF' => 'cf',
             'FIELD_VIEWS' => 'views',
             'FIELD_VOTES' => 'votes',
+            'FIELD_REPORTS' => 'reports',
             'FIELD_STATUS' => 'status',
             'FIELD_STATUS_ADMIN' => 'status_admin',
             'FIELD_COMMENTS' => 'comments',

+ 78 - 0
modules/boonex/courses/classes/BxCoursesMenuSnippetMeta.php

@@ -19,6 +19,84 @@ class BxCoursesMenuSnippetMeta extends BxBaseModGroupsMenuSnippetMeta
 
         unset($this->_aConnectionToFunctionCheck['sys_profiles_friends']);
     }
+
+    protected function _getMenuItemReports($aItem, $aParams = [])
+    {
+        $bShowAsObject = isset($aParams['show_as_object']) && (bool)$aParams['show_as_object'] === true;
+
+        if($bShowAsObject || $this->_bIsApi)  //--- API: Object base votes are used by default
+            return $this->_getMenuItemReportObject($aItem, $aParams);
+
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if(empty($CNF['FIELD_REPORTS']) || (empty($this->_aContentInfo[$CNF['FIELD_REPORTS']]) && !$this->_bShowZeros))
+            return false;
+
+        $sTitle = _t('_report_n_reports', $this->_aContentInfo[$CNF['FIELD_REPORTS']]);
+
+        if($this->_bIsApi)
+            return $this->_getMenuItemAPI($aItem, 'text', [
+                'title' => $sTitle
+            ]);
+
+        return $this->getUnitMetaItemText($sTitle);
+    }
+
+    protected function _getMenuItemReportObject($aItem, $aParams = [])
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if(empty($CNF['OBJECT_REPORTS']))
+            return false;
+
+        $oObject = BxDolReport::getObjectInstance($CNF['OBJECT_REPORTS'], $this->_aContentInfo[$CNF['FIELD_ID']]);
+        if(!$oObject || !$oObject->isEnabled())
+            return false;
+
+        $aObjectOptions = [
+            'show_do_report_as_button' => true,
+            'show_do_report_label' => true,
+            'show_counter' => true
+        ];
+        if(!empty($aParams['object_options']) && is_array($aParams['object_options']))
+            $aObjectOptions = array_merge($aObjectOptions, $aParams['object_options']);
+
+        if($this->_bIsApi)
+            return $this->_getMenuItemElementAPI($aItem, $oObject->getElementApi($aObjectOptions));
+
+        return $this->getUnitMetaItemCustom($oObject->getElementInline($aObjectOptions));
+    }
+
+    protected function _getMenuItemPass($aItem, $aParams = [])
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $iProfileId = bx_get_logged_profile_id();
+        if(!$this->_oContentProfile || !$this->_oModule->serviceIsFan($this->_oContentProfile->id(), $iProfileId))
+            return false;
+
+        list($iPassPercent, $aPassDetails, $sPassStatus, $sPassTitle) = $this->_oModule->getEntryPass($iProfileId, $this->_iContentId);
+        if(empty($sPassTitle))
+            return false;
+
+        $sLink = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'], [
+            'id' => $this->_iContentId
+        ]));
+
+        if($this->_bIsApi)
+            return $this->_getMenuItemAPI($aItem, ['display' => 'link'], [
+                'title' => $sTitle,
+                'link' => bx_api_get_relative_url($sLink)
+            ]);
+
+        return [
+            $this->getUnitMetaItemButton($sPassTitle, [
+                'class' => !empty($aItem['primary']) ? 'bx-btn-primary' : '',
+                'href' => $sLink
+            ]),
+            'bx-menu-item-button'
+        ];
+    }
 }
 
 /** @} */

+ 3 - 6
modules/boonex/courses/classes/BxCoursesModule.php

@@ -254,7 +254,7 @@ class BxCoursesModule extends BxBaseModGroupsModule
             'parent_id' => $aData['node_id']
         ]);
 
-        return $this->_bIsApi ? bx_api_get_relative_url($sUrl) : $sUrl;
+        return $this->_bIsApi ? '' : $sUrl;
     }
 
     public function serviceOnContentDeleted($sContentType, $iContentId, $iContextId)
@@ -483,7 +483,8 @@ class BxCoursesModule extends BxBaseModGroupsModule
             $this->getNodePass($iProfileId, $iContentId, $aChild, $aPassDetails);
 
         $iPassPercent = 0;
-        $sPassStatus = $sPassTitle = '';
+        $sPassStatus = '_bx_courses_txt_status_not_started';
+        $sPassTitle = '_bx_courses_txt_pass_start';
         $iLevelMax = $this->_oConfig->getContentLevelMax();
         if(isset($aPassDetails[$iLevelMax]) && ($aPassLevelMax = $aPassDetails[$iLevelMax])) {
             $iPassPercent = ($iTotal = (int)$aPassLevelMax['total']) != 0 ? (int)round(100 * $aPassLevelMax['passed']/$iTotal) : 0;
@@ -498,10 +499,6 @@ class BxCoursesModule extends BxBaseModGroupsModule
                     $sPassTitle = '_bx_courses_txt_pass_again';
                 }
             }
-            else {
-                $sPassStatus = '_bx_courses_txt_status_not_started';
-                $sPassTitle = '_bx_courses_txt_pass_start';
-            }
         }
 
         return [

+ 1 - 1
modules/boonex/courses/classes/BxCoursesTemplate.php

@@ -605,7 +605,7 @@ class BxCoursesTemplate extends BxBaseModGroupsTemplate
                     ] : [
                         'size' => $bTmplVarsShowSize ? $aTmplVarsShowSize['size'] : '',
                         'view_link' => $bTmplVarsShowLink ? bx_api_get_relative_url($sLink) : '',
-                        'download_link' => $bTmplVarsShowDownload ? bx_api_get_relative_url($aTmplVarsShowDownload['link']) : '',
+                        'download_link' => $bTmplVarsShowDownload ? $aTmplVarsShowDownload['link'] : '',
                     ]));
                 }
                 else 

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

@@ -344,6 +344,8 @@
     <string name="_bx_courses_menu_item_title_sm_leave"><![CDATA[Leave]]></string>
     <string name="_bx_courses_menu_item_title_sm_leave_reject"><![CDATA[Reject attend request]]></string>
     <string name="_bx_courses_menu_item_title_sm_leave_cancel"><![CDATA[Cancel attend request]]></string>
+    <string name="_bx_courses_menu_item_title_system_sm_reports"><![CDATA[Reports]]></string>
+    <string name="_bx_courses_menu_item_title_system_sm_pass"><![CDATA[Pass]]></string>
 
     <string name="_bx_courses_menu_title_content_add"><![CDATA[Add Content]]></string>
     <string name="_bx_courses_menu_set_title_content_add"><![CDATA[Add Content]]></string>

+ 3 - 1
modules/boonex/courses/install/sql/enable.sql

@@ -388,12 +388,14 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_courses_snippet_meta', 'bx_courses', 'comments', '_sys_menu_item_title_system_sm_comments', '_sys_menu_item_title_sm_comments', '', '', '', '', '', 2147483647, '', 0, 0, 1, 20),
 ('bx_courses_snippet_meta', 'bx_courses', 'members', '_bx_courses_menu_item_title_system_sm_members', '_bx_courses_menu_item_title_sm_members', '', '', '', '', '', 2147483647, '', 1, 0, 1, 25),
 ('bx_courses_snippet_meta', 'bx_courses', 'subscribers', '_sys_menu_item_title_system_sm_subscribers', '_sys_menu_item_title_sm_subscribers', '', '', '', '', '', 2147483647, '', 0, 0, 1, 30),
+('bx_courses_snippet_meta', 'bx_courses', 'reports', '_bx_courses_menu_item_title_system_sm_reports', '', '', '', '', '', '', 2147483647, '', 0, 0, 1, 33),
 ('bx_courses_snippet_meta', 'bx_courses', 'nl', '_sys_menu_item_title_system_sm_nl', '_sys_menu_item_title_sm_nl', '', '', '', '', '', 2147483647, '', 1, 0, 1, 35),
 ('bx_courses_snippet_meta', 'bx_courses', 'join-paid', '_sys_menu_item_title_system_sm_join_paid', '_sys_menu_item_title_sm_join_paid', '', '', '', '', '', 2147483647, 'a:3:{s:6:"module";s:10:"bx_courses";s:6:"method";s:33:"is_paid_join_avaliable_by_content";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 1, 40),
 ('bx_courses_snippet_meta', 'bx_courses', 'join', '_bx_courses_menu_item_title_system_sm_join', '_bx_courses_menu_item_title_sm_join', '', '', '', '', '', 2147483647, 'a:3:{s:6:"module";s:10:"bx_courses";s:6:"method";s:33:"is_free_join_avaliable_by_content";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 1, 45),
 ('bx_courses_snippet_meta', 'bx_courses', 'leave', '_sys_menu_item_title_system_sm_leave', '_sys_menu_item_title_sm_leave', '', '', '', '', '', 2147483647, '', 0, 0, 1, 50),
 ('bx_courses_snippet_meta', 'bx_courses', 'subscribe', '_sys_menu_item_title_system_sm_subscribe', '_sys_menu_item_title_sm_subscribe', '', '', '', '', '', 2147483647, '', 0, 0, 1, 55),
-('bx_courses_snippet_meta', 'bx_courses', 'unsubscribe', '_sys_menu_item_title_system_sm_unsubscribe', '_sys_menu_item_title_sm_unsubscribe', '', '', '', '', '', 2147483647, '', 0, 0, 1, 60);
+('bx_courses_snippet_meta', 'bx_courses', 'unsubscribe', '_sys_menu_item_title_system_sm_unsubscribe', '_sys_menu_item_title_sm_unsubscribe', '', '', '', '', '', 2147483647, '', 0, 0, 1, 60),
+('bx_courses_snippet_meta', 'bx_courses', 'pass', '_bx_courses_menu_item_title_system_sm_pass', '', '', '', '', '', '', 2147483647, '', 0, 0, 1, 65);
 
 -- MENU: profile stats
 SET @iNotifMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name` = 'sys_profile_stats' AND `active` = 1 LIMIT 1);

+ 1 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -105,6 +105,7 @@
         <string name="_report_status_check_out"><![CDATA[Processed]]></string>
         <string name="_report_status_all"><![CDATA[All]]></string>
 	<string name="_report_counter"><![CDATA[{0}]]></string>
+        <string name="_report_n_reports"><![CDATA[{0} reports]]></string>
 	<string name="_report_do_report"><![CDATA[Report]]></string>
         <string name="_report_do_report_with_sample"><![CDATA[Report {0}]]></string>
         <string name="_report_do_unreport"><![CDATA[Cancel report]]></string>

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

@@ -343,6 +343,8 @@
     <string name="_bx_courses_menu_item_title_sm_leave"><![CDATA[Покинуть]]></string>
     <string name="_bx_courses_menu_item_title_sm_leave_reject"><![CDATA[Отклонить запрос на посещение]]></string>
     <string name="_bx_courses_menu_item_title_sm_leave_cancel"><![CDATA[Отменить запрос на посещение]]></string>
+    <string name="_bx_courses_menu_item_title_system_sm_reports"><![CDATA[Жалобы]]></string>
+    <string name="_bx_courses_menu_item_title_system_sm_pass"><![CDATA[Пройти]]></string>
 
     <string name="_bx_courses_menu_title_content_add"><![CDATA[Добавить контент]]></string>
     <string name="_bx_courses_menu_set_title_content_add"><![CDATA[Добавить контент]]></string>

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

@@ -103,6 +103,7 @@
   <string name="_report_status_check_out"><![CDATA[Обработан]]></string>
   <string name="_report_status_all"><![CDATA[Все]]></string>
 	<string name="_report_counter"><![CDATA[{0}]]></string>
+        <string name="_report_n_reports"><![CDATA[{0} жалоб]]></string>
 	<string name="_report_do_report"><![CDATA[Пожаловаться]]></string>
         <string name="_report_do_report_with_sample"><![CDATA[Пожаловаться]]></string>
         <string name="_report_do_unreport"><![CDATA[Отменить жалобу]]></string>

+ 2 - 1
template/scripts/BxBaseMenuUnitMeta.php

@@ -225,7 +225,8 @@ class BxBaseMenuUnitMeta extends BxTemplMenuCustom
             'display_type' => $sDisplayType,
             'content_type' => $sContentType,
             'title' => $aItem['title'],
-            'link' => !empty($aItem['link']) && $aItem['link'] != 'javascript:void(0)' ? $aItem['link'] : ''
+            'link' => !empty($aItem['link']) && $aItem['link'] != 'javascript:void(0)' ? $aItem['link'] : '',
+            'primary' => !empty($aItem['primary']),
         ], $aData);
 
         return $aItemData;