Index: trunk/expressoMail1_2/inc/class.db_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.db_functions.inc.php	(revision 5348)
+++ trunk/expressoMail1_2/inc/class.db_functions.inc.php	(revision 5380)
@@ -177,27 +177,36 @@
 			$j = count($array_addrs_final);
 
-			if(!strchr($array_addrs[$i],'@') 
-					&& strchr($array_addrs[$i],'<')
-					 && strchr($array_addrs[$i],'>')) {		
-
-				$alias = substr($array_addrs[$i], strpos($array_addrs[$i],'<'), strpos($array_addrs[$i],'>'));				
-		 		$alias = str_replace('<','', str_replace('>','',$alias));
-		 		 		        	           		
-		 		$arrayContacts = $this -> getContactsByGroupAlias($alias);
-
-				if($arrayContacts) {
-					foreach($arrayContacts as $index => $contact){
-						if($contact['names_ordered']) {
-							$array_addrs_final[$j] = '"'.$contact['names_ordered'].'" <'.$contact['connection_value'].'>';
+			if(preg_replace('/\s+/', '', $array_addrs[$i]) != ""){
+				if(strchr($array_addrs[$i],'@') == "") {		
+					if(strpos($array_addrs[$i],'<') && strpos($array_addrs[$i],'>')){
+						$alias = substr($array_addrs[$i], strpos($array_addrs[$i],'<'), strpos($array_addrs[$i],'>'));
+						$alias = str_replace('<','', str_replace('>','',$alias));
+					}
+					else{
+						$alias = $array_addrs[$i];			
+						$alias = preg_replace('/\s/', '', $alias);
+					} 	
+					$arrayContacts = $this -> getContactsByGroupAlias($alias);
+
+					if($arrayContacts) {
+						foreach($arrayContacts as $index => $contact){
+							if($contact['names_ordered']) {
+								$array_addrs_final[$j] = '"'.$contact['names_ordered'].'" <'.$contact['connection_value'].'>';
+							}
+							else 
+								$array_addrs_final[$j] = $contact['connection_value'];
+
+							$j++;
 						}
-						else 
-							$array_addrs_final[$j] = $contact['connection_value'];
-
-						$j++;
+					}else{
+						return array("False" => "$alias");
 					}
 				}
-	   		}
-	   		else
-	   			$array_addrs_final[$j++] = $array_addrs[$i]; 							
+				else{
+					$array_addrs_final[$j] = $array_addrs[$i]; 
+				}
+			}else{
+				$array_addrs_final[$j] = $array_addrs[$i]; 
+			}
 		}
 		return $array_addrs_final;
@@ -354,13 +363,14 @@
 	
 	function import_vcard($params){
-            include_once('class.imap_functions.inc.php');
-            $objImap = new imap_functions();
-            $msg_number = $params['msg_number'];
-            $idx_file = $params['idx_file'];
-            $msg_part = $params['msg_part'];
-            $msg_folder = $params['msg_folder'];
+			
+		include_once('class.imap_functions.inc.php');
+		$objImap = new imap_functions();
+		$msg_number = $params['msg_number'];
+		$idx_file = $params['idx_file'];
+		$msg_part = $params['msg_part'];
+		$msg_folder = $params['msg_folder'];
             $from_ajax = $params['from_ajax'];
-            $encoding = strtolower($params['encoding']);
-            $fileContent = "";
+		$encoding = strtolower($params['encoding']);
+		$fileContent = "";
             $cirus_delimiter = $params['cirus_delimiter'];
             $expFolder = explode($cirus_delimiter, $msg_folder);
@@ -368,5 +378,5 @@
             if($msg_number != null && $msg_part != null && $msg_folder != null && (intval($idx_file == '0' ? '1' : $idx_file)))
             {
-                require_once PHPGW_INCLUDE_ROOT.'/expressoMail1_2/inc/class.attachment.inc.php';
+                require_once dirname(__FILE__).'/class.attachment.inc.php';
                 $attachmentObj = new attachment();
                 $attachmentObj->setStructureFromMail($msg_folder,$msg_number);
@@ -374,44 +384,15 @@
                 $info = $attachmentObj->getAttachmentInfo($msg_part);
                 $filename = $info['name'];
-            }
-            else
-                    $filename = $idx_file;
-                    
-            // It's necessary to access calendar method.
+		}
+		else
+			$filename = $idx_file;
+					
+		// It's necessary to access calendar method. 
             $GLOBALS['phpgw_info']['flags']['noappheader'] = True;
             $GLOBALS['phpgw_info']['flags']['noappfooter'] = True;
             $GLOBALS['phpgw_info']['flags']['currentapp'] = 'calendar';
-            include_once(PHPGW_INCLUDE_ROOT.'/header.inc.php');
-            $uiicalendar = CreateObject("calendar.uiicalendar");
-			if($params['selected'] || $params['readable']){
-				$_REQUEST['data'] = $fileContent;
-				$_REQUEST['type'] = 'iCal';
-				$_REQUEST['params']['calendar'] = $params['selected'];
-				$_REQUEST['readable'] = $params['readable'] ? true : false;
-				$_REQUEST['params']['status'] = $params['status'];
-				$_REQUEST['params']['owner'] = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];
-				ob_start();
-				include_once(PHPGW_INCLUDE_ROOT.'/prototype/converter.php');
-				$output = ob_get_clean();			
-				$valid = json_decode($output, true);
-
-				if($_REQUEST['readable']){	
-					if(!$valid)
-					{
-						$return = false;
-						$output = unserialize($output);
-						foreach($output[0] as $key => $value){
-							if(array_key_exists("id",$output[0][$key]))
-								$return = true;
-						}
-						return $return;
-					}
-					return false;
-				}
-
-				if(empty($valid))
-					return "error";	
-				return "ok";
-			}
+		include_once(PHPGW_INCLUDE_ROOT.'/header.inc.php'); 
+		$uiicalendar = CreateObject("calendar.uiicalendar");
+
             if(strtoupper($expFolder[0]) == 'USER' && $expFolder[1]) // IF se a conta o ical estiver em uma conta compartilhada
             {
