[Vtigercrm-commits] [vtiger-commits] r6570 - in /vtigercrm/trunk/modules/Webmails: ListView.php MailParse.php Webmail.php body.php webmails.js
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Sat May 27 22:20:45 EDT 2006
Author: mmbrich
Date: Sat May 27 20:20:42 2006
New Revision: 6570
Log:
misc cleanups of old code, better attachment checking and quicker loading
Modified:
vtigercrm/trunk/modules/Webmails/ListView.php
vtigercrm/trunk/modules/Webmails/MailParse.php
vtigercrm/trunk/modules/Webmails/Webmail.php
vtigercrm/trunk/modules/Webmails/body.php
vtigercrm/trunk/modules/Webmails/webmails.js
Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Sat May 27 20:20:42 2006
@@ -167,7 +167,7 @@
$flags = "<tr id='row_".$num."'><td><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
// Attachment Icons
- if(getAttachments($num,$mbox) || getInlineAttachments($num,$mbox))
+ if(getAttachments($num,$mbox))
$flags.='<a href="javascript:;" onclick="displayAttachments('.$num.');"><img src="modules/Webmails/images/stock_attach.png" border="0" width="14px" height="14"></a> ';
else
$flags.='<img src="modules/Webmails/images/blank.png" border="0" width="14px" height="14" alt=""> ';
Modified: vtigercrm/trunk/modules/Webmails/MailParse.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/MailParse.php (original)
+++ vtigercrm/trunk/modules/Webmails/MailParse.php Sat May 27 20:20:42 2006
@@ -52,64 +52,17 @@
}
return $mbox;
}
-function getInlineAttachments($mailid,$mbox) {
- $struct = imap_fetchstructure($mbox, $mailid);
- $parts = $struct->parts;
-
- $done="false";
- $i = 0;
- if (!$parts)
- return;
- else {
- $stack = array(); /* Stack while parsing message */
- $content = ""; /* Content of message */
- $attachment = array(); /* Attachments */
- $endwhile = false;
- while (!$endwhile) {
- if (!$parts[$i]) {
- if (count($stack) > 0) {
- $parts = $stack[count($stack)-1]["p"];
- $i = $stack[count($stack)-1]["i"] + 1;
- array_pop($stack);
- } else {
- $endwhile = true;
- }
- }
- if (!$endwhile) {
- /* Create message part first (example '1.2.3') */
- $partstring = "";
- foreach ($stack as $s) {
- $partstring .= ($s["i"]+1) . ".";
- }
- $partstring .= ($i+1);
- if (strtoupper($parts[$i]->disposition) == "INLINE" && strtoupper($parts[$i]->subtype) != "PLAIN")
- $attachment[] = array("filename" => $parts[$i]->dparameters[0]->value, "filedata" => imap_fetchbody($mbox, $mailid, $partstring),"ID"=> $parts[$i]->parts[0]);
- }
- if ($parts[$i]->parts) {
- $stack[] = array("p" => $parts, "i" => $i);
- $parts = $parts[$i]->parts;
- $i = 0;
- } else {
- $i++;
- }
- }
- }
- return $attachment;
-}
-
-function getAttachmentDetails($mailid,$mbox) {
+function getAttachments($mailid,$mbox) {
$struct = imap_fetchstructure($mbox, $mailid);
$parts = $struct->parts;
$done="false";
$i = 0;
if (!$parts)
- return;
- else {
-
- $stack = array(); /* Stack while parsing message */
- $content = ""; /* Content of message */
- $attachment = array(); /* Attachments */
+ return false; // simple message
+ else {
+ $stack = array();
+ $inline = array();
$endwhile = false;
@@ -123,18 +76,17 @@
$endwhile = true;
}
}
-
if (!$endwhile) {
- /* Create message part first (example '1.2.3') */
+
$partstring = "";
foreach ($stack as $s) {
$partstring .= ($s["i"]+1) . ".";
}
$partstring .= ($i+1);
- if (strtoupper($parts[$i]->disposition) == "ATTACHMENT")
- $attachment[] = array("filename" => $parts[$i]->dparameters[0]->value,"filesize"=>$parts[$i]->bytes);
- }
+ if (strtoupper($parts[$i]->disposition) == "INLINE" || strtoupper($parts[$i]->disposition) == "ATTACHMENT")
+ return true;
+ }
if ($parts[$i]->parts) {
$stack[] = array("p" => $parts, "i" => $i);
$parts = $parts[$i]->parts;
@@ -142,125 +94,8 @@
} else {
$i++;
}
- } /* while */
- } /* complicated message */
- return $attachment;
+ }
+ }
+ return false;
}
-
-function getAttachments($mailid,$mbox) {
- $struct = imap_fetchstructure($mbox, $mailid);
- $parts = $struct->parts;
-
- $done="false";
- $i = 0;
- if (!$parts)
- return;
- else {
-
- $stack = array(); /* Stack while parsing message */
- $content = ""; /* Content of message */
- $attachment = array(); /* Attachments */
-
- $endwhile = false;
-
- while (!$endwhile) {
- if (!$parts[$i]) {
- if (count($stack) > 0) {
- $parts = $stack[count($stack)-1]["p"];
- $i = $stack[count($stack)-1]["i"] + 1;
- array_pop($stack);
- } else {
- $endwhile = true;
- }
- }
-
- if (!$endwhile) {
- /* Create message part first (example '1.2.3') */
- $partstring = "";
- foreach ($stack as $s) {
- $partstring .= ($s["i"]+1) . ".";
- }
- $partstring .= ($i+1);
- if (strtoupper($parts[$i]->disposition) == "ATTACHMENT")
- $attachment[] = array("filename" => $parts[$i]->dparameters[0]->value,"filesize"=>$parts[$i]->bytes, "filedata" => imap_fetchbody($mbox, $mailid, $partstring));
- }
-
- if ($parts[$i]->parts) {
- $stack[] = array("p" => $parts, "i" => $i);
- $parts = $parts[$i]->parts;
- $i = 0;
- } else {
- $i++;
- }
- } /* while */
- } /* complicated message */
- return $attachment;
-}
-function getBody($mailid, $mbox) {
- $struct = imap_fetchstructure($mbox, $mailid);
- $parts = $struct->parts;
-
- $done="false";
- $i = 0;
- if (!$parts) { /* Simple message, only 1 piece */
- $attachment = array(); /* No attachments */
- $bod=imap_body($mbox, $mailid);
- if(preg_match("/\<br\>/",$bod))
- $content = $bod;
- else
- $content = nl2br($bod);
- return $content;
- } else { /* Complicated message, multiple parts */
-
- $stack = array(); /* Stack while parsing message */
- $content = ""; /* Content of message */
- $attachment = array(); /* Attachments */
-
- $endwhile = false;
-
- while (!$endwhile) {
- if (!$parts[$i]) {
- if (count($stack) > 0) {
- $parts = $stack[count($stack)-1]["p"];
- $i = $stack[count($stack)-1]["i"] + 1;
- array_pop($stack);
- } else {
- $endwhile = true;
- }
- }
-
- $search = array("/=20=/","/=20/","/=\r\n/","/=3D/","@&(<a|<A);@i","/=0A/i","/=A0/i");
- $replace = array("","","","=","<a target='_blank' ","");
- if (!$endwhile) {
- /* Create message part first (example '1.2.3') */
- $partstring = "";
- foreach ($stack as $s) {
- $partstring .= ($s["i"]+1) . ".";
- }
- $partstring .= ($i+1);
-
- $done='';
- if (strtoupper($parts[$i]->subtype) == "HTML") {
- $content = preg_replace($search,$replace,imap_fetchbody($mbox, $mailid, $partstring));
- return $content;
- } elseif (strtoupper($parts[$i]->subtype) == "TEXT" && $done != "html") {
- $content = nl2br(imap_fetchbody($mbox, $mailid, $partstring));
- $done="text";
- } elseif (strtoupper($parts[$i]->subtype) == "PLAIN" && $done != "html") {
- $content = nl2br(imap_fetchbody($mbox, $mailid, $partstring));
- $done="plain";
- }
- }
-
- if ($parts[$i]->parts) {
- $stack[] = array("p" => $parts, "i" => $i);
- $parts = $parts[$i]->parts;
- $i = 0;
- } else {
- $i++;
- }
- } /* while */
- } /* complicated message */
- return $content;
-}
-?>
+?>
Modified: vtigercrm/trunk/modules/Webmails/Webmail.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Webmail.php (original)
+++ vtigercrm/trunk/modules/Webmails/Webmail.php Sat May 27 20:20:42 2006
@@ -15,11 +15,11 @@
require_once('include/database/PearDatabase.php');
require_once('data/SugarBean.php');
require_once('data/CRMEntity.php');
-
+
class Webmail extends CRMEntity {
var $log;
var $db;
-
+
var $mailid;
var $to = array();
var $to_name = array();
@@ -39,98 +39,98 @@
var $mbox;
var $email;
var $relationship = array();
-
-
- function Webmail($mbox,$mailid) {
- $this->db = new PearDatabase();
- $this->mbox=$mbox;
- $this->mailid=$mailid;
-
- $headers = load_headers($this->mailid,$this->mbox);
- $this->to = $headers["header"]["to"];
- $this->to_name = $headers["header"]["to_name"];
-
- $this->from = $headers["header"]["from"];
- $this->fromname = $headers["header"]["from_name"];
- $this->fromaddr = $headers["header"]["fromaddr"];
-
- $this->reply_to = $headers["header"]["reply_to"];
- $this->reply_to_name = $headers["header"]["reply_to_name"];
-
- $this->cc_list = $headers["header"]["cc_list"];
- $this->cc_list_name = $headers["header"]["cc_list_name"];
-
- $this->subject = $headers["header"]["subject"];
- $this->date = $headers["header"]["date"];
-
- $this->relationship = find_relationships($this->db,ltrim(rtrim($this->from)));
- }
-
- function delete() {
- imap_delete($this->mbox, $this->mailid);
- }
-
- function loadMail() {
+
+
+ function Webmail($mbox,$mailid) {
+ $this->db = new PearDatabase();
+ $this->mbox=$mbox;
+ $this->mailid=$mailid;
+
+ $headers = load_headers($this->mailid,$this->mbox);
+ $this->to = $headers["header"]["to"];
+ $this->to_name = $headers["header"]["to_name"];
+
+ $this->from = $headers["header"]["from"];
+ $this->fromname = $headers["header"]["from_name"];
+ $this->fromaddr = $headers["header"]["fromaddr"];
+
+ $this->reply_to = $headers["header"]["reply_to"];
+ $this->reply_to_name = $headers["header"]["reply_to_name"];
+
+ $this->cc_list = $headers["header"]["cc_list"];
+ $this->cc_list_name = $headers["header"]["cc_list_name"];
+
+ $this->subject = $headers["header"]["subject"];
+ $this->date = $headers["header"]["date"];
+
+ $this->relationship = find_relationships($this->db,ltrim(rtrim($this->from)));
+ }
+
+ function delete() {
+ imap_delete($this->mbox, $this->mailid);
+ }
+
+ function loadMail() {
$this->email = load_mail($this->mailid,$this->mbox);
$this->inline = $this->email["inline"];
$this->attachments = $this->email["attachments"];
$this->body = $this->email["content"]["body"];
- }
-
- function unDeleteMsg() {
- imap_undelete($this->mbox, $this->mailid);
- }
-
- function setFlag() {
- $status=imap_setflag_full($this->mbox,$this->mailid,"\\Flagged");
- }
-
- function delFlag() {
- $status=imap_clearflag_full($this->mbox,$this->mailid,"\\Flagged");
- }
-
- function getBodyType() {
- return $this->body_type;
- }
-
- function downloadInlineAttachments() {
- return dl_inline($this->mailid,$this->mbox);
- }
-
- function downloadAttachments() {
- return dl_attachments($this->mailid,$this->mbox);
- }
-}
-function load_headers($mailid,$mbox) {
- // get the header info
- $mailHeader=Array();
- $header = @imap_headerinfo($mbox, $mailid);
- $tmp = imap_mime_header_decode($header->fromaddress);
-
- for($p=0;$p<count($header->to);$p++) {
- $mailHeader['to'][] = $header->to[$p]->mailbox.'@'.$header->to[$p]->host;
- $mailHeader['to_name'][] = $header->to[$p]->personal;
- }
- $mailHeader['from'] = $header->from[0]->mailbox.'@'.$header->from[0]->host;
- $mailHeader['from_name'] = $header->from[0]->personal;
- $mailHeader['fromaddr'] = $header->fromaddress;
-
- $mailHeader['subject'] = strip_tags($header->subject);
- $mailHeader['date'] = $header->date;
-
- for($p=0;$p<count($header->reply_to);$p++) {
- $mailHeader['reply_to'][] = $header->reply_to[$p]->mailbox.'@'.$header->reply_to[$p]->host;
- $mailHeader['reply_to_name'][] = $header->reply_to[$p]->personal;
- }
- for($p=0;$p<count($header->cc);$p++) {
- $mailHeader['cc_list'][] = $header->cc[$p]->mailbox.'@'.$header->cc[$p]->host;
- $mailHeader['cc_list_name'][] = $header->cc[$p]->personal;
- }
- return $ret = Array("header"=>$mailHeader);
-}
-function find_relationships($db,$from) {
-
- // leads search
+ }
+
+ function unDeleteMsg() {
+ imap_undelete($this->mbox, $this->mailid);
+ }
+
+ function setFlag() {
+ $status=imap_setflag_full($this->mbox,$this->mailid,"\\Flagged");
+ }
+
+ function delFlag() {
+ $status=imap_clearflag_full($this->mbox,$this->mailid,"\\Flagged");
+ }
+
+ function getBodyType() {
+ return $this->body_type;
+ }
+
+ function downloadInlineAttachments() {
+ return dl_inline($this->mailid,$this->mbox);
+ }
+
+ function downloadAttachments() {
+ return dl_attachments($this->mailid,$this->mbox);
+ }
+}
+function load_headers($mailid,$mbox) {
+ // get the header info
+ $mailHeader=Array();
+ $header = @imap_headerinfo($mbox, $mailid);
+ $tmp = imap_mime_header_decode($header->fromaddress);
+
+ for($p=0;$p<count($header->to);$p++) {
+ $mailHeader['to'][] = $header->to[$p]->mailbox.'@'.$header->to[$p]->host;
+ $mailHeader['to_name'][] = $header->to[$p]->personal;
+ }
+ $mailHeader['from'] = $header->from[0]->mailbox.'@'.$header->from[0]->host;
+ $mailHeader['from_name'] = $header->from[0]->personal;
+ $mailHeader['fromaddr'] = $header->fromaddress;
+
+ $mailHeader['subject'] = strip_tags($header->subject);
+ $mailHeader['date'] = $header->date;
+
+ for($p=0;$p<count($header->reply_to);$p++) {
+ $mailHeader['reply_to'][] = $header->reply_to[$p]->mailbox.'@'.$header->reply_to[$p]->host;
+ $mailHeader['reply_to_name'][] = $header->reply_to[$p]->personal;
+ }
+ for($p=0;$p<count($header->cc);$p++) {
+ $mailHeader['cc_list'][] = $header->cc[$p]->mailbox.'@'.$header->cc[$p]->host;
+ $mailHeader['cc_list_name'][] = $header->cc[$p]->personal;
+ }
+ return $ret = Array("header"=>$mailHeader);
+}
+function find_relationships($db,$from) {
+
+ // leads search
$sql = "SELECT * from leaddetails left join crmentity on crmentity.crmid=leaddetails.leadid where leaddetails.email = '".$from."' AND crmentity.deleted='0'";
$res = $db->query($sql,true,"Error: "."<BR>$query");
$numRows = $db->num_rows($res);
@@ -153,21 +153,21 @@
return 0;
}
-
-function dl_inline($mailid,$mbox) {
- $struct = imap_fetchstructure($mbox, $mailid);
- $parts = $struct->parts;
-
- $i = 0;
- if (!$parts)
- return;
- else {
-
- $stack = array();
- $inline = array();
-
- $endwhile = false;
-
+
+function dl_inline($mailid,$mbox) {
+ $struct = imap_fetchstructure($mbox, $mailid);
+ $parts = $struct->parts;
+
+ $i = 0;
+ if (!$parts)
+ return;
+ else {
+
+ $stack = array();
+ $inline = array();
+
+ $endwhile = false;
+
while (!$endwhile) {
if (!$parts[$i]) {
if (count($stack) > 0) {
@@ -187,20 +187,20 @@
$partstring .= ($i+1);
if (strtoupper($parts[$i]->disposition) == "INLINE")
- $inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring));
- }
- if ($parts[$i]->parts) {
- $stack[] = array("p" => $parts, "i" => $i);
- $parts = $parts[$i]->parts;
- $i = 0;
- } else {
- $i++;
- }
- }
+ $inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring),"subtype"=>$parts[$i]->subtype,"filesize"=>$parts[$i]->bytes);
+ }
+ if ($parts[$i]->parts) {
+ $stack[] = array("p" => $parts, "i" => $i);
+ $parts = $parts[$i]->parts;
+ $i = 0;
+ } else {
+ $i++;
+ }
+ }
}
return $inline;
}
-function dl_attachments($mailid,$mbox) {
+function dl_attachments($mailid,$mbox) {
$struct = imap_fetchstructure($mbox, $mailid);
$parts = $struct->parts;
@@ -215,116 +215,115 @@
$endwhile = false;
- while (!$endwhile) {
- if (!$parts[$i]) {
- if (count($stack) > 0) {
- $parts = $stack[count($stack)-1]["p"];
- $i = $stack[count($stack)-1]["i"] + 1;
- array_pop($stack);
- } else {
- $endwhile = true;
- }
- }
- if (!$endwhile) {
-
+ while (!$endwhile) {
+ if (!$parts[$i]) {
+ if (count($stack) > 0) {
+ $parts = $stack[count($stack)-1]["p"];
+ $i = $stack[count($stack)-1]["i"] + 1;
+ array_pop($stack);
+ } else {
+ $endwhile = true;
+ }
+ }
+ if (!$endwhile) {
+
+ $partstring = "";
+ foreach ($stack as $s) {
+ $partstring .= ($s["i"]+1) . ".";
+ }
+ $partstring .= ($i+1);
+
+ if (strtoupper($parts[$i]->disposition) == "ATTACHMENT")
+ $attachment[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring),"subtype"=>$parts[$i]->subtype,"filesize"=>$parts[$i]->bytes);
+ }
+ if ($parts[$i]->parts) {
+ $stack[] = array("p" => $parts, "i" => $i);
+ $parts = $parts[$i]->parts;
+ $i = 0;
+ } else {
+ $i++;
+ }
+ }
+ }
+ return $attachment;
+}
+function load_mail($mailid,$mbox) {
+
+ // parse the message
+ $struct = imap_fetchstructure($mbox, $mailid);
+ $parts = $struct->parts;
+
+ $content = array();
+ $i = 0;
+ if (!$parts) { /* Simple message, only 1 piece */
+ $attachment = array(); /* No attachments */
+ $bod=imap_body($mbox, $mailid);
+ if(preg_match("/\<br\>/",$bod))
+ $content['body'] = $bod;
+ else
+ $content['body'] = nl2br($bod);
+ } else {
+
+ $stack = array();
+ $attachment = array();
+
+ $endwhile = false;
+
+ while (!$endwhile) {
+ if (!$parts[$i]) {
+ if (count($stack) > 0) {
+ $parts = $stack[count($stack)-1]["p"];
+ $i = $stack[count($stack)-1]["i"] + 1;
+ array_pop($stack);
+ } else {
+ $endwhile = true;
+ }
+ }
+ $search = array("/=20=/","/=20/","/=\r\n/","/=3D/","@&(<a|<A);@i","/=0A/i","/=A0/i");
+ $replace = array("","","","=","<a target='_blank' ","");
+ if (!$endwhile) {
+
$partstring = "";
- foreach ($stack as $s) {
- $partstring .= ($s["i"]+1) . ".";
- }
- $partstring .= ($i+1);
-
- if (strtoupper($parts[$i]->disposition) == "ATTACHMENT")
- $attachment[] = array("filename" => $parts[$i]->parameters[0]->value,"filesize"=>$parts[$i]->bytes,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring));
- }
- if ($parts[$i]->parts) {
- $stack[] = array("p" => $parts, "i" => $i);
- $parts = $parts[$i]->parts;
- $i = 0;
- } else {
- $i++;
- }
- }
- }
- return $attachment;
-}
-function load_mail($mailid,$mbox) {
-
- // parse the message
- $struct = imap_fetchstructure($mbox, $mailid);
- $parts = $struct->parts;
-
- $content = array();
- $i = 0;
- if (!$parts) { /* Simple message, only 1 piece */
- $attachment = array(); /* No attachments */
- $bod=imap_body($mbox, $mailid);
- if(preg_match("/\<br\>/",$bod))
- $content['body'] = $bod;
- else
- $content['body'] = nl2br($bod);
- } else {
-
- $stack = array();
- $attachment = array();
-
- $endwhile = false;
-
- while (!$endwhile) {
- if (!$parts[$i]) {
- if (count($stack) > 0) {
- $parts = $stack[count($stack)-1]["p"];
- $i = $stack[count($stack)-1]["i"] + 1;
- array_pop($stack);
- } else {
- $endwhile = true;
- }
- }
- $search = array("/=20=/","/=20/","/=\r\n/","/=3D/","@&(<a|<A);@i","/=0A/i","/=A0/i");
- $replace = array("","","","=","<a target='_blank' ","");
- if (!$endwhile) {
-
- $partstring = "";
- foreach ($stack as $s) {
- $partstring .= ($s["i"]+1) . ".";
- }
- $partstring .= ($i+1);
-
- $type='';
+ foreach ($stack as $s) {
+ $partstring .= ($s["i"]+1) . ".";
+ }
+ $partstring .= ($i+1);
+
+ $type='';
if (strtoupper($parts[$i]->disposition) == "INLINE" && strtoupper($parts[$i]->subtype) != "PLAIN") {
- //$inline[] = array("filename" => $parts[$i]);
- $inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring),"subtype"=>$parts[$i]->subtype);
+ $inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"subtype"=>$parts[$i]->subtype,"filesize"=>$parts[$i]->bytes);
} elseif (strtoupper($parts[$i]->disposition) == "ATTACHMENT") {
- $attachment[] = array("filename" => $parts[$i]->parameters[0]->value,"filesize"=>$parts[$i]->bytes);
-
- } elseif (strtoupper($parts[$i]->subtype) == "HTML") {
- $content['body'] = preg_replace($search,$replace,imap_fetchbody($mbox, $mailid, $partstring));
- $stat="done";
- } elseif (strtoupper($parts[$i]->subtype) == "TEXT" && !$stat == "done") {
- $content['body'] = nl2br(imap_fetchbody($mbox, $mailid, $partstring));
- $stat="done";
- } elseif (strtoupper($parts[$i]->subtype) == "PLAIN" && !$stat == "done") {
- $content['body'] = nl2br(imap_fetchbody($mbox, $mailid, $partstring));
- $stat="done";
- } elseif (!$stat == "done") {
- $content['body'] = nl2br(imap_fetchbody($mbox, $mailid, $partstring));
- }
- }
-
- if ($parts[$i]->parts) {
- $stack[] = array("p" => $parts, "i" => $i);
- $parts = $parts[$i]->parts;
- $i = 0;
- } else {
- $i++;
- }
- }
- }
- if($struct->encoding==3)
- $content['body'] = base64_decode($content['body']);
- if($struct->encoding==4)
- $content['body'] = quoted_printable_decode($content['body']);
-
- $ret = Array("content" => $content,"attachments"=>$attachment,"inline"=>$inline);
- return $ret;
-}
-?>
+ $attachment[] = array("filename" => $parts[$i]->dparameters[0]->value,"subtype"=>$parts[$i]->subtype,"filesize"=>$parts[$i]->bytes);
+
+ } elseif (strtoupper($parts[$i]->subtype) == "HTML") {
+ $content['body'] = preg_replace($search,$replace,imap_fetchbody($mbox, $mailid, $partstring));
+ $stat="done";
+ } elseif (strtoupper($parts[$i]->subtype) == "TEXT" && !$stat == "done") {
+ $content['body'] = nl2br(imap_fetchbody($mbox, $mailid, $partstring));
+ $stat="done";
+ } elseif (strtoupper($parts[$i]->subtype) == "PLAIN" && !$stat == "done") {
+ $content['body'] = nl2br(imap_fetchbody($mbox, $mailid, $partstring));
+ $stat="done";
+ } elseif (!$stat == "done") {
+ $content['body'] = nl2br(imap_fetchbody($mbox, $mailid, $partstring));
+ }
+ }
+
+ if ($parts[$i]->parts) {
+ $stack[] = array("p" => $parts, "i" => $i);
+ $parts = $parts[$i]->parts;
+ $i = 0;
+ } else {
+ $i++;
+ }
+ }
+ }
+ if($struct->encoding==3)
+ $content['body'] = base64_decode($content['body']);
+ if($struct->encoding==4)
+ $content['body'] = quoted_printable_decode($content['body']);
+
+ $ret = Array("content" => $content,"attachments"=>$attachment,"inline"=>$inline);
+ return $ret;
+}
+?>
Modified: vtigercrm/trunk/modules/Webmails/body.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/body.php (original)
+++ vtigercrm/trunk/modules/Webmails/body.php Sat May 27 20:20:42 2006
@@ -59,18 +59,18 @@
echo $email->body;
echo "<br><br>";
if(is_array($email->inline)) {
- $inline = $email->inline;
+ $inline = $email->downloadInlineAttachments();
$num=sizeof($inline);
echo "<p style='border-bottom:1px solid black;font-weight:bold'>Inline Attachments:</p>";
for($i=0;$i<$num;$i++) {
//var_dump($inline[$i]);
// PLAIN TEXT
if($inline[$i]["subtype"] == "RFC822") {
- echo "<a href='javascript:show_inline(".$i.");'>".$inline[$i]["filename"]."</a><blockquote id='block_".$i."' style='border:1px solid gray;padding:6px;background-color:#FFFFCC;display:none'>";
+ echo ($i+1).") <a href='javascript:show_inline(".$i.");'>".$inline[$i]["filename"]."</a><blockquote id='block_".$i."' style='border:1px solid gray;padding:6px;background-color:#FFFFCC;display:none'>";
echo nl2br($inline[$i]["filedata"]);
echo "</blockquote>";
- } elseif($inline[$i]["subtype"] == "JPEG") {
- echo "<a href='javascript:show_inline(".$i.");'>".$inline[$i]["filename"]."</a><br><br><div id='block_".$i."' style='border:1px solid gray;padding:6px;background-color:#FFFFCC;display:none;width:95%'>";
+ } elseif($inline[$i]["subtype"] == "JPEG" || $inline[$i]["subtype"] == "GIF") {
+ echo ($i+1).") <a href='javascript:show_inline(".$i.");'>".$inline[$i]["filename"]."</a><br><br><div id='block_".$i."' style='border:1px solid gray;padding:6px;background-color:#FFFFCC;display:none;width:95%;overflow:auto'>";
global $root_directory;
$save_path=$root_directory.'/modules/Webmails/tmp';
if(!is_dir($save_path))
@@ -83,13 +83,12 @@
fputs($fp, base64_decode($inline[$i]["filedata"]));
$filename = 'modules/Webmails/tmp/cache/'.$inline[$i]['filename'];
fclose($fp);
- echo '<img src="'.$filename.'" border="0" width="100%">';
- echo '</div>';
+ echo '<img src="'.$filename.'" border="0" >';
+ echo '</div> <br>';
} else
- echo "<br>".($i+1).") <a target='_BLANK' href='index.php?module=Webmails&action=dlAttachments&inline=true&num=".$i."&mailid=".$mailid."'>".$inline[$i]["filename"]."</a>";
+ echo ($i+1).") <a target='_BLANK' href='index.php?module=Webmails&action=dlAttachments&inline=true&num=".$i."&mailid=".$mailid."'>".$inline[$i]["filename"]."</a> <br>";
}
}
}
imap_close($mbox);
-
?>
Modified: vtigercrm/trunk/modules/Webmails/webmails.js
==============================================================================
--- vtigercrm/trunk/modules/Webmails/webmails.js (original)
+++ vtigercrm/trunk/modules/Webmails/webmails.js Sat May 27 20:20:42 2006
@@ -77,7 +77,7 @@
'modules/Webmails/WebmailsAjax.php',
{queue: {position: 'end', scope: 'command'},
method: 'post',
- postBody: 'module=Webmails&action=ListView&mailbox='+mbox+'&command=check_mbox&ajax=true',
+ postBody: 'mailbox='+mbox+'&command=check_mbox&ajax=true',
onComplete: function(t) {
try {
var data = eval('(' + t.responseText + ')');
More information about the vtigercrm-commits
mailing list