Index: trunk/contactcenter/inc/class.so_group.inc.php
===================================================================
--- trunk/contactcenter/inc/class.so_group.inc.php	(revision 2)
+++ trunk/contactcenter/inc/class.so_group.inc.php	(revision 16)
@@ -112,10 +112,11 @@
 		function selectAllContacts()
 		{
-			$query = 'select C.id_connection, A.id_contact, A.names_ordered, C.connection_value from phpgw_cc_contact A,'.
+						
+			$query = 'select C.id_connection, A.id_contact, A.names_ordered, C.connection_value , B.id_typeof_contact_connection from phpgw_cc_contact A,'.
 			'phpgw_cc_contact_conns B, phpgw_cc_connections C where '.
-			'A.id_contact = B.id_contact and B.id_connection = C.id_connection '.
-			'and B.id_typeof_contact_connection = 1 and '.
+			'A.id_contact = B.id_contact and B.id_connection = C.id_connection and '.
 			'A.id_owner ='.$this->owner.' order by A.names_ordered';
-						
+
+					
 			if (!$this->db->query($query))
 			{
Index: trunk/contactcenter/inc/class.ui_data.inc.php
===================================================================
--- trunk/contactcenter/inc/class.ui_data.inc.php	(revision 15)
+++ trunk/contactcenter/inc/class.ui_data.inc.php	(revision 16)
@@ -1895,6 +1895,6 @@
 			$width = imagesx($photo);
 			$height = imagesy($photo);
-			$twidth = 80;
-			$theight = 106;
+			$twidth = 70;
+			$theight = 90;
 			$small_photo = imagecreatetruecolor ($twidth, $theight);
 			imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
@@ -2415,4 +2415,17 @@
 				echo null;
 
+
+			// Essa iteração transforma uma esturuta com contatos redundantes e separados por email ou tel.
+			// em outra com apenas 1 elemento pra cada contato
+			$i=0;
+			foreach($contacts as $object){
+				$i=($object['id_contact'] - 1);
+				$all_contacts[$i]['name']=$object['names_ordered'];
+				if ($object['id_typeof_contact_connection'] == 1)
+					$all_contacts[$i]['email']=$object['connection_value'];
+				else
+					$all_contacts[$i]['phone']=$object['connection_value'];
+			}
+			
 			switch($typeExport) {
 
@@ -2420,6 +2433,6 @@
 					$streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;".
 							"Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";							
-					foreach($contacts as $index => $object){
-						$streamBuffer.= $object['names_ordered'].";".$object['connection_value'].";;;;;;;;;\r\n";
+					foreach($all_contacts as $index => $object){
+						$streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n";
 					}
 				break;
@@ -2432,6 +2445,6 @@
 					"CEP do endereço comercial;Estado do endereço comercial;".
 					"País/região do endereço comercial;Telefone comercial;Empresa;Cargo\r\n";							
-					foreach($contacts as $index => $object){
-						$streamBuffer.= $object['names_ordered'].";".$object['connection_value'].";;;;;;;;;;;;;;\r\n";
+					foreach($all_contacts as $index => $object){
+						$streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n";
 					}
 				break;
@@ -2456,6 +2469,6 @@
 					"\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",".
 					"\"Sexo\"\r\n";
-					foreach($contacts as $index => $object){
-						$streamBuffer.= ",\"".$object['names_ordered']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\"".$object['connection_value']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
+					foreach($all_contacts as $index => $object){
+						$streamBuffer.= ",\"".$object['name']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,\"".$object['email']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
 					}
 				break;
@@ -2472,6 +2485,6 @@
 					"Gender,Government ID Number,Hobby,Initials,Internet Free Busy,Keywords,Language,Location,Manager's Name,Mileage,Notes,".
 					"Office Location,Organizational ID Number,PO Box,Priority,Private,Profession,Referred By,Sensitivity,Spouse,User 1,User 2,User 3,User 4,Web Page\r\n";
-					foreach($contacts as $index => $object){
-						$streamBuffer.= ",".$object['names_ordered'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['connection_value'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
+					foreach($all_contacts as $index => $object){
+						$streamBuffer.= ",".$object['name'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,".$object['email'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
 					}
 				break;
@@ -2479,13 +2492,13 @@
 				case 'thunderbird':
 					$streamBuffer = "";							
-					foreach($contacts as $index => $object){
-						$streamBuffer.= ",,".$object['names_ordered'].",,".$object['connection_value'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
+					foreach($all_contacts as $index => $object){
+						$streamBuffer.= ",,".$object['name'].",,".$object['email'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
 					}
 				break;
 				
 				default:
-					$streamBuffer = "Nome,Email,Nota\r\n";
-					foreach($contacts as $index => $object){
-						$streamBuffer.= $object['names_ordered'].",".$object['connection_value'].",\r\n";
+					$streamBuffer = "Nome,Email,Telefone\r\n";
+					foreach($all_contacts as $index => $object){
+						$streamBuffer.= $object['name'].",".$object['email'].",".$object['phone']."\r\n";
 					}
 				break;
@@ -2498,5 +2511,5 @@
 			if(!$f)
 				echo null;
-
+		
 			fputs($f,$streamBuffer);
 			fclose($f);
@@ -2504,4 +2517,5 @@
 			echo $tempDir.'/'.$file;
 		}
+
 
 		function import_contacts($typeImport){
@@ -2528,14 +2542,22 @@
 				switch($typeImport){
 					case 'outlook2000':
-						$namepos=1;
-						$emailpos=56;
+						$name_pos=1;
+						$email_pos=56;
+						$phone_pos=44;
+						break;
+					case 'outlook':
+						$name_pos=0;
+						$email_pos=1;
+						$phone_pos=7;
 						break;
 					case 'thunderbird':
-						$namepos=2;
-						$emailpos=4;
+						$name_pos=2;
+						$email_pos=4;
+						$phone_pos=5;
 						break;
 					default:
-						$namepos=0;
-						$emailpos=1;
+						$name_pos=0;
+						$email_pos=1;
+						$phone_pos=2;
 				}
 				
@@ -2546,15 +2568,17 @@
        				
 					$sdata = array();
-					$full_name  = trim($row[$header[$namepos]]);
-					$email		= trim($row[$header[$emailpos]]);
+					$full_name  = trim($row[$header[$name_pos]]);
+					$email		= trim($row[$header[$email_pos]]);
+					$phone		= trim($row[$header[$phone_pos]]);
 					$array_name = explode(' ', str_replace('"','',(str_replace('\'','',$full_name))));
 					$sdata['given_names'] = $array_name[0];
 					$array_name[0] = null;
 					$sdata['family_names'] = trim(implode(' ',$array_name));
-					//$sdata['connections']['default_phone']['connection_name'] = lang('Main');
-					//$sdata['connections']['default_phone']['connection_value'] = $tdata[3];
 					$sdata['connections']['default_email']['connection_name'] = lang('Main');
-					$sdata['connections']['default_email']['connection_value'] = $email;					
-
+					$sdata['connections']['default_email']['connection_value'] = $email;
+
+					$sdata['connections']['default_phone']['connection_name'] = lang('Main');
+					$sdata['connections']['default_phone']['connection_value'] = $phone;
+					
 					// 	verifica se email já existe!
 					$contact = $boGroup->verify_contact($email);
@@ -2565,5 +2589,5 @@
 					else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
 						$return['_failure']++;
-					}			
+					}
 					else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){						
 						$return['_failure']++;							
