Index: /trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 1467)
+++ /trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 1472)
@@ -8,5 +8,5 @@
 {
 	var $public_functions = array
-	(	
+	(
 		'get_range_msgs'				=> True,
 		'get_info_msg'					=> True,
@@ -31,7 +31,7 @@
 		$this->imap_port	  = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
 		$this->imap_delimiter = $_SESSION['phpgw_info']['expressomail']['email_server']['imapDelimiter'];
-		$this->functions	  = new functions();		
+		$this->functions	  = new functions();
 		$this->has_cid = false;
-		
+
 		if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes')
 		{
@@ -66,10 +66,10 @@
 		}
 		// This condition verifies if SESSION is expired.
-		elseif(!count($_SESSION))			
+		elseif(!count($_SESSION))
 			return "nosession";
 
 		return $error;
 	}
-	
+
 	function get_range_msgs2($params)
 	{
@@ -77,14 +77,14 @@
 		$msg_range_begin = $params['msg_range_begin'];
 		$msg_range_end = $params['msg_range_end'];
-		$sort_box_type = $params['sort_box_type'];		
+		$sort_box_type = $params['sort_box_type'];
 		$sort_box_reverse = $params['sort_box_reverse'];
 		$search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false;
 		$sort_array_msg = $this-> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse,$msg_range_begin,$msg_range_end);
-		
+
 		$return = array();
 		$i = 0;
 		$num_msgs = imap_num_msg($this->mbox);
 		if(is_array($sort_array_msg)){
-			foreach($sort_array_msg as $msg_number => $value) 
+			foreach($sort_array_msg as $msg_number => $value)
 			{
 				$temp = $this->get_info_head_msg($msg_number);
@@ -108,5 +108,5 @@
 
 
-		/*Como eu preciso do atributo Importance para saber se o email é 
+		/*Como eu preciso do atributo Importance para saber se o email é
 		 * importante ou não, uso abaixo a função imap_fetchheader e busco
 		 * o atributo importance nela. Isso faz com que eu acesse o cabeçalho
@@ -184,6 +184,6 @@
 
 	function decode_string($string)
-	{	
-		
+	{
+
 		if ((strpos(strtolower($string), '=?iso-8859-1') !== false) || (strpos(strtolower($string), '=?windows-1252') !== false))
 		{
@@ -191,5 +191,5 @@
 			foreach ($tmp as $tmp1)
 				$return .= $this->htmlspecialchars_encode($tmp1->text);
-				
+
 			return $return;
 		}
@@ -227,5 +227,5 @@
 		if(!$this->mbox)
 			$this->mbox = $this->open_mbox();
- 		
+
  		if( preg_match('/local_/',$params["folder"]) )
 		{
@@ -239,5 +239,5 @@
 		$errors = array();
 		$invalid_format = false;
-		$filename = $params['FILES'][0]['name']; 
+		$filename = $params['FILES'][0]['name'];
 		$params["folder"] = mb_convert_encoding($params["folder"], "UTF7-IMAP","ISO_8859-1");
 		$quota = imap_get_quotaroot($this->mbox, $params["folder"]);
@@ -323,20 +323,20 @@
 		$return["status"] = true;
 		$header = "";
-		
+
 		$headertemp = explode("\n",imap_fetchheader($this->mbox, imap_msgno($this->mbox, $params["msg_num"])));
 		foreach($headertemp as $head) {//Se eu colocar todo o header do email dá pau no append, então procuro apenas o que interessa.
 			$head1 = explode(":",$head);
-			if ( (strtoupper($head1[0]) == "TO") || 
-					(strtoupper($head1[0]) == "FROM") || 
+			if ( (strtoupper($head1[0]) == "TO") ||
+					(strtoupper($head1[0]) == "FROM") ||
 					(strtoupper($head1[0]) == "SUBJECT") ||
 					(strtoupper($head1[0]) == "DATE") )
 				$header .= $head."\r\n";
 		}
-				
+
 		$msg = &new message_components($this->mbox);
-		$msg->fetch_structure($params["msg_num"]);/* O fetchbody tava trazendo o email com problemas na acentuação. 
-							     Então uso essa classe para verificar a codificação e o charset, 
+		$msg->fetch_structure($params["msg_num"]);/* O fetchbody tava trazendo o email com problemas na acentuação.
+							     Então uso essa classe para verificar a codificação e o charset,
 							     para que o método decodeBody do expresso possa trazer tudo certinho*/
-		
+
 		$status = imap_append($this->mbox,
 				"{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$params["folder"],
@@ -346,7 +346,7 @@
 							imap_fetchbody($this->mbox,imap_msgno($this->mbox, $params["msg_num"]),"1"),
 							$msg->encoding[$params["msg_num"]][0], $msg->charset[$params["msg_num"]][0]
-							)					
+							)
 					), "\\Seen"); //Append do novo email, só com header e conteúdo sem anexos.
-		
+
 		if(!$status)
 		{
@@ -357,16 +357,16 @@
 		{
 			$status = imap_status($this->mbox, "{".$this->imap_server.":".$this->imap_port."}".$params['folder'], SA_UIDNEXT);
-			$return['msg_no'] = $status->uidnext - 1; 
+			$return['msg_no'] = $status->uidnext - 1;
 			imap_delete($this->mbox, imap_msgno($this->mbox, $params["msg_num"]));
 			imap_expunge($this->mbox);
 		}
-		
+
 		return $return;
-		
+
 	}
 
 /**
-	 * 
-	 * @return 
+	 *
+	 * @return
 	 * @param $params Object
 	 */
@@ -395,15 +395,15 @@
 			$this->mbox=false;
 			array_push($return,serialize($msg_info));
-		
+
 			if($msg_info['Unseen'] == "U" || $msg_info['Recent'] == "N"){
-					array_push($unseen_msgs,$msg_number);		
-			}				
-		}		
+					array_push($unseen_msgs,$msg_number);
+			}
+		}
 		if($unseen_msgs){
 			$msgs_list = implode(",",$unseen_msgs);
 			$array_msgs = array('folder' => $new_params["msg_folder"], "msgs_to_set" => $msgs_list, "flag" => "unseen");
-			$this->set_messages_flag($array_msgs);	
-		}
-		
+			$this->set_messages_flag($array_msgs);
+		}
+
 		return $return;
 	}
@@ -414,18 +414,18 @@
 		$msg_number = $params['msg_number'];
 		$msg_folder = $params['msg_folder'];
-		
+
 		if(!$this->mbox || !is_resource($this->mbox))
-			$this->mbox = $this->open_mbox($msg_folder);		
-		
+			$this->mbox = $this->open_mbox($msg_folder);
+
 		$header = $this->get_header($msg_number);
 		if (!$header) {
-			$return['status_get_msg_info'] = "false";			
+			$return['status_get_msg_info'] = "false";
 			return $return;
 		}
-		
+
 		$header_ = imap_fetchheader($this->mbox, $msg_number, FT_UID);
 
 		$return_get_body = $this->get_body_msg($msg_number, $msg_folder);
-		
+
 		//Substituição de links em email para abrir no próprio expresso
 		$body = mb_ereg_replace("<a[^>]*href=[\'\"]mailto:([^\"\']+)[\'\"]>([^<]+)</a>","<a href=\"javascript:new_message_to('\\1')\">\\2</a>",$return_get_body['body']);
@@ -454,5 +454,5 @@
 		$return['Recent']	= $header->Recent;
 		$return['Unseen']	= $header->Unseen;
-		$return['Deleted']	= $header->Deleted;		
+		$return['Deleted']	= $header->Deleted;
 		$return['Flagged']	= $header->Flagged;
 
@@ -460,13 +460,13 @@
 			$return['Forwarded'] = 'F';
 		}
- 
+
 		else {
 			$return['Answered']	= $header->Answered;
-			$return['Draft']	= $header->Draft;	
+			$return['Draft']	= $header->Draft;
 		}
 
 		$return['msg_number'] = $msg_number;
 		$return['msg_folder'] = $msg_folder;
-	
+
 		$date_msg = gmdate("d/m/Y",$header->udate);
 		if (date("d/m/Y") == $date_msg)
@@ -474,8 +474,8 @@
 		else
 			$return['udate'] = $date_msg;
-		
-		$return['msg_day'] = $date_msg; 
+
+		$return['msg_day'] = $date_msg;
 		$return['msg_hour'] = gmdate("H:i",$header->udate);
