[Vtigercrm-commits] [vtiger-commits] r6523 - in /vtigercrm/trunk/modules/Webmails: ListView.php MailParse.php Webmail.php body.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Sat May 27 05:34:57 EDT 2006
Author: mmbrich
Date: Sat May 27 03:34:55 2006
New Revision: 6523
Log:
fixes for certain inline attachments, more inline attachments functions
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
Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Sat May 27 03:34:55 2006
@@ -20,7 +20,6 @@
require_once('include/utils/utils.php');
require_once('include/utils/UserInfoUtil.php');
require_once("modules/Webmails/MailParse.php");
-require_once('modules/CustomView/CustomView.php');
$mailInfo = getMailServerInfo($current_user);
if($adb->num_rows($mailInfo) < 1) {
@@ -168,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(getAttachmentDetails($start_message,$mbox) || getInlineAttachments($num,$mbox))
+ if(getAttachments($num,$mbox) || getInlineAttachments($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 03:34:55 2006
@@ -15,6 +15,10 @@
$mailOverviews = @imap_fetch_overview($mbox, "1:$numEmails", 0);
$out = array("headers"=>$mailHeaders,"overview"=>$mailOverviews,"count"=>$numEmails);
return $out;
+}
+function isBase64($iVal){
+ //$_tmp=preg_replace("/[^A-Z0-9\+\/\=]/i","",$iVal);
+ return (strlen($iVal) % 4 == 0 ) ? "y" : "n";
}
function getImapMbox($mailbox,$temprow) {
global $mbox;
@@ -77,10 +81,10 @@
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]->parameters[0]->value, "filedata" => imap_fetchbody($mbox, $mailid, $partstring),"ID"=> $parts[$i]->parts[0]);
- }
+ $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;
@@ -128,7 +132,7 @@
}
$partstring .= ($i+1);
if (strtoupper($parts[$i]->disposition) == "ATTACHMENT")
- $attachment[] = array("filename" => $parts[$i]->parameters[0]->value,"filesize"=>$parts[$i]->bytes);
+ $attachment[] = array("filename" => $parts[$i]->dparameters[0]->value,"filesize"=>$parts[$i]->bytes);
}
if ($parts[$i]->parts) {
@@ -178,19 +182,19 @@
}
$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));
+ $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;
+ 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);
Modified: vtigercrm/trunk/modules/Webmails/Webmail.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/Webmail.php (original)
+++ vtigercrm/trunk/modules/Webmails/Webmail.php Sat May 27 03:34:55 2006
@@ -71,10 +71,10 @@
}
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"];
+ $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() {
@@ -84,7 +84,7 @@
function setFlag() {
$status=imap_setflag_full($this->mbox,$this->mailid,"\\Flagged");
}
-
+
function delFlag() {
$status=imap_clearflag_full($this->mbox,$this->mailid,"\\Flagged");
}
@@ -187,7 +187,7 @@
$partstring .= ($i+1);
if (strtoupper($parts[$i]->disposition) == "INLINE")
- $inline[] = array("filename" => $parts[$i]->parameters[0]->value,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring));
+ $inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>imap_fetchbody($mbox, $mailid, $partstring));
}
if ($parts[$i]->parts) {
$stack[] = array("p" => $parts, "i" => $i);
@@ -290,11 +290,12 @@
$partstring .= ($i+1);
$type='';
- if (strtoupper($parts[$i]->disposition) == "INLINE" && strtoupper($parts[$i]->subtype) != "PLAIN") {
- $inline[] = array("filename" => $parts[$i]->parameters[0]->value,"filesize"=>$parts[$i]->bytes);
- } elseif (strtoupper($parts[$i]->disposition) == "ATTACHMENT") {
- $attachment[] = array("filename" => $parts[$i]->parameters[0]->value,"filesize"=>$parts[$i]->bytes);
-
+ 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);
+ } 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";
Modified: vtigercrm/trunk/modules/Webmails/body.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/body.php (original)
+++ vtigercrm/trunk/modules/Webmails/body.php Sat May 27 03:34:55 2006
@@ -58,15 +58,34 @@
<?
echo $email->body;
echo "<br><br>";
- if(getInlineAttachments($mailid,$mbox)) {
- $inline = getInlineAttachments($mailid,$mbox);
+ if(is_array($email->inline)) {
+ $inline = $email->inline;
$num=sizeof($inline);
echo "<b>Inline Attachments</b>:<br>";
for($i=0;$i<$num;$i++) {
- if($inline[$i]["ID"]->subtype == "PLAIN") {
- 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;visibility:hidden'>".nl2br($inline[$i]["filedata"])."</blockquote>";
- } else
- echo "<br>".($i+1).") <a href='index.php?module=Webmails&action=dlAttachments&inline=true&num=".$i."&mailid=".$mailid."'>".$inline[$i]["filename"];
+ //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;visibility:hidden'>";
+ echo nl2br($inline[$i]["filedata"]);
+ echo "</blockquote>";
+ } elseif($inline[$i]["subtype"] == "JPEG") {
+ echo "<a href='javascript:show_inline(".$i.");'>".$inline[$i]["filename"]."</a><div id='block_".$i."' style='border:1px solid gray;padding:6px;background-color:#FFFFCC;visibility:hidden'>";
+ global $root_directory;
+ $save_path=$root_directory.'/modules/Webmails/tmp';
+ if(!is_dir($save_path))
+ mkdir($save_path);
+ $save_dir=$save_path."/cache";
+ if(!is_dir($save_dir))
+ mkdir($save_dir);
+
+ $fp = fopen($save_dir.'/'.$inline[$i]["filename"], "w") or die("Can't open file");
+ fputs($fp, base64_decode($inline[$i]["filedata"]));
+ $filename = 'modules/Webmails/tmp/cache/'.$inline[$i]['filename'];
+ echo '<img src="'.$filename.'" border="0">';
+ echo '</div>';
+ } 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>";
}
}
}
More information about the vtigercrm-commits
mailing list