From 80d4f852d9f8a10f237c179c0da9e8b1ad32267d Mon Sep 17 00:00:00 2001 From: AntonLV Date: Fri, 25 Oct 2024 15:07:31 +0300 Subject: [PATCH] Ticket #4817 - Courses improvements. --- .../files/classes/BxBaseModFilesModule.php | 18 ++++++++++++++++-- .../courses/classes/BxCoursesTemplate.php | 8 ++++---- .../boonex/videos/classes/BxVideosModule.php | 12 ++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/modules/base/files/classes/BxBaseModFilesModule.php b/modules/base/files/classes/BxBaseModFilesModule.php index acc52c4268..384d6675f8 100644 --- a/modules/base/files/classes/BxBaseModFilesModule.php +++ b/modules/base/files/classes/BxBaseModFilesModule.php @@ -24,12 +24,26 @@ public function serviceGetFile ($iContentId, $aParams = []) if(empty($aContentInfo) || !is_array($aContentInfo)) return false; - $sStorage = !empty($aParams['storage']) ? $aParams['storage'] : $CNF['OBJECT_STORAGE']; + $sStorage = ''; + if(!empty($aParams['storage'])) + $sStorage = $aParams['storage']; + else if(!empty($CNF['OBJECT_STORAGE'])) + $sStorage = $CNF['OBJECT_STORAGE']; + else + return false; + $oStorage = BxDolStorage::getObjectInstance($sStorage); if(!$oStorage) return false; - $sFieldFileId = !empty($aParams['field']) ? $aParams['field'] : $CNF['FIELD_FILE_ID']; + $sFieldFileId = ''; + if(!empty($aParams['field'])) + $sFieldFileId = $aParams['field']; + else if(!empty($CNF['FIELD_FILE_ID'])) + $sFieldFileId = $CNF['FIELD_FILE_ID']; + else + return false; + return $oStorage->getFile($aContentInfo[$sFieldFileId]); } } diff --git a/modules/boonex/courses/classes/BxCoursesTemplate.php b/modules/boonex/courses/classes/BxCoursesTemplate.php index 72454aefd5..44b005cb8c 100644 --- a/modules/boonex/courses/classes/BxCoursesTemplate.php +++ b/modules/boonex/courses/classes/BxCoursesTemplate.php @@ -584,10 +584,10 @@ protected function _entryNodeItems($iProfileId, $iContentId, $aNode, $iUsage) if(!empty($aFileInfo) && is_array($aFileInfo)) { $aTmplVarsShowSize['size'] = _t_format_size($aFileInfo['size']); - $bTmplVarsShowDownload = !empty($aFileInfo['url_download']); - $aTmplVarsShowDownload = [ - 'link' => $aFileInfo['url_download'] - ]; + if(($bTmplVarsShowDownload = !empty($aFileInfo['url_download']))) + $aTmplVarsShowDownload = [ + 'link' => $aFileInfo['url_download'] + ]; } } diff --git a/modules/boonex/videos/classes/BxVideosModule.php b/modules/boonex/videos/classes/BxVideosModule.php index 38735f3369..4fb7af3dc5 100644 --- a/modules/boonex/videos/classes/BxVideosModule.php +++ b/modules/boonex/videos/classes/BxVideosModule.php @@ -124,6 +124,18 @@ public function serviceGetVideo ($iContentId) return $this->getVideoData($aContentInfo); } + public function serviceGetFile ($iContentId, $aParams = []) + { + $CNF = &$this->_oConfig->CNF; + + if(!isset($aParams['storage'])) + $aParams['storage'] = $CNF['OBJECT_STORAGE_VIDEOS']; + if(!isset($aParams['field'])) + $aParams['field'] = $CNF['FIELD_VIDEO']; + + return parent::serviceGetFile($iContentId, $aParams); + } + public function getVideoData($aContentInfo) { $CNF = &$this->_oConfig->CNF;