try to tackle problem encountered with mail2infolog/tracker

This commit is contained in:
Klaus Leithoff 2014-01-20 13:14:18 +00:00
parent 546fb77abb
commit 35dc435ab9
2 changed files with 11 additions and 10 deletions

View File

@ -2410,12 +2410,12 @@ class infolog_ui
//error_log(__METHOD__.__LINE__.array2string($attachment)); //error_log(__METHOD__.__LINE__.array2string($attachment));
if (trim(strtoupper($attachment['type'])) == 'MESSAGE/RFC822' && !empty($attachment['uid']) && !empty($attachment['folder'])) if (trim(strtoupper($attachment['type'])) == 'MESSAGE/RFC822' && !empty($attachment['uid']) && !empty($attachment['folder']))
{ {
$mailobject->reopen($attachment['folder']); $mailobject->reopen(($attachment['folder']?$attachment['folder']:$mailbox));
// get the message itself, and attach it, as we are able to display it in egw // get the message itself, and attach it, as we are able to display it in egw
// instead of fetching only the attachments attached files (as we did previously) // instead of fetching only the attachments attached files (as we did previously)
$message = $mailobject->getMessageRawBody($attachment['uid'],$attachment['partID']); $message = $mailobject->getMessageRawBody($attachment['uid'],$attachment['partID'],($attachment['folder']?$attachment['folder']:$mailbox));
$headers = $mailobject->getMessageHeader($attachment['uid'],$attachment['partID'],true); $headers = $mailobject->getMessageHeader($attachment['uid'],$attachment['partID'],true,false,($attachment['folder']?$attachment['folder']:$mailbox));
$subject = str_replace('$$','__',($headers['SUBJECT']?$headers['SUBJECT']:lang('(no subject)'))); $subject = str_replace('$$','__',($headers['SUBJECT']?$headers['SUBJECT']:lang('(no subject)')));
$attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
$tmpfile = fopen($attachment_file,'w'); $tmpfile = fopen($attachment_file,'w');
@ -2501,8 +2501,8 @@ class infolog_ui
// this is done to have a simple archive functionality (ToDo: opening .eml in email module) // this is done to have a simple archive functionality (ToDo: opening .eml in email module)
if ($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='add_raw') if ($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='add_raw')
{ {
$message = $mailobject->getMessageRawBody($uid, $partid); $message = $mailobject->getMessageRawBody($uid, $partid,$mailbox);
$headers = $mailobject->getMessageHeader($uid, $partid,true); $headers = $mailobject->getMessageHeader($uid, $partid,true,false,$mailbox);
$subject = str_replace('$$','__',($headers['SUBJECT']?$headers['SUBJECT']:lang('(no subject)'))); $subject = str_replace('$$','__',($headers['SUBJECT']?$headers['SUBJECT']:lang('(no subject)')));
$attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
$tmpfile = fopen($attachment_file,'w'); $tmpfile = fopen($attachment_file,'w');

View File

@ -3653,6 +3653,7 @@ class mail_bo
* @param string $_partID=null , the partID, may be omitted * @param string $_partID=null , the partID, may be omitted
* @param Horde_Mime_Part $_structure=null if given use structure for parsing * @param Horde_Mime_Part $_structure=null if given use structure for parsing
* @param boolean $_preserveSeen flag to preserve the seenflag by using body.peek * @param boolean $_preserveSeen flag to preserve the seenflag by using body.peek
* @param string $_folder folder to work on
* @return array containing the message body, mimeType and charset * @return array containing the message body, mimeType and charset
*/ */
function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '') function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '')
@ -4250,15 +4251,15 @@ class mail_bo
* get the message raw body * get the message raw body
* @param string/int $_uid the messageuid, * @param string/int $_uid the messageuid,
* @param string/int $_partID='' , the partID, may be omitted * @param string/int $_partID='' , the partID, may be omitted
* @param string $_folder folder to work on
* @return string the message body * @return string the message body
*/ */
function getMessageRawBody($_uid, $_partID = '') function getMessageRawBody($_uid, $_partID = '', $_folder='')
{ {
//TODO: caching einbauen static! //TODO: caching einbauen static!
static $rawBody; static $rawBody;
if (is_null($rawBody)) $rawBody = array(); if (is_null($rawBody)) $rawBody = array();
if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
$_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox());
if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]))
{ {
//error_log(__METHOD__.__LINE__." Using Cache for raw Body $_uid, $_partID in Folder $_folder"); //error_log(__METHOD__.__LINE__." Using Cache for raw Body $_uid, $_partID in Folder $_folder");
@ -4772,10 +4773,10 @@ class mail_bo
static function get_mailcontent(&$mailClass,$uid,$partid='',$mailbox='', $preserveHTML = false, $addHeaderSection=true, $includeAttachments=true) static function get_mailcontent(&$mailClass,$uid,$partid='',$mailbox='', $preserveHTML = false, $addHeaderSection=true, $includeAttachments=true)
{ {
//echo __METHOD__." called for $uid,$partid <br>"; //echo __METHOD__." called for $uid,$partid <br>";
$headers = $mailClass->getMessageHeader($uid,$partid,true); $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox);
if (empty($headers)) return false; if (empty($headers)) return false;
// dont force retrieval of the textpart, let mailClass preferences decide // dont force retrieval of the textpart, let mailClass preferences decide
$bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid); $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox);
// if we do not want HTML but there is no TextRepresentation with the message itself, try converting // if we do not want HTML but there is no TextRepresentation with the message itself, try converting
if ( !$preserveHTML && $bodyParts[0]['mimeType']=='text/html') if ( !$preserveHTML && $bodyParts[0]['mimeType']=='text/html')
{ {