Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x

This commit is contained in:
Sarven Capadisli 2009-07-20 23:12:13 +00:00
commit d20d1a4823

View File

@ -299,25 +299,37 @@ class MailerDaemon
$attachments = array();
$this->extract_part($parsed,$msg,$attachments);
return array($from, $to, $msg, $attachments);
}
function extract_part($parsed,&$msg,&$attachments){
if ($parsed->ctype_primary == 'multipart') {
foreach ($parsed->parts as $part) {
if ($part->ctype_primary == 'text' &&
$part->ctype_secondary == 'plain') {
$msg = $part->body;
if($parsed->ctype_secondary == 'alternative'){
$altmsg = $this->extract_msg_from_multipart_alternative_part($parsed);
if(!empty($altmsg)) $msg = $altmsg;
}else{
if ($part->body) {
foreach($parsed->parts as $part){
$this->extract_part($part,$msg,$attachments);
}
}
} else if ($parsed->ctype_primary == 'text'
&& $parsed->ctype_secondary=='plain') {
$msg = $parsed->body;
}else if(!empty($parsed->body)){
$attachment = tmpfile();
fwrite($attachment, $part->body);
fwrite($attachment, $parsed->body);
$attachments[] = $attachment;
}
}
function extract_msg_from_multipart_alternative_part($parsed){
foreach ($parsed->parts as $part) {
$this->extract_part($part,$msg,$attachments);
}
} else if ($type == 'text/plain') {
$msg = $parsed->body;
} else {
$this->unsupported_type($type);
}
return array($from, $to, $msg, $attachments);
//we don't want any attachments that are a result of this parsing
return $msg;
}
function unsupported_type($type)