Преглед на файлове

#556 Files module - extension for downloaded file, border for iframe viewer, author must have permission to add files

Alex Trofimov преди 9 години
родител
ревизия
1b2bcac04c

+ 12 - 3
modules/boonex/files/classes/BxFilesMenuView.php

@@ -28,17 +28,26 @@ class BxFilesMenuView extends BxBaseModTextMenuView
 
         $aFile = $this->_oModule->getContentFile($this->_aContentInfo);
         if (!$aFile || !$aFile['private']) {
-            $this->addMarkers(array('file_download_token' => ''));
+            $this->addMarkers(array(
+                'file_download_token' => '',
+                'file_ext' => $aFile['ext'] ? $aFile['ext'] : '',
+            ));
             return;
         }
 
         $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
         if (!$oStorage) {
-            $this->addMarkers(array('file_download_token' => ''));
+            $this->addMarkers(array(
+                'file_download_token' => '',
+                'file_ext' => $aFile['ext'],
+            ));
             return;
         }
 
-        $this->addMarkers(array('file_download_token' => $oStorage->genToken($aFile['id'])));
+        $this->addMarkers(array(
+            'file_download_token' => $oStorage->genToken($aFile['id']),
+            'file_ext' => $aFile['ext'],
+        ));
     }
 
 }

+ 6 - 6
modules/boonex/files/classes/BxFilesModule.php

@@ -47,7 +47,9 @@ class BxFilesModule extends BxBaseModTextModule
             return true;
 
         $sProfileModule = $oProfile->getModule();
-        if (BxDolService::call($sProfileModule, 'is_group_profile') && BxDolService::call($sProfileModule, 'is_fan', array($iGroupProfileId)))
+
+        $aContentInfo = BxDolService::call($sProfileModule, 'get_content_info_by_id', array($oProfile->getContentId()));
+        if (BxDolService::call($sProfileModule, 'is_group_profile') && (BxDolService::call($sProfileModule, 'is_fan', array($iGroupProfileId)) || bx_get_logged_profile_id() == $aContentInfo['author']))
             return true;
 
         return false;
@@ -57,11 +59,8 @@ class BxFilesModule extends BxBaseModTextModule
     {
         if (!$iProfileId)
             $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
-        if (!$iProfileId || !($oProfile = BxDolProfile::getInstance($iProfileId)))
-            return false;
 
-        $sProfileModule = $oProfile->getModule();
-        if ($iProfileId != $this->_iProfileId && !(BxDolService::call($sProfileModule, 'is_group_profile') && BxDolService::call($sProfileModule, 'is_fan', array($iProfileId))))
+        if (!$this->serviceIsAllowedAddContentToProfile($iProfileId))
             return false;
 
         $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_MY_ENTRIES']);
@@ -73,8 +72,9 @@ class BxFilesModule extends BxBaseModTextModule
         return _t('_sys_txt_access_denied');
     }
 
-    public function actionDownload($iContentId, $sToken = '') 
+    public function actionDownload($iContentId) 
     {
+        $sToken = bx_get('token');
         $CNF = $this->_oConfig->CNF;
         
         $aData = $this->_oDb->getContentInfoById((int)$iContentId);

+ 1 - 1
modules/boonex/files/install/sql/enable.sql

@@ -182,7 +182,7 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 ('bx_files_view', 'bx_files', '_bx_files_menu_set_title_view_entry', 0);
 
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
-('bx_files_view', 'bx_files', 'download-file', '_bx_files_menu_item_title_system_download_file', '_bx_files_menu_item_title_download_file', 'modules/?r=files/download/{content_id}/{file_download_token}', '', '_blank', 'download', '', 2147483647, 1, 0, 1),
+('bx_files_view', 'bx_files', 'download-file', '_bx_files_menu_item_title_system_download_file', '_bx_files_menu_item_title_download_file', 'modules/?r=files/download/{content_id}.{file_ext}?token={file_download_token}', '', '_blank', 'download', '', 2147483647, 1, 0, 1),
 ('bx_files_view', 'bx_files', 'edit-file', '_bx_files_menu_item_title_system_edit_entry', '_bx_files_menu_item_title_edit_entry', 'page.php?i=edit-file&id={content_id}', '', '', 'pencil', '', 2147483647, 1, 0, 2),
 ('bx_files_view', 'bx_files', 'delete-file', '_bx_files_menu_item_title_system_delete_entry', '_bx_files_menu_item_title_delete_entry', 'page.php?i=delete-file&id={content_id}', '', '', 'remove', '', 2147483647, 1, 0, 3);
 

+ 1 - 1
template/file_handler_iframe.html

@@ -1 +1 @@
-<iframe class="bx_file_handler_iframe __class__" src="__src__" frameborder="0"></iframe>
+<iframe class="bx_file_handler_iframe __class__ bx-def-border" src="__src__" frameborder="0"></iframe>