mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 01:13:25 +01:00
add helperfunction to normalize bodyParts structure (as of problems with reply on mails with MULTIPART/RELATED with array as subparts)
This commit is contained in:
parent
aab5e27530
commit
e542243d30
@ -330,7 +330,7 @@
|
||||
$searchfor = '/^\['.lang('printview').':\]/';
|
||||
$this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']);
|
||||
$bodyParts = $bofelamimail->getMessageBody($_uid, $this->preferencesArray['always_display'], $_partID);
|
||||
#_debug_array($bodyParts);
|
||||
//_debug_array($bodyParts);
|
||||
|
||||
#$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL'];
|
||||
if($bodyParts['0']['mimeType'] == 'text/html') {
|
||||
@ -435,15 +435,27 @@
|
||||
$this->saveSessionData();
|
||||
}
|
||||
|
||||
/**
|
||||
* getRandomString - function to be used to fetch a random string and md5 encode that one
|
||||
* @param none
|
||||
* @returns string - a random number which is md5 encoded
|
||||
*/
|
||||
function getRandomString() {
|
||||
mt_srand((float) microtime() * 1000000);
|
||||
return md5(mt_rand (100000, 999999));
|
||||
}
|
||||
|
||||
// $_mode can be:
|
||||
// single: for a reply to one address
|
||||
// all: for a reply to all
|
||||
// forward: inlineforwarding of a message with its attachments
|
||||
/**
|
||||
* getReplyData - function to gather the replyData and save it with the session, to be used then.
|
||||
* @param $_mode can be:
|
||||
* single: for a reply to one address
|
||||
* all: for a reply to all
|
||||
* forward: inlineforwarding of a message with its attachments
|
||||
* @param $_icServer number (0 as it is the active Profile)
|
||||
* @param $_folder string
|
||||
* @param $_uid number
|
||||
* @param $_partID number
|
||||
*/
|
||||
function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID)
|
||||
{
|
||||
$foundAddresses = array();
|
||||
|
@ -2310,21 +2310,21 @@
|
||||
case 'MULTIPART':
|
||||
switch($structure->subType) {
|
||||
case 'ALTERNATIVE':
|
||||
return array($this->getMultipartAlternative($_uid, $structure->subParts, $this->htmlOptions));
|
||||
$bodyParts = array($this->getMultipartAlternative($_uid, $structure->subParts, $this->htmlOptions));
|
||||
|
||||
break;
|
||||
|
||||
case 'MIXED':
|
||||
case 'REPORT':
|
||||
case 'SIGNED':
|
||||
return $this->getMultipartMixed($_uid, $structure->subParts, $this->htmlOptions);
|
||||
$bodyParts = $this->getMultipartMixed($_uid, $structure->subParts, $this->htmlOptions);
|
||||
break;
|
||||
|
||||
case 'RELATED':
|
||||
return $this->getMultipartRelated($_uid, $structure->subParts, $this->htmlOptions);
|
||||
$bodyParts = $this->getMultipartRelated($_uid, $structure->subParts, $this->htmlOptions);
|
||||
break;
|
||||
}
|
||||
|
||||
return self::normalizeBodyParts($bodyParts);
|
||||
break;
|
||||
case 'AUDIO': // some servers send audiofiles and imagesfiles directly, without any stuff surround it
|
||||
case 'IMAGE': // they are displayed as Attachment NOT INLINE
|
||||
@ -2353,13 +2353,13 @@
|
||||
} else {
|
||||
// what if the structure->disposition is attachment ,...
|
||||
}
|
||||
return $bodyPart;
|
||||
return self::normalizeBodyParts($bodyPart);
|
||||
break;
|
||||
case 'MESSAGE':
|
||||
switch($structure->subType) {
|
||||
case 'RFC822':
|
||||
$newStructure = array_shift($structure->subParts);
|
||||
return $this->getMessageBody($_uid, $_htmlOptions, $newStructure->partID, $newStructure);
|
||||
return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure->partID, $newStructure));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -2375,6 +2375,32 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* normalizeBodyParts - function to gather and normalize all body Information
|
||||
* @param _bodyParts - Body Array
|
||||
* @returns array - a normalized Bodyarray
|
||||
*/
|
||||
static function normalizeBodyParts($_bodyParts)
|
||||
{
|
||||
if (is_array($_bodyParts))
|
||||
{
|
||||
foreach($_bodyParts as $singleBodyPart)
|
||||
{
|
||||
if (!isset($singleBodyPart['body'])) {
|
||||
$buff = self::normalizeBodyParts($singleBodyPart);
|
||||
foreach ($buff as $val) $body2return[] = $val;
|
||||
continue;
|
||||
}
|
||||
$body2return[] = $singleBodyPart;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$body2return = $_bodyParts;
|
||||
}
|
||||
return $body2return;
|
||||
}
|
||||
|
||||
function getMessageHeader($_uid, $_partID = '',$decode=false)
|
||||
{
|
||||
$retValue = $this->icServer->getParsedHeaders($_uid, true, $_partID, true);
|
||||
|
Loading…
Reference in New Issue
Block a user