take care that winmail.dat attachments are only resolved by tnef (if available) if required (e.g.:the message is opened)

This commit is contained in:
Klaus Leithoff 2011-07-19 10:07:26 +00:00
parent 9a7b0dfd7b
commit 769e60d51f
2 changed files with 28 additions and 7 deletions

View File

@ -480,8 +480,10 @@
function decode_winmail( $_uid, $_partID, $_filenumber=0 )
{
$attachment = $this->getAttachment( $_uid, $_partID );
$dir = $GLOBALS['egw_info']['server']['temp_dir']."/fmail_winmail/$_uid";
$dirname = $this->accountid.'_'.$this->profileID.'_'.$this->sessionData['mailbox'].'_'.$_uid.'_'.$_partID;
if (self::$debug) error_log(__METHOD__.__LINE__.' Dirname:'.$dirname);
$dirname = md5($dirname);
$dir = $GLOBALS['egw_info']['server']['temp_dir']."/fmail_winmail/$dirname";
$mime = CreateObject('phpgwapi.mime_magic');
if ( $attachment['type'] == 'APPLICATION/MS-TNEF' && $attachment['filename'] == 'winmail.dat' )
{
@ -2243,7 +2245,7 @@
return $this->mailPreferences;
}
function getMessageAttachments($_uid, $_partID='', $_structure='')
function getMessageAttachments($_uid, $_partID='', $_structure='', $resolveTNEF=true)
{
if (self::$debug) echo __METHOD__."$_uid, $_partID<br>";
@ -2275,7 +2277,7 @@
$newAttachment['cid'] = $structure->cid;
}
# if the new attachment is a winmail.dat, we have to decode that first
if ( $newAttachment['name'] == 'winmail.dat' &&
if ( $resolveTNEF && $newAttachment['name'] == 'winmail.dat' &&
( $wmattachments = $this->decode_winmail( $_uid, $newAttachment['partID'] ) ) )
{
$attachments = array_merge( $attachments, $wmattachments );
@ -2307,7 +2309,7 @@
{
if ($subPart->type == 'MULTIPART' && $subPart->subType == 'ALTERNATIVE')
{
$attachments = array_merge($this->getMessageAttachments($_uid, '', $subPart), $attachments);
$attachments = array_merge($this->getMessageAttachments($_uid, '', $subPart, $resolveTNEF), $attachments);
}
if (!($subPart->type=='TEXT' && $subPart->disposition =='INLINE' && $subPart->filename)) continue;
}
@ -2319,7 +2321,7 @@
$subPart->subType == 'SIGNED' ||
$subPart->subType == 'APPLEDOUBLE'))
{
$attachments = array_merge($this->getMessageAttachments($_uid, '', $subPart), $attachments);
$attachments = array_merge($this->getMessageAttachments($_uid, '', $subPart, $resolveTNEF), $attachments);
} else {
$newAttachment = array();
$newAttachment['name'] = self::getFileNameFromStructure($subPart);
@ -2334,7 +2336,7 @@
$newAttachment['cid'] = $subPart->cid;
}
# if the new attachment is a winmail.dat, we have to decode that first
if ( $newAttachment['name'] == 'winmail.dat' &&
if ( $resolveTNEF && $newAttachment['name'] == 'winmail.dat' &&
( $wmattachments = $this->decode_winmail( $_uid, $newAttachment['partID'] ) ) )
{
$attachments = array_merge( $attachments, $wmattachments );

View File

@ -377,6 +377,18 @@ class uiwidgets
substr($header['mimetype'],0,11) == 'application' ||
substr($header['mimetype'],0,5) == 'audio') {
$image = html::image('felamimail','attach');
if (//$header['mimetype'] != 'multipart/mixed' &&
$header['mimetype'] != 'multipart/signed'
)
{
if ($this->bofelamimail->icServer->_connected != 1)
{
$this->bofelamimail->openConnection(0); // connect to the current server
$this->bofelamimail->reopen($_folderName);
}
$attachments = $this->bofelamimail->getMessageAttachments($header['uid'],'','',$resolveTNEF=false);
if (count($attachments)<1) $image = '&nbsp;';
}
$this->t->set_var('attachment_image', $image);
} else {
$this->t->set_var('attachment_image', '&nbsp;');
@ -683,6 +695,13 @@ class uiwidgets
$image = "<a name=\"subject_url\" href=\"#\"
onclick=\"fm_readAttachments('".$GLOBALS['egw']->link('/index.php',$linkDataAttachments)."', '".$windowName."', this); return false;\"
title=\"".$headerData['subject']."\">".$image."</a>";
if (//$headerData['mimetype'] != 'multipart/mixed' &&
$header['mimetype'] != 'multipart/signed'
)
{
$attachments = $this->bofelamimail->getMessageAttachments($headerData['uid'],'','',$resolveTNEF=false);
if (count($attachments)<1) $image = '&nbsp;';
}
$windowName = ($_readInNewWindow == 1 ? 'displayMessage' : 'displayMessage_'.$header['uid']);
} else {