[Vtigercrm-commits] [vtiger-commits] r9903 - in /vtigercrm/branches/5.0.3: index.php modules/Webmails/MailParse.php modules/Webmails/Webmail.php modules/Webmails/body.php modules/Webmails/dlAttachments.php modules/Webmails/webmails.js

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Thu Nov 23 10:32:40 EST 2006


Author: richie
Date: Thu Nov 23 08:32:31 2006
New Revision: 9903

Log:
* Modified to fix some issues include attachment issues - Mickie

Modified:
    vtigercrm/branches/5.0.3/index.php
    vtigercrm/branches/5.0.3/modules/Webmails/MailParse.php
    vtigercrm/branches/5.0.3/modules/Webmails/Webmail.php
    vtigercrm/branches/5.0.3/modules/Webmails/body.php
    vtigercrm/branches/5.0.3/modules/Webmails/dlAttachments.php
    vtigercrm/branches/5.0.3/modules/Webmails/webmails.js

Modified: vtigercrm/branches/5.0.3/index.php
==============================================================================
--- vtigercrm/branches/5.0.3/index.php (original)
+++ vtigercrm/branches/5.0.3/index.php Thu Nov 23 08:32:31 2006
@@ -278,10 +278,9 @@
 		ereg("^HeadLines",$action) ||
 		ereg("^TodoSave",$action) ||
 		ereg("^RecalculateSharingRules",$action) ||
-		(ereg("^body",$action) &&
-			ereg("^Webmails",$module)) ||
-			(ereg("^DetailView",$action) &&
-			ereg("^Webmails",$module) ))
+		(ereg("^body",$action) && ereg("^Webmails",$module)) ||
+		(ereg("^dlAttachments",$action) && ereg("^Webmails",$module)) ||
+		(ereg("^DetailView",$action) &&	ereg("^Webmails",$module) ))
 	{
 		$skipHeaders=true;
 		//skip headers for all these invocations as they are mostly popups

Modified: vtigercrm/branches/5.0.3/modules/Webmails/MailParse.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/MailParse.php (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/MailParse.php Thu Nov 23 08:32:31 2006
@@ -87,9 +87,9 @@
         }
 
         if($mails[$start_message]->deleted)
-                $listview_entries[$num][] = '<td nowrap align="center" id="deleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','.$num.');"><img src="modules/Webmails/images/emailDelete.gif" border="0" width="14" height="14" alt="del"></a></span></td></tr>';
+                $listview_entries[$num][] = '<td nowrap align="center" id="deleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'undelete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"></a></span></td></tr>';
         else
-                $listview_entries[$num][] = '<td nowrap align="center" id="ndeleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','.$num.');"><img src="modules/Webmails/images/emailDelete.gif" border="0" width="14" height="14" alt="del"></a></span></td></tr>';
+                $listview_entries[$num][] = '<td nowrap align="center" id="ndeleted_td_'.$num.'"><span id="del_link_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'delete_msg\','.$num.');"><img src="modules/Webmails/images/gnome-fs-trash-empty.png" border="0" width="14" height="14" alt="del"></a></span></td></tr>';
 
         return $listview_entries[$num];
 }

Modified: vtigercrm/branches/5.0.3/modules/Webmails/Webmail.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/Webmail.php (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/Webmail.php Thu Nov 23 08:32:31 2006
@@ -114,7 +114,7 @@
 	}
 
 	function downloadAttachments() {
-		return $this->dl_attachments($this->mailid,$this->mbox);
+		return $this->dl_attachments();
 	}
 
     function load_headers() {
@@ -146,7 +146,7 @@
     }
 
     private function get_attachments() {
-       $struct = imap_fetchstructure($this->mbox, $this->mailid);
+       $struct = @imap_fetchstructure($this->mbox, $this->mailid);
        $parts = $struct->parts;
 
         $done="false";
@@ -217,177 +217,361 @@
 	return 0;
     }
 
