From a1c8fac94c67afda860440b751a2bfaa94afc57d Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 1 Mar 2023 13:20:35 +0100 Subject: [PATCH] *Mail: fix mail attachments action not being set properly based on users preference set in Filemanager (eg. open with Collabora or download) --- filemanager/inc/class.filemanager_hooks.inc.php | 16 ++++++++++++++++ mail/inc/class.mail_ui.inc.php | 16 +++++++++++++--- mail/templates/default/app.css | 3 ++- mail/templates/default/display.xet | 10 ++++------ 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/filemanager/inc/class.filemanager_hooks.inc.php b/filemanager/inc/class.filemanager_hooks.inc.php index af49637741..84d05fe695 100644 --- a/filemanager/inc/class.filemanager_hooks.inc.php +++ b/filemanager/inc/class.filemanager_hooks.inc.php @@ -308,6 +308,22 @@ class filemanager_hooks return $link; } + /** + * Get supported mime types for editor based on user preferences + * @return array|mixed + */ + static function getEditorPrefMimes() + { + $mimes = self::getEditorLink()['mime']??[]; + $excluedMimes = is_string($GLOBALS['egw_info']['user']['preferences']['filemanager']['collab_excluded_mimes'])? + explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['collab_excluded_mimes']) : []; + foreach ($mimes as $mime => $value) + { + if (in_array($mime, $excluedMimes)) unset($mimes[$mime]); + } + return $mimes; + } + /** * Hooks called by vfs, implemented to be able to notify subscribed users about changed files * diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 558f7fcb50..84081e13ef 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -2526,9 +2526,19 @@ $filter['before']= date("d-M-Y", $cutoffdate2); $attachmentHTML[$key]['mail_id'] = $rowID; $attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; $attachmentHTML[$key]['smime_type'] = $value['smime_type']; - $attachmentHTML[$key]['actions'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_doubleclick_action'] === 'collabora' ? - 'collabora' : 'downloadOneAsFile'; - $attachmentHTML[$key]['actionsDefaultLabel'] = 'Download'; + + if ($GLOBALS['egw_info']['apps']['collabora'] + && $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_doubleclick_action'] === 'collabora' + && array_key_exists($value['mimeType'], filemanager_hooks::getEditorPrefMimes())) + { + $attachmentHTML[$key]['actions'] = 'collabora'; + $attachmentHTML[$key]['actionsDefaultLabel'] = 'Open with Collabora'; + } + else + { + $attachmentHTML[$key]['actions'] = 'downloadOneAsFile'; + $attachmentHTML[$key]['actionsDefaultLabel'] = 'Download'; + } // reset mode array as it should be considered differently for // each attachment diff --git a/mail/templates/default/app.css b/mail/templates/default/app.css index b45581a118..89d5199c4c 100644 --- a/mail/templates/default/app.css +++ b/mail/templates/default/app.css @@ -1134,4 +1134,5 @@ et2-split#mail-index_mailSplitter.squeezed .mail-index_quotabox{ } .expanderFirstRow { position: absolute; -} \ No newline at end of file +} +.attachments et2-dropdown-button[id$="\[actions\]"]{display: inline} \ No newline at end of file diff --git a/mail/templates/default/display.xet b/mail/templates/default/display.xet index c228491fee..3fcda9995b 100644 --- a/mail/templates/default/display.xet +++ b/mail/templates/default/display.xet @@ -108,8 +108,7 @@ - - + @@ -118,7 +117,6 @@ - @@ -131,8 +129,8 @@ - - + + @@ -143,7 +141,7 @@ - +