*Mail: fix mail attachments action not being set properly based on users preference set in Filemanager (eg. open with Collabora or download)

This commit is contained in:
Hadi Nategh 2023-03-01 13:20:35 +01:00
parent a4b253abc7
commit a1c8fac94c
4 changed files with 35 additions and 10 deletions

View File

@ -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
*

View File

@ -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

View File

@ -1134,4 +1134,5 @@ et2-split#mail-index_mailSplitter.squeezed .mail-index_quotabox{
}
.expanderFirstRow {
position: absolute;
}
}
.attachments et2-dropdown-button[id$="\[actions\]"]{display: inline}

View File

@ -108,8 +108,7 @@
<column disabled="!@showtempname"/>
<column disabled="!@showtempname"/>
<column width="70%"/>
<column width="11%"/>
<column width="10%"/>
<column width="30%"/>
</columns>
<rows>
<row class="row attachmentRow">
@ -118,7 +117,6 @@
<et2-description id="mail_displayattachments[0][type]"></et2-description>
<et2-description id="mail_displayattachments[0][winmailFlag]"></et2-description>
<et2-description-expose class="et2_link useEllipsis" id="mail_displayattachments[0][filename]" mime="@mail_displayattachments[0][type]" href="@mail_displayattachments[0][mime_url]" noLang="1" mimeData="@mail_displayattachments[0][mime_data]"></et2-description-expose>
<et2-description align="right" id="mail_displayattachments[0][size]"></et2-description>
<et2-description align="right" value="@attachmentsBlockTitle" class="et2_bold"></et2-description>
</row>
</rows>
@ -131,8 +129,8 @@
<column disabled="!@showtempname"/>
<column disabled="!@showtempname"/>
<column width="70%" />
<column width="11%" />
<column width="10%"/>
<column width="10%" />
<column width="20"/>
<column />
</columns>
<rows>
@ -143,7 +141,7 @@
<et2-description id="${row}[winmailFlag]"></et2-description>
<et2-description-expose class="et2_link useEllipsis" id="${row}[filename]" mime="$row_cont[type]" href="$row_cont[mime_url]" noLang="1" mimeData="$row_cont[mime_data]"></et2-description-expose>
<et2-description align="right" id="${row}[size]"></et2-description>
<et2-dropdown-button id="${row}[actions]" label="$row_cont[actionsDefaultLabel]" readonly="false" disabled="false" onchange="app.mail.attachmentsBlockActions" onclick="app.mail.attachmentsBlockActions"/>
<et2-dropdown-button id="${row}[actions]" label="$row_cont[actionsDefaultLabel]" readonly="false" disabled="false" onchange="app.mail.attachmentsBlockActions" onclick="app.mail.attachmentsBlockActions"/>
</row>
</rows>
</grid>