mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-28 19:03:14 +01:00
Mail: Add attachment action to open in Collabora
This commit is contained in:
parent
49c9939e67
commit
cce1088486
@ -794,27 +794,33 @@ class mail_hooks
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'downloadOneAsFile' => [
|
'downloadOneAsFile' => [
|
||||||
'id' => 'downloadOneAsFile',
|
'id' => 'downloadOneAsFile',
|
||||||
'label' => 'Download',
|
'label' => 'Download',
|
||||||
'icon' => 'fileexport',
|
'icon' => 'fileexport',
|
||||||
'value' => 'downloadOneAsFile'
|
'value' => 'downloadOneAsFile'
|
||||||
],
|
],
|
||||||
'saveOneToVfs' => [
|
'collabora' => [
|
||||||
'id' => 'saveOneToVfs',
|
'id' => 'collabora',
|
||||||
|
'label' => 'Open with Collabora',
|
||||||
|
'icon' => 'open',
|
||||||
|
'value' => 'collabora'
|
||||||
|
],
|
||||||
|
'saveOneToVfs' => [
|
||||||
|
'id' => 'saveOneToVfs',
|
||||||
'label' => 'Save in Filemanager',
|
'label' => 'Save in Filemanager',
|
||||||
'icon' => 'filemanager/navbar.svg',
|
'icon' => 'filemanager/navbar',
|
||||||
'value' => 'saveOneToVfs'
|
'value' => 'saveOneToVfs'
|
||||||
],
|
],
|
||||||
'saveAllToVfs' => [
|
'saveAllToVfs' => [
|
||||||
'id' => 'saveAllToVfs',
|
'id' => 'saveAllToVfs',
|
||||||
'label' => 'Save all to Filemanager',
|
'label' => 'Save all to Filemanager',
|
||||||
'icon' => 'mail/save_all',
|
'icon' => 'mail/save_all',
|
||||||
'value' => 'saveAllToVfs'
|
'value' => 'saveAllToVfs'
|
||||||
],
|
],
|
||||||
'downloadAllToZip' => [
|
'downloadAllToZip' => [
|
||||||
'id' => 'downloadAllToZip',
|
'id' => 'downloadAllToZip',
|
||||||
'label' => 'Save as ZIP',
|
'label' => 'Save as ZIP',
|
||||||
'icon' => 'mail/save_zip',
|
'icon' => 'mail/save_zip',
|
||||||
'value' => 'downloadAllToZip'
|
'value' => 'downloadAllToZip'
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
@ -2924,20 +2924,44 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$subject = Api\Mail::clean_subject_for_filename($subject);
|
$subject = Api\Mail::clean_subject_for_filename($subject);
|
||||||
$mime='text/html'; $size=0;
|
$mime = 'text/html';
|
||||||
Api\Header\Content::safe($message, $subject.".eml", $mime, $size, true, false);
|
$size = 0;
|
||||||
print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>';
|
Api\Header\Content::safe($message, $subject . ".eml", $mime, $size, true, false);
|
||||||
|
print '<pre>' . htmlspecialchars($message, ENT_NOQUOTES | ENT_SUBSTITUTE, 'utf-8') . '</pre>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajax function to save message(s)/attachment(s) in the vfs
|
||||||
|
*
|
||||||
|
* @param string $attachment_id
|
||||||
|
* @param string $filename
|
||||||
|
*
|
||||||
|
* @return string Temporary path to open
|
||||||
|
*/
|
||||||
|
function ajax_vfsOpen($attachment_id, $filename)
|
||||||
|
{
|
||||||
|
// Use a sub-dir so we can give a nice filename
|
||||||
|
$temp_path = '/home/' . $GLOBALS['egw_info']['user']['account_lid'] . "/.mail/";
|
||||||
|
if(!Vfs::is_dir($temp_path))
|
||||||
|
{
|
||||||
|
Vfs::mkdir($temp_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->vfsSaveAttachments([$attachment_id], $temp_path . $filename, 'rename');
|
||||||
|
|
||||||
|
$response = Api\Json\Response::get();
|
||||||
|
$response->data($result['savepath'][$attachment_id] ?? "");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajax function to save message(s)/attachment(s) in the vfs
|
* Ajax function to save message(s)/attachment(s) in the vfs
|
||||||
*
|
*
|
||||||
* @param array $params array of mail ids and action name
|
* @param array $params array of mail ids and action name
|
||||||
* params = array (
|
* params = array (
|
||||||
* ids => array of string
|
* ids => array of string
|
||||||
* action => string
|
* action => string
|
||||||
* )
|
* )
|
||||||
* @param string $path path to save the emails
|
* @param string $path path to save the emails
|
||||||
* @param string $submit_button_id dialog button id of triggered submit
|
* @param string $submit_button_id dialog button id of triggered submit
|
||||||
* @param string $savemode save mode: 'overwrite' or 'rename'
|
* @param string $savemode save mode: 'overwrite' or 'rename'
|
||||||
@ -3191,6 +3215,7 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
|
|||||||
{
|
{
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
$res['savepath'][$id] = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->mail_bo->closeConnection();
|
$this->mail_bo->closeConnection();
|
||||||
|
@ -1102,14 +1102,14 @@ app.classes.mail = AppJS.extend(
|
|||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
id: 'downloadOneAsFile',
|
id: 'downloadOneAsFile',
|
||||||
label:'Download',
|
label: 'Download',
|
||||||
icon:'fileexport',
|
icon: 'fileexport',
|
||||||
value:'downloadOneAsFile'
|
value: 'downloadOneAsFile'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'saveOneToVfs',
|
id: 'saveOneToVfs',
|
||||||
label: 'Save in Filemanager',
|
label: 'Save in Filemanager',
|
||||||
icon: 'filemanager/navbar.svg',
|
icon: 'filemanager/navbar',
|
||||||
value: 'saveOneToVfs'
|
value: 'saveOneToVfs'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1125,14 +1125,24 @@ app.classes.mail = AppJS.extend(
|
|||||||
value: 'downloadAllToZip'
|
value: 'downloadAllToZip'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
if (typeof this.egw.user('apps')['collabora'] !== "undefined")
|
||||||
|
{
|
||||||
|
actions.push({
|
||||||
|
id: 'collabora',
|
||||||
|
label: 'Open',
|
||||||
|
icon: 'collabora/navbar',
|
||||||
|
value: 'collabora'
|
||||||
|
});
|
||||||
|
}
|
||||||
data.attachmentsBlockTitle = `${data.attachmentsBlock.length} attachments`;
|
data.attachmentsBlockTitle = `${data.attachmentsBlock.length} attachments`;
|
||||||
data.attachmentsBlock.forEach(_item => {
|
data.attachmentsBlock.forEach(_item =>
|
||||||
_item.actions='downloadOneAsFile';
|
{
|
||||||
|
_item.actions = 'downloadOneAsFile';
|
||||||
// for some reason label needs to be set explicitly for the dropdown button. It needs more investigation.
|
// for some reason label needs to be set explicitly for the dropdown button. It needs more investigation.
|
||||||
_item.actionsDefaultLabel='Download';
|
_item.actionsDefaultLabel = 'Download';
|
||||||
});
|
});
|
||||||
|
|
||||||
sel_options.attachmentsBlock = {actions:actions};
|
sel_options.attachmentsBlock = {actions: actions};
|
||||||
}
|
}
|
||||||
|
|
||||||
mailPreview.set_value({content:data, sel_options:sel_options});
|
mailPreview.set_value({content:data, sel_options:sel_options});
|
||||||
@ -3127,11 +3137,36 @@ app.classes.mail = AppJS.extend(
|
|||||||
method: 'mail.mail_ui.ajax_vfsSave',
|
method: 'mail.mail_ui.ajax_vfsSave',
|
||||||
button_label: this.egw.lang(action === 'saveOneToVfs' ? 'Save' : 'Save all'),
|
button_label: this.egw.lang(action === 'saveOneToVfs' ? 'Save' : 'Save all'),
|
||||||
dialog_title: this.egw.lang(action === 'saveOneToVfs' ? 'Save attachment' : 'Save attachments'),
|
dialog_title: this.egw.lang(action === 'saveOneToVfs' ? 'Save attachment' : 'Save attachments'),
|
||||||
method_id: ids.length > 1 ? {ids:ids, action:'attachment'} : {ids: ids[0], action: 'attachment'},
|
method_id: ids.length > 1 ? {ids: ids, action: 'attachment'} : {ids: ids[0], action: 'attachment'},
|
||||||
name: action === 'saveOneToVfs' ? attachments[0]['filename'] : null
|
name: action === 'saveOneToVfs' ? attachments[0]['filename'] : null
|
||||||
});
|
});
|
||||||
vfs_select.click();
|
vfs_select.click();
|
||||||
break;
|
break;
|
||||||
|
case 'collabora':
|
||||||
|
attachment = attachments[row_id];
|
||||||
|
let id = mail_id + '::' + attachment.partID + '::' + attachment.winmailFlag + '::' + attachment.filename;
|
||||||
|
|
||||||
|
// This can take a few seconds, show loader
|
||||||
|
this.egw.loading_prompt('mail_open_file', true, attachment.filename);
|
||||||
|
|
||||||
|
// Temp save to VFS
|
||||||
|
this.egw.request('mail.mail_ui.ajax_vfsOpen', [id, attachment.filename]).then((temp_path) =>
|
||||||
|
{
|
||||||
|
if (temp_path)
|
||||||
|
{
|
||||||
|
// Open in Collabora
|
||||||
|
window.open(this.egw.link('/index.php', {
|
||||||
|
'menuaction': 'collabora.EGroupware\\collabora\\Ui.editor',
|
||||||
|
'path': temp_path,
|
||||||
|
'cd': 'no' // needed to not reload framework in sharing
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}).finally(() =>
|
||||||
|
{
|
||||||
|
// Hide load prompt
|
||||||
|
this.egw.loading_prompt('mail_open_file', false);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
case 'downloadOneAsFile':
|
case 'downloadOneAsFile':
|
||||||
case 'downloadAllToZip':
|
case 'downloadAllToZip':
|
||||||
|
Loading…
Reference in New Issue
Block a user