-		
+
 		if (date("d/m/Y") == $date_msg) //no dia
 		{
@@ -483,11 +483,11 @@
 			$return['smalldate'] = gmdate("H:i",$header->udate);
 
-			$timestamp_now = strtotime("now");  			
+			$timestamp_now = strtotime("now");
 			$timestamp_msg_time = $header->udate;
-			// $timestamp_now is GMT and $timestamp_msg_time is MailDate TZ. 
+			// $timestamp_now is GMT and $timestamp_msg_time is MailDate TZ.
 			// The variable $timestamp_diff is calculated without MailDate TZ.
 			$pdate = date_parse($header->MailDate);
 			$timestamp_diff = $timestamp_now - $timestamp_msg_time  + ($pdate['zone']*(-60));
-			
+
 			if (gmdate("H",$timestamp_diff) > 0)
 			{
@@ -511,5 +511,5 @@
 			$return['smalldate'] = gmdate("d/m/Y",$header->udate);
 		}
-		
+
 		$from = $header->from;
 		$return['from'] = array();
@@ -525,8 +525,8 @@
 		else
 			$return['from']['full'] = $return['from']['email'];
-		
+
 		// Sender attribute
 		$sender = $header->sender;
-		$return['sender'] = array();		
+		$return['sender'] = array();
 		$return['sender']['name'] = $this->decode_string($sender[0]->personal);
 		$return['sender']['email'] = $this->decode_string($sender[0]->mailbox . "@" . $sender[0]->host);
@@ -576,6 +576,6 @@
 		{
 			$return['toaddress2'] = "&lt;Empty&gt;";
-		}	
-		
+		}
+
 		$cc = $header->cc;
 		$return['cc'] = "";
@@ -605,5 +605,5 @@
 		{
 			$return['cc'] = "";
-		}	
+		}
 
 		##
@@ -639,5 +639,5 @@
 		{
 			$return['bcc'] = "";
-		}	
+		}
 
 		$reply_to = $header->reply_to;
@@ -679,5 +679,5 @@
 		return $return;
 	}
-	
+
 	function get_body_msg($msg_number, $msg_folder)
 	{
@@ -686,11 +686,11 @@
 		$msg->fetch_structure($msg_number);
 		$return = array();
-		$return['attachments'] = $this-> download_attachment($msg,$msg_number);		
+		$return['attachments'] = $this-> download_attachment($msg,$msg_number);
 		if(!$this->has_cid)
 		{
 			$return['thumbs']  = $this->get_thumbs($msg,$msg_number,urlencode($msg_folder));
 			$return['signature'] = $this->get_signature($msg,$msg_number,$msg_folder);
-		}			
-		
+		}
+
 		if(!$msg->structure[$msg_number]->parts) //Simple message, only 1 piece
 		{
@@ -717,5 +717,5 @@
 			}
 		}
-		else 
+		else
 		{ //Complicated message, multiple parts
 			$html_body = '';
@@ -723,8 +723,8 @@
 			$has_multipart = true;
 			$this->has_cid = false;
-			
+
 			if (strtolower($msg->structure[$msg_number]->subtype) == "related")
 				$this->has_cid = true;
-			
+
 			if (strtolower($msg->structure[$msg_number]->subtype) == "alternative") {
 				$show_only_html = false;
@@ -732,5 +732,5 @@
 					$file_type = strtolower($msg->file_type[$msg_number][$values]);
 					if($file_type == "text/html")
-						$show_only_html = true;			
+						$show_only_html = true;
 				}
 			}
@@ -740,13 +740,13 @@
 			foreach($msg->pid[$msg_number] as $values => $msg_part)
 			{
-				
+
 				$file_type = strtolower($msg->file_type[$msg_number][$values]);
 				if($file_type == "message/rfc822")
 					$has_multipart = false;
-	
+
 				if($file_type == "multipart/alternative")
 					$has_multipart = false;
-	
-				if(($file_type == "text/plain" 
+
+				if(($file_type == "text/plain"
 					|| $file_type == "text/html")
 					&& $file_type != 'attachment')
@@ -756,5 +756,5 @@
 						// if TXT file size > 100kb, then it will not expand.
 						if(!($file_type == "text/plain" && $msg->fsize[$msg_number][$values] > 102400)) {
-							$content .= nl2br(htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])));							
+							$content .= nl2br(htmlentities($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values])));
 						}
 					}
@@ -768,21 +768,21 @@
 				else if($file_type == "message/delivery-status"){
 					$content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
-					$content .= nl2br($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]));						
+					$content .= nl2br($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]));
 
 				}
 				else if($file_type == "message/rfc822" || $file_type == "text/rfc822-headers"){
-					
+
 					include_once("class.imap_attachment.inc.php");
 					$att = new imap_attachment();
 					$attachments =  $att -> get_attachment_info($this->mbox,$msg_number);
-					if($attachments['number_attachments'] > 0) {												
+					if($attachments['number_attachments'] > 0) {
 						foreach($attachments ['attachment'] as $index => $attachment){
 							if(strtolower($attachment['type']) == "delivery-status" ||
-								strtolower($attachment['type']) == "rfc822" ||								
+								strtolower($attachment['type']) == "rfc822" ||
 								strtolower($attachment['type']) == "rfc822-headers" ||
 								strtolower($attachment['type']) == "plain"
 							){
-								$obj = imap_rfc822_parse_headers(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values]);					
-								$content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";					
+								$obj = imap_rfc822_parse_headers(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID), $msg->encoding[$msg_number][$values]);
+								$content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
 								$content .= "<br><table  style='margin:2px;border:1px solid black;background:#EAEAEA'>";
 								$content .= "<tr><td><b>".$this->functions->getLang("Subject").":</b></td><td>".$this->decode_string($obj->subject)."</td></tr>";
@@ -790,8 +790,8 @@
 								$content .= "<tr><td><b>".$this->functions->getLang("Date").":</b></td><td>".$obj->date."</td></tr>";
 								$content .= "<tr><td><b>".$this->functions->getLang("TO").":</b></td><td>".$this->decode_string($obj->to[0]->mailbox."@".$obj->to[0]->host)."</td></tr>";
-								$content .= !$obj->cc ? "</table><br>" :"<tr><td><b>".$this->functions->getLang("CC").":</b></td><td>".$this->decode_string($obj->cc[0]->mailbox."@".$obj->cc[0]->host)."</td></tr></table><br>";								
+								$content .= !$obj->cc ? "</table><br>" :"<tr><td><b>".$this->functions->getLang("CC").":</b></td><td>".$this->decode_string($obj->cc[0]->mailbox."@".$obj->cc[0]->host)."</td></tr></table><br>";
 								$ix_part = 	strtolower($attachment['type']) == "delivery-status" ? 1 : 0;
-								$content .= nl2br($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, ($attachment['part_in_msg']+$ix_part).".1", FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]));								
-								break;			
+								$content .= ($this->decodeBody(imap_fetchbody($this->mbox, $msg_number, ($attachment['part_in_msg']+$ix_part).".1", FT_UID), $msg->encoding[$msg_number][$values], $msg->charset[$msg_number][$values]));
+								break;
 							}
 						}
@@ -803,9 +803,9 @@
 					$content .= nl2br(imap_base64(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID)));
 				else if(!strtolower($msg->structure[$msg_number]->subtype) == "mixed")
-					$content .= nl2br(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID));				
-			}
-		} 
+					$content .= nl2br(imap_fetchbody($this->mbox, $msg_number, $msg_part, FT_UID));
+			}
+		}
 		// Force message with flag Seen (imap_fetchbody not works correctly)
-		$params = array('folder' => $msg_folder, "msgs_to_set" => $msg_number, "flag" => "seen");				
+		$params = array('folder' => $msg_folder, "msgs_to_set" => $msg_number, "flag" => "seen");
 		$this->set_messages_flag($params);
 		$content = $this->process_embedded_images($msg,$msg_number,$content, $msg_folder);
@@ -814,9 +814,9 @@
 		return $return;
 	}
-	
+
 	function htmlfilter($body)
 	{
 		require_once('htmlfilter.inc');
-		
+
 		$tag_list = Array(
 				false,
@@ -891,6 +891,6 @@
                         		  '\\1round:\\2\\1'
                           		)
-		                    ),     
-          
+		                    ),
+
 		          '/^style/i' =>
     		              Array(
@@ -918,6 +918,6 @@
 				'/^a$/i' => Array('target' => '"_new"')
 		);
-    	
-    	
+
+
 		$trusted_body = sanitize($body,
 				$tag_list,
@@ -929,8 +929,8 @@
 				$add_attr_to_tag
 		);
-    	
+
 	    return $trusted_body;
 	}
-	
+
 	function decodeBody($body, $encoding, $charset=null)
 	{
@@ -944,5 +944,5 @@
 		{
 			/*
-			
+
 			for($i=0;$i<256;$i++) {
 				$c1=dechex($i);
@@ -951,20 +951,20 @@
 				$myqprinta[]=$c1;
 				$myqprintb[]=chr($i);
-			}	    	
+			}
 			 */
 			$body = str_replace($myqprinta,$myqprintb,($body));
 			$body = quoted_printable_decode($body);
-        	while (ereg("=\n", $body)) 
+        	while (ereg("=\n", $body))
         	{
            		$body = ereg_replace ("=\n", '', $body);
         	}
     	}
-    	else if ($encoding == 'base64') 
+    	else if ($encoding == 'base64')
     	{
         	$body = base64_decode($body);
     	}
-    	else if ($encoding == '7bit') 
+    	else if ($encoding == '7bit')
     	{
-        	$body = quoted_printable_decode($body);        	        	        	
+        	$body = quoted_printable_decode($body);
     	}
 		// All other encodings are returned raw.
@@ -974,5 +974,5 @@
 			return $body;
 	}
