mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-01 04:13:28 +01:00
Mail: Add attachment action to open in Collabora
This commit is contained in:
parent
49c9939e67
commit
cce1088486
@ -799,10 +799,16 @@ class mail_hooks
|
|||||||
'icon' => 'fileexport',
|
'icon' => 'fileexport',
|
||||||
'value' => 'downloadOneAsFile'
|
'value' => 'downloadOneAsFile'
|
||||||
],
|
],
|
||||||
|
'collabora' => [
|
||||||
|
'id' => 'collabora',
|
||||||
|
'label' => 'Open with Collabora',
|
||||||
|
'icon' => 'open',
|
||||||
|
'value' => 'collabora'
|
||||||
|
],
|
||||||
'saveOneToVfs' => [
|
'saveOneToVfs' => [
|
||||||
'id' => 'saveOneToVfs',
|
'id' => 'saveOneToVfs',
|
||||||
'label' => 'Save in Filemanager',
|
'label' => 'Save in Filemanager',
|
||||||
'icon' => 'filemanager/navbar.svg',
|
'icon' => 'filemanager/navbar',
|
||||||
'value' => 'saveOneToVfs'
|
'value' => 'saveOneToVfs'
|
||||||
],
|
],
|
||||||
'saveAllToVfs' => [
|
'saveAllToVfs' => [
|
||||||
|
@ -2924,12 +2924,36 @@ $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';
|
||||||
|
$size = 0;
|
||||||
Api\Header\Content::safe($message, $subject . ".eml", $mime, $size, true, false);
|
Api\Header\Content::safe($message, $subject . ".eml", $mime, $size, true, false);
|
||||||
print '<pre>' . htmlspecialchars($message, ENT_NOQUOTES | ENT_SUBSTITUTE, 'utf-8') . '</pre>';
|
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
|
||||||
*
|
*
|
||||||
@ -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();
|
||||||
|
@ -1109,7 +1109,7 @@ app.classes.mail = AppJS.extend(
|
|||||||
{
|
{
|
||||||
id: 'saveOneToVfs',
|
id: 'saveOneToVfs',
|
||||||
label: 'Save in Filemanager',
|
label: 'Save in Filemanager',
|
||||||
icon: 'filemanager/navbar.svg',
|
icon: 'filemanager/navbar',
|
||||||
value: 'saveOneToVfs'
|
value: 'saveOneToVfs'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1125,8 +1125,18 @@ 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';
|
||||||
@ -3132,6 +3142,31 @@ app.classes.mail = AppJS.extend(
|
|||||||
});
|
});
|
||||||
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