Index: branches/2.2/contactcenter/inc/class.so_group.inc.php
===================================================================
--- branches/2.2/contactcenter/inc/class.so_group.inc.php	(revision 3322)
+++ branches/2.2/contactcenter/inc/class.so_group.inc.php	(revision 3334)
@@ -105,4 +105,23 @@
 									
 			return True;		
+		}
+		
+		function selectGroupsOwnerCanImportContacts($owner) {
+			$query = "select id_group,title,short_name from phpgw_cc_groups where owner=$owner or owner in (select B.acl_location::bigint from phpgw_acl A, phpgw_acl B where 
+						A.acl_location=B.acl_account and A.acl_account=B.acl_location
+						and A.acl_appname = 'contactcenter' and B.acl_appname = 'contactcenter'
+						and A.acl_rights & 4 <> 0 and B.acl_rights & 1 <> 0
+						and A.acl_location = $owner)"; //He can import contacts only to his groups, or shared groups that he gave read permission.
+			$this->db->query($query);
+			
+			$return = array();
+			
+			while($this->db->next_record())
+			{
+				$return[] = $this->db->row(); 
+			}
+			
+			return $return;
+			
 		}
 		
@@ -492,4 +511,29 @@
 			return True;		
 		}
+		
+		function add_user_by_name($id_group){
+			$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 A.last_update = (select max(up.last_update) from phpgw_cc_contact up where up.id_owner ='.$this->owner.")".
+					 	' and A.id_owner ='.$this->owner.' and C.connection_is_default = true'.
+					 ' order by A.names_ordered,C.connection_value';
+			
+						
+			if (!$this->db->query($query)){
+				exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
+			}
+			 
+			$return = array(); 
+			
+			$array_connections = array();
+			while($this->db->next_record()){
+				$return = $this->db->row();
+				array_push($array_connections, $return['id_connection']);				
+			}			
+			$this -> insertContactsByGroup($id_group, $array_connections);
+									
+		}
+		
 	}
 ?>
Index: branches/2.2/contactcenter/inc/class.ui_data.inc.php
===================================================================
--- branches/2.2/contactcenter/inc/class.ui_data.inc.php	(revision 3333)
+++ branches/2.2/contactcenter/inc/class.ui_data.inc.php	(revision 3334)
@@ -22,4 +22,5 @@
 
 		var $bo;
+		var $so_group;
 		var $typeContact;
 
@@ -259,4 +260,19 @@
 			$GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name'));
 