-	
+
 	function process_embedded_images($msg, $msgno, $body, $msg_folder)
 	{
@@ -991,12 +991,12 @@
 			}
 		}
-		
+
 		return $body;
 	}
-	
+
 	function replace_special_characters($body)
 	{
 		// Suspected TAGS!
-		/*$tag_list = Array(   
+		/*$tag_list = Array(
 			'blink','object','meta',
 			'html','link','frame',
@@ -1007,6 +1007,6 @@
 		*/
 
-		// Layout problem: Change html elements 
-		// with absolute position to relate position, CASE INSENSITIVE. 
+		// Layout problem: Change html elements
+		// with absolute position to relate position, CASE INSENSITIVE.
 		$body = @mb_eregi_replace("POSITION: ABSOLUTE;","",$body);
 
@@ -1016,5 +1016,5 @@
 
 		$body = $this-> replace_links($body);
-		$blocked_tags = array();		
+		$blocked_tags = array();
 		foreach($tag_list as $index => $tag) {
 			$new_body = @mb_eregi_replace("<$tag", "<!--$tag", $body);
@@ -1034,5 +1034,5 @@
 	}
 
-	function replace_links($body) {					
+	function replace_links($body) {
   		$matches = array();
 		// Verify exception.
@@ -1041,9 +1041,9 @@
 		if(count($matches))
 			return $body;
-			
+
 		$pattern = '/[\s\r\n>;]+((http(s?):\/\/((?:[\w]\.?)+(?::[\d]+)?[:\/.\-~&=?%;@#,+\w]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\:\/\w.\-~&=?%;@+]*))/i';
 		$replacement = '<a href="http$3://$4$5" target="_blank">$1</a>';
-		return preg_replace($pattern, $replacement, $body); 
-		
+		return preg_replace($pattern, $replacement, $body);
+
 		// Original
 		//return preg_replace('/(?<=[\s|(<br>)|\n|\r|;])((http(s?):\/\/((?:[\w]\.?)+(?::[\d]+)?[\/.\-~&=?%;@#,+\w]*))|((?:www?\.)(?:\w\.?)*(?::\d+)?[\/\w.\-~&=?%;@+]*))/i', '<a href="http$3://$4$5" target="_blank">http$3://$4$5</a>', $body);
@@ -1060,7 +1060,7 @@
 			if($temp['ContentType'] =='normal') return $sign;
 			$file_type = strtolower($file_type);
-			if(strtolower($msg->encoding[$msg_number][$index]) == 'base64') 
+			if(strtolower($msg->encoding[$msg_number][$index]) == 'base64')
 			{
-				if ($file_type == 'application/x-pkcs7-signature' || $file_type == 'application/pkcs7-signature') 
+				if ($file_type == 'application/x-pkcs7-signature' || $file_type == 'application/pkcs7-signature')
 				{
 					if(!$this->mbox || !is_resource($this->mbox))
@@ -1186,5 +1186,5 @@
 			}
 		}
-   		return $sign;	
+   		return $sign;
 	}
 
@@ -1207,12 +1207,12 @@
     	return $thumbs_array;
 	}
-		
+
 	/*function delete_msg($params)
 	{
 		$folder = $params['folder'];
 		$msgs_to_delete = explode(",",$params['msgs_to_delete']);
-		
+
 		$mbox_stream = $this->open_mbox($folder);
-		
+
 		foreach ($msgs_to_delete as $msg_number){
 			imap_delete($mbox_stream, $msg_number, FT_UID);
@@ -1225,12 +1225,12 @@
 	function delete_msgs($params)
 	{
-		
+
 		$folder = $params['folder'];
 		$folder =  mb_convert_encoding($folder, "UTF7-IMAP","ISO-8859-1");
 		$msgs_number = explode(",",$params['msgs_number']);
 		$border_ID = $params['border_ID'];
-		
+
 		$return = array();
-		
+
 		if ($params['get_previous_msg']){
 			$return['previous_msg'] = $this->get_info_previous_msg($params);
@@ -1239,7 +1239,7 @@
 		}
 
-		//$mbox_stream = $this->open_mbox($folder);	 	
+		//$mbox_stream = $this->open_mbox($folder);
 	 	$mbox_stream = @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$folder, $this->username, $this->password) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error()))));
-		
+
 		foreach ($msgs_number as $msg_number)
 		{
@@ -1247,8 +1247,8 @@
 				$return['msgs_number'][] = $msg_number;
 		}
-		
+
 		$return['folder'] = $folder;
 		$return['border_ID'] = $border_ID;
-		
+
 		if($mbox_stream)
 			imap_close($mbox_stream, CL_EXPUNGE);
@@ -1256,14 +1256,14 @@
 	}
 
-		
+
 	function refresh($params)
 	{
 		include_once("class.imap_attachment.inc.php");
-		$imap_attachment = new imap_attachment();		
+		$imap_attachment = new imap_attachment();
 		$folder = $params['folder'];
 		$msg_range_begin = $params['msg_range_begin'];
 		$msg_range_end = $params['msg_range_end'];
 		$msgs_existent = $params['msgs_existent'];
-		$sort_box_type = $params['sort_box_type'];		
+		$sort_box_type = $params['sort_box_type'];
 		$sort_box_reverse = $params['sort_box_reverse'];
 		$msgs_in_the_server = array();
@@ -1273,11 +1273,11 @@
 		if(!count($msgs_in_the_server))
 			return array();
-			
+
 		$num_msgs = (count($msgs_in_the_server) - imap_num_recent($this->mbox));
-		$msgs_in_the_client = explode(",", $msgs_existent);	
+		$msgs_in_the_client = explode(",", $msgs_existent);
 
 		$msg_to_insert  = array_diff($msgs_in_the_server, $msgs_in_the_client);
 		$msg_to_delete = array_diff($msgs_in_the_client, $msgs_in_the_server);
-		
+
 		$msgs_to_exec = array();
 		if ((count($msg_to_insert)) && ($msgs_existent))
@@ -1305,5 +1305,5 @@
 			}
 		}
-		
+
 		$return = array();
 		$i = 0;
@@ -1311,5 +1311,5 @@
 		{
 			/*A função imap_headerinfo não traz o cabeçalho completo, e sim alguns
-			* atributos do cabeçalho. Como eu preciso do atributo Importance 
+			* atributos do cabeçalho. Como eu preciso do atributo Importance
 			* para saber se o email é importante ou não, uso abaixo a função
 			* imap_fetchheader e busco o atributo importance nela para passar
@@ -1323,5 +1323,5 @@
 			$flag = preg_match('/importance *: *(.*)\r/i', $tempHeader, $importance);
 			$return[$i]['Importance'] = $flag==0?"Normal":$importance[1];
-			
+
 			$header = $this->get_header($msg_number);
 			if (!is_object($header))
@@ -1330,5 +1330,5 @@
 			$return[$i]['msg_number']	= $msg_number;
 			$return[$i]['command']		= $command;
-			
+
 			$return[$i]['msg_folder']	= $folder;
             // Atribui o tipo (normal, signature ou cipher) ao campo Content-Type
@@ -1346,5 +1346,5 @@
 			else
 				$return[$i]['udate'] = $date_msg;
-			
+
 			$from = $header->from;
 			$return[$i]['from'] = array();
@@ -1352,8 +1352,8 @@
 			$return[$i]['from']['name'] = $tmp[0]->text;
 			$return[$i]['from']['email'] = $from[0]->mailbox . "@" . $from[0]->host;
-			//$return[$i]['from']['full'] ='"' . $return[$i]['from']['name'] . '" ' . '<' . $return[$i]['from']['email'] . '>'; 
+			//$return[$i]['from']['full'] ='"' . $return[$i]['from']['name'] . '" ' . '<' . $return[$i]['from']['email'] . '>';
 			if(!$return[$i]['from']['name'])
 				$return[$i]['from']['name'] = $return[$i]['from']['email'];
-			
+
 			/*$toaddress = imap_mime_header_decode($header->toaddress);
 			$return[$i]['toaddress'] = '';
@@ -1366,10 +1366,10 @@
 			$return[$i]['to']['email'] = $to[0]->mailbox . "@" . $to[0]->host;
 			$return[$i]['to']['full'] ='"' . $return[$i]['to']['name'] . '" ' . '<' . $return[$i]['to']['email'] . '>';
-			
+
 			$return[$i]['subject'] = $this->decode_string($header->fetchsubject);
 
 			$return[$i]['Size'] = $header->Size;
 			$return[$i]['reply_toaddress'] = $header->reply_toaddress;
-			
+
 			$return[$i]['attachment'] = array();
 			$return[$i]['attachment'] = $imap_attachment->get_attachment_headerinfo($this->mbox, $msg_number);
@@ -1413,10 +1413,10 @@
      * Se usar $params['noSharedFolders'] = true, ira retornar todas as pastas do usuário logado,
      * excluindo as compartilhadas para ele.
-     * @return Retorna um array contendo as seguintes informacoes de cada pasta: folder_unseen, 
+     * @return Retorna um array contendo as seguintes informacoes de cada pasta: folder_unseen,
      * folder_id, folder_name, folder_parent e folder_hasChildren.
-     */	
+     */
 	function get_folders_list($params = null)
 	{
-		$mbox_stream = $this->open_mbox();		
+		$mbox_stream = $this->open_mbox();
 		$serverString = "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}";
 		$folders_list = imap_getmailboxes($mbox_stream, $serverString, ($params && $params['noSharedFolders']) ? "INBOX/*" : "*");
@@ -1425,9 +1425,9 @@
 		$tmp = array();
 		$result = array();
-		
+
 		if (is_array($folders_list)) {
   			reset($folders_list);
             $this->ldap = new ldap_functions();
-			
+
 			$i = 0;
   			while (list($key, $val) = each($folders_list)) {
@@ -1444,5 +1444,5 @@
   				$folder_id = $tmp_folder_id[1];
 				$result[$i]['folder_id'] = $folder_id;
-				
+
 				$tmp_folder_parent = explode($this->imap_delimiter, $folder_id);
 				$result[$i]['folder_name'] = array_pop($tmp_folder_parent);
@@ -1454,8 +1454,8 @@
 					}
 				}
-				
+
 				$tmp_folder_parent = implode($this->imap_delimiter, $tmp_folder_parent);
 				$result[$i]['folder_parent'] = $tmp_folder_parent == 'INBOX' ? '' : $tmp_folder_parent;
-					
+
 				if (($val->attributes == 32) && ($result[$i]['folder_name'] != 'Inbox'))
 					$result[$i]['folder_hasChildren'] = 1;
@@ -1463,20 +1463,20 @@
 					$result[$i]['folder_hasChildren'] = 0;
 
-				$i++;				
+				$i++;
   			}
 		}