-    private function dl_inline() {
-        $struct = imap_fetchstructure($this->mbox, $this->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) {
-               $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) == "INLINE")
-                        $inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>imap_fetchbody($this->mbox, $this->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;
-    }
-
-    private function dl_attachments() {
-        $struct = imap_fetchstructure($this->mbox, $this->mailid);
-        $parts = $struct->parts;
-
-        $content = array();
-        $i = 0;
-        if (!$parts)
-		return;
-        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;
-             }
-        }
-           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($this->mbox, $this->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;
-    }
-    private function load_mail() {
-	// parse the message
-	$struct = imap_fetchstructure($this->mbox, $this->mailid);
-       	$parts = $struct->parts;
-
-        $content = array();
-        $i = 0;
-        if (!$parts) { /* Simple message, only 1 piece */
-         $attachment = array(); /* No vtiger_attachments */
-         $bod=imap_body($this->mbox, $this->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='';
-	     if (strtoupper($parts[$i]->disposition) == "INLINE" && strtoupper($parts[$i]->subtype) != "PLAIN") {
-                        $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]->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($this->mbox, $this->mailid, $partstring));
-			$stat="done";
-             } elseif (strtoupper($parts[$i]->subtype) == "TEXT" && !$stat == "done") {
-                        $content['body'] = nl2br(imap_fetchbody($this->mbox, $this->mailid, $partstring));
-			$stat="done";
-             } elseif (strtoupper($parts[$i]->subtype) == "PLAIN" && !$stat == "done") {
-                        $content['body'] = nl2br(imap_fetchbody($this->mbox, $this->mailid, $partstring));
-			$stat="done";
-             } elseif (!$stat == "done") {
-                        $content['body'] = nl2br(imap_fetchbody($this->mbox, $this->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;
-    }
+    
+	private function dl_inline()
+	{
+		$struct = imap_fetchstructure($this->mbox, $this->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)
+					{
+						$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) == "INLINE")
+					{
+						//if the type is JPEG or GIF then call mail_fetchpart else fetchbody
+						if($parts[$i]->subtype == "JPEG" || $parts[$i]->subtype == "GIF")
+							$filedata = $this->mail_fetchpart($partstring);
+						else
+							$filedata = imap_fetchbody($this->mbox, $this->mailid, $partstring);
+						
+						$inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>$filedata,"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;
+	}
+
+	private function dl_attachments()
+	{
+
+		$struct = imap_fetchstructure($this->mbox, $this->mailid);
+		$parts = $struct->parts;
+
+		$i = 0;
+		if (!$parts)
+			return;
+		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;
+					}
+				}
+				if (!$endwhile)
+				{
+					$partstring = "";
+					foreach ($stack as $s)
+					{
+						$partstring .= ($s["i"]+1) . ".";
+					}
+					$partstring .= ($i+1);
+
+					if (strtoupper($parts[$i]->disposition) == "ATTACHMENT")
+					{
+						$filedata = $this->mail_fetchpart($partstring);
+						$attachment[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>$filedata,"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;
+	}
+
+
+	private function load_mail()
+	{
+		// parse the message
+		$struct = imap_fetchstructure($this->mbox, $this->mailid);
+		$parts = $struct->parts;
+
+		$content = array();
+		$i = 0;
+		if (!$parts)
+		{
+			/* Simple message, only 1 piece */
+			$attachment = array(); /* No vtiger_attachments */
+			$bod=imap_body($this->mbox, $this->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='';
+					if (strtoupper($parts[$i]->disposition) == "INLINE" && strtoupper($parts[$i]->subtype) != "PLAIN")
+					{
+						$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]->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($this->mbox, $this->mailid, $partstring));
+						$stat="done";
+					}
+					elseif (strtoupper($parts[$i]->subtype) == "TEXT" && !$stat == "done")
+					{
+						$content['body'] = nl2br(imap_fetchbody($this->mbox, $this->mailid, $partstring));
+						$stat="done";
+					}
+					elseif (strtoupper($parts[$i]->subtype) == "PLAIN" && !$stat == "done")
+					{
+						$content['body'] = nl2br(imap_fetchbody($this->mbox, $this->mailid, $partstring));
+						$stat="done";
+					}
+					elseif (!$stat == "done")
+					{
+						$content['body'] = nl2br(imap_fetchbody($this->mbox, $this->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;
+	}
+
+
+
+
+
+
+
+	// get the body of a part of a message according to the
+	// string in $part
+	function mail_fetchpart($part)
+	{
+		$parts = $this->mail_fetchparts();
+
+		$partNos = explode(".", $part);
+
+		$currentPart = $parts;
+		while(list ($key, $val) = each($partNos))
+		{
+			$currentPart = $currentPart[$val];
+		}
+
+		if ($currentPart != "") return $currentPart;
+		else return false;
+	}
+
+	// splits a message given in the body if it is
+	// a mulitpart mime message and returns the parts,
+	// if no parts are found, returns false
+	function mail_mimesplit($header, $body)
+	{
+		$parts = array();
+
+		$PN_EREG_BOUNDARY = "Content-Type:(.*)boundary=\"([^\"]+)\"";
+
+		if (eregi ($PN_EREG_BOUNDARY, $header, $regs))
+		{
+			$boundary = $regs[2];
+
+			$delimiterReg = "([^\r\n]*)$boundary([^\r\n]*)";
+			if (eregi ($delimiterReg, $body, $results))
+			{
+				$delimiter = $results[0];
+				$parts = explode($delimiter, $body);
+				$parts = array_slice ($parts, 1, -1);
+			}
+
+			return $parts;
+		}
+		else
+		{
+			return false;
+		}   
+	}
+
+	// returns an array with all parts that are
+	// subparts of the given part
+	// if no subparts are found, return the body of
+	// the current part
+	function mail_mimesub($part)
+	{
+		$i = 1;
+		$headDelimiter = "\r\n\r\n";
+		$delLength = strlen($headDelimiter);
+
+		// get head & body of the current part
+		$endOfHead = strpos( $part, $headDelimiter);
+		$head = substr($part, 0, $endOfHead);
+		$body = substr($part, $endOfHead + $delLength, strlen($part));
+
+		// check whether it is a message according to rfc822
+		if (stristr($head, "Content-Type: message/rfc822"))
+		{
+			$part = substr($part, $endOfHead + $delLength, strlen($part));
+			$returnParts[1] = $this->mail_mimesub($part);
+			return $returnParts;
+			// if no message, get subparts and call function recursively
+		}
+		elseif ($subParts = $this->mail_mimesplit($head, $body))
+		{
+			// got more subparts
+			while (list ($key, $val) = each($subParts))
+			{
+				$returnParts[$i] = $this->mail_mimesub($val);
+				$i++;
+			}           
+			return $returnParts;
+			}
+			else
+			{
+				return $body;
+			}
+	}
+
+	// get an array with the bodies all parts of an email
+	// the structure of the array corresponds to the
+	// structure that is available with imap_fetchstructure
+	function mail_fetchparts()
+	{
+		$parts = array();
+		$header = imap_fetchheader($this->mbox, $this->mailid);
+		$body = imap_body($this->mbox, $this->mailid, FT_INTERNAL);
+
+		$i = 1;
+
+		if ($newParts = $this->mail_mimesplit($header, $body))
+		{
+			while (list ($key, $val) = each($newParts))
+			{
+				$parts[$i] = $this->mail_mimesub($val);
+				$i++;               
+			}
+		}
+		else
+		{
+			$parts[$i] = $body;
+		}
+		return $parts;
+	}
+
+
+
+
+
+    
 }
 ?>

Modified: vtigercrm/branches/5.0.3/modules/Webmails/body.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/body.php (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/body.php Thu Nov 23 08:32:31 2006
@@ -31,40 +31,54 @@
 		el.style.display='block';
 }
 </script>
-<?
-	$email->loadMail();
-	echo $email->body;
-	echo "<br><br>";
-	if(is_array($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 ($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" || $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))
-       		 				mkdir($save_path);
-					$save_dir=$save_path."/cache";
-					if(!is_dir($save_dir))
-       		 				mkdir($save_dir);
+<?php
+
+$email->loadMail();
+echo $email->body;
+echo "<br><br>";
+
+if(is_array($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 "<br>".($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" || $inline[$i]["subtype"] == "GIF")
+		{
+			echo "<br>".($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))
+				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'];
-					fclose($fp);
-					echo '<img src="'.$filename.'" border="0" >';
-					echo '</div> <br>';
-				} else 
-					echo ($i+1).") <a target='_BLANK' href='index.php?module=Webmails&action=dlAttachments&inline=true&num=".$i."&mailid=".$mailid."'>".$inline[$i]["filename"]."</a> <br>";
+			$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'];
+			fclose($fp);
+			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> <br>";
 	}
+}
 imap_close($MailBox->mbox);
+
+
 ?>

Modified: vtigercrm/branches/5.0.3/modules/Webmails/dlAttachments.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/dlAttachments.php (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/dlAttachments.php Thu Nov 23 08:32:31 2006
@@ -1,4 +1,4 @@
-<?php
+<?php
 /*********************************************************************************
  ** The contents of this file are subject to the vtiger CRM Public License Version 1.0
   * ("License"); You may not use this file except in compliance with the License
@@ -10,9 +10,9 @@
   ********************************************************************************/
 
 
-include('config.php');
-require_once('include/utils/UserInfoUtil.php');
-require_once('include/utils/utils.php');
+include('config.php');
+require_once('include/utils/UserInfoUtil.php');
+require_once('include/utils/utils.php');
 require_once('modules/Webmails/Webmail.php');
 require_once('modules/Webmails/MailBox.php');
 
@@ -26,52 +26,64 @@
 $attachments=$email->downloadAttachments();
 $inline=$email->downloadInlineAttachments();
 
-if($num == "" || !isset($num) && count($attachments) >0 ) {
-	echo "<table width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td align='center'>There are ".count($attachments)." attachment(s) to choose from:</td></tr>";
+if($num == "" || !isset($num) && count($attachments) >0 )
+{
+	echo "<table class='small' width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td width='10%'>&nbsp;</td><td width='90%'>There are ".count($attachments)." attachment(s) to choose from:</td></tr>";
 
-	for($i=0;$i<count($attachments);$i++) {
-		echo "<tr><td align='center'>".count($attachments).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&mailbox=".$_REQUEST["mailbox"]."'>".$attachments[$i]["filename"]."</td></tr>";
+	for($i=0;$i<count($attachments);$i++)
+	{
+		echo "<tr><td width='10%'>&nbsp;</td><td width='90%'>&nbsp;&nbsp;&nbsp;".($i+1).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&mailbox=".$_REQUEST["mailbox"]."'>".$attachments[$i]["filename"]."</td></tr>";
 	}
 
 	echo "</table><br>";
-	echo "<table width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td align='center'>There are ".count($inline)." <b>inline</b> attachment(s) to choose from:</td></tr>";
+	echo "<table class='small' width='100%' cellspacing='1' cellpadding='0' border='0'><tr><td width='10%'>&nbsp;</td><td width='90%'>There are ".count($inline)." <b>inline</b> attachment(s) to choose from:</td></tr>";
 
-	for($i=0;$i<count($inline);$i++) {
-		echo "<tr><td align='center'>".count($inline).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&inline=true&mailbox=".$_REQUEST["mailbox"]."'>".$inline[$i]["filename"]."</td></tr>";
+	for($i=0;$i<count($inline);$i++)
+	{
+		echo "<tr><td width='10%'>&nbsp;</td><td width='90%'>&nbsp;&nbsp;&nbsp;".($i+1).") &nbsp; <a href='index.php?module=Webmails&action=dlAttachments&mailid=".$mailid."&num=".$i."&inline=true&mailbox=".$_REQUEST["mailbox"]."'>".$inline[$i]["filename"]."</td></tr>";
 	}
 
 	echo "</table><br><br>";
 
-} elseif (count(attachments) == 0 && count($inline) == 0) {
+}
+elseif (count($attachments) == 0 && count($inline) == 0)
+{
 	echo "<center><strong>No vtiger_attachments for this email</strong></center><br><br>";
-} else {
+}
+else
+{
 
-global $root_directory;
-$save_path=$root_directory.'/modules/Webmails/tmp';
-if(!is_dir($save_path))
-	mkdir($save_path);
+	global $root_directory;
+	$save_path=$root_directory.'/modules/Webmails/tmp';
+	if(!is_dir($save_path))
+		mkdir($save_path);
 
-$user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
-if(!is_dir($user_dir))
-	mkdir($user_dir);
+	$user_dir=$save_path."/".$_SESSION["authenticated_user_id"];
+	if(!is_dir($user_dir))
+		mkdir($user_dir);
 
-if(isset($_REQUEST["inline"]) && $_REQUEST["inline"] == "true") {
-	$fp = fopen($user_dir.'/'.$inline[$num]["filename"], "w") or die("Can't open file");
-	fputs($fp, base64_decode($inline[$num]["filedata"]));
-	$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$inline[$num]['filename'];
-} else {
-	$fp = fopen($user_dir.'/'.$attachments[$num]["filename"], "w") or die("Can't open file");
-	fputs($fp, base64_decode($attachments[$num]["filedata"]));
-	$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$attachments[$num]['filename'];
+	if(isset($_REQUEST["inline"]) && $_REQUEST["inline"] == "true")
+	{
+		$fp = fopen($user_dir.'/'.$inline[$num]["filename"], "w") or die("Can't open file");
+		fputs($fp, base64_decode($inline[$num]["filedata"]));
+		$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$inline[$num]['filename'];
+	}
+	else
+	{
+		$fp = fopen($user_dir.'/'.$attachments[$num]["filename"], "w") or die("Can't open file");
+		fputs($fp, base64_decode($attachments[$num]["filedata"]));
+		$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$attachments[$num]['filename'];
+	}
+	fclose($fp);
+	imap_close($MailBox->mbox);
+
+	?>
+	<center><h2>File Download</h2></center>
+	<META HTTP-EQUIV="Refresh"
+	CONTENT="0; URL=<?php echo $filename;?>"
+	]"
+	<?
 }
-fclose($fp);
-imap_close($MailBox->mbox);
+
 
 ?>
-<center><h2>File Download</h2></center>
-<META HTTP-EQUIV="Refresh"
-CONTENT="0; URL=<?php echo $filename;?>"
-]"
-<?
-}
-?>

Modified: vtigercrm/branches/5.0.3/modules/Webmails/webmails.js
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/webmails.js (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/webmails.js Thu Nov 23 08:32:31 2006
@@ -336,6 +336,10 @@
                 	if(els[i].type === "checkbox" && els[i].name.indexOf("_")) {
                         	if(els[i].checked) {
                                 	var nid = els[i].name.substr((els[i].name.indexOf("_")+1),els[i].name.length);
+
+					//change the selected rows as red when they deleted
+					$("row_"+nid).className = "delete_email";
+
 					if(typeof nid == 'undefined' || nid == "checkbox")
 						nids += '';
 					else





More information about the vtigercrm-commits mailing list