+			$select_groups = '';
+			
+			$this->so_group = CreateObject('contactcenter.so_group');
+			
+			$array_groups = $this->so_group->selectGroupsOwnerCanImportContacts($GLOBALS['phpgw_info']['user']['account_id']);
+			
+			$select_groups = "<select id='id_group'>";//<option value=0>Selecione um grupo...</option></select>";
+			$select_groups .= "<option value=0 selected>Nenhum...</option>";
+			foreach ($array_groups as $group){
+				$select_groups .= "<option value='".$group['id_group']."'>".$group['title']."</option>";						
+			} 					
+			$select_groups .= "</select>";
+			
+			$GLOBALS['phpgw']->template->set_var('cc_select_groups',$select_groups);
+			
 			if($GLOBALS['phpgw_info']['server']['personal_contact_type']=='True'){
 				$GLOBALS['phpgw']->template->set_var('cc_contact_type', 'advanced');
@@ -417,5 +433,5 @@
 
 				case 'import_contacts':
-					return $this->import_contacts($_GET['typeImport']);
+					return $this->import_contacts($_GET['typeImport'],$_GET['id_group']);
 
 				case 'export_contacts':
@@ -519,5 +535,5 @@
 				level
 			@author Raphael Derosso Pereira
-            @author Mï¿œrio Cï¿œsar Kolling (error messages and timeout)
+            @author Mário César Kolling (error messages and timeout)
 
 			@param (string) $level The level to be taken
@@ -1281,6 +1297,5 @@
 				//echo 'ID_I: '.$id_i.'<br>';
 				//echo 'ID_F: '.$id_f.'<br>';
-				///---------------- Correï¿œï¿œo Temporï¿œria PHP5 -----------------------///
-
+				///---------------- Correção Temporária PHP5 -----------------------///
 				$ids = array();
 /**rev 104**/
@@ -1411,5 +1426,5 @@
 
 /**rev 104**/
-				// ?aqui alterar a chamada desse mï¿œtodo para receber o base dn?
+				// ?aqui alterar a chamada desse método para receber o base dn?
 				//$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields);
 
@@ -1437,6 +1452,6 @@
 				{
 					/*
-					 * TODO: Os timeouts de conexï¿œo foram retirados, ver se serï¿œ necessï¿œrio retornar essa funcionalidade, e,
-					 * neste caso, terminar a implementaï¿œï¿œo das mensagens de retorno.
+					 * TODO: Os timeouts de conexão foram retirados, ver se será necessário retornar essa funcionalidade, e,
+					 * neste caso, terminar a implementação das mensagens de retorno.
 					 */
 					if ($index !== 'error'){
@@ -1789,5 +1804,5 @@
 			}
 
-			// verifica se email jï¿œ existe!
+			// verifica se email já existe!
 			$boGroup = CreateObject('contactcenter.bo_group');
 			$contact = $boGroup->verify_contact($tdata[4]);
@@ -2848,5 +2863,5 @@
 				of the entries that matches the search argument
 			@author Raphael Derosso Pereira
-			@author Mï¿œrio Cï¿œsar Kolling (external catalogs)
+			@author Mário César Kolling (external catalogs)
 
 			@param string $str_data A serialized array with two informations:
@@ -3852,5 +3867,5 @@
 		//em 19/06/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br);
 		function import_contacts($typeImport){
-
+			$this->so_group = CreateObject('contactcenter.so_group');
 			if($file = $_SESSION['contactcenter']['importCSV']) {
 				unset($_SESSION['contactcenter']['importCSV']);
@@ -4144,6 +4159,10 @@
 						$return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>";
 					}
-					else
-						$return['_new']++;
+					else{	
+							if($id_group != 0){								
+								$this->so_group->add_user_by_name($id_group,$full_name);
+							}						
+							$return['_new']++;
+		   				}
        			}
    				fclose($handle);
Index: branches/2.2/contactcenter/js/ccIEContacts.js
===================================================================
--- branches/2.2/contactcenter/js/ccIEContacts.js	(revision 285)
+++ branches/2.2/contactcenter/js/ccIEContacts.js	(revision 3334)
@@ -2,5 +2,5 @@
 		this.win;
 		this.el;		
-		this.wWidth = 395;
+		this.wWidth = 610;
 		this.wHeight = 255;
 	}
@@ -93,5 +93,6 @@
 			'<option value="thunderbird">'+("Mozilla Thunderbird")+'</option>'+
 			'<option value="expresso" selected>'+lang_expresso_default+'</option></select><br>'+
-			'<br>'+lang_choose_contacts_file+'<br><br>'+			
+			'<br> Selecione um grupo:&nbsp;' + Element('cc_select_groups').value + '<br>' +
+			'<br>'+lang_choose_contacts_file+'<br><br>'+		
 			'<input id="import_file" type="file" name="import_file">'+
 			'</form></td></tr>'+
@@ -237,6 +238,7 @@
 		var _onload = function(){
 			var typeImport = Element('typeImport').value;
-
-			Connector.newRequest('import_contacts','../index.php?menuaction=contactcenter.ui_data.data_manager&method=import_contacts&typeImport='+typeImport,'GET',handler_import);
+			var id_group = Element('id_group').value;
+			
+			Connector.newRequest('import_contacts','../index.php?menuaction=contactcenter.ui_data.data_manager&method=import_contacts&typeImport='+typeImport+'&id_group='+id_group,'GET',handler_import);
 		}
 