-		
+
 		foreach ($result as $folder_info)
 		{
 			$array_tmp[] = $folder_info['folder_id'];
 		}
-		
+
 		natcasesort($array_tmp);
-		
+
 		foreach ($array_tmp as $key => $folder_id)
 		{
 			$result2[] = $result[$key];
 		}
-		
+
 		$current_folder = "INBOX";
 		if($params && $params['folder'])
@@ -1484,5 +1484,5 @@
 		return array_merge($result2, $this->get_quota(array(folder_id => $current_folder)));
 	}
-	
+
 	function create_mailbox($arr)
 	{
@@ -1491,18 +1491,18 @@
 		$imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
 		$namebox =  mb_convert_encoding($namebox, "UTF7-IMAP", "UTF-8");
-		
+
 		$result = "Ok";
 		if(!imap_createmailbox($mbox_stream,"{".$imap_server."}$namebox"))
 		{
 			$result = implode("<br />\n", imap_errors());
-		}	
-		
+		}
+
 		if($mbox_stream)
 			imap_close($mbox_stream);
-					
+
 		return $result;
-		
-	}
-	
+
+	}
+
 	function create_extra_mailbox($arr)
 	{
@@ -1511,10 +1511,10 @@
 		$mbox_stream = $this->open_mbox();
 		$imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
-		foreach($nameboxs as $key=>$tmp){			
+		foreach($nameboxs as $key=>$tmp){
 			if($tmp != ""){
 				if(!imap_createmailbox($mbox_stream,imap_utf7_encode("{".$imap_server."}$tmp"))){
 					$result = implode("<br />\n", imap_errors());
 					if($mbox_stream)
-						imap_close($mbox_stream);					
+						imap_close($mbox_stream);
 					return $result;
 				}
@@ -1525,5 +1525,5 @@
 		return true;
 	}
-	
+
 	function delete_mailbox($arr)
 	{
@@ -1532,5 +1532,5 @@
 		$mbox_stream = $this->open_mbox();
 		//$del_folder = imap_deletemailbox($mbox_stream,"{".$imap_server."}INBOX.$namebox");
-		
+
 		$result = "Ok";
 		$namebox = mb_convert_encoding($namebox, "UTF7-IMAP","UTF-8");
@@ -1543,5 +1543,5 @@
 		return $result;
 	}
-	
+
 	function ren_mailbox($arr)
 	{
@@ -1551,19 +1551,19 @@
 		$mbox_stream = $this->open_mbox();
 		//$ren_folder = imap_renamemailbox($mbox_stream,"{".$imap_server."}INBOX.$namebox","{".$imap_server."}INBOX.$new_box");
-		
+
 		$result = "Ok";
 		$namebox = mb_convert_encoding($namebox, "UTF7-IMAP","UTF-8");
 		$new_box = mb_convert_encoding($new_box, "UTF7-IMAP","UTF-8");
-		
+
 		if(!imap_renamemailbox($mbox_stream,"{".$imap_server."}$namebox","{".$imap_server."}$new_box"))
 		{
-			$result = imap_errors();			
+			$result = imap_errors();
 		}
 		if($mbox_stream)
 			imap_close($mbox_stream);
 		return $result;
-		
-	}
-	
+
+	}
+
 	function get_num_msgs($params)
 	{
@@ -1573,12 +1573,12 @@
 			if(!$this->mbox || !is_resource($this->mbox))
 			return imap_last_error();
-		}		
+		}
 		$num_msgs = imap_num_msg($this->mbox);
 		if($this->mbox && is_resource($this->mbox))
 			imap_close($this->mbox);
-		
+
 		return $num_msgs;
 	}
-	
+
 	function send_mail($params)
 	{
@@ -1661,14 +1661,14 @@
 		$forwarding_attachments = $params['forwarding_attachments'];
 		$local_attachments = $params['local_attachments'];
-		 
+
 		$folder =$params['folder'];
-		$folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1");		
-		$folder_name = $params['folder_name'];		
+		$folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1");
+		$folder_name = $params['folder_name'];
 		// Fix problem with cyrus delimiter changes.
-		// Dots in names: enabled/disabled.				
+		// Dots in names: enabled/disabled.
 		$folder = @eregi_replace("INBOX/", "INBOX".$this->imap_delimiter, $folder);
 		$folder = @eregi_replace("INBOX.", "INBOX".$this->imap_delimiter, $folder);
 		// End Fix.
-		if ($folder != 'null'){			
+		if ($folder != 'null'){
 			$mail->SaveMessageInFolder = $folder;
 		}
@@ -1683,5 +1683,5 @@
 		else
             $mail->IsSMTP();
-            
+
 		$mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer'];
 		$mail->Port = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpPort'];
@@ -1694,5 +1694,5 @@
 			$mail->From = $fromaddress[1];
 		}
-				
+
 		$this->add_recipients("to", $toaddress, &$mail);
 		$this->add_recipients("cc", $ccaddress, &$mail);
@@ -1806,7 +1806,7 @@
                 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36);
 		        }
-		        $cid = $cid_array[$cid_imgs[4][$j].$val]; 
+		        $cid = $cid_array[$cid_imgs[4][$j].$val];
         		$mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body);
-        		
+
 				if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail?
 				{
@@ -1821,5 +1821,5 @@
 					$file_description = unserialize(rawurldecode($attach_img));
 
-					foreach($file_description as $i => $descriptor){				
+					foreach($file_description as $i => $descriptor){
 						$file_description[$i]  = eregi_replace('\'*\'','',$descriptor);
 					}
@@ -1831,5 +1831,5 @@
 				}
 				$tempDir = ini_get("session.save_path");
-				$file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";	
+				$file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";
 				$f = fopen($tempDir.'/'.$file,"w");
 				fputs($f,$fileContent);
@@ -1838,5 +1838,5 @@
 					$mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType);
 				//else
-				//	return "Error loading image attachment content";						
+				//	return "Error loading image attachment content";
 
 		}
@@ -1853,14 +1853,14 @@
 			}
 			if( $total_uploaded_size > $upload_max_filesize)
