[Vtigercrm-commits] [vtiger-commits] r6503 - in /vtigercrm/trunk/modules/Webmails: ListView.php MailParse.php WebmailsAjax.php dlAttachments.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Fri May 26 17:43:17 EDT 2006


Author: mmbrich
Date: Fri May 26 15:43:15 2006
New Revision: 6503

Log:
inline attachment capabilities

Modified:
    vtigercrm/trunk/modules/Webmails/ListView.php
    vtigercrm/trunk/modules/Webmails/MailParse.php
    vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
    vtigercrm/trunk/modules/Webmails/dlAttachments.php

Modified: vtigercrm/trunk/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/ListView.php (original)
+++ vtigercrm/trunk/modules/Webmails/ListView.php Fri May 26 15:43:15 2006
@@ -117,7 +117,7 @@
 
 					webmail[mailid] = new Array();
 					webmail[mailid]["from"] = from;
-					webmail[mailid]["to"] = "myname";
+					webmail[mailid]["to"] = data.mails[i].mail.to;
 					webmail[mailid]["subject"] = subject;
 					webmail[mailid]["date"] = date;
 
@@ -141,7 +141,7 @@
 					// images
 					// Attachment
 					imgtd = Builder.node('td');
-					if(attachments > 0)  {
+					if(attachments === "1")  {
 					    var attach = Builder.node('a',
 						{href: 'javascript:;', onclick: 'displayAttachments('+mailid+')'},
 						[ Builder.node('img',
@@ -158,7 +158,7 @@
 					var unread = Builder.node('span',
 						{id: 'unread_img_'+mailid},
 						[ Builder.node('a',
-							{href: 'index.php?module=Webmails&action=DetailView&<?php echo $detailParams;?>'},
+							{href: 'index.php?module=Webmails&action=DetailView&record='+mailid+'&mailbox=<?php echo $mailbox;?>&mailid='+mailid},
 							[ Builder.node('img',
 								{src: 'modules/Webmails/images/stock_mail-unread.png', border: '0', width: '14px', height: '14'}
 							)]
@@ -475,8 +475,7 @@
 		$mails[$start_message]->subject="(No Subject)";
 
   	// Let's pre-build our URL parameters since it's too much of a pain not to
-  	$detailParams = 'record='.$record_id.'&mailbox='.$mailbox.'&mailid='.$num.'&parenttab=My Home Page';
- 	$defaultParams = 'parenttab=My Home Page&mailbox='.$mailbox.'&start='.$start.'&viewname='.$viewname;
+  	$detailParams = 'record='.$num.'&mailbox='.$mailbox.'&mailid='.$num.'&parenttab=My Home Page';
 
 	$displayed_msgs++;
 	if ($mails[$start_message]->deleted && !$show_hidden) {
@@ -490,7 +489,7 @@
 		$flags = "<tr id='row_".$num."'><td colspan='1'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
 
   	// Attachment Icons
-  	if(getAttachmentDetails($start_message,$mbox))
+  	if(getAttachmentDetails($start_message,$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>&nbsp;';
   	else
 		$flags.='<img src="modules/Webmails/images/blank.png" border="0" width="14px" height="14" alt="">&nbsp;';
@@ -498,7 +497,7 @@
   	// read/unread/forwarded/replied
   	if(!$mails[$start_message]->seen || $mails[$start_message]->recent)
 	{
-  		$flags.='<span id="unread_img_'.$num.'"><a href="sssindex.php?module=Webmails&action=DetailView&'.$detailParams.'"><img src="modules/Webmails/images/stock_mail-unread.png" border="0" width="10" height="14"></a></span>&nbsp;';
+  		$flags.='<span id="unread_img_'.$num.'"><a href="index.php?module=Webmails&action=DetailView&'.$detailParams.'"><img src="modules/Webmails/images/stock_mail-unread.png" border="0" width="10" height="14"></a></span>&nbsp;';
 	}
   	elseif ($mails[$start_message]->in_reply_to || $mails[$start_message]->references || preg_match("/^re:/i",$mails[$start_message]->subject))
 		$flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-replied.png" border="0" width="10" height="12"></a>&nbsp;';
@@ -521,15 +520,15 @@
 	$listview_entries[$num][] = $flags."</td>";
 
   	if ($mails[$start_message]->deleted) {
-        	$listview_entries[$num][] = '<td colspan="1" align="left" id="deleted_subject_'.$num.'"><s><a href="javascript:;" onclick="load_webmail(\''.$num.'\');">'.substr($mails[$start_message]->subject,0,50).'</a></s></td>';
+        	$listview_entries[$num][] = '<td colspan="1" align="left" id="deleted_subject_'.$num.'"><s><a href="javascript:;" onclick="load_webmail(\''.$num.'\');">'.substr($mails[$start_message]->subject,0,40).'</a></s></td>';
         	$listview_entries[$num][] = '<td colspan="1" align="left" nowrap id="deleted_date_'.$num.'"><s>'.$mails[$start_message]->date.'</s></td>';
         	$listview_entries[$num][] = '<td colspan="1" align="left" id="deleted_from_'.$num.'"><s>'.substr($from,0,30).'</s></td>';
   	} elseif(!$mails[$start_message]->seen || $mails[$start_message]->recent) {
-        	$listview_entries[$num][] = '<td colspan="1" align="left" ><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,50).'</a></td>';
+        	$listview_entries[$num][] = '<td colspan="1" align="left" ><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,40).'</a></td>';
         	$listview_entries[$num][] = '<td colspan="1" align="left" nowrap id="ndeleted_date_'.$num.'" >'.$mails[$start_message]->date.' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td>';
         	$listview_entries[$num][] = '<td  colspan="1" align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,30).'</td>';
   	} else {
-        	$listview_entries[$num][] = '<td colspan="1" align="left" ><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,50).'</a></td>';
+        	$listview_entries[$num][] = '<td colspan="1" align="left" ><a href="javascript:;" onclick="load_webmail(\''.$num.'\');" id="ndeleted_subject_'.$num.'">'.substr($mails[$start_message]->subject,0,40).'</a></td>';
         	$listview_entries[$num][] = '<td colspan="1" align="left" nowrap id="ndeleted_date_'.$num.'">'.$mails[$start_message]->date.'</td>';
         	$listview_entries[$num][] = '<td colspan="1" align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,30).'</td>';
   	}

Modified: vtigercrm/trunk/modules/Webmails/MailParse.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/MailParse.php (original)
+++ vtigercrm/trunk/modules/Webmails/MailParse.php Fri May 26 15:43:15 2006
@@ -94,55 +94,55 @@
 }
 
 function getAttachmentDetails($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]->parameters[0]->value,"filesize"=>$parts[$i]->bytes);
-           }
-
-           if ($parts[$i]->parts) {
-             $stack[] = array("p" => $parts, "i" => $i);
-             $parts = $parts[$i]->parts;
-             $i = 0;
-           } else {
-             $i++;
-           }
-         } /* while */
-       } /* complicated message */
+       $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]->parameters[0]->value,"filesize"=>$parts[$i]->bytes);
+           }
+
+           if ($parts[$i]->parts) {
+             $stack[] = array("p" => $parts, "i" => $i);
+             $parts = $parts[$i]->parts;
+             $i = 0;
+           } else {
+             $i++;
+           }
+         } /* while */
+       } /* complicated message */
 	return $attachment;
-}
-
+}
+
 function getAttachments($mailid,$mbox) {
        $struct = imap_fetchstructure($mbox, $mailid);
        $parts = $struct->parts;

Modified: vtigercrm/trunk/modules/Webmails/WebmailsAjax.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/WebmailsAjax.php (original)
+++ vtigercrm/trunk/modules/Webmails/WebmailsAjax.php Fri May 26 15:43:15 2006
@@ -53,10 +53,11 @@
 		$ret .= '{"mail":';
 		$ret .= '{';
 		$ret .= '"mailid":"'.$data[$i]->msgno.'",';
-		$ret .= '"subject":"'.substr($data[$i]->subject,0,50).'",';
-		$ret .= '"date":"'.$data[$i]->date.'",';
-		$ret .= '"from":"'.$data[$i]->from.'",';
-		if(sizeof($part->parts) >0)
+		$ret .= '"subject":"'.substr($data[$i]->subject,0,40).'",';
+		$ret .= '"date":"'.substr($data[$i]->date,0,30).'",';
+		$ret .= '"from":"'.substr($data[$i]->from,0,20).'",';
+		$ret .= '"to":"'.$data[$i]->to.'",';
+		if(getAttachmentDetails($data[$i]->msgno,$mbox) || getInlineAttachments($data[$i]->msgno,$mbox))
 			$ret .= '"attachments":"1"}';
 		else
 			$ret .= '"attachments":"0"}';

Modified: vtigercrm/trunk/modules/Webmails/dlAttachments.php
==============================================================================
--- vtigercrm/trunk/modules/Webmails/dlAttachments.php (original)
+++ vtigercrm/trunk/modules/Webmails/dlAttachments.php Fri May 26 15:43:15 2006
@@ -29,30 +29,45 @@
 
 $email = new Webmail($mbox,$mailid);
 $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>";
 	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."'>".$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>";
+	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'>".$inline[$i]["filename"]."</td></tr>";
+	}
 	echo "</table><br><br>";
 
-} elseif (count(attachments) == 0) {
+} elseif (count(attachments) == 0 && count($inline) == 0) {
 	echo "<center><strong>No attachments for this email</strong></center><br><br>";
 } else {
 
 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);
 
-$fp = fopen($user_dir.'/'.$attachments[$num]["filename"], "w") or die("Can't open file");
-fputs($fp, base64_decode($attachments[$num]["filedata"]));
+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($mbox);
 
-$filename = 'modules/Webmails/tmp/'.$_SESSION['authenticated_user_id'].'/'.$attachments[$num]['filename'];
 ?>
 <center><h2>File Download</h2></center>
 <META HTTP-EQUIV="Refresh"





More information about the vtigercrm-commits mailing list