From 35dc435ab9f34a680238c7406567c1be6590df1f Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 20 Jan 2014 13:14:18 +0000 Subject: [PATCH] try to tackle problem encountered with mail2infolog/tracker --- infolog/inc/class.infolog_ui.inc.php | 10 +++++----- mail/inc/class.mail_bo.inc.php | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 1d0f5085e9..b4f406be2c 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -2410,12 +2410,12 @@ class infolog_ui //error_log(__METHOD__.__LINE__.array2string($attachment)); 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 // instead of fetching only the attachments attached files (as we did previously) - $message = $mailobject->getMessageRawBody($attachment['uid'],$attachment['partID']); - $headers = $mailobject->getMessageHeader($attachment['uid'],$attachment['partID'],true); + $message = $mailobject->getMessageRawBody($attachment['uid'],$attachment['partID'],($attachment['folder']?$attachment['folder']:$mailbox)); + $headers = $mailobject->getMessageHeader($attachment['uid'],$attachment['partID'],true,false,($attachment['folder']?$attachment['folder']:$mailbox)); $subject = str_replace('$$','__',($headers['SUBJECT']?$headers['SUBJECT']:lang('(no subject)'))); $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); $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) if ($GLOBALS['egw_info']['user']['preferences'][$sessionLocation]['saveAsOptions']==='add_raw') { - $message = $mailobject->getMessageRawBody($uid, $partid); - $headers = $mailobject->getMessageHeader($uid, $partid,true); + $message = $mailobject->getMessageRawBody($uid, $partid,$mailbox); + $headers = $mailobject->getMessageHeader($uid, $partid,true,false,$mailbox); $subject = str_replace('$$','__',($headers['SUBJECT']?$headers['SUBJECT']:lang('(no subject)'))); $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); $tmpfile = fopen($attachment_file,'w'); diff --git a/mail/inc/class.mail_bo.inc.php b/mail/inc/class.mail_bo.inc.php index a02b237bac..301268f619 100644 --- a/mail/inc/class.mail_bo.inc.php +++ b/mail/inc/class.mail_bo.inc.php @@ -3653,6 +3653,7 @@ class mail_bo * @param string $_partID=null , the partID, may be omitted * @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 string $_folder folder to work on * @return array containing the message body, mimeType and charset */ 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 * @param string/int $_uid the messageuid, * @param string/int $_partID='' , the partID, may be omitted + * @param string $_folder folder to work on * @return string the message body */ - function getMessageRawBody($_uid, $_partID = '') + function getMessageRawBody($_uid, $_partID = '', $_folder='') { //TODO: caching einbauen static! static $rawBody; if (is_null($rawBody)) $rawBody = array(); - - $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); + if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); 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"); @@ -4772,10 +4773,10 @@ class mail_bo static function get_mailcontent(&$mailClass,$uid,$partid='',$mailbox='', $preserveHTML = false, $addHeaderSection=true, $includeAttachments=true) { //echo __METHOD__." called for $uid,$partid
"; - $headers = $mailClass->getMessageHeader($uid,$partid,true); + $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox); if (empty($headers)) return false; // 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 ( !$preserveHTML && $bodyParts[0]['mimeType']=='text/html') {