-				return $this->parse_error("message file too big");			
+				return $this->parse_error("message file too big");
 		}
 		else if(($params['is_local_forward']=="1") && (count($local_attachments))) { //Caso seja forward de mensagens locais
 
 			$total_uploaded_size = 0;
-			$upload_max_filesize = str_replace("M","",ini_get('upload_max_filesize')) * 1024 * 1024;			
+			$upload_max_filesize = str_replace("M","",ini_get('upload_max_filesize')) * 1024 * 1024;
 			foreach($local_attachments as $local_attachment) {
 				$file_description = unserialize(rawurldecode($local_attachment));
 				$tmp = array_values($file_description);
-				foreach($file_description as $i => $descriptor){				
+				foreach($file_description as $i => $descriptor){
 					$tmp[$i]  = eregi_replace('\'*\'','',$descriptor);
 				}
@@ -1879,14 +1879,14 @@
 				$name_cid_files[count($name_cid_files)] = $name_cid_files[0];
 				$name_cid_files[0] = null;
-			}			
-			
+			}
+
 			foreach($forwarding_attachments as $forwarding_attachment)
 			{
 					$file_description = unserialize(rawurldecode($forwarding_attachment));
 					$tmp = array_values($file_description);
-					foreach($file_description as $i => $descriptor){				
+					foreach($file_description as $i => $descriptor){
 						$tmp[$i]  = eregi_replace('\'*\'','',$descriptor);
 					}
-					$file_description = $tmp;					
+					$file_description = $tmp;
 					$fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]);
 					$fileName = $file_description[2];
@@ -1909,5 +1909,5 @@
 
 		$sent = $mail->Send();
-		
+
 		if(!$sent)
 		{
@@ -1920,5 +1920,5 @@
 				return $sent;
 			}
-			if($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] == "True") 
+			if($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_enable_log_messages'] == "True")
 			{
 				$userid = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
@@ -1926,8 +1926,8 @@
 				$now = date("d/m/y H:i:s");
 				$addrs = $toaddress.$ccaddress.$ccoaddress;
-				$sent = trim($sent);									   			
+				$sent = trim($sent);
    				error_log("$now - $userip - $sent [$subject] - $userid => $addrs\r\n", 3, "/home/expressolivre/mail_senders.log");
 			}
-			if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] && 
+			if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['number_of_contacts'] &&
 		   	   $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts']) {
 				$contacts = new dynamic_contacts();
@@ -1961,11 +1961,11 @@
 	function add_recipients($recipient_type, $full_address, $mail)
 	{
-		$parse_address = imap_rfc822_parse_adrlist($full_address, "");		
-		foreach ($parse_address as $val) 
+		$parse_address = imap_rfc822_parse_adrlist($full_address, "");
+		foreach ($parse_address as $val)
 		{
 			//echo "<script language=\"javascript\">javascript:alert('".$val->mailbox."@".$val->host."');</script>";
 			if ($val->mailbox == "INVALID_ADDRESS")
 				continue;
-			
+
 			if (empty($val->personal))
 			{
@@ -2001,9 +2001,9 @@
 		return true;
 	}
-	
+
 	function get_forwarding_attachment($msg_folder, $msg_number, $msg_part, $encoding)
 	{
 		$mbox_stream = $this->open_mbox(utf8_decode(urldecode($msg_folder)));
-		$fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID);		
+		$fileContent = imap_fetchbody($mbox_stream, $msg_number, $msg_part, FT_UID);
 		if($encoding == 'base64')
 			# The function imap_base64 adds a new line
@@ -2014,20 +2014,20 @@
 			$fileContent = base64_decode($fileContent);
 		else if($encoding == 'quoted-printable')
-			$fileContent = quoted_printable_decode($fileContent);				
+			$fileContent = quoted_printable_decode($fileContent);
 		return $fileContent;
 	}
-	
+
 	function del_last_caracter($string)
 	{
 		$string = substr($string,0,(strlen($string) - 1));
-		return $string;	
-	}
-	
+		return $string;
+	}
+
 	function del_last_two_caracters($string)
 	{
 		$string = substr($string,0,(strlen($string) - 2));
-		return $string;	
-	}
-	
+		return $string;
+	}
+
 	function messages_sort($sort_box_type,$sort_box_reverse, $search_box_type,$offsetBegin,$offsetEnd)
 	{
@@ -2101,8 +2101,8 @@
 		if(!is_array($sort))
 			$sort = array();
-			
+
 		if ($slice_array)
 			$sort = array_slice($sort,$offsetBegin-1,$offsetEnd-($offsetBegin-1),true);
-			
+
 
 		return $sort;
@@ -2111,10 +2111,10 @@
 
 
-	function move_search_messages($params){		
-		$params['selected_messages'] = urldecode($params['selected_messages']);	
+	function move_search_messages($params){
+		$params['selected_messages'] = urldecode($params['selected_messages']);
 		$params['new_folder'] = urldecode($params['new_folder']);
 		$params['new_folder_name'] = urldecode($params['new_folder_name']);
 		$sel_msgs = explode(",", $params['selected_messages']);
-		@reset($sel_msgs);	
+		@reset($sel_msgs);
 		$sorted_msgs = array();
 		foreach($sel_msgs as $idx => $sel_msg) {
@@ -2122,5 +2122,5 @@
 			 if(array_key_exists($sel_msg[0], $sorted_msgs)){
 			 	$sorted_msgs[$sel_msg[0]] .= ",".$sel_msg[1];
-			 }	
+			 }
 			 else {
 				$sorted_msgs[$sel_msg[0]] = $sel_msg[1];
@@ -2128,10 +2128,10 @@
 		}
 		@ksort($sorted_msgs);
-		$last_return = false;		
-		foreach($sorted_msgs as $folder => $msgs_number) {			
+		$last_return = false;
+		foreach($sorted_msgs as $folder => $msgs_number) {
 			$params['msgs_number'] = $msgs_number;
-			$params['folder'] = $folder;	
+			$params['folder'] = $folder;
 			if($params['new_folder'] && $folder != $params['new_folder']){
-				$last_return = $this -> move_messages($params);				
+				$last_return = $this -> move_messages($params);
 			}
 			elseif(!$params['new_folder'] || $params['delete'] ){
@@ -2142,9 +2142,9 @@
 		return $last_return;
 	}
-	
+
 	function move_messages($params)
 	{
-		$folder = $params['folder'];		
-		$mbox_stream = $this->open_mbox($folder);		
+		$folder = $params['folder'];
+		$mbox_stream = $this->open_mbox($folder);
 		$newmailbox = ($params['new_folder']);
 		$newmailbox = mb_convert_encoding($newmailbox, "UTF7-IMAP","ISO_8859-1");
@@ -2156,5 +2156,5 @@
 						'border_ID' => $params['border_ID'],
 						'status' => true); //Status foi adicionado para validar as permissoes ACL
-		
+
 		//Este bloco tem a finalidade de averiguar as permissoes para pastas compartilhadas
         if (substr($folder,0,4) == 'user'){
@@ -2177,5 +2177,5 @@
         }
         //Este bloco tem a finalidade de transformar o CPF das pastas compartilhadas em common name
-        if (substr($new_folder_name,0,4) == 'user'){        	
+        if (substr($new_folder_name,0,4) == 'user'){
         	$this->ldap = new ldap_functions();
         	$tmp_folder_name = explode($this->imap_delimiter, $new_folder_name);
@@ -2185,6 +2185,6 @@
 					$return['new_folder_name'] = $cn;
         }
-		
-		// Caso estejamos no box principal, nao eh necessario pegar a informacao da mensagem anterior. 		
+
+		// Caso estejamos no box principal, nao eh necessario pegar a informacao da mensagem anterior.
 		if (($params['get_previous_msg']) && ($params['border_ID'] != 'null') && ($params['border_ID'] != ''))
 		{
@@ -2193,6 +2193,6 @@
 			$return['previous_msg']['body'] = str_replace(array('{','}'), array('&#123;','&#125;'), $return['previous_msg']['body']);
 		}
-		
-		$mbox_stream = $this->open_mbox($folder);	
+
+		$mbox_stream = $this->open_mbox($folder);
 		if(imap_mail_move($mbox_stream, $msgs_number, $newmailbox, CP_UID)) {
 			imap_expunge($mbox_stream);
@@ -2201,19 +2201,19 @@
 			return $return;
 		}else {
-			if(strstr(imap_last_error(),'Over quota')) {				
+			if(strstr(imap_last_error(),'Over quota')) {
 				$accountID	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapAdminUsername'];
-				$pass		= $_SESSION['phpgw_info']['expressomail']['email_server']['imapAdminPW'];									
-				$userID 	= $_SESSION['phpgw_info']['expressomail']['user']['userid'];								
+				$pass		= $_SESSION['phpgw_info']['expressomail']['email_server']['imapAdminPW'];
+				$userID 	= $_SESSION['phpgw_info']['expressomail']['user']['userid'];
 				$server 	= $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
 				$mbox		= @imap_open("{".$this->imap_server.":".$this->imap_port.$this->imap_options."}INBOX", $accountID, $pass) or die(serialize(array('imap_error' => $this->parse_error(imap_last_error()))));
 				if(!$mbox)
 					return imap_last_error();
-				$quota 	= imap_get_quotaroot($mbox_stream, "INBOX");				
+				$quota 	= imap_get_quotaroot($mbox_stream, "INBOX");
 				if(! imap_set_quota($mbox, "user".$this->imap_delimiter.$userID, 2.1 * $quota['usage'])) {
 					if($mbox_stream)
 						imap_close($mbox_stream);
-					if($mbox)									
+					if($mbox)
 						imap_close($mbox);
-					return "move_messages(): Error setting quota for MOVE or DELETE!! ". "user".$this->imap_delimiter.$userID." line ".__LINE__."\n";								
+					return "move_messages(): Error setting quota for MOVE or DELETE!! ". "user".$this->imap_delimiter.$userID." line ".__LINE__."\n";
 				}
 				if(imap_mail_move($mbox_stream, $msgs_number, $newmailbox, CP_UID)) {
@@ -2225,7 +2225,7 @@
 						if($mbox)
 							imap_close($mbox);
-						return "move_messages(): Error setting quota for MOVE or DELETE!! line ".__LINE__."\n";								
+						return "move_messages(): Error setting quota for MOVE or DELETE!! line ".__LINE__."\n";
 					}
-					return $return;													
+					return $return;
 				}
 				else {
@@ -2235,9 +2235,9 @@
 						if($mbox)
 							imap_close($mbox);
-						return "move_messages(): Error setting quota for MOVE or DELETE!! line ".__LINE__."\n";								
+						return "move_messages(): Error setting quota for MOVE or DELETE!! line ".__LINE__."\n";
 					}
-					return imap_last_error();				
-				}
-				
+					return imap_last_error();
+				}
+
 			}
 			else {
@@ -2246,10 +2246,10 @@
 				return "move_messages() line ".__LINE__.": ". imap_last_error()." folder:".$newmailbox;
 			}
-		}		
-	}
-	
+		}
+	}
+
 	function save_msg($params)
 	{
-		
+
 		include_once("class.phpmailer.php");
 		$mail = new PHPMailer();
@@ -2266,16 +2266,16 @@
 		$attachments = $params['FILES'];
 		$return_files = $params['FILES'];
-		 
+
 		$folder = $params['folder'];
-		$folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1");		
+		$folder = mb_convert_encoding($folder, "UTF7-IMAP","ISO_8859-1");
 		// Fix problem with cyrus delimiter changes.
-		// Dots in names: enabled/disabled.				
+		// Dots in names: enabled/disabled.
 		$folder = @eregi_replace("INBOX/", "INBOX".$this->imap_delimiter, $folder);
 		$folder = @eregi_replace("INBOX.", "INBOX".$this->imap_delimiter, $folder);
 		// End Fix.
-					
+
 		$mail->SaveMessageInFolder = $folder;
 		$mail->SMTPDebug = false;
-						
+
 		$mail->IsSMTP();
 		$mail->Host = $_SESSION['phpgw_info']['expressomail']['email_server']['smtpServer'];
@@ -2283,10 +2283,10 @@
 		$mail->From = $_SESSION['phpgw_info']['expressomail']['user']['email'];
 		$mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname'];
-		
+
 		$mail->Sender = $mail->From;
 		$mail->SenderName = $mail->FromName;
 		$mail->FromName = $_SESSION['phpgw_info']['expressomail']['user']['fullname'];
 		$mail->From =  $_SESSION['phpgw_info']['expressomail']['user']['email'];
-				
+
 		$this->add_recipients("to", $toaddress, &$mail);
 		$this->add_recipients("cc", $ccaddress, &$mail);
@@ -2294,5 +2294,5 @@
 		$mail->IsHTML(true);
 		$mail->Body = $body;
-		
+
 		//	Build CID for embedded Images!!!
 		$pattern = '/src="([^"]*?show_embedded_attach.php\?msg_folder=(.+)?&(amp;)?msg_num=(.+)?&(amp;)?msg_part=(.+)?)"/isU';
@@ -2306,7 +2306,7 @@
                 $cid_array[$cid_imgs[4][$j].$val] = base_convert(microtime(), 10, 36);
 		        }
-		        $cid = $cid_array[$cid_imgs[4][$j].$val]; 
+		        $cid = $cid_array[$cid_imgs[4][$j].$val];
         		$mail->Body = str_replace($cid_imgs[1][$j], "cid:".$cid, $mail->Body);
-        		
+
 				if ($msg_uid != $cid_imgs[4][$j]) // The image isn't in the same mail?
 				{
@@ -2328,5 +2328,5 @@
 					$attach_img = $forwarding_attachments[$cid_imgs[6][$j]-2];
 					$file_description = unserialize(rawurldecode($attach_img));
-					foreach($file_description as $i => $descriptor){				
+					foreach($file_description as $i => $descriptor){
 						$file_description[$i]  = eregi_replace('\'*\'','',$descriptor);
 					}
@@ -2343,5 +2343,5 @@
 				}
 				$tempDir = ini_get("session.save_path");
-				$file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";					
+				$file = "cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].$cid_imgs[6][$j].".dat";
 				$f = fopen($tempDir.'/'.$file,"w");
 				fputs($f,$fileContent);
@@ -2350,9 +2350,9 @@
 					$mail->AddEmbeddedImage($tempDir.'/'.$file, $cid, $fileName, $fileCode, $fileType);
 				//else
-				//	return "Error loading image attachment content";						
-
-		}
-	
-	//	Build Forwarding Attachments!!!		
+				//	return "Error loading image attachment content";
+
+		}
+
+	//	Build Forwarding Attachments!!!
 		if (count($forwarding_attachments) > 0)
 		{
@@ -2361,19 +2361,19 @@
 				$file_description = unserialize(rawurldecode($forwarding_attachment));
 				$tmp = array_values($file_description);
-				foreach($file_description as $i => $descriptor){				
+				foreach($file_description as $i => $descriptor){
 					$tmp[$i]  = eregi_replace('\'*\'','',$descriptor);
 				}
 				$file_description = $tmp;
-				
+
 				$fileContent = $this->get_forwarding_attachment($file_description[0], $file_description[1], $file_description[3],$file_description[4]);
 				$fileName = $file_description[2];
-				
+
 				$file_description[5] = strlen($fileContent); //Size of file
 				$return_forward[] = $file_description;
-			
+
 					$mail->AddStringAttachment($fileContent, $fileName, $file_description[4], $this->get_file_type($file_description[2]));
 			}
 		}
-		
+
 		if ((count($return_forward) > 0) && (count($return_files) > 0))
 			$return_files = array_merge_recursive($return_forward,$return_files);
@@ -2381,5 +2381,5 @@
 			if (count($return_files) < 1)
 				$return_files = $return_forward;
-	
+
 		//	Build Uploading Attachments!!!
 		$sizeof_attachments = count($attachments);
@@ -2419,5 +2419,5 @@
 					imagecopyresampled($image_new, $image_big, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
 					$tmpDir = ini_get("session.save_path");
-					$_file = "/cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".dat"; 
+					$_file = "/cidimage_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".dat";
 					imagejpeg($image_new,$tmpDir.$_file, 85);
 					$mail->AddAttachment($tmpDir.$_file, $attach['name'], "base64", $this->get_file_type($tmpDir.$_file));
@@ -2427,8 +2427,8 @@
 				// optional name
 				}
-	
-	
-	
-		
+
+
+
+
 		if(!empty($mail->AltBody))
             $mail->ContentType = "multipart/alternative";
@@ -2437,7 +2437,7 @@
 		$mail->SetMessageType();
 		$header = $mail->CreateHeader();
-		$body = $mail->CreateBody(); 
-
-		$mbox_stream = $this->open_mbox($folder);	
+		$body = $mail->CreateBody();
+
+		$mbox_stream = $this->open_mbox($folder);
 		$new_header = str_replace("\n", "\r\n", $header);
 		$new_body = str_replace("\n", "\r\n", $body);
@@ -2449,5 +2449,5 @@
 		if($mbox_stream)
 			imap_close($mbox_stream);
-		if (is_array($return_files))		  
+		if (is_array($return_files))
 			foreach ($return_files as $index => $_attachment) {
 				if (array_key_exists("name",$_attachment)){
@@ -2461,14 +2461,14 @@
 			}
 		}
-		
+
 		$return['files'] = serialize($return_files);
 		$return["subject"] = $subject;
-				
+
 		if (!$return['append'])
 			$return['append'] = imap_last_error();
-		
+
 		return $return;
 	}
-	
+
 	function set_messages_flag($params)
 	{
@@ -2479,8 +2479,8 @@
 		$return["msgs_to_set"] = $msgs_to_set;
 		$return["flag"] = $flag;
-		
+
 		if(!$this->mbox && !is_resource($this->mbox))
 			$this->mbox = $this->open_mbox($folder);
-		
+
 		if ($flag == "unseen")
 			$return["status"] = imap_clearflag_full($this->mbox, $msgs_to_set, "\\Seen", ST_UID);
@@ -2502,5 +2502,5 @@
 				preg_match('/importance *: *(.*)\r/i',
 					imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number))
-					,$importance);		
+					,$importance);
 				if(strtolower($importance[1])=="high" && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) {
 					$flag_importance=true;
@@ -2508,5 +2508,5 @@
 				else {
 					$unflagged_msgs.=$msg_number.",";
-				}				
+				}
 			}
 
@@ -2527,15 +2527,15 @@
 			}
 		}
-		
+
 		if($this->mbox && is_resource($this->mbox))
 			imap_close($this->mbox);
 		return $return;
 	}
-	
+
 	function get_file_type($file_name)
 	{
 		$file_name = strtolower($file_name);
 	   	$strFileType = strrev(substr(strrev($file_name),0,4));
-	   	if ($strFileType == ".asf") 
+	   	if ($strFileType == ".asf")
    			return "video/x-ms-asf";
 	   	if ($strFileType == ".avi")
@@ -2563,13 +2563,13 @@
 	   	if ($strFileType == ".htm" || $strFileType == "html")
    			return "text/html";
-	   	if ($strFileType == ".xml") 
+	   	if ($strFileType == ".xml")
    			return "text/xml";
-	   	if ($strFileType == ".xsl") 
+	   	if ($strFileType == ".xsl")
    			return "text/xsl";
-	   	if ($strFileType == ".css") 
+	   	if ($strFileType == ".css")
    			return "text/css";
-	   	if ($strFileType == ".php") 
+	   	if ($strFileType == ".php")
    			return "text/php";
-	   	if ($strFileType == ".asp") 
+	   	if ($strFileType == ".asp")
    			return "text/asp";
 	   	if ($strFileType == ".pdf")
@@ -2599,9 +2599,9 @@
 		if ($strFileType == ".stw")
 			return "application/vnd.sun.xml.writer.template";
-   		
-   		
-   		return "application/octet-stream";  		
-	}
-	
+
+
+   		return "application/octet-stream";
+	}
+
 	function htmlspecialchars_encode($str)
 	{
@@ -2612,5 +2612,5 @@
 		return  str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&#123;','&#125;'), array('&', '"','\'','<','>','{','}'), $str);
 	}
-	
+
 	function get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse,$offsetBegin = 0,$offsetEnd = 0)
 	{
@@ -2620,5 +2620,5 @@
 		return $this->messages_sort($sort_box_type,$sort_box_reverse, $search_box_type,$offsetBegin,$offsetEnd);
 	}
-	
+
 	function get_info_next_msg($params)
 	{
@@ -2629,6 +2629,6 @@
 		$reuse_border = $params['reuse_border'];
 		$search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false;
-		$sort_array_msg = $this -> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse);				
-		
+		$sort_array_msg = $this -> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse);
+
 		$success = false;
 		if (is_array($sort_array_msg))
@@ -2649,10 +2649,10 @@
 			return $params;
 		}
-		
+
 		$params = array();
 		$params['msg_number'] = $sort_array_msg[($i+1)];
 		$params['msg_folder'] = $folder;
-		
-		$return = $this->get_info_msg($params);		
+
+		$return = $this->get_info_msg($params);
 		$return["reuse_border"] = $reuse_border;
 		return $return;
@@ -2668,5 +2668,5 @@
 		$search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false;
 		$sort_array_msg = $this -> get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse);
-		
+
 		$success = false;
 		if (is_array($sort_array_msg))
@@ -2686,37 +2686,37 @@
 			return $params;
 		}
-		
+
 		$params = array();
 		$params['msg_number'] = $sort_array_msg[($i-1)];
 		$params['msg_folder'] = $folder;
-		
+
 		$return = $this->get_info_msg($params);
 		$return["reuse_border"] = $reuse_border;
 		return $return;
 	}
-	
+
 	// This function updates the values: quota, paging and new messages menu.
 	function get_menu_values($params){
 		$return_array = array();
 		$return_array = $this->get_quota($params);
-		
+
 		$mbox_stream = $this->open_mbox($params['folder']);
-		$return_array['num_msgs'] = imap_num_msg($mbox_stream);		
+		$return_array['num_msgs'] = imap_num_msg($mbox_stream);
 		if($mbox_stream)
 			imap_close($mbox_stream);
-				
-		return $return_array; 
-	}
-	
+
+		return $return_array;
+	}
+
 	function get_quota($params){
 		// folder_id = user/{uid} for shared folders
 		if(substr($params['folder_id'],0,5) != 'INBOX' && preg_match('/user\\'.$this->imap_delimiter.'/i', $params['folder_id'])){
 			$array_folder =  explode($this->imap_delimiter,$params['folder_id']);
-			$folder_id = "user".$this->imap_delimiter.$array_folder[1];		
+			$folder_id = "user".$this->imap_delimiter.$array_folder[1];
 		}
 		// folder_id = INBOX for inbox folders
 		else
 			$folder_id = "INBOX";
-		
+
 		if(!$this->mbox || !is_resource($this->mbox))
 			$this->mbox = $this->open_mbox();
@@ -2725,5 +2725,5 @@
 		if($this->mbox && is_resource($this->mbox))
 			imap_close($this->mbox);
-			
+
 		if (!$quota){
 			return array(
@@ -2733,5 +2733,5 @@
 			);
 		}
-		
+
 		if(count($quota) && $quota['limit']) {
 			$quota_limit = (($quota['limit']/1024)* 100 + .5 )* .01;
@@ -2752,14 +2752,14 @@
 			);
 		}
-		else 
+		else
 			return array();
 	}
-	
+
 	function send_notification($params){
 		require_once("class.phpmailer.php");
 		$mail = new PHPMailer();
-		 
+
 		$toaddress = $params['notificationto'];
-		
+
 		$subject = 'Confirmação de leitura: ' . $params['subject'];
 		$body = 'Sua mensagem: ' . $params['subject'] . '<br>';
@@ -2776,5 +2776,5 @@
 		$mail->IsHTML(true);
 		$mail->Body = $body;
-		
+
 		if(!$mail->Send()){
    			return $mail->ErrorInfo;
@@ -2783,8 +2783,8 @@
    			return true;
 	}
-	
+
 	function empty_trash()
 	{
-		$folder = 'INBOX' . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder']; 
+		$folder = 'INBOX' . $this->imap_delimiter . $_SESSION['phpgw_info']['expressomail']['email_server']['imapDefaultTrashFolder'];
 		$mbox_stream = $this->open_mbox($folder);
 		$return = imap_delete($mbox_stream,'1:*');
@@ -2793,13 +2793,13 @@
 		return $return;
 	}
-	
+
 	function search($params)
 	{
 		include("class.imap_attachment.inc.php");
-		$imap_attachment = new imap_attachment();				
+		$imap_attachment = new imap_attachment();
 		$criteria = $params['criteria'];
 		$return = array();
 		$folders = $this->get_folders_list();
-		
+
 		$j = 0;
 		foreach($folders as $folder)
@@ -2807,12 +2807,12 @@
 			$mbox_stream = $this->open_mbox($folder);
 			$messages = imap_search($mbox_stream, $criteria, SE_UID);
-			
+
 			if ($messages == '')
 				continue;
-		
+
 			$i = 0;
 			$return[$j] = array();
 			$return[$j]['folder_name'] = $folder['name'];
-			
+
 			foreach($messages as $msg_number)
 			{
@@ -2820,5 +2820,5 @@
 				if (!is_object($header))
 					return false;
-				
+
 				$return[$j][$i]['msg_folder']	= $folder['name'];
 				$return[$j][$i]['msg_number']	= $msg_number;
@@ -2829,5 +2829,5 @@
 				$return[$j][$i]['Draft']		= $header->Draft;
 				$return[$j][$i]['Flagged']		= $header->Flagged;
-	
+
 				$date_msg = gmdate("d/m/Y",$header->udate);
 				if (gmdate("d/m/Y") == $date_msg)
@@ -2835,10 +2835,10 @@
 				else
 					$return[$j][$i]['udate'] = $date_msg;
-			
+
 				$fromaddress = imap_mime_header_decode($header->fromaddress);
 				$return[$j][$i]['fromaddress'] = '';
 				foreach ($fromaddress as $tmp)
 					$return[$j][$i]['fromaddress'] .= $this->replace_maior_menor($tmp->text);
-			
+
 				$from = $header->from;
 				$return[$j][$i]['from'] = array();
@@ -2846,5 +2846,5 @@
 				$return[$j][$i]['from']['name'] = $tmp[0]->text;
 				$return[$j][$i]['from']['email'] = $from[0]->mailbox . "@" . $from[0]->host;
-				$return[$j][$i]['from']['full'] ='"' . $return[$j][$i]['from']['name'] . '" ' . '<' . $return[$j][$i]['from']['email'] . '>'; 
+				$return[$j][$i]['from']['full'] ='"' . $return[$j][$i]['from']['name'] . '" ' . '<' . $return[$j][$i]['from']['email'] . '>';
 
 				$to = $header->to;
@@ -2853,5 +2853,5 @@
 				$return[$j][$i]['to']['name'] = $tmp[0]->text;
 				$return[$j][$i]['to']['email'] = $to[0]->mailbox . "@" . $to[0]->host;
-				$return[$j][$i]['to']['full'] ='"' . $return[$i]['to']['name'] . '" ' . '<' . $return[$i]['to']['email'] . '>'; 
+				$return[$j][$i]['to']['full'] ='"' . $return[$i]['to']['name'] . '" ' . '<' . $return[$i]['to']['email'] . '>';
 
 				$subject = imap_mime_header_decode($header->fetchsubject);
@@ -2862,8 +2862,8 @@
 				$return[$j][$i]['Size'] = $header->Size;
 				$return[$j][$i]['reply_toaddress'] = $header->reply_toaddress;
-			
+
 				$return[$j][$i]['attachment'] = array();
 				$return[$j][$i]['attachment'] = $imap_attachment->get_attachment_headerinfo($mbox_stream, $msg_number);
-						
+
 				$i++;
 			}
@@ -2872,23 +2872,23 @@
 				imap_close($mbox_stream);
 		}
-	
+
 		return $return;
 	}
-	
+
 	function delete_and_show_previous_message($params)
 	{
 		$return = $this->get_info_previous_msg($params);
-		
+
 		$params_tmp1 = array();
 		$params_tmp1['msgs_to_delete'] = $params['msg_number'];
 		$params_tmp1['folder'] = $params['msg_folder'];
 		$return_tmp1 = $this->delete_msg($params_tmp1);
-		
+
 		$return['msg_number_deleted'] = $return_tmp1;
-		
+
 		return $return;
 	}
-		
-	
+
+
 	function automatic_trash_cleanness($params)
 	{
@@ -2908,10 +2908,10 @@
 // 	Fix the search problem with special characters!!!!
 	function remove_accents($string) {
-		return strtr($string, 
-	 	"?Ó??ó?Ý?úÁÀÃÂÄÇÉÈÊËÍÌ?ÎÏÑÕÔÓÒÖÚÙ?ÛÜ?áàãâäçéèêëíì?îïñóòõôöúù?ûüýÿ", 
+		return strtr($string,
+	 	"?Ó??ó?Ý?úÁÀÃÂÄÇÉÈÊËÍÌ?ÎÏÑÕÔÓÒÖÚÙ?ÛÜ?áàãâäçéèêëíì?îïñóòõôöúù?ûüýÿ",
 	 	"SOZsozYYuAAAAACEEEEIIIIINOOOOOUUUUUsaaaaaceeeeiiiiinooooouuuuuyy");
 	}
 
-	function search_msg($params = ''){		
+	function search_msg($params = ''){
 		$retorno = "";
 		$mbox_stream = "";
@@ -2920,5 +2920,5 @@
 		}
 		else {
-			$search = explode(",",$params['condition']);			
+			$search = explode(",",$params['condition']);
 		}
 
@@ -2938,6 +2938,6 @@
 						$filter .= '"'.$filter_array[1].'"';
 					}
-				}		
-				$name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" ); 
+				}
+				$name_box = mb_convert_encoding(utf8_decode($name_box), "UTF7-IMAP", "ISO_8859-1" );
 				$filter = $this->remove_accents($filter);
 				//Este bloco tem a finalidade de transformar o login (quando numerico) das pastas compartilhadas em common name
@@ -2950,19 +2950,19 @@
 				}
 				$folder_name = implode($this->imap_delimiter,$folder_name);
-				
+
 				if(!is_resource($mbox_stream))
 					$mbox_stream = $this->open_mbox($name_box);
 				else
 					imap_reopen($mbox_stream, "{".$this->imap_server.":".$this->imap_port.$this->imap_options."}".$name_box);
-			
-				if (preg_match("/^.?\bALL\b/", $filter)){ // Quick Search, note: this ALL isn't the same ALL from imap_search 	
-				
+
+				if (preg_match("/^.?\bALL\b/", $filter)){ // Quick Search, note: this ALL isn't the same ALL from imap_search
+
 					$all_criterias = array ("TO","SUBJECT","FROM","CC");
 					foreach($all_criterias as $criteria_fixed)
 					{
 						$_filter = $criteria_fixed . substr($filter,4);
-					
+
 						$search_criteria = imap_search($mbox_stream, $_filter, SE_UID);
-						
+
 						if($search_criteria && count($search_criteria) < 50)
 						{
@@ -2972,7 +2972,7 @@
 									$retorno .= $m_token;
 							}
-						}						
-						else if(count($search_criteria) >= 50)							
-							return "many results";						
+						}
+						else if(count($search_criteria) >= 50)
+							return "many results";
 					}
 				}
@@ -2988,9 +2988,9 @@
 		}
 		if($mbox_stream)
-			imap_close($mbox_stream);		
-						
+			imap_close($mbox_stream);
+
 		return $retorno ? $retorno : "none";
 	}
-	
+
 	function get_msg($uid_msg,$name_box, $mbox_stream )
 	{
@@ -3014,13 +3014,13 @@
 			$from = $header->from[0]->personal;
 		$ret_msg = $this->decode_string($from) . "--" . $subject . "--". gmdate("d/m/Y",$header ->udate)."--". $this->size_msg($header->Size) ."--". $flag;
-		return $ret_msg;                    
-	}	
+		return $ret_msg;
+	}
 
 	function size_msg($size){
 		$var = floor($size/1024);
 		if($var >= 1){
-			return $var." kb";	
+			return $var." kb";
 		}else{
-			return $size ." b";	
+			return $size ." b";
 		}
 	}
@@ -3049,13 +3049,13 @@
 	   }
 	}
-	
+
 	function getacl()
 	{
 		$this->ldap = new ldap_functions();
-		
+
 		$return = array();
-		$mbox_stream = $this->open_mbox();	
+		$mbox_stream = $this->open_mbox();
 		$mbox_acl = imap_getacl($mbox_stream, 'INBOX');
-		
+
 		$i = 0;
 		foreach ($mbox_acl as $user => $acl)
@@ -3070,5 +3070,5 @@
 		return $return;
 	}
-	
+
 	function setacl($params)
 	{
@@ -3076,5 +3076,5 @@
 		if (!count($old_users))
 			$old_users = array();
-		
+
 		$tmp_array = array();
 		foreach ($old_users as $index => $user_info)
@@ -3083,9 +3083,9 @@
 		}
 		$old_users = $tmp_array;
-		
+
 		$users = unserialize($params['users']);
 		if (!count($users))
 			$users = array();
-		
+
 		//$add_share = array_diff($users, $old_users);
 		$remove_share = array_diff($old_users, $users);
@@ -3110,5 +3110,5 @@
 			}
 		}*/
-		
+
 		if (count($remove_share))
 		{
@@ -3123,19 +3123,19 @@
                 	}
         		}
-			}	
-		}
-		
+			}
+		}
+
 		return true;
 	}
-	
+
 	function getaclfromuser($params)
 	{
 		$useracl = $params['user'];
-		
+
 		$return = array();
 		$return[$useracl] = 'false';
-		$mbox_stream = $this->open_mbox();	
+		$mbox_stream = $this->open_mbox();
 		$mbox_acl = imap_getacl($mbox_stream, 'INBOX');
-		
+
 		foreach ($mbox_acl as $user => $acl)
 		{
@@ -3161,5 +3161,5 @@
 		return $mbox_acl[$this->username];
 	}
-	
+
 
 	function setaclfromuser($params)
@@ -3167,5 +3167,5 @@
 		$user = $params['user'];
 		$acl = $params['acl'];
-		
+
 		$mbox_stream = $this->open_mbox();
 
@@ -3190,12 +3190,12 @@
 			return true;
 	}
-	
+
 	function download_attachment($msg,$msgno)
 	{
-		$array_parts_attachments = array();		
+		$array_parts_attachments = array();
 		$array_parts_attachments['names'] = '';
 		include_once("class.imap_attachment.inc.php");
-		$imap_attachment = new imap_attachment();		
-		
+		$imap_attachment = new imap_attachment();
+
 		if (count($msg->fname[$msgno]) > 0)
 		{
@@ -3214,5 +3214,5 @@
 		$array_parts_attachments['names'] = substr($array_parts_attachments['names'],0,(strlen($array_parts_attachments['names']) - 2));
 		return $array_parts_attachments;
-	}	
+	}
 
 	function spam($params)
@@ -3265,12 +3265,12 @@
 		$pdate = date_parse($header->MailDate);
  		$header->udate +=  $pdate['zone']*(-60);
-		
+
 		if($header->Flagged != "F" && $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_important_flag']) {
 			$flag = preg_match('/importance *: *(.*)\r/i',
 						imap_fetchheader($this->mbox, imap_msgno($this->mbox, $msg_number))
-						,$importance);		
+						,$importance);
 			$header->Flagged = $flag==0?false:strtolower($importance[1])=="high"?"F":false;
 		}
-		
+
 		return $header;
 	}
@@ -3314,5 +3314,5 @@
         //error_log("source: $source\nversao: " . PHP_VERSION, 3, '/tmp/teste.log');
         $source = str_replace(" ", "+", $source,$i);
-        
+
         if (version_compare(PHP_VERSION, '5.2.0', '>=')){
             if(!$source = base64_decode($source,true))
@@ -3356,5 +3356,5 @@
 
     }
-    
+
 //Por Bruno Costa(bruno.vieira-costa@serpro.gov.br - Trata fontes de emails enviados via POST para o servidor por um xmlhttprequest, as partes codificados com
 //Base64 os "+" são substituidos por " " no envio e essa função arruma esse efeito.
