Explorar o código

Ticket #5726 - Tasks: Use own storage for comments with different file types support.

AntonLV hai 3 semanas
pai
achega
75ca82d6a3

+ 22 - 2
modules/boonex/tasks/classes/BxTasksCmts.php

@@ -17,11 +17,13 @@ class BxTasksCmts extends BxTemplCmts
 
     public function __construct($sSystem, $iId, $iInit = 1)
     {
-        parent::__construct($sSystem, $iId, $iInit);
-
         $this->_sModule = 'bx_tasks';
         $this->_oModule = BxDolModule::getInstance($this->_sModule);
 
+        $this->_sTableImages = 'bx_tasks_files';
+
+        parent::__construct($sSystem, $iId, $iInit, $this->_oModule->_oTemplate);        
+
         $this->_iAuthorAuto = (int)getParam('sys_profile_bot');
 
         $this->_aT = array_merge($this->_aT, [
@@ -158,6 +160,24 @@ class BxTasksCmts extends BxTemplCmts
 
         return $sText;
     }
+
+    protected function _getFormObject($sAction = BX_CMT_ACTION_POST)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+        $sFldImage = 'cmt_image';
+
+        $oResult = parent::_getFormObject($sAction);
+        if(!isset($oResult->aInputs[$sFldImage]))
+            return $oResult;
+
+        $oResult->aInputs[$sFldImage] = array_merge($oResult->aInputs[$sFldImage], [
+            'storage_object' => $CNF['OBJECT_STORAGE_CMTS'],
+            'images_transcoder' => '',
+            'upload_buttons_titles' => ['HTML5' => 'paperclip']
+        ]);
+
+        return $oResult;
+    }
 }
 
 /** @} */

+ 1 - 0
modules/boonex/tasks/classes/BxTasksConfig.php

@@ -129,6 +129,7 @@ class BxTasksConfig extends BxBaseModTextConfig
             'OBJECT_STORAGE_FILES' => 'bx_tasks_files',
             'OBJECT_STORAGE_PHOTOS' => 'bx_tasks_photos',
             'OBJECT_STORAGE_VIDEOS' => 'bx_tasks_videos',
+            'OBJECT_STORAGE_CMTS' => 'bx_tasks_files_cmts', // for comments
             'OBJECT_IMAGES_TRANSCODER_PREVIEW' => 'bx_tasks_preview',
             'OBJECT_IMAGES_TRANSCODER_GALLERY' => 'bx_tasks_gallery',
             'OBJECT_IMAGES_TRANSCODER_COVER' => 'bx_tasks_cover',

+ 1 - 1
modules/boonex/tasks/classes/BxTasksTemplate.php

@@ -297,7 +297,7 @@ class BxTasksTemplate extends BxBaseModTextTemplate
                 $sState = 'paused';
 
             return [
-                'id' => $aTimer['id'],
+                'id' => $bTimer ? $aTimer['id'] : 0,
                 'time' => [
                     'hours' => $iHours,
                     'minutes' => $iMinutes,

+ 5 - 1
modules/boonex/tasks/install/sql/install.sql

@@ -147,6 +147,7 @@ CREATE TABLE IF NOT EXISTS `bx_tasks_files` (
   `mime_type` varchar(128) NOT NULL,
   `ext` varchar(32) NOT NULL,
   `size` bigint(20) NOT NULL,
+  `dimensions` varchar(24) NOT NULL,
   `added` int(11) NOT NULL,
   `modified` int(11) NOT NULL,
   `private` int(11) NOT NULL,
@@ -452,7 +453,10 @@ INSERT INTO `sys_objects_storage` (`object`, `engine`, `params`, `token_life`, `
 ('bx_tasks_videos', @sStorageEngine, '', 360, 2592000, 3, 'bx_tasks_videos', 'allow-deny', '{video}', '', 0, 0, 0, 0, 0, 0),
 ('bx_tasks_videos_resized', @sStorageEngine, '', 360, 2592000, 3, 'bx_tasks_videos_resized', 'allow-deny', '{imagevideo}', '', 0, 0, 0, 0, 0, 0),
 
-('bx_tasks_files', @sStorageEngine, '', 360, 2592000, 3, 'bx_tasks_files', 'deny-allow', '', '{dangerous}', 0, 0, 0, 0, 0, 0);
+('bx_tasks_files', @sStorageEngine, '', 360, 2592000, 3, 'bx_tasks_files', 'deny-allow', '', '{dangerous}', 0, 0, 0, 0, 0, 0),
+
+-- For Comments
+('bx_tasks_files_cmts', @sStorageEngine, '', 360, 2592000, 3, 'bx_tasks_files', 'deny-allow', '', '{dangerous}', 0, 0, 0, 0, 0, 0);
 
 INSERT INTO `sys_objects_transcoder` (`object`, `storage_object`, `source_type`, `source_params`, `private`, `atime_tracking`, `atime_pruning`, `ts`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_tasks_preview', 'bx_tasks_photos_resized', 'Storage', 'a:1:{s:6:"object";s:15:"bx_tasks_covers";}', 'no', '1', '2592000', '0', '', ''),

+ 16 - 0
modules/boonex/tasks/template/comment_attachments.html

@@ -0,0 +1,16 @@
+<div class="pswp-gallery">
+<bx_repeat:attached>
+    <div class="__style_prefix__-attached-preview bx-forum-attached-preview bx-def-round-corners bx-def-padding-thd">
+        <bx_if:show_image>
+            <a class="flex space-x-2" href="__file__" data-file-id="__file_id__" data-src="__file__" data-pswp-src="__file__" data-pswp-width="__w__" data-pswp-height="__h__" title="<bx_text_attribute:_cmt_view_attached_image />">
+                <img class="bg-cover w-8 h-8" src="<bx_image_url:spacer.gif />" style="background-image:url(__preview__)" /><span>__file_name__</span><span class="bx-def-font-grayed">__file_size__</span>
+            </a>
+        </bx_if:show_image>
+        <bx_if:show_file>
+            <a class="flex space-x-2" href="__file__" title="<bx_text_attribute:_cmt_download_attached_file />">
+                <i class="sys-icon __file_icon__ w-8 h-8"></i><span>__file_name__</span><span class="bx-def-font-grayed">__file_size__</span>
+            </a>
+        </bx_if:show_file>
+    </div>
+</bx_repeat:attached>
+</div>

+ 3 - 0
template/scripts/BxBaseCmts.php

@@ -1680,6 +1680,9 @@ class BxBaseCmts extends BxDolCmts
 
             foreach($aFiles as $aFile) {
                 $sFile = $oStorage->getFileUrlById($aFile['image_id']);
+                if(!$sFile)
+                    continue;
+
                 $bImage = $oTranscoder && ($oTranscoder->isMimeTypeSupported($aFile['mime_type']) || $oTranscoder->isMimeTypeSvg($aFile['mime_type']));
 
                 $sPreview = '';

+ 2 - 0
template/scripts/BxBaseIconsetLucide.php

@@ -71,7 +71,9 @@ class BxBaseIconsetLucide extends BxBaseIconset
             'file-import' => 'file-input',
             'file-export' => 'file-output',
             'file-invoice' => 'receipt',
+            'file-pdf' => 'file-text',
             'file-word' => 'file-text',
+            'file-excel' => 'file-spreadsheet',
             'fire' => 'flame',
             'group' => 'users',
             'google' => 'log-in', //TODO: Brand icon. Update later.