handle message/rfc822 attachments as display when opened from drafted message; properly restore message/rfc822 attachments stored with .eml files

This commit is contained in:
Klaus Leithoff 2014-07-15 07:03:23 +00:00
parent 596d81bb2c
commit 719ede5829
3 changed files with 38 additions and 15 deletions

View File

@ -6023,7 +6023,7 @@ class emailadmin_imapbase
* parseRawMessageIntoMailObject - parses a message/rfc mail from file to the mailobject and returns the header and body via reference * parseRawMessageIntoMailObject - parses a message/rfc mail from file to the mailobject and returns the header and body via reference
* throws egw_exception_assertion_failed when the required Pear Class is not found/loadable * throws egw_exception_assertion_failed when the required Pear Class is not found/loadable
* @param object $mailObject instance of the SMTP Mailer Object * @param object $mailObject instance of the SMTP Mailer Object
* @param string $message string containing the RawMessage * @param mixed string/object $message string containing the RawMessage / object Mail_mimeDecoded message (part))
* @param string &$Header reference used to return the imported Mailheader * @param string &$Header reference used to return the imported Mailheader
* @param string &$Body reference to return the imported Body * @param string &$Body reference to return the imported Body
* @return void Mailheader and body is returned via Reference in $Header $Body * @return void Mailheader and body is returned via Reference in $Header $Body
@ -6038,8 +6038,15 @@ class emailadmin_imapbase
//echo '<pre>'.$message.'</pre>'; //echo '<pre>'.$message.'</pre>';
//error_log(__METHOD__.' ('.__LINE__.') '.$message); //error_log(__METHOD__.' ('.__LINE__.') '.$message);
if (class_exists('Mail_mimeDecode',false)==false && (@include_once 'Mail/mimeDecode.php') === false) throw new egw_exception_assertion_failed(lang('Required PEAR class Mail/mimeDecode.php not found.')); if (class_exists('Mail_mimeDecode',false)==false && (@include_once 'Mail/mimeDecode.php') === false) throw new egw_exception_assertion_failed(lang('Required PEAR class Mail/mimeDecode.php not found.'));
if (is_string($message))
{
$mailDecode = new Mail_mimeDecode($message); $mailDecode = new Mail_mimeDecode($message);
$structure = $mailDecode->decode(array('include_bodies'=>true,'decode_bodies'=>true,'decode_headers'=>true)); $structure = $mailDecode->decode(array('include_bodies'=>true,'decode_bodies'=>true,'decode_headers'=>true));
}
if (is_object($message))
{
$structure = $message;
}
//error_log(__METHOD__.' ('.__LINE__.') '.array2string($structure)); //error_log(__METHOD__.' ('.__LINE__.') '.array2string($structure));
//_debug_array($structure); //_debug_array($structure);
//exit; //exit;
@ -6272,8 +6279,8 @@ class emailadmin_imapbase
//error_log( __METHOD__.' ('.__LINE__.') '." Recursion to fetch subparts:".$part->ctype_primary.'/'.$part->ctype_secondary); //error_log( __METHOD__.' ('.__LINE__.') '." Recursion to fetch subparts:".$part->ctype_primary.'/'.$part->ctype_secondary);
$this->createBodyFromStructure($mailObject, $part, $parenttype=null, $decode); $this->createBodyFromStructure($mailObject, $part, $parenttype=null, $decode);
} }
//error_log(__METHOD__.' ('.__LINE__.') '.$structure->ctype_primary.'/'.$structure->ctype_secondary.' => '.$part->ctype_primary.'/'.$part->ctype_secondary.' Part:'.array2string($part)); //error_log(__METHOD__.' ('.__LINE__.') '.$structure->ctype_primary.'/'.$structure->ctype_secondary.' => '.$part->ctype_primary.'/'.$part->ctype_secondary.' Part:'.array2string($part->body));
if ($part->body && ((strtolower($structure->ctype_secondary)=='mixed' && strtolower($part->ctype_primary)!='multipart') || if (($part->body||strtolower($part->ctype_primary.'/'.$part->ctype_secondary)=="message/rfc822") && ((strtolower($structure->ctype_secondary)=='mixed' && strtolower($part->ctype_primary)!='multipart') ||
trim(strtolower($part->disposition)) == 'attachment' || trim(strtolower($part->disposition)) == 'attachment' ||
trim(strtolower($part->disposition)) == 'inline' || trim(strtolower($part->disposition)) == 'inline' ||
isset($part->headers['content-id']))) isset($part->headers['content-id'])))
@ -6347,7 +6354,20 @@ class emailadmin_imapbase
} }
else else
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.' Add String '.($part->disposition=='attachment'?'Attachment':'Part').' of type:'.$part->ctype_primary.'/'.$part->ctype_secondary); //error_log(__METHOD__.' ('.__LINE__.') '.' Add String '.($part->disposition=='attachment'?'Attachment':'Part').' of type:'.$part->ctype_primary.'/'.$part->ctype_secondary.array2string($part->parts));
if (strtolower($part->ctype_primary.'/'.$part->ctype_secondary)=="message/rfc822")
{
$localMailObject = new egw_mailer();
$this->parseRawMessageIntoMailObject($localMailObject,$part->parts[0],$_Header,$_Body);
//error_log(__METHOD__.__LINE__.$_Header.$localMailObject->LE.$localMailObject->LE.$_Body);
$mailObject->AddStringAttachment($_Header.$localMailObject->LE.$localMailObject->LE.$_Body,
$filename,
($part->headers['content-transfer-encoding']?$part->headers['content-transfer-encoding']:'base64'),
$part->ctype_primary.'/'.$part->ctype_secondary
);
}
else
{
$mailObject->AddStringAttachment($part->body, //($part->headers['content-transfer-encoding']?base64_decode($part->body):$part->body), $mailObject->AddStringAttachment($part->body, //($part->headers['content-transfer-encoding']?base64_decode($part->body):$part->body),
$filename, $filename,
($part->headers['content-transfer-encoding']?$part->headers['content-transfer-encoding']:'base64'), ($part->headers['content-transfer-encoding']?$part->headers['content-transfer-encoding']:'base64'),
@ -6355,6 +6375,7 @@ class emailadmin_imapbase
); );
} }
} }
}
if (!(trim(strtolower($part->disposition))=='attachment' || trim(strtolower($part->disposition)) == 'inline' || isset($part->headers['content-id'])) && $partFetched==false) if (!(trim(strtolower($part->disposition))=='attachment' || trim(strtolower($part->disposition)) == 'inline' || isset($part->headers['content-id'])) && $partFetched==false)
{ {
//error_log(__METHOD__.' ('.__LINE__.') '.' Add String '.($part->disposition=='attachment'?'Attachment':'Part').' of type:'.$part->ctype_primary.'/'.$part->ctype_secondary.' Body:'.$part->body); //error_log(__METHOD__.' ('.__LINE__.') '.' Add String '.($part->disposition=='attachment'?'Attachment':'Part').' of type:'.$part->ctype_primary.'/'.$part->ctype_secondary.' Body:'.$part->body);

View File

@ -455,10 +455,10 @@ class mail_ui
//$content[self::$nm_index]['path'] = self::get_home_dir(); //$content[self::$nm_index]['path'] = self::get_home_dir();
} }
} }
else if ($content['mailPreview']['mailPreviewHeadersAttachments']['previewAttachmentArea'][0]['save_zip']) // else if ($content['mailPreview']['mailPreviewHeadersAttachments']['previewAttachmentArea'][0]['save_zip'])
{ // {
$this->download_zip(current($content[self::$nm_index]['selected'])); // $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,'.($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]['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; $content[self::$nm_index]['csv_fields'] = false;
@ -2100,10 +2100,10 @@ class mail_ui
$rowID = $_requesteddata['id']; $rowID = $_requesteddata['id'];
//unset($_REQUEST); //unset($_REQUEST);
} }
if($_requesteddata['mail_displayattachments'][0]['save_zip']) // if($_requesteddata['mail_displayattachments'][0]['save_zip'])
{ // {
$this->download_zip($_requesteddata['mail_id']); // $this->download_zip($_requesteddata['mail_id']);
} // }
$preventRedirect=false; $preventRedirect=false;
if(isset($_GET['id'])) $rowID = $_GET['id']; if(isset($_GET['id'])) $rowID = $_GET['id'];
if(isset($_GET['part'])) $partID = $_GET['part']; if(isset($_GET['part'])) $partID = $_GET['part'];
@ -2279,6 +2279,7 @@ class mail_ui
$linkData = array $linkData = array
( (
'menuaction' => 'mail.mail_ui.displayMessage', 'menuaction' => 'mail.mail_ui.displayMessage',
//'mode' => 'display', //message/rfc822 attachments should be opened in display mode
'id' => $rowID, 'id' => $rowID,
'part' => $value['partID'], 'part' => $value['partID'],
'is_winmail' => $value['is_winmail'] 'is_winmail' => $value['is_winmail']

View File

@ -2012,6 +2012,7 @@ app.classes.mail = AppJS.extend(
{ {
case 'MESSAGE/RFC822': case 'MESSAGE/RFC822':
url += 'menuaction=mail.mail_ui.displayMessage'; // todo compose for Draft folder url += 'menuaction=mail.mail_ui.displayMessage'; // todo compose for Draft folder
url += '&mode=display';//message/rfc822 attachments should be opened in display mode
url += '&id='+mailid; url += '&id='+mailid;
url += '&part='+attgrid.partID; url += '&part='+attgrid.partID;
url += '&is_winmail='+attgrid.winmailFlag; url += '&is_winmail='+attgrid.winmailFlag;