mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
Add save all attachments as zip to mail preview
This commit is contained in:
parent
f2dec7deac
commit
ed6d15098a
@ -453,6 +453,10 @@ class mail_ui
|
||||
//$content[self::$nm_index]['path'] = self::get_home_dir();
|
||||
}
|
||||
}
|
||||
else if ($content['mailPreview']['mailPreviewHeadersAttachments']['previewAttachmentArea'][0]['save_zip'])
|
||||
{
|
||||
$this->download_zip(current($content[self::$nm_index]['selected']));
|
||||
}
|
||||
//$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,'.($toSchema?'toaddress':'fromaddress').',date,size'; // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
|
||||
$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
|
||||
$content[self::$nm_index]['csv_fields'] = false;
|
||||
@ -2818,6 +2822,53 @@ class mail_ui
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Zip all attachments and send to user
|
||||
* @param string $message_id
|
||||
*/
|
||||
function download_zip($message_id)
|
||||
{
|
||||
// First, get all attachment IDs
|
||||
$attachments = $this->mail_bo->getMessageAttachments($message_id);
|
||||
|
||||
// put them in VFS so they can be zipped
|
||||
$header = $this->mail_bo->getMessageHeader($message_id);
|
||||
$temp_path = egw_vfs::get_home_dir() . "/.mail_$message_id";
|
||||
if(egw_vfs::is_dir($temp_path)) egw_vfs::remove ($temp_path);
|
||||
|
||||
// Add subject to path, so it gets used as the file name
|
||||
$path = $temp_path . '/' . ($header['SUBJECT'] ? egw_vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/';
|
||||
if(!egw_vfs::mkdir($path, 0700, true))
|
||||
{
|
||||
egw_framework::message("Unable to open temp directory $path",'error');
|
||||
return;
|
||||
}
|
||||
|
||||
$file_list = array();
|
||||
foreach($attachments as $file)
|
||||
{
|
||||
$this->mail_bo->reopen($this->mail_bo->sessionData['mailbox']);
|
||||
$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false);
|
||||
|
||||
if (!($fp = egw_vfs::fopen($path.$file['filename'],'wb')) ||
|
||||
!fwrite($fp,$attachment['attachment']))
|
||||
{
|
||||
egw_framework::message("Unable to zip {$file['filename']}",'error');
|
||||
}
|
||||
$file_list[] = $path.$file['filename'];
|
||||
if ($fp) fclose($fp);
|
||||
}
|
||||
$this->mail_bo->closeConnection();
|
||||
|
||||
// Zip it up
|
||||
egw_vfs::download_zip($file_list);
|
||||
|
||||
// Clean up
|
||||
egw_vfs::remove($temp_path);
|
||||
|
||||
common::egw_exit();
|
||||
}
|
||||
|
||||
function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null)
|
||||
{
|
||||
// seems to be needed, as if we open a mail from notification popup that is
|
||||
|
@ -102,6 +102,7 @@
|
||||
<buttononly id="${row}[save]" value="save" image="fileexport" onclick="app.mail.saveAttachment"/>
|
||||
<buttononly id="${row}[saveAsVFS]" value="save" image="filemanager/navbar" onclick="app.mail.saveAttachmentToVFS"/>
|
||||
<buttononly class="$row_cont[classSaveAllPossiblyDisabled]" id="${row}[save_all]" value="save_all" image="mail/save_all" onclick="app.mail.saveAllAttachmentsToVFS"/>
|
||||
<buttononly class="$row_cont[classSaveAllPossiblyDisabled]" id="${row}[save_zip]" value="save_zip" image="mail/save_all" onclick="widget.getInstanceManager().postSubmit();" label="Save as Zip/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
Loading…
Reference in New Issue
Block a user