[Vtigercrm-commits] [vtiger-commits] r9932 - in /vtigercrm/branches/5.0.3/modules/Webmails: DetailView.php ListView.php MailParse.php Webmail.php body.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue Dec 5 01:08:08 EST 2006


Author: richie
Date: Mon Dec  4 23:08:02 2006
New Revision: 9932

Log:
* Added utf6 decoding to display the all language characters correctly -- Mickie

Modified:
    vtigercrm/branches/5.0.3/modules/Webmails/DetailView.php
    vtigercrm/branches/5.0.3/modules/Webmails/ListView.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

Modified: vtigercrm/branches/5.0.3/modules/Webmails/DetailView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/DetailView.php (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/DetailView.php Mon Dec  4 23:08:02 2006
@@ -31,6 +31,10 @@
 echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">';
 echo '<tr><td width="10%">From:</td><td>'.$elist->from.'</td></tr>';
 echo '<tr><td width="10%">To:</td><td>'.$elist->to.'</td></tr>';
+
+//Added to get the UTF-8 string - 30-11-06 - Mickie
+$elist->subject = utf8_decode(imap_utf8($elist->subject));
+
 echo '<tr><td width="10%">Subject:</td><td>'.$elist->subject.'</td></tr>';
 echo '<tr><td width="10%">Date:</td><td>'.$elist->date.'</td></tr>';
 echo '</table>';

Modified: vtigercrm/branches/5.0.3/modules/Webmails/ListView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Webmails/ListView.php (original)
+++ vtigercrm/branches/5.0.3/modules/Webmails/ListView.php Mon Dec  4 23:08:02 2006
@@ -157,7 +157,7 @@
 );
 </script>
 <script language="JavaScript" type="text/javascript" src="modules/Webmails/webmails.js"></script>
-<?
+<?php
 
 global $displayed_msgs;
 // AJAX commands (should be moved)
@@ -217,7 +217,7 @@
 // these are mainly used in the preview window and could be ajaxified/
 // during the preview window load instead.
 var msgCount = "<?php echo $numEmails;?>";
-<?
+<?php
 $mails = array();
 if (is_array($overview)) {
    foreach ($overview as $val) {
@@ -226,9 +226,15 @@
 	webmail[<?php echo $val->msgno;?>] = new Array();
 	webmail[<?php echo $val->msgno;?>]["from"]="<?php echo addslashes($val->from);?>";
 	webmail[<?php echo $val->msgno;?>]["to"]="<?php echo addslashes($val->to);?>";
+
+	<?php 
+		//Added to get the UTF-8 string - 30-11-06 - Mickie
+		$val->subject = utf8_decode(imap_utf8($val->subject));
+	?>
+		
 	webmail[<?php echo $val->msgno;?>]["subject"]="<?php echo addslashes($val->subject);?>";
 	webmail[<?php echo $val->msgno;?>]["date"]="<?php echo addslashes($val->date);?>";
-	<?
+	<?php
    }
 }
 echo "</script>";

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 Mon Dec  4 23:08:02 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
@@ -11,35 +11,47 @@
 
 
 // draw a row for the listview entry
-function show_msg($mails,$start_message) {
-        global $MailBox,$displayed_msgs,$show_hidden,$new_msgs;
+function show_msg($mails,$start_message)
+{
+	global $MailBox,$displayed_msgs,$show_hidden,$new_msgs;
 
-        $num = $mails[$start_message]->msgno;
-        $msg_ob = new Webmail($MailBox->mbox,$mails[$start_message]->msgno);
+	$num = $mails[$start_message]->msgno;
+	$msg_ob = new Webmail($MailBox->mbox,$mails[$start_message]->msgno);
 
-        // TODO: scan the current db vtiger_tables to find a
-        // matching email address that will make a good
-        // candidate for record_id
-        // this module will also need to be able to associate to any entity type
-        $record_id='';
+	// TODO: scan the current db vtiger_tables to find a
+	// matching email address that will make a good
+	// candidate for record_id
+	// this module will also need to be able to associate to any entity type
+	$record_id='';
 
-        if($mails[$start_message]->subject=="")
-                $mails[$start_message]->subject="(No Subject)";
+	if($mails[$start_message]->subject=="")
+		$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='.$num.'&mailbox='.$mailbox.'&mailid='.$num.'&parenttab=My Home Page';
+	// Let's pre-build our URL parameters since it's too much of a pain not to
+	$detailParams = 'record='.$num.'&mailbox='.$mailbox.'&mailid='.$num.'&parenttab=My Home Page';
 
-        $displayed_msgs++;
-        if ($mails[$start_message]->deleted && !$show_hidden) {
+	$displayed_msgs++;
+	if ($mails[$start_message]->deleted && !$show_hidden)
+	{
                 $flags = "<tr id='row_".$num."' class='mailSelected' style='display:none'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
-        $displayed_msgs--;
-        } elseif ($mails[$start_message]->deleted && $show_hidden)
-                $flags = "<tr id='row_".$num."' class='mailSelected'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
-        elseif (!$mails[$start_message]->seen || $mails[$start_message]->recent) {
-                $flags = "<tr class='mailSelected' id='row_".$num."'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
-                $new_msgs++;
-        } else
-                $flags = "<tr onmouseover='this.className=\"tabSelected\"' onmouseout='this.className=\"\"' id='row_".$num."'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
+        	$displayed_msgs--;
+	}
+	elseif ($mails[$start_message]->deleted && $show_hidden)
+	{
+		$flags = "<tr id='row_".$num."' class='mailSelected'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
+	}
+	elseif (!$mails[$start_message]->seen || $mails[$start_message]->recent)
+	{
+		$flags = "<tr class='mailSelected' id='row_".$num."'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
+		$new_msgs++;
+	}
+	else
+	{
+		$flags = "<tr onmouseover='this.className=\"tabSelected\"' onmouseout='this.className=\"\"' id='row_".$num."'><td width='2px'><input type='checkbox' name='checkbox_".$num."' class='msg_check'></td><td colspan='1'>";
+	}
+
+
+
 
         // Attachment Icons
         if($msg_ob->has_attachments)
@@ -47,17 +59,25 @@
         else
                 $flags.='<img src="modules/Webmails/images/blank.png" border="0" width="14px" height="14" alt="">&nbsp;';
 
+
+
         // read/unread/forwarded/replied
         if(!$mails[$start_message]->seen || $mails[$start_message]->recent)
-        {
-                $flags.='<span id="unread_img_'.$num.'"><a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><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;';
-        elseif (preg_match("/^fw:/i",$mails[$start_message]->subject))
-                $flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-forward.png" border="0" width="10" height="13"></a>&nbsp;';
-        else
+	{
+		$flags.='<span id="unread_img_'.$num.'"><a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><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;';
+	}
+	elseif (preg_match("/^fw:/i",$mails[$start_message]->subject))
+	{
+		$flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-forward.png" border="0" width="10" height="13"></a>&nbsp;';
+	}
+	else
+	{
                 $flags.='<a href="javascript:;" onclick="OpenCompose(\''.$num.'\',\'reply\');"><img src="modules/Webmails/images/stock_mail-read.png" border="0" width="10" height="11"></a>&nbsp;';
+	}
 
         // Set IMAP flag
         if($mails[$start_message]->flagged)
@@ -66,31 +86,61 @@
                 $flags.='<span id="set_td_'.$num.'"><a href="javascript:void(0);" onclick="runEmailCommand(\'set_flag\','.$num.');"><img src="modules/Webmails/images/plus.gif" border="0" width="11" height="11" id="set_flag_img_'.$num.'"></a></span>';
 
 
+
         $tmp=imap_mime_header_decode($mails[$start_message]->from);
         $from = $tmp[0]->text;
         $listview_entries[$num] = array();
 
         $listview_entries[$num][] = $flags."</td>";
 
-        if ($mails[$start_message]->deleted) {
-                $listview_entries[$num][] = '<td width="20%" nowrap 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 width="10%" nowrap align="left" nowrap id="deleted_date_'.$num.'"><s>'.substr($mails[$start_message]->date,0,30).'</s></td>';
-                $listview_entries[$num][] = '<td width="10%" nowrap align="left" id="deleted_from_'.$num.'"><s>'.substr($from,0,20).'</s></td>';
-        } elseif(!$mails[$start_message]->seen || $mails[$start_message]->recent) {
-                $listview_entries[$num][] = '<td width="20%" nowrap 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 width="10%" nowrap align="left" nowrap id="ndeleted_date_'.$num.'" >'.substr($mails[$start_message]->date,0,30).' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td>';
-                $listview_entries[$num][] = '<td  width="10%" nowrap align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,20).'</td>';
-        } else {
-                $listview_entries[$num][] = '<td width="20%" nowrap 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 width="10%" npwrap align="left" nowrap id="ndeleted_date_'.$num.'">'.substr($mails[$start_message]->date,0,30).'</td>';
-                $listview_entries[$num][] = '<td width="10%" nowrap align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,20).'</td>';
-        }
+	if ($mails[$start_message]->deleted)
+	{
+		$listview_entries[$num][] = '<td width="20%" nowrap 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 width="10%" nowrap align="left" nowrap id="deleted_date_'.$num.'"><s>'.substr($mails[$start_message]->date,0,30).'</s></td>';
+		$listview_entries[$num][] = '<td width="10%" nowrap align="left" id="deleted_from_'.$num.'"><s>'.substr($from,0,20).'</s></td>';
+	}
+	elseif(!$mails[$start_message]->seen || $mails[$start_message]->recent)
+	{
+		$listview_entries[$num][] = '<td width="20%" nowrap 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 width="10%" nowrap align="left" nowrap id="ndeleted_date_'.$num.'" >'.substr($mails[$start_message]->date,0,30).' &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</td>';
+		$listview_entries[$num][] = '<td  width="10%" nowrap align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,20).'</td>';
+	}
+	else
+	{
+		//IMPORTANT - This UTF-8 conversion has been done in ListView.php so no need to do again here
+		//Added to shown the original UTF-8 characters - Mickie - 30-11-06 - Starts
+		//we can use the option 1 or option 2
+		//Option 1 - Starts
+		/*
+		$translated_subject = imap_mime_header_decode($mails[$start_message]->subject);
+		for($i=0;$i<count($translated_subject);$i++)
+		{
+			if($translated_subject[$i]->charset != 'default')
+			{
+				$tmp .= $translated_subject[$i]->text;
+				$mails[$start_message]->subject = utf8_decode($tmp);//$tmp;
+			}
+		}
+		//Option 1 - Ends
+		*/
+		//Option 2 - Starts
+		//$mails[$start_message]->subject = utf8_decode(imap_utf8($mails[$start_message]->subject));//imap_utf8($mails[$start_message]->subject);
+		//Option 2 - Ends
+		//Added to shown the original UTF-8 characters - Mickie - 30-11-06 - Ends
 
+		$listview_entries[$num][] = '<td width="20%" nowrap 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 width="10%" npwrap align="left" nowrap id="ndeleted_date_'.$num.'">'.substr($mails[$start_message]->date,0,30).'</td>';
+		$listview_entries[$num][] = '<td width="10%" nowrap align="left" id="ndeleted_from_'.$num.'">'.substr($from,0,20).'</td>';
+	}
+
+
+	
         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/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/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 Mon Dec  4 23:08:02 2006
@@ -145,7 +145,7 @@
     	return $ret = Array("theader"=>$mailHeader);
     }
 
-    private function get_attachments() {
+    function get_attachments() {
        $struct = @imap_fetchstructure($this->mbox, $this->mailid);
        $parts = $struct->parts;
 
@@ -192,7 +192,7 @@
         return false;
     }
 
-    private function find_relationships() {
+    function find_relationships() {
 	// leads search
 	$sql = "SELECT * from vtiger_leaddetails left join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_leaddetails.leadid where vtiger_leaddetails.email = '".trim($this->from)."' AND vtiger_crmentity.deleted='0'";
 	$res = $this->db->query($sql,true,"Error: "."<BR>$query");
@@ -218,7 +218,7 @@
     }
 
     
-	private function dl_inline()
+	function dl_inline()
 	{
 		$struct = imap_fetchstructure($this->mbox, $this->mailid);
 		$parts = $struct->parts;
@@ -264,7 +264,10 @@
 							$filedata = $this->mail_fetchpart($partstring);
 						else
 							$filedata = imap_fetchbody($this->mbox, $this->mailid, $partstring);
-						
+
+						//Added to get the UTF-8 string - 30-11-06 - Mickie
+						$parts[$i]->dparameters[0]->value = utf8_decode(imap_utf8($parts[$i]->dparameters[0]->value));
+
 						$inline[] = array("filename" => $parts[$i]->dparameters[0]->value,"filedata"=>$filedata,"subtype"=>$parts[$i]->subtype,"filesize"=>$parts[$i]->bytes);
 					}
 				}
@@ -283,7 +286,7 @@
 		return $inline;
 	}
 
-	private function dl_attachments()
+	function dl_attachments()
 	{
 
 		$struct = imap_fetchstructure($this->mbox, $this->mailid);
@@ -345,7 +348,7 @@
 	}
 
 
-	private function load_mail()
+	function load_mail()
 	{
 		// parse the message
 		$struct = imap_fetchstructure($this->mbox, $this->mailid);

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 Mon Dec  4 23:08:02 2006
@@ -34,6 +34,10 @@
 <?php
 
 $email->loadMail();
+
+//Added to get the UTF-8 string - 30-11-06 - Mickie
+$email->body = utf8_decode(imap_utf8($email->body));
+
 echo $email->body;
 echo "<br><br>";
 





More information about the vtigercrm-commits mailing list