Index: /trunk/contactcenter/setup/tables_current.inc.php
===================================================================
--- /trunk/contactcenter/setup/tables_current.inc.php	(revision 3282)
+++ /trunk/contactcenter/setup/tables_current.inc.php	(revision 5131)
@@ -288,5 +288,8 @@
 				'notes'			=> array( 'type' => 'text' ),
 				'is_global'		=> array( 'type' => 'bool' ),
-				'corporate_name'=> array( 'type' => 'varchar', 'precision' => 100)
+				'corporate_name'=> array( 'type' => 'varchar', 'precision' => 100),
+				'web_page'=> array( 'type' => 'varchar', 'precision' => 100),
+				'job_title'=> array( 'type' => 'varchar', 'precision' => 40),
+				'department'=> array( 'type' => 'varchar', 'precision' => 30)
 			),
 			'pk' => array('id_contact'),
Index: /trunk/contactcenter/setup/tables_update.inc.php
===================================================================
--- /trunk/contactcenter/setup/tables_update.inc.php	(revision 4306)
+++ /trunk/contactcenter/setup/tables_update.inc.php	(revision 5131)
@@ -65,3 +65,15 @@
  	    return $GLOBALS['setup_info']['contactcenter']['currentver']; 
  	}
+	
+	$test[] = '2.2.3'; 
+ 	function contactcenter_upgrade2_2_3() { 
+		$GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_cc_contact ALTER COLUMN alias TYPE character varying(100);");
+ 	    $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.2.3.1';
+		return $GLOBALS['setup_info']['contactcenter']['currentver']; 
+ 	}
+	$test[] = '2.2.3.1'; 
+ 	function contactcenter_upgrade2_2_3_1() { 
+ 	    $GLOBALS['setup_info']['contactcenter']['currentver'] = '2.4.0';
+		return $GLOBALS['setup_info']['contactcenter']['currentver']; 
+ 	}
 ?>
Index: /trunk/contactcenter/setup/setup.inc.php
===================================================================
--- /trunk/contactcenter/setup/setup.inc.php	(revision 4306)
+++ /trunk/contactcenter/setup/setup.inc.php	(revision 5131)
@@ -17,5 +17,5 @@
 	$setup_info['contactcenter']['name']      = 'contactcenter';
 	$setup_info['contactcenter']['title']     = 'ContactCenter';
-	$setup_info['contactcenter']['version']   = '2.2.2';
+	$setup_info['contactcenter']['version']   = '2.4.0';
 	$setup_info['contactcenter']['app_order'] = 4;
 	$setup_info['contactcenter']['enable']    = 1;
@@ -76,5 +76,5 @@
 	$setup_info['contactcenter']['depends'][] = array(
 		'appname' => 'phpgwapi',
-		'versions' => Array('2.2')
+		'versions' => Array('2.4.0')
 	);
 ?>
Index: /trunk/contactcenter/inc/class.so_group.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.so_group.inc.php	(revision 4754)
+++ /trunk/contactcenter/inc/class.so_group.inc.php	(revision 5131)
@@ -93,4 +93,40 @@
 		}
 		
+                function touchContacts( $pContacts )
+                {
+                   
+                    $qSelect =  'SELECT A.id_contact from phpgw_cc_contact A,'.
+                                'phpgw_cc_contact_conns B WHERE '.
+                                'A.id_contact = B.id_contact and B.id_connection in('.implode( ',' , $pContacts ).')';
+                    
+                    
+                    $qUpdate = 'UPDATE phpgw_cc_contact '.
+                               'SET last_status = \'U\', last_update = \''.time().'000\' '.
+                               'WHERE id_contact IN( '.$qSelect.' )';   
+                    
+                      if (!$this->db->query($qUpdate))
+                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
+                }
+                
+                function touchContactsByGroup ( $pIdGroup )
+                {
+                    $qSelect = 'SELECT A.id_contact from phpgw_cc_contact A,'.
+			'phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D where '.
+			'A.id_contact = B.id_contact and B.id_connection = C.id_connection '.
+			' and '.
+			' D.id_connection = C.id_connection and D.id_group = '.$pIdGroup;
+
+                    
+                    $qUpdate = 'UPDATE phpgw_cc_contact '.
+                             'SET last_status = \'U\', last_update = \''.time().'000\' '.
+                             'WHERE id_contact IN( '.$qSelect.' )';   
+   
+
+                    if (!$this->db->query($qUpdate))
+			exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
+			
+                    
+                }
+                
 		function delete($data)
 		{
@@ -423,74 +459,4 @@
 		}
 
-		function verifyContact($email, $name, $phone)
-		{
-			if ($email) {
-			
-				$query = 'select A.names_ordered, C.id_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_owner ='" .$this->owner."' and C.connection_value = '".$email. "'";
-
-				if (!$this->db->query($query))
-				{	
-					exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
-				}
-			 
-				$return = false;
-			
-				while($this->db->next_record())
-				{
-					$row = $this->db->row();
-					$return[] =  $row['names_ordered']; 
-				}
-			} 
-			
-			if (!$return && $phone) { 
-
-				$query = 'select A.names_ordered, C.id_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 = 2 and '.
-				"A.id_owner ='" .$this->owner."' and C.connection_value = '".$phone. "'";
-
-				if (!$this->db->query($query))
-				{	
-					exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
-				}
-			 
-				$return = false;
-			
-				while($this->db->next_record())
-				{
-					$row = $this->db->row();
-					$return[] =  $row['names_ordered']; 
-				}
-
-			}
-			
-			if (!$return && $name) { 
-
-				$query = "select names_ordered, C.id_connection from phpgw_cc_contact where id_owner = '" . $this->owner . "' and RTRIM(names_ordered) = '". $name. "'";
-
-				if (!$this->db->query($query))
-				{	
-					exit ('Query failed! File: '.__FILE__.' on line'.__LINE__);
-				}
-			 
-				$return = false;
-			
-				while($this->db->next_record())
-				{
-					$row = $this->db->row();
-					$return[] =  $row['names_ordered']; 
-				}
-
-			}
-		    $return[] =  $row['id_connection'];
-
-			return $return;
-		}		
-
 		function verifySharedContact($owner,$email)
 		{
@@ -588,5 +554,8 @@
 		function updateContactsByGroup($id_group, $contacts)
 		{
-						
+                        //Atualiza timestamp de status dos contatos afetados
+                        $this -> touchContacts($contacts);
+                        $this -> touchContactsByGroup($id_group);
+                        ///---------------------------------------------------//
 			$query = 'select C.id_connection from phpgw_cc_contact A,'.
 			'phpgw_cc_contact_conns B, phpgw_cc_connections C,phpgw_cc_contact_grps D where '.
@@ -724,4 +693,104 @@
 		}
 		
+		
+		function verifyContact($email, $name, $phone) 
+	 	                { 
+								if($email && $phone && $name){
+								
+									$query = 'select A.names_ordered, C.id_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_owner ='" .$this->owner."' and (C.connection_value = '".$email. "' or C.connection_value = '".$phone. "') and RTRIM(A.names_ordered) = '". $name. "'"; 
+								
+									if (!$this->db->query($query)) 
+	 	                                {        
+	 	                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
+	 	                                } 
+	 	                          
+	 	                                $return = false; 
+	 	                         
+	 	                                while($this->db->next_record()) 
+	 	                                { 
+	 	                                        $row = $this->db->row(); 
+	 	                                        $return[] =  $row['names_ordered'];  
+	 	                                } 
+								}
+	 	                        if (!$return && $email) { 
+	 	                         
+	 	                                $query = 'select A.names_ordered, C.id_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_owner ='" .$this->owner."' and C.connection_value = '".$email. "' and RTRIM(A.names_ordered) = '". $name. "'"; 
+	 	 
+	 	                                if (!$this->db->query($query)) 
+	 	                                {        
+	 	                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
+	 	                                } 
+	 	                          
+	 	                                $return = false; 
+	 	                         
+	 	                                while($this->db->next_record()) 
+	 	                                { 
+	 	                                        $row = $this->db->row(); 
+	 	                                        $return[] =  $row['names_ordered'];  
+	 	                                } 
+	 	                        }  	               
+	 	                        if (!$return && $phone) {  
+	 	 
+										$query = 'select A.names_ordered, C.id_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 = 2 and '. 
+	 	                                "A.id_owner ='" .$this->owner."' and C.connection_value = '".$phone. "' and RTRIM(A.names_ordered) = '". $name. "'"; 
+	 	 
+	 	                                if (!$this->db->query($query)) 
+	 	                                {        
+	 	                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
+	 	                                } 
+	 	                          
+	 	                                $return = false; 
+	 	                         
+	 	                                while($this->db->next_record()) 
+	 	                                { 
+	 	                                        $row = $this->db->row(); 
+	 	                                        $return[] =  $row['names_ordered'];  
+	 	                                } 
+	 	 
+	 	                        } 
+
+	 	                        if (!$return && $name) {  
+	 	 
+	 	                                $query = "
+										select A.names_ordered, C.id_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 = 2 and
+										A.id_owner = '" . $this->owner . "' and RTRIM(A.names_ordered) = '". $name. "'"; 
+	 	 
+	 	                                if (!$this->db->query($query)) 
+	 	                                {        
+	 	                                        exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
+	 	                                } 
+	 	                          
+	 	                                $return = false; 
+	 	                         
+	 	                                while($this->db->next_record()) 
+	 	                                { 
+	 	                                        $row = $this->db->row(); 
+	 	                                        $return[] =  $row['names_ordered'];  
+	 	                                } 
+	 	 
+	 	                        } 
+	 	                    $return[] =  $row['id_connection']; 
+
+	 	                        return $return; 
+	 	                } 
+		
+		
 	}
 ?>
Index: /trunk/contactcenter/inc/class.bo_catalog_group_catalog.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.bo_catalog_group_catalog.inc.php	(revision 3970)
+++ /trunk/contactcenter/inc/class.bo_catalog_group_catalog.inc.php	(revision 5131)
@@ -75,5 +75,5 @@
 			if ($ldap_info = $this->catalog['ldap'])
 			{
-				$meta_catalog =& CreateObject('contactcenter.bo_global_ldap_catalog',$ldap_info['id_source'], $ldap_info['context'], $this->external);
+				$meta_catalog = CreateObject('contactcenter.bo_global_ldap_catalog',$ldap_info['id_source'], $ldap_info['context'], $this->external);
 				return $meta_catalog->find($what, $rules, $other, false, $recursive);
 			}
Index: /trunk/contactcenter/inc/cc_updown.php
===================================================================
--- /trunk/contactcenter/inc/cc_updown.php	(revision 4880)
+++ /trunk/contactcenter/inc/cc_updown.php	(revision 5131)
@@ -2,5 +2,5 @@
 	require_once '../../header.session.inc.php';
 //	This script upload an CSV file to import contacts ....	
-	if($ftmp = $_FILES['import_file']['tmp_name']){				 		
+	if(array_key_exists('import_file', $_FILES) && $ftmp = $_FILES['import_file']['tmp_name']){				 		
 		// Foi necessário modificar o caminho onde se recuperava o diretório temporário.
 		// Esse caminho foi hardcodificado na string abaixo ( /tmp ) temporariamente, mas deve ser recuperada atraves
Index: /trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php	(revision 4838)
+++ /trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php	(revision 5131)
@@ -127,5 +127,5 @@
 		    }
 
-		    if(!((strlen($find) == 2 && substr($find, -1) == '%') || $find == '%' ))
+		    if(!((strlen($find) == 2 && substr($find, -1) == '%') || $find == '%' ) && !$this->external)
                           return $this->findAddress($find,$other);
 
@@ -160,5 +160,8 @@
 			$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true);
 			$result_r = $recursive ? ldap_search($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']) :
-			ldap_list($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']);
+			//Traz apenas 10 resultados,
+			//ldap_list($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']);
+			//Traz todos os usuários
+			ldap_list($ldap , $this->src_info['context'], $filter, $fields, 0, 0);
 
 			 if (!$result_r)
@@ -350,5 +353,5 @@
 		
 		*/
-		function process_restrictions( $rules, &$trans_table, $join_type='&' )
+		function process_restrictions( &$rules, &$trans_table, $join_type='&' )
 		{
 			if (!is_array($rules) or !count($rules))
@@ -832,9 +835,8 @@
 					case 'connections':
 	                    $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences');
-	                    if (!is_array($preferences))
-	                    {
-							$preferences['personCardEmail'] = 1;
-							$preferences['personCardPhone'] = 2;
-						}
+
+                                                if(!array_key_exists('personCardEmail', $preferences)) $preferences['personCardEmail'] = 1;
+                                                if(!array_key_exists('personCardPhone', $preferences)) $preferences['personCardPhone'] = 2;        		
+                            
 						unset($l_fields);
 				 		$l_fields['connection_name'] = $this->trans_table['contact.connection.connection_name'];
Index: /trunk/contactcenter/inc/class.bo_group.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.bo_group.inc.php	(revision 4754)
+++ /trunk/contactcenter/inc/class.bo_group.inc.php	(revision 5131)
@@ -42,10 +42,4 @@
 		}
 		
-		function verify_contact($email, $name, $phone){
-		
-			$result = $this-> so -> verifyContact($email, $name, $phone);
-			return $result;
-		}
-
 		function verify_shared_contact($owner,$email){
 
@@ -58,4 +52,9 @@
 			$result = $this-> so -> selectContactsByGroup($id);
 			return $result;
+		}
+		
+		function verify_contact($email, $name, $phone){  	                 
+            $result = $this->so->verifyContact($email, $name, $phone); 
+            return $result; 
 		}
 		
Index: /trunk/contactcenter/inc/class.abo_catalog.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.abo_catalog.inc.php	(revision 4742)
+++ /trunk/contactcenter/inc/class.abo_catalog.inc.php	(revision 5131)
@@ -188,6 +188,6 @@
 		function init()
 		{
-			$this->db =& $GLOBALS['phpgw']->db;
-			$this->security =& CreateObject('contactcenter.security_manager');
+			$this->db = $GLOBALS['phpgw']->db;
+			$this->security = CreateObject('contactcenter.security_manager');
 		}
 
@@ -729,11 +729,11 @@
 						
 					case 'iLIKE':
-						$return_t[] = 'UPPER( '.$associative_tree[$restrict_data['field']]['table'].'.'.
-						              $associative_tree[$restrict_data['field']]['field'].') LIKE UPPER(\''.$restrict_data['value'].'\')';
+						$return_t[] = 'UPPER( translate('.$associative_tree[$restrict_data['field']]['table'].'.'.
+						              $associative_tree[$restrict_data['field']]['field'].',\'áàâãäéèêëíìïóòôõöúùûüÁÀÂÃÄÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜçÇñÑ\',\'aaaaaeeeeiiiooooouuuuAAAAAEEEEIIIOOOOOUUUUcCnN\')) LIKE UPPER(translate(\''.$restrict_data['value'].'\', \'áàâãäéèêëíìïóòôõöúùûüÁÀÂÃÄÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜçÇñÑ\',\'aaaaaeeeeiiiooooouuuuAAAAAEEEEIIIOOOOOUUUUcCnN\'))';
 						break;
 					
 					case 'LIKE and ~=':
-						$return_t[] = 'UPPER( to_ascii('.$associative_tree[$restrict_data['field']]['table'].'.'.
-                                      $associative_tree[$restrict_data['field']]['field'].')) LIKE UPPER( to_ascii (\''."%".$restrict_data['value']."%".'\'))';
+					$return_t[] = 'UPPER(translate('.$associative_tree[$restrict_data['field']]['table'].'.'.
+                                      $associative_tree[$restrict_data['field']]['field'].',\'áàâãäéèêëíìïóòôõöúùûüÁÀÂÃÄÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜçÇñÑ\',\'aaaaaeeeeiiiooooouuuuAAAAAEEEEIIIOOOOOUUUUcCnN\')) LIKE UPPER(translate(\''."%".($restrict_data['value'])."%".'\', \'áàâãäéèêëíìïóòôõöúùûüÁÀÂÃÄÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜçÇñÑ\',\'aaaaaeeeeiiiooooouuuuAAAAAEEEEIIIOOOOOUUUUcCnN\'))';
 						break;
 					
@@ -883,5 +883,5 @@
 			foreach($id_states as $id_state)
 			{
-				$state =& CreateObject('contactcenter.so_state', $id_state['id_state']);
+				$state = CreateObject('contactcenter.so_state', $id_state['id_state']);
 				
 				$result[$id_state['id_state']]['id_state']   = $state->get_id();
@@ -945,5 +945,5 @@
 			foreach($id_cities as $id_city)
 			{
-				$city =& CreateObject('contactcenter.so_city', $id_city['id_city']);
+				$city = CreateObject('contactcenter.so_city', $id_city['id_city']);
 				
 				$result[$id_city['id_city']]['id_city']      = $city->get_id();
@@ -1035,5 +1035,5 @@
 			}
 
-			$city =& CreateObject('contactcenter.so_city');
+			$city = CreateObject('contactcenter.so_city');
 
 			$city->set_id_country($city_info['id_country']);
@@ -1107,5 +1107,5 @@
 			}
 
-			$state =& CreateObject('contactcenter.so_state');
+			$state = CreateObject('contactcenter.so_state');
 
 			$state->set_id_country($state_info['id_country']);
Index: /trunk/contactcenter/inc/class.bo_people_catalog.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.bo_people_catalog.inc.php	(revision 4502)
+++ /trunk/contactcenter/inc/class.bo_people_catalog.inc.php	(revision 5131)
@@ -608,5 +608,5 @@
 				$added_groups = $groups['added'];
 				$removed_groups = $groups['removed'];
-					
+				if(is_array($added_groups))	
 				foreach ($added_groups as $group)
 				{
@@ -616,5 +616,5 @@
 					$bo_group->add_contacts_in_group($group['id_group'], $c);
 				}
-					
+				if(is_array($removed_groups))	
 				foreach ($removed_groups as $group)
 				{
@@ -1285,4 +1285,5 @@
 			}else{
 				$default =1;
+				if(isset($data['connections']['aditional_phone']))
 				foreach($data['connections']['aditional_phone'] as $connection_name => $connection_fields)
 				{
@@ -1567,4 +1568,5 @@
 					
 					case 'addresses':
+						if(is_array($value))
 						foreach($value as $address_name => $address_fields)
 						{
Index: /trunk/contactcenter/inc/class.ui_api.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.ui_api.inc.php	(revision 4500)
+++ /trunk/contactcenter/inc/class.ui_api.inc.php	(revision 5131)
@@ -48,4 +48,5 @@
 			$template->set_var('cc_msg_err_serialize_data_unknown',lang('Data to be serialized is of unknown type!'));
 			$template->set_var('cc_msg_err_shared',lang('No shared catalog that has permission to add.'));
+			$template->set_var('cc_msg_err_duplicate_group',lang('This group name already exists, please enter another name.'));
 			/* End Messages */
 
@@ -422,5 +423,5 @@
 				}
 				else if ($i == 4){
-					$fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" maxlength="100" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n";
+					$fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" onkeyup="emailTolower(\'ccQuickAddI' .$i. '\')" maxlength="100" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n";
 				}else if ($i == 3){
 					$fieldsHTML .= '<input id="ccQuickAddI'.$i.'" type="text" value="" onkeyup="formatPhone(this)" maxlength="30" style="position: absolute; top: '.($fieldsTop+$i*$fieldsSpace).'px; left: 110px; width: 135px;">'."\n";
Index: /trunk/contactcenter/inc/class.ui_data.inc.php
===================================================================
--- /trunk/contactcenter/inc/class.ui_data.inc.php	(revision 4838)
+++ /trunk/contactcenter/inc/class.ui_data.inc.php	(revision 5131)
@@ -19,4 +19,5 @@
 		var $public_functions = array(
 			'data_manager' => true,
+                        'advanced_searh_fields' => true 
 		);
 
@@ -68,5 +69,5 @@
 			}
 
-			$this->page_info['actual_catalog'] =& $this->bo->set_catalog($this->page_info['actual_catalog']);
+			$this->page_info['actual_catalog'] = $this->bo->set_catalog($this->page_info['actual_catalog']);
 
 
@@ -257,8 +258,10 @@
 			$GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_pt', lang('Export as Outlook 2000 (Portuguese) CSV.'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2k_en', lang('Export as Outlook 2000 (English) CSV.'));
+			$GLOBALS['phpgw']->template->set_var('cc_msg_outlook_2003', lang('Export as Outlook 2003 CSV.'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_expresso_default_csv', lang('Export as Expresso (Default) CSV.'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_copy_to_catalog', lang('Copy to personal catalog.'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_add_contact_to_group', lang('You did not add any contact for this group.'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_fill_field_name', lang('Fill the field Full Name'));
+			$GLOBALS['phpgw']->template->set_var('cc_msg_show_extra_detail', lang("Show extra contact's details."));
 
 			$select_groups = '';
@@ -282,4 +285,53 @@
 				$GLOBALS['phpgw']->template->set_var('cc_contact_type', 'default');
 			}
+                        
+                        /*
+                         * Monta Contactcenter Busca Avancada
+                         */
+                        $c = CreateObject('phpgwapi.config','contactcenter');
+                        $c->read_repository();
+                        $current_config = $c->config_data;
+
+                        $arraySearch = array();
+                        foreach ($current_config as $index => $value)
+                        {
+
+                            if(substr($index, 0, 24) == 'cc_attribute_searchable_')
+                            {
+                                if($value == 'true')
+                                {
+                                    $v = substr($index, 24, strlen($index));
+                                    $arraySearch[] = $v;
+                                }
+                            }
+                        }
+                        $advanceSearchArray = array();
+                        foreach ($arraySearch as $value)
+                        {
+                            foreach ($current_config as $index => $value2)
+                            {
+                                if($value == substr($index, 22, strlen($index)) && substr($index, 0, 22) == 'cc_attribute_ldapname_')
+                                {
+                                    foreach ($current_config as $index2 => $value3)
+                                    {
+                                        if($value == substr($index2, 18, strlen($index2)) && substr($index2, 0, 18) == 'cc_attribute_name_')
+                                             $advanceSearchArray[$value2] =  $value3;
+                                    }
+                                }
+
+                            }
+                        }
+
+                        $advanceSearch = array();
+                        foreach ($advanceSearchArray as $index => $value)
+                            $advanceSearch[] ='"'.$index.'":"'.$value.'"';
+
+                        $advancedFields =  "{".implode(',',$advanceSearch)."}";
+
+
+                        $GLOBALS['phpgw']->template->set_var('cc_config_advanced_search', $advancedFields);
+
+                        
+                        
 			$GLOBALS['phpgw']->template->parse('out','index');
 
@@ -289,4 +341,5 @@
 			$main .= $api->get_quick_add_plugin();
 			$main .= $api->get_add_group();
+			$main .= $api->get_contact_details();
 			$main .= $GLOBALS['phpgw']->template->get_var('out');
 
@@ -358,5 +411,5 @@
 				case 'get_catalog_add_contact':
 					// To support ldap catalogs with accentuation
-					echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id'])));
+					echo serialize($this->get_catalog_add_contact($_POST['id']));
 					return;
 
@@ -450,5 +503,6 @@
 					echo $this->get_list_owners_perms_add();
 					return;
-
+				case 'get_contact_details':
+					return $this->get_contact_details($_GET['id']);
 			}
 		}
@@ -487,5 +541,5 @@
 		{
 			$id_catalog = str_replace('\\"', '"', $id_catalog);
-			$temp =& $this->bo->set_catalog($id_catalog);
+			$temp = $this->bo->set_catalog($id_catalog);
 
                         if(!$this->bo->catalog->src_info) {
@@ -505,5 +559,5 @@
 				$this->page_info['changed'] = true;
 				$this->page_info['actual_entries'] = false;
-				$this->page_info['actual_catalog'] =& $temp;
+				$this->page_info['actual_catalog'] = $temp;
 				$this->save_session();
 
@@ -1330,4 +1384,8 @@
 				);
 
+				//verifica se esta habilitado a opcao de exibir os detalhes extras
+				$objconfig = CreateObject('phpgwapi.config', 'contactcenter');
+				$config = $objconfig->read_repository();
+				
 				//echo 'Page: '.$page.'<br>';
 				$n_entries = count($this->page_info['actual_entries']);
@@ -1389,4 +1447,24 @@
 					for($z = 0; $z < $info['count']; $z++) {
 						$owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]);
+					}
+
+					//SAMPLE : dc=teste, dc=diretorio, dc=empresa
+					if(!count($owner_names)){
+						$dns = explode(',', $dn);
+						for($i = count($dns); $i > 0; $i--){
+							$ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false);
+							//verifica se veio a base como parametro, remoção de erros gerados por paramentro null
+							//if(isset($dns[$i])){
+								$sr = ldap_search($ds,$dns[$i], $filter,$justThese);
+								$info = ldap_get_entries($ds, $sr);
+								ldap_close($ds);
+								for($z = 0; $z < $info['count']; $z++) {
+									$owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]);
+								}	
+								if(count($owner_names)){
+									$i = 0;
+								}
+						//	}
+						}
 					}
 				}
@@ -1418,5 +1496,5 @@
 					);
 
-					$groups =& $this->bo->catalog->get_multiple_entries($ids,$fields);
+					$groups = $this->bo->catalog->get_multiple_entries($ids,$fields);
 
 					$i = 0;
@@ -1473,12 +1551,9 @@
 				if($external)
 				{
-					$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields,false,true);
+					$contacts = $this->bo->catalog->get_multiple_entries($ids,$fields,false,true);
 				} else{
-					$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields);
-				}
-
+					$contacts = $this->bo->catalog->get_multiple_entries($ids,$fields);
+				}
 /*******/
-
-
 				if (!is_array($contacts) or !count($contacts))
 				{
@@ -1517,5 +1592,5 @@
 /********/
 
-						$final[3][$i][2] = $contact['companies']['company1']['title']? urldecode( $contact['companies']['company1']['title'] ) :'none';
+						$final[3][$i][2] = $contact['companies']['company1']['title']? $contact['companies']['company1']['title']:'none';
 
 						//Para exibir a matricula do empregado
@@ -1551,5 +1626,8 @@
 										$default_phone_found = true;
 									}
-
+									if($final[3][$i][4] == 'none' or !$final[3][$i][4]){
+										$final[3][$i][4] = "Não informado.";
+										$final[3][$i][13] = $conn_info['id_connection'];
+									}
 /**rev 104**/
 									//if ($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && !$external){
@@ -1563,4 +1641,9 @@
 									$final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none';
 								}
+								if($final[3][$i][4] == 'none' or !$final[3][$i][4]){
+									$final[3][$i][4] = 'Não informado';
+									$final[3][$i][13] = $conn_info['id_connection'];
+								
+								}
 							}
 						}
@@ -1571,11 +1654,12 @@
 						}
 
-						if (!$final[3][$i][4])
-						{
-							$final[3][$i][4] = 'none';
+						if($final[3][$i][4] == 'none' or !$final[3][$i][4]){
+									$final[3][$i][4] = 'Não informado.';
+									$final[3][$i][13] = $conn_info['id_connection'];
+								
 						}
 
 						$final[3][$i][5] = $contact['alias']? urldecode( $contact['alias'] ):'none';
-						$final[3][$i][6] = $ids[$i];
+						$final[3][$i][6] = utf8_decode($ids[$i]);
 
 /**rev 104**/
@@ -1593,7 +1677,9 @@
 							$final[3][$i][12] = lang('Shared').": ".$owner_names[$owners[$i]]['cn'];
 						}
-/******/
 
 						$final[4][$i] = $contact['photo'] ? 1  : 0;
+						
+
+
 						$i++;
 					}
@@ -1610,6 +1696,6 @@
 				$final[9] = $count;
                                 $final[11] = $this->bo->catalog_level;
-
-
+				$final[12] = isset($config['cc_allow_details'])? $config['cc_allow_details'] : false;
+				$final[13] = '<span class="" ';
 				$this->page_info['actual_letter'] = $letter;
 				$this->page_info['actual_page'] = $page;
@@ -1656,4 +1742,19 @@
 				}
 				ldap_close($ds);
+				if(!count($owner_names)){
+						$dns = explode(',', $dn);
+						for($i = count($dns); $i > 0; $i--){
+							$ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false);
+							$sr = ldap_search($ds,$dns[$i], $filter,$justThese);
+							$info = ldap_get_entries($ds, $sr);
+							ldap_close($ds);
+							for($z = 0; $z < $info['count']; $z++) {
+								$owner_names[$info[$z]['uidnumber'][0]] = array("cn" => $info[$z]['cn'][0], "uid" => $info[$z]['uid'][0]);
+							}
+							if(count($owner_names)){
+								$i = 0;
+							}
+						}
+					}
 			}
 			echo serialize ($owner_names);	
@@ -1690,10 +1791,14 @@
 			$boGroup = CreateObject('contactcenter.bo_group');
 
-			$all_contacts = $boGroup->get_all_contacts('only_email',$shared_from);
+			$all_contacts = $boGroup->get_all_contacts(false,$shared_from);
 			
 			$contact_options = "";
 			if(count($all_contacts)) {					
 				foreach($all_contacts as $idx => $contact) {				
-					$contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered']." (".$contact['connection_value'].")</OPTION>";
+					$contact_options .= "<OPTION value='".$contact['id_connection']."'>".$contact['names_ordered'];
+					if (isset($contact['connection_value']))
+						$contact_options .= " (".$contact['connection_value'].")</OPTION>";
+					else
+						$contact_options .= " (". $contact['phone'].")</OPTION>";
 				}
 			}
@@ -1805,4 +1910,30 @@
 
 			/* Relations */
+                        /* Groups */
+			/*
+			 * Criado uma estrutura no data que conterá os grupos do
+			 * contato. O formato é:
+			 * data['groups'] = array(
+			 * 						'id_group' => array(
+			 * 										'id_group', 'title', 'short_name'
+			 * 										)
+			 * 						);
+			 */
+			$boGroup = CreateObject('contactcenter.bo_group');
+			$groups = $boGroup->get_contact_groups($id);
+			
+			$i = 0;
+			$data['groups'] = array();
+			if(is_array($groups))
+			foreach($groups as $group)
+			{
+				$idGroup = $group['id_group'];
+				$data['groups'][$idGroup] = array(
+					'title' 		=> $group['title'],
+					'id_group' 		=> $idGroup,
+					'short_name' 	=> $group['short_name']
+				);
+				$i++;
+			}
 
 			echo serialize($data);
@@ -1824,6 +1955,20 @@
 			$predata[] = $boPeopleCatalog -> get_all_countries();
 			$predata[] = $boPeopleCatalog -> get_all_connections_types();
+			$boGroup = CreateObject('contactcenter.bo_group'); 
+            //$predata[] = $boGroup->get_groups_by_user();
 			//$predata[] = $this->bo->catalog->get_all_relations_types();
 
+			if ($this->typeContact == 'shared_contacts') {  
+ 		                                $so_contact = CreateObject('contactcenter.so_contact',  $GLOBALS['phpgw_info']['user']['account_id']); 
+ 		                $relacionados = $so_contact->get_relations(); 
+ 		                         
+ 		                foreach($relacionados as $uid_relacionado => $tipo_relacionamento) {     
+ 	                                        $predata[] = $boGroup->get_groups_by_user($uid_relacionado);                                             
+ 		                                }        
+ 		                        } else { 
+ 		                                                $predata[] = $boGroup->get_groups_by_user(); 
+ 		                                        }
+			
+			
 			$i = 0;
 			foreach($predata as $data_)
@@ -1883,32 +2028,4 @@
                                 }
 			}
-
-			// verifica se email já existe!
-			$boGroup = CreateObject('contactcenter.bo_group');
-			$contact = $boGroup->verify_contact($tdata[4]);
-
-			if($contact)
-			{
-				$str_contact = "\r\n - ".implode("\r\n - ",$contact);
-
-                            if ($echo)
-                            {
-				echo serialize(array(
-					'msg'    => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),
-					'status' => 'alreadyExists'
-				));
-
-				return;
-                            }
-                            else
-                                {
-                                    return serialize(array(
-					'msg'       => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),
-					'status'    => 'alreadyExists',
-                                        'id_connection'  => $contact[1]
-                                    ));
-                                }
-			}
-
 			$data['alias'] = addslashes($tdata[0]);
 			$data['given_names'] = addslashes($tdata[1]);
@@ -2305,16 +2422,4 @@
 					$email = $dataConn['connection'.$i]['connection_value'];
 				    }
-				}
-				// verifica se email já existe!
-				$boGroup = CreateObject('contactcenter.bo_group');
-				$contact = $boGroup->verify_contact($email);
-				if($contact)
-				{
-				    $str_contact = "\r\n - ".implode("\r\n - ",$contact);
-				    echo serialize(array(
-				    'msg'    => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),
-				    'status' => 'alreadyExists'
-				    ));
-				    return;
 				}
 
@@ -2448,5 +2553,8 @@
 						/* Does nothing... */
 						break;
-
+					case 'groups':
+						$groups = $data['groups'];
+						unset($data['groups']);
+						break;
 					default:
 						echo serialize(array(
@@ -2482,4 +2590,11 @@
 					'status' => 'fail'
 				);
+			}
+                        else
+			{
+				if (isset($old_connections))
+					$this->bo->catalog->update_contact_groups($id, $groups, $old_connections);
+				else
+					$this->bo->catalog->update_contact_groups($id, $groups);
 			}
 
@@ -2617,16 +2732,4 @@
 					$email = $dataConn['connection'.$i]['connection_value'];
 				    }
-				}
-				// verifica se email já existe!
-				$boGroup = CreateObject('contactcenter.bo_group');
-				$contact = $boGroup->verify_shared_contact($owner,$email);
-				if($contact)
-				{
-				    $str_contact = "\r\n - ".implode("\r\n - ",$contact);
-				    echo serialize(array(
-				    'msg'    => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),
-				    'status' => 'alreadyExists'
-				    ));
-				    return;
 				}
 
@@ -2765,27 +2868,29 @@
 			}
 
-			$code = '$id = $this->bo->catalog->';
+			//$code = '$id = $this->bo->catalog->';
 
 			if (!is_null($id) and $id !== '')
 			{
-				$code .= $code.'update_single_info($id, $data);';
+				//$code .= $code.'update_single_info($id, $data);';
+				$id = $this->bo->catalog->update_single_info($id, $data);
+				if(!$id){
 				$result = array(
-					'msg' => lang('Updated Successfully!'),
+						'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'.
+				        'Report the problem to the Administrator.'),
+						'status' => 'fail'
+				);
+			}
+				else{
+				$result = array(
+						'msg' => lang('Updated Successfully!'),
 					'status' => 'ok'
 				);
 			}
+			}
 			else
 			{
-				$code .= 'add_single_entry($data,'.$owner.');';
-				$result = array(
-					'msg' => lang('Entry Added Successfully!'),
-					'status' => 'ok'
-				);
-			}
-
-			eval($code);
-
-			if (!($id))
-			{
+				//$code .= 'add_single_entry($data,'.$owner.');';
+				$id = $this->bo->catalog->add_single_entry($data,$owner);
+				if(!$id){
 				$result = array(
 					'msg' => lang('Some problem occured when trying to insert/update contact information.<br>'.
@@ -2794,7 +2899,13 @@
 				);
 			}
-
+				else{
+					$result = array(
+						'msg' => lang('Entry Added Successfully!'),
+						'status' => 'ok'
+					);
+				}
+			}
 			echo serialize($result);
-}
+		}
 		/*!
 
@@ -3096,10 +3207,17 @@
 			if (!is_array($data) || (!$data['search_for'] && !$full_search) || !is_array($data['fields']))
 			{
-				echo serialize(array(
-					'msg'    => lang('Invalid parameters'),
-					'status' => 'abort'
-				));
-
-				return array('error' => lang('Invalid parameters'));
+			//	echo serialize(array(
+			//		'msg'    => lang('Invalid parameters'),
+			//		'status' => 'abort'
+			//	));
+
+			//	return array('error' => lang('Invalid parameters'));
+				$rules = array(
+					0 => array(
+						'field' => $data['fields']['search'],
+						'type'  => 'LIKE',
+						'value' => '%'
+					)
+				);
 			}
 
@@ -3118,5 +3236,5 @@
 			{
 
-				$data['search_for'] = utf8_encode($data['search_for']);
+				$data['search_for'] = $data['search_for'];
 			}
 
@@ -3245,6 +3363,5 @@
 				// Get only this attributes: dn, cn for external catalogs,
 				// used to restrict the attributes used in filters
-				$ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for'] != null);
-			}
+				$ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC', 'customFilter' => $data['custom_filter'], 'CN' => $data['CN'], 'exact' => $data['exact']), $data['search_for'] != null);	}
 			else
 			{
@@ -3259,6 +3376,5 @@
 					'contact.connection.mail',
 					'contact.connection.phone'
-					), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for_area'], $data['search_for'] != null );
-			}
+					), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC', 'customFilter' => $data['custom_filter'], 'CN' => $data['CN'], 'exact' => $data['exact']), $data['search_for_area'], $data['search_for'] != null ); }
 
 			if (!is_array($ids) || !count($ids))
@@ -3641,4 +3757,5 @@
 			for($z = 0; $z < 5; $z++) {
 				$participant = $info[0][$justThese[$z]];
+				$participant[0] = utf8_decode($participant[0]);
 				array_push($array_participants, $participant);
 			}
@@ -3755,4 +3872,5 @@
 			$contacts = $boGroup->get_all_contacts();
 			$streamBuffer = '';
+			$stramArray = Array();
 
 			if(!count($contacts))
@@ -3780,5 +3898,5 @@
 
 				case 'outlook_pt-BR':
-					$streamBuffer = "Nome;Sobrenome;Segundo nome;Nome;Apelido;End. de email;Endereço residencial;"
+					$streamBuffer = "Nome;Apelido;End. de email;Endereço residencial;"
 									."Cidade do endereço residencial;CEP do endereço residencial;Estado;País/região do endereço residencial;"
 									."Telefone residencial;Fax residencial;Telefone celular;Página pessoal da Web;Rua do endereço comercial;"
@@ -3789,5 +3907,4 @@
 					foreach($contacts as $index => $object){
 						$streamBuffer.= "\"".$object[ 'names_ordered'] . "\";"
-							.";;;"
 							. "\"".$object[ 'alias' ] . "\";"
 							. "\"".$object[ 'main-mail' ] . "\";"
@@ -3813,5 +3930,5 @@
 							. "\"".$object[ 'job_title' ] . "\";"
 							. "\"".$object[ 'department' ] . "\";"
-							.";"
+							."\"\";"
 							. "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"\r\n";
 					}
@@ -3958,42 +4075,58 @@
 						."Home Address 2,Home City,Home State,Home ZipCode,Home Country,Work Address,Work Address 2,"
 						."Work City,Work State,Work ZipCode,Work Country,Job Title,Department,Organization,Web Page 1,"
-						."Web Page 2,Birth Year,Birth Month,Birth Day,Custom 1,Custom 2,Custom 3,Custom 4,Notes,\n";
+						."Web Page 2,Birth Year,Birth Month,Birth Day,Custom 1,Custom 2,Custom 3,Custom 4,Notes,\r\n";
 
 					foreach($contacts as $index => $object){
 						$array_birth = explode("-",$object[ 'birthdate' ]);
-						$streamBuffer.= "\"".$object[ 'names_ordered'] . "\","
-							.",,"
-							. "\"".$object[ 'alias' ] . "\","
-							. "\"".$object[ 'main-mail' ] . "\","
-							. "\"".$object[ 'alternative-mail' ] . "\","
-							.","
-                                                        . "\"".$phone . "\","
-							. "\"".$object[ 'home-phone' ] . "\","
-							. "\"".$object[ 'business-fax' ] . "\","
-							. "\"".$object[ 'business-pager' ] . "\","
-							. "\"".$object[ 'mobile' ] . "\","
-							. "\"".$object[ 'home-address' ] . "\","
-							. "\"".$object[ 'home-address-2' ] . "\","
-							. "\"".$object[ 'home-city_name' ] . "\","
-							. "\"".$object[ 'home-state_name' ] . "\","
-							. "\"".$object[ 'home-postal_code' ] . "\","
-							. "\"".$object[ 'home-id_country' ] . "\","
-							. "\"".$object[ 'business-address' ] . "\","
-							. "\"".$object[ 'business-address-2' ] . "\","
-							. "\"".$object[ 'business-city_name' ] . "\","
-							. "\"".$object[ 'business-state_name' ] . "\","
-							. "\"".$object[ 'business-postal_code' ] . "\","
-							. "\"".$object[ 'business-id_country' ] . "\","
-							. "\"".$object[ 'job_title' ] . "\","
-							. "\"".$object[ 'department' ] . "\","
-							. "\"".$object[ 'corporate_name' ] . "\","
-							. "\"".$object[ 'web_page' ] . "\","
-							. "\"".$object[ 'web_page' ] . "\","
-							. "\"".$array_birth[0] . "\","
-							. "\"".$array_birth[1] . "\","
-							. "\"".$array_birth[2] . "\","
-							.",,,,"
-							. "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\",\r\n";
-
+
+						$stramArray[0] = "\"".$object[ 'names_ordered'] . "\"";
+						$stramArray[1] = "";
+						$stramArray[2] = "\"".$object[ 'names_ordered'] . "\"";
+						$stramArray[3] = "\"".$object[ 'alias' ] . "\"";
+						$stramArray[4] = "\"".$object[ 'main-mail' ] . "\"";
+						$stramArray[5] = "\"".$object[ 'alternative-mail' ] . "\"";
+						$stramArray[6] = "";
+						$stramArray[7] = "\"".$object[ 'business-phone' ] . "\"";
+						$stramArray[8] = "\"".$object[ 'home-phone' ] . "\"";
+						$stramArray[9] = "\"".$object[ 'business-fax' ] . "\"";
+						$stramArray[10] = "\"".$object[ 'business-pager' ] . "\"";
+						$stramArray[11] = "\"".$object[ 'mobile' ] . "\"";
+						$stramArray[12] = "\"".$object[ 'home-address' ] . "\"";
+						$stramArray[13] = "\"".$object[ 'home-address-2' ] . "\"";
+						$stramArray[14] = "\"".$object[ 'home-city_name' ] . "\"";
+						$stramArray[15] = "\"".$object[ 'home-state_name' ] . "\"";
+						$stramArray[16] = "\"".$object[ 'home-postal_code' ] . "\"";
+						$stramArray[17] = "\"".$object[ 'home-id_country' ] . "\"";
+						$stramArray[18] = "\"".$object[ 'business-address' ] . "\"";
+						$stramArray[19] = "\"".$object[ 'business-address-2' ] . "\"";
+						$stramArray[20] = "\"".$object[ 'business-city_name' ] . "\"";
+						$stramArray[21] = "\"".$object[ 'business-state_name' ] . "\"";
+						$stramArray[22] = "\"".$object[ 'business-postal_code' ] . "\"";
+						$stramArray[23] = "\"".$object[ 'business-id_country' ] . "\"";
+						$stramArray[24] = "\"".$object[ 'job_title' ] . "\"";
+						$stramArray[25] = "\"".$object[ 'department' ] . "\"";
+						$stramArray[26] = "\"".$object[ 'corporate_name' ] . "\"";
+						$stramArray[27] = "";
+						$stramArray[28] = "";
+						$stramArray[29] = "\"".$array_birth[0] . "\"";
+						$stramArray[30] = "\"".$array_birth[1] . "\"";
+						$stramArray[31] = "\"".$array_birth[2] . "\"";
+						$stramArray[32] = "";
+						$stramArray[33] = "";
+						$stramArray[34] = "";
+						$stramArray[35] = "";
+						$stramArray[36] = "";
+						$stramArray[37] = "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"\r\n";
+						
+						if($object[ 'phone' ]){
+							if(!$object[ 'home-phone' ])
+								$stramArray[8] = "\"".$object[ 'phone' ]. "\"";
+							else if(!$object[ 'mobile' ])
+								$stramArray[11] = "\"".$object[ 'phone' ]. "\"";
+							else if(!$object[ 'business-phone' ])
+								$stramArray[7] = "\"".$object[ 'phone' ]. "\"";
+						}
+						
+						$streamBuffer .= implode("," , $stramArray);
 					}
 				break;
@@ -4007,45 +4140,173 @@
 
 	                    foreach($contacts as $index => $object){
-	                        $streamBuffer .= "\"".$object[ 'names_ordered'] . "\","
-	                            . "\"".$object[ 'alias' ] . "\","
-	                            . "\"".$object[ 'main-mail' ] . "\","
-	                            . "\"".$object[ 'alternative-mail' ] . "\","
-	                            . "\"".$object[ 'mobile' ] . "\","
-	                            . "\"".$object[ 'business-phone' ] . "\","
-	                            . "\"".$object[ 'business-address' ] . "\","
-	                            . "\"".$object[ 'business-complement' ] . "\","
-	                            . "\"".$object[ 'business-postal_code' ] . "\","
-	                            . "\"".$object[ 'business-city_name' ] . "\","
-	                            . "\"".$object[ 'business-state_name' ] . "\","
-	                            . "\"".$object[ 'business-id_country' ] . "\","
-	                            . "\"".$object[ 'home-phone' ] . "\","
-	                            . "\"".$object[ 'home-address' ] . "\","
-	                            . "\"".$object[ 'home-complement' ] . "\","
-	                            . "\"".$object[ 'home-postal_code' ] . "\","
-	                            . "\"".$object[ 'home-city_name' ] . "\","
-	                            . "\"".$object[ 'home-state_name' ] . "\","
-	                            . "\"".$object[ 'home-id_country' ] . "\","
-								. "\"".$object[ 'birthdate' ] . "\","
-								. "\"".$object[ 'sex' ] . "\","
-								. "\"".$object[ 'pgp_key' ] . "\","
-								. "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\","
-								. "\"".$object[ 'web_page' ] . "\","
-								. "\"".$object[ 'corporate_name' ] . "\","
-								. "\"".$object[ 'job_title' ] . "\","
-								. "\"".$object[ 'department' ] . "\","
-								. "\"".$object[ 'business-fax' ] . "\","
-								. "\"".$object[ 'business-pager' ] . "\","
-								. "\"".$object[ 'business-mobile' ] . "\","
-								. "\"".$object[ 'home-fax' ] . "\","
-								. "\"".$object[ 'home-pager' ] . "\","
-								. "\"".$object[ 'business-address-2' ] . "\","
-								. "\"".$object[ 'home-address-2' ] . "\"\r\n";
+								$stramArray[0] = "\"".$object[ 'names_ordered'] . "\"";
+								$stramArray[1] = "\"".$object[ 'alias' ] . "\"";
+								$stramArray[2] = "\"".$object[ 'main-mail' ] . "\"";
+								$stramArray[3] = "\"".$object[ 'alternative-mail' ] . "\"";
+								$stramArray[4] = "\"".$object[ 'mobile' ] . "\"";
+								$stramArray[5] = "\"".$object[ 'business-phone' ] . "\"";
+								$stramArray[6] = "\"".$object[ 'business-address' ] . "\"";
+								$stramArray[7] = "\"".$object[ 'business-complement' ] . "\"";
+								$stramArray[8] = "\"".$object[ 'business-postal_code' ] . "\"";
+								$stramArray[9] = "\"".$object[ 'business-city_name' ] . "\"";
+								$stramArray[10] = "\"".$object[ 'business-state_name' ] . "\"";
+								$stramArray[11] = "\"".$object[ 'business-id_country' ] . "\"";
+								$stramArray[12] = "\"".$object[ 'home-phone' ] . "\"";
+								$stramArray[13] = "\"".$object[ 'home-address' ] . "\""; 
+								$stramArray[14] = "\"".$object[ 'home-complement' ] . "\"";
+								$stramArray[15] = "\"".$object[ 'home-postal_code' ] . "\"";
+								$stramArray[16] = "\"".$object[ 'home-city_name' ] . "\"";
+								$stramArray[17] = "\"".$object[ 'home-state_name' ] . "\"";
+								$stramArray[18] = "\"".$object[ 'home-id_country' ] . "\"";
+								$stramArray[19] = "\"".$object[ 'birthdate' ] . "\"";
+								$stramArray[20] = "\"".$object[ 'sex' ] . "\"";
+								$stramArray[21] = "\"".$object[ 'pgp_key' ] . "\"";
+								$stramArray[22] = "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"";
+								$stramArray[23] = "\"".$object[ 'web_page' ] . "\"";
+								$stramArray[24] = "\"".$object[ 'corporate_name' ] . "\"";
+								$stramArray[25] = "\"".$object[ 'job_title' ] . "\"";
+								$stramArray[26] = "\"".$object[ 'department' ] . "\"";
+								$stramArray[27] = "\"".$object[ 'business-fax' ] . "\"";
+								$stramArray[28] = "\"".$object[ 'business-pager' ] . "\"";
+								$stramArray[29] = "\"".$object[ 'business-mobile' ] . "\"";
+								$stramArray[30] = "\"".$object[ 'home-fax' ] . "\"";
+								$stramArray[31] = "\"".$object[ 'home-pager' ] . "\"";
+								$stramArray[32] = "\"".$object[ 'business-address-2' ] . "\"";
+								$stramArray[33] = "\"".$object[ 'home-address-2' ] . "\"\r\n";
+								
+								if($object[ 'phone' ]){
+									if(!$object[ 'home-phone' ])
+										$stramArray[12] = "\"".$object[ 'phone' ]. "\"";
+									else if(!$object[ 'mobile' ])
+										$stramArray[4] = "\"".$object[ 'phone' ]. "\"";
+									else if(!$object[ 'business-phone' ])
+										$stramArray[5] = "\"".$object[ 'phone' ]. "\"";
+								}
+						
+								$streamBuffer .= implode("," , $stramArray);
 	                    }
 	                break;
+					
+					case 'outlook2003':
+					$streamBuffer = "\"Tratamento\",\"Primeiro nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",".
+					"\"Empresa\",\"Departamento\",\"Cargo\",\"Business Street\",\"Rua do endereço comercial 2\",".
+					"\"Rua do endereço comercial 3\",\"Business City\",\"Business State\",".
+					"\"Business Postal Code\",\"Business Country\",\"Endereço residencial\",\"Endereço residencial 2\",".
+					"\"Endereço residencial 3\",\"Cidade do endereço residencial\",\"Estado\",\"CEP do endereço residencial\",\"País do endereço residencial\",".
+					"\"Outro endereço\",\"Outro endereço 2\",\"Outro endereço 3\",\"Cidade\",\"Estado\",\"CEP\",\"País\",".
+					"\"Telefone do assistente\",\"Fax comercial\",\"Telefone comercial\",\"Telefone comercial 2\",\"Retorno de chamada\",".
+					"\"Telefone do carro\",\"Telefone principal da empresa\",\"Fax residencial\",\"Telefone residencial\",".
+					"\"Telefone residencial 2\",\"ISDN\",\"Telefone celular\",\"Outro fax\",\"Outro telefone\",\"Pager\",\"Telefone principal\",".
+					"\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Anotações\",\"Birthday\",\"Caixa postal de outro endereço\",\"Caixa postal do endereço comercial\",".
+					"\"Caixa postal do endereço residencial\",\"Categorias\",\"Código da empresa\",\"Código do governo\",\"Conta\",\"Datas especiais\",\"Disponibilidade da internet\",\"E-mail Address\",".
+					"\"Tipo de email\",\"Nome para exibição do email\",\"Endereço de email 2\",".
+					"\"Tipo de email 2\",\"Nome para exibição do email 2\",".
+					"\"Endereço de email 3\",\"Tipo de email 3\",\"Nome para exibição de email 3\",".
+					"\"Filhos\",\"Hobby\",\"Idioma\",\"Indicação\",\"Informações para cobrança\",\"Iniciais\",\"Local\",".
+					"\"Nome do assistente\",\"Nome do gerenciador\",\"Página da Web\",\"Palavras-chave\",\"Particular\",\"Personalizado 1\",\"Personalizado 2\",".
+					"\"Personalizado 3\",\"Personalizado 4\",\"Prioridade\",\"Profissão\",\"Quilometragem\",\"Sala\",\"Sensibilidade\",\"Servidor de diretório\",".
+					"\"Sexo\",\"Spouse\"\r\n";
+					foreach($contacts as $index => $object){
+						$stramArray[0] = "\"".$object[ 'alias' ] . "\"";
+						$stramArray[1] = "\"".$object[ 'names_ordered'] . "\"";
+						$stramArray[2] = "";
+						$stramArray[3] = "";
+						$stramArray[4] = "";												
+						$stramArray[5] = "\"".$object[ 'corporate_name' ] . "\"";			
+						$stramArray[6] = "\"".$object[ 'department' ] . "\"";
+						$stramArray[7] = "\"".$object[ 'job_title' ] . "\"";				
+						$stramArray[8] = "\"".$object[ 'business-address' ] . "\"";
+						$stramArray[9] = "\"".$object[ 'business-address-2' ] . "\"";
+						$stramArray[10] = "";
+						$stramArray[11] = "\"".$object[ 'business-city_name' ] . "\"";		
+						$stramArray[12] = "\"".$object[ 'business-state_name' ] . "\"";		
+						$stramArray[13] = "\"".$object[ 'business-postal_code' ] . "\"";	
+						$stramArray[14] = "\"".$object[ 'business-id_country' ] . "\"";		
+						$stramArray[15] = "\"".$object[ 'home-address' ] . "\"";			
+						$stramArray[16] = "\"".$object[ 'business-address-2' ] . "\"";		
+						$stramArray[17] = "";												
+						$stramArray[18] = "\"".$object[ 'home-city_name' ] . "\"";
+						$stramArray[19] = "\"".$object[ 'home-state_name' ] . "\"";
+						$stramArray[20] = "\"".$object[ 'home-postal_code' ] . "\"";
+						$stramArray[21] = "\"".$object[ 'home-id_country' ] . "\"";
+						$stramArray[22] = "";
+						$stramArray[23] = "";
+						$stramArray[24] = "";
+						$stramArray[25] = "\"".$object[ 'home-city_name' ] . "\"";
+						$stramArray[26] = "\"".$object[ 'home-state_name' ] . "\"";
+						$stramArray[27] = "\"".$object[ 'home-postal_code' ] . "\"";
+						$stramArray[28] = "\"".$object[ 'home-id_country' ] . "\"";
+						$stramArray[29] = "";
+						$stramArray[30] = "\"".$object[ 'business-fax' ] . "\"";
+						$stramArray[31] = "\"".$object[ 'business-phone' ] . "\"";
+						$stramArray[32] = "\"".$object[ 'mobile' ] . "\"";
+						$stramArray[33] = "";
+						$stramArray[34] = "";
+						$stramArray[35] = "";
+						$stramArray[36] = "\"".$object[ 'home-fax' ] . "\"";
+						$stramArray[37] = "\"".$object[ 'home-phone' ] . "\"";
+						$stramArray[38] = "";
+						$stramArray[39] = "";
+						$stramArray[40] = "\"".$object[ 'mobile' ] . "\"";
+						$stramArray[41] = "";
+						$stramArray[42] = "";
+						$stramArray[43] = "\"".$object[ 'home-pager' ] . "\"";
+						$stramArray[44] = "\"".$object[ 'phone' ] . "\"";
+						$stramArray[45] = "";
+						$stramArray[46] = "";
+						$stramArray[47] = "";
+						$stramArray[48] = "\"".str_replace("\r\n\x0a","\t",$object[ 'notes' ]) . "\"";
+						$stramArray[49] = "\"".$object[ 'birthdate' ] . "\"";
+						$stramArray[50] = "";
+						$stramArray[51] = "";
+						$stramArray[52] = "";
+						$stramArray[53] = "";
+						$stramArray[54] = "";
+						$stramArray[55] = "";
+						$stramArray[56] = "";
+						$stramArray[57] = "";
+						$stramArray[58] = "";
+						$stramArray[59] = "\"".$object[ 'main-mail' ] . "\"";
+						$stramArray[60] = "";
+						$stramArray[61] = "";
+						$stramArray[62] = "\"".$object[ 'alternative-mail' ] . "\"";
+						$stramArray[63] = "";
+						$stramArray[64] = "";
+						$stramArray[65] = "";
+						$stramArray[66] = "";
+						$stramArray[67] = "";
+						$stramArray[68] = "";
+						$stramArray[69] = "";
+						$stramArray[70] = "";
+						$stramArray[71] = "";
+						$stramArray[72] = "";
+						$stramArray[73] = "";
+						$stramArray[74] = "";
+						$stramArray[75] = "";
+						$stramArray[76] = "";
+						$stramArray[77] = "\"".$object[ 'web_page' ] . "\"";
+						$stramArray[78] = "";
+						$stramArray[79] = "";
+						$stramArray[80] = "";
+						$stramArray[81] = "";
+						$stramArray[82] = "";
+						$stramArray[83] = "";
+						$stramArray[84] = "";
+						$stramArray[85] = "";
+						$stramArray[86] = "";
+						$stramArray[87] = "";
+						$stramArray[88] = "";
+						$stramArray[89] = "";
+						$stramArray[90] = "\"".$object[ 'sex' ] . "\"";
+						$stramArray[91] = "\r\n";
+						
+						$streamBuffer .= implode("," , $stramArray);
+	                    }
+	                break;
 
 			}
 
 			$file = "contacts_".md5(microtime()).".swp";
-			$tempDir = ini_get("session.save_path");
+			$tempDir = $GLOBALS['phpgw_info']['server']['temp_dir'];
 			$f = fopen($tempDir.'/'.$file,"w");
 			if(!$f)
@@ -4095,7 +4356,9 @@
 		//sobrenome, notas e e-mail;
 		//em 19/06/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br);
-		function import_contacts($typeImport, $id_group=false){
+		function import_contacts($typeImport, $id_group=false)
+		{
 			$this->so_group = CreateObject('contactcenter.so_group');
-			if($file = $_SESSION['contactcenter']['importCSV']) {
+			if($file = $_SESSION['contactcenter']['importCSV']) 
+			{
 				unset($_SESSION['contactcenter']['importCSV']);
 				$len = filesize($file);
@@ -4107,5 +4370,5 @@
 				if ($typeImport == 'outlook')
 					$delim = ';';
-				else if ($typeImport == 'auto')
+				else if ($typeImport == 'auto' || $typeImport== 'thunderbird')
 				$delim = strstr($input_header,',') ? ',' : ';';
 				else
@@ -4149,12 +4412,12 @@
 							break;
 						case 'outlook':
-							$name_pos=3;
-							$email_pos=4;
-							$phone_pos=7;
-							$home_phone_pos=10;
-							$personal_cell_pos=12;
-							$corporate_street_pos=13;
-							$cep_pos=15;
-							$phone_pos=18;
+							$name_pos=0;
+							$email_pos=2;
+							$phone_pos=8;
+							$home_phone_pos=9;
+							$personal_cell_pos=10;
+							$corporate_street_pos=12;
+							$cep_pos=14;
+							$corporate_phone_pos=18;
 							$fax_pos=19;
 							$pager_pos=20;
@@ -4163,6 +4426,73 @@
 						case 'thunderbird':
 							$name_pos=2;
+							$alias_pos=3;
+							//MAILS
 							$email_pos=4;
-							$phone_pos=7;
+							$aditionalEmail_pos=5;
+							
+							//PHONES
+							$corporate_phone_pos=7; 
+							$main_phone_pos=8;
+							$home_phone_pos=8;
+							$fax_pos=9;
+							$pager_pos=10;
+							$personal_cell_pos=11;
+							
+							//ADRESS
+							$street_pos=12;
+							$street_2_pos = 13;
+							$city_pos=14;
+							$state_pos=15;
+							$cep_pos=16;
+							$country_pos=17;
+							
+							//CORPORATE ADRESS
+							$corporate_street_pos=18;
+							$corporate_city_pos=20;
+							$corporate_state_pos=21;
+							$corporate_cep_pos=22;
+							$corporate_country_pos=23;
+							
+							//CORPORATE DETAILS
+							$job_title_pos=24;
+							$department_pos=25;
+							$corporate_name_pos=26;
+							
+							$notes_pos=36;
+							break;
+						case 'outlook2003':
+							$alias_pos=0;
+							$name_pos=1;
+							//CORPORATE DETAILS
+							$corporate_name_pos=5;
+							$department_pos=6;
+							$job_title_pos=7;
+							//CORPORATE ADRESS
+							$corporate_comp_pos=7;
+							$corporate_street_pos=8;
+							$street_2_pos = 9;	
+							$corporate_city_pos=11;
+							$corporate_state_pos=12;
+							$corporate_cep_pos=13;
+							$corporate_country_pos=14;
+							//HOME ADRESS
+							$street_pos=13;
+							$comp_pos=14;
+							$cep_pos=15;
+							$city_pos=16;
+							$state_pos=17;
+							$country_pos=18;
+							//PHONE's
+							$corporate_phone_pos=31;
+							$fax_pos=36;
+							$home_phone_pos=37;
+							$pager_pos=43;
+							$main_phone_pos=44;
+							//OTHER's
+							$notes_pos=48;
+							$birth_pos=49;
+							//EMAIL's
+							$email_pos=59;
+							$aditionalEmail_pos=62;
 							break;
 						case 'expresso':
@@ -4276,29 +4606,28 @@
 				}
 
-				while (($data = fgetcsv($handle, $len, $delim))) {
+
+		
+				while (($data = fgetcsv($handle, $len, $delim))) 
+				{
 					foreach ($header as $key=>$heading)
                			$row[$heading]=(isset($data[$key])) ? $data[$key] : '';
 
 						$sdata = array();
-						$full_name  = trim($row[$header[$name_pos]]);
-						$email		= trim($row[$header[$email_pos]]);
-						$phone		= trim($row[$header[$phone_pos]]);
-						$name2		= trim($row[$header[$name2_pos]]);
-						$name3		= trim($row[$header[$name3_pos]]);
-
-						$birth		= trim($row[$header[$birth_pos]]);
-						$notes 		= trim($row[$header[$notes_pos]]);
-						$altEmail	= trim($row[$header[$altEmail_pos]]);
-						$sdata['alias']         		= trim($row[$header[$alias_pos]]);
-						$sdata['corporate_name']      = trim($row[$header[$corporate_name_pos]]);
-						$sdata['job_title']         	= trim($row[$header[$job_title_pos]]);
-						$sdata['department']       	= trim($row[$header[$department_pos]]);
-						$sdata['web_page']			= trim($row[$header[$web_page_pos]]);
+						$full_name               = addslashes(trim($row[$header[$name_pos]]));
+						$email		             = addslashes(trim($row[$header[$email_pos]]));
+						$phone		             = addslashes(trim($row[$header[$main_phone_pos]]));
+						$name2	               	 = addslashes(trim($row[$header[$name2_pos]]));
+						$name3		             = addslashes(trim($row[$header[$name3_pos]]));
+						$birth		             = addslashes(trim($row[$header[$birth_pos]]));
+						$notes 					 = addslashes(trim($row[$header[$notes_pos]]));
+						$altEmail			 	 = addslashes(trim($row[$header[$altEmail_pos]]));
+						$sdata['alias']          = addslashes(trim($row[$header[$alias_pos]]));
+						$sdata['corporate_name'] = addslashes(trim($row[$header[$corporate_name_pos]]));
+						$sdata['job_title']      = addslashes(trim($row[$header[$job_title_pos]]));
+						$sdata['department']     = addslashes(trim($row[$header[$department_pos]]));
+						$sdata['web_page']		 = addslashes(trim($row[$header[$web_page_pos]]));
+						$sdata['sex']         	 = addslashes(trim($row[$header[$sex_pos]]));
+						$sdata['pgp_key']      	 = addslashes(trim($row[$header[$pgp_key_pos]]));
 						
-						$sdata['sex']         		= trim($row[$header[$sex_pos]]);
-						$sdata['pgp_key']      = trim($row[$header[$pgp_key_pos]]);
-
-
-					$full_name = $full_name;
 					$array_name = explode(' ', str_replace('"','',(str_replace('\'','',$full_name))));
 					$sdata['given_names'] = addslashes($array_name[0]);
@@ -4386,5 +4715,6 @@
 						$sdata['addresses']['address_personal']['id_city'] =  trim($row[$header[$city_pos]]);
 
-					if(trim($birth)) {
+					if(trim($birth)) 
+					{
 						$array_birth = explode("/",trim($birth));
 						$sdata['birthdate'] = date('Y-m-d', mktime(0,0,0,$array_birth[1],$array_birth[0],$array_birth[2]));
@@ -4394,10 +4724,13 @@
 					//$sdata['is_quick_add'] = true;
 					$sdata['connections']['default_phone']['connection_value'] = $phone;
-
+					if(!$phone){
+
+					}
 					// 	verifica se email já existe!
 					$email = addslashes($email);
-					$contact = $boGroup->verify_contact($email);
-
-					if(!$sdata['given_names'] && $email){
+					$contact = false;
+					$contact = $boGroup->verify_contact($email, $full_name, $phone);
+					if(!$sdata['given_names'] && $email)
+					{
 							$a_email = explode("@",$email);
 							$sdata['given_names'] = addslashes($a_email[0]);
@@ -4406,8 +4739,9 @@
 					$line_iteration = $return['_failure'] + $return['_existing'] + $return['_new'];
 
-					if($contact){
+					if($contact[0] != null)
+					{
 						$return['_existing']++;
 					}
-					else if((!eregi("^[/_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) && $email) {
+					else if((!eregi("^[a-zA-Z0-9][_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*$", $email)) && $email) {
 						$return['_failure']++;
 						$return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>";
@@ -4432,4 +4766,66 @@
 			echo serialize($return);
 		}
+		
+		function get_contact_details($id)
+		{
+			$data = array();
+			
+			if(!$this->bo->catalog->src_info) {
+				$ldap = CreateObject('contactcenter.bo_ldap_manager');
+				$this->bo->catalog->src_info = $ldap->srcs[1];
+			}
+			//$id = urlencode($id);
+			$ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);				
+			$dn=$this->bo->catalog->src_info['dn'];
+
+			//buscar os atributos do ldap
+			$configobj = CreateObject('phpgwapi.config', 'contactcenter');
+			$prefs = $configobj->read_repository();
+			$attr_names = array();
+			$attr_types = array();
+			$justThese = array();
+			foreach ($prefs as $pref_key => $pref_value)
+			{
+				if (stripos($pref_key, "cc_attribute_name_") !== false)
+				{
+					$num = substr($pref_key, strlen("cc_attribute_name_"));
+					$attr_names[] = $prefs["cc_attribute_name_$num"];
+					$attr_types[] = $prefs["cc_attribute_type_$num"];
+					$justThese[] = strtolower($prefs["cc_attribute_ldapname_$num"]);
+				}
+			}
+			
+
+
+			$sr = ldap_read($ds,utf8_encode($id), "objectClass=*",$justThese);							
+			$info = ldap_get_entries($ds, $sr);
+			if ($info)
+			{
+				for ($i = 0; $i < count($justThese); $i++)
+				{
+					$attr = array();
+					$attr['name'] = $attr_names[$i];
+					if ($attr_types[$i] == 'multivalues')
+					{
+						$attr['type'] = 'multivalues';
+						$attr['value'] = array();
+						for ($j = 0; $j < $info[0][$justThese[$i]]['count']; $j++)
+							$attr['value'][] = utf8_decode($info[0][$justThese[$i]][$j]);
+					}
+					else
+					{
+						$attr['type'] = 'text';
+						$attr['value'] = utf8_decode($info[0][$justThese[$i]][0]);
+					}
+					$data[] = $attr;
+				}
+			}
+			else
+				$data = 'error';
+			ldap_close($ds);
+			
+			echo serialize($data);
+		}
+		
 	}
 
Index: /trunk/contactcenter/js/cc_config.js
===================================================================
--- /trunk/contactcenter/js/cc_config.js	(revision 4548)
+++ /trunk/contactcenter/js/cc_config.js	(revision 5131)
@@ -22,29 +22,4 @@
 	function cc_attribute_clear(form)
 	{
-
-		var vars = document.getElementsByClassName("cc_attribute");
-		
-		var tupla;
-		var select;
-		var inputs;
-		
-		for (var i=0; i<vars.length; i++) {	
-			tupla = vars[i];
-			inputs = tupla.getElementsByTagName("input");
-			
-			if(inputs[0].value == "" || inputs[1].value == "") 
-			{		
-				//tupla.parentNode.removeChild(tupla);
-				inputs[0].setAttribute("value", "");
-				inputs[1].setAttribute("value", "");
-				
-				select = tupla.getElementsByTagName("select");
-				select[0].innerHTML = "<option value=\"\" selected=\"selected\"></option>";
-				select[1].innerHTML = "<option value=\"\" selected=\"selected\"></option>";
-				
-				tupla.style.visible = "hidden";
-				tupla.style.display = "none";
-			}
-		}
 		form.submit();
 	}
@@ -60,12 +35,16 @@
 	function cc_attribute_add()
 	{
-		var stringTexto = document.getElementsByClassName("cc_attribute")[0].getElementsByTagName("select")[0].getElementsByTagName("option")[0].innerHTML;
-		var stringMultivalorado = document.getElementsByClassName("cc_attribute")[0].getElementsByTagName("select")[0].getElementsByTagName("option")[1].innerHTML
+		var stringTexto = document.getElementById('textHidden').value;
+		var stringMultivalorado = document.getElementById('multitextHidden').value;
+		var stringYes = document.getElementById('yesHidden').value;
+		var stringNo = document.getElementById('noHidden').value;
+		var stringDelete = document.getElementById('deleteHidden').value;
 		
 		var numeroAtributo = 0;
-		var vars = document.getElementsByClassName("cc_attribute");
+		var table = document.getElementsByName("cc_newconftable");
+		var vars = table[0].getElementsByTagName("TR"); 
 		
 		var maior = 0;
-		for (var i=0; i<vars.length; i++) {
+		for (var i=1; i<vars.length; i++) {
 			var tupla = vars[i];
 			var linhaIndice = tupla.getElementsByTagName("input")[0];
@@ -88,74 +67,71 @@
 		var cc_attribute_searchable = "newsettings[cc_attribute_searchable_" + numeroAtributo + "]";
 		
-		var pool = document.getElementById("cc_attribute_fields");
-		var btn = document.getElementById("c_attribute_box_adder"); // nome do id definido no template.
+		var pool = document.getElementById("cc_newconftable");
 		
-		var newDiv = document.createElement("div");
-			newDiv.setAttribute("class", "cc_attribute");
+		//LINHA DOS CAMPOS
+		var tudo = document.createElement("TR");
 	
-		var formularioNome = document.createElement("input");
-			formularioNome.setAttribute("type", "text");
-			formularioNome.setAttribute("name", cc_attribute_name);
-			formularioNome.setAttribute("value", "");
-			formularioNome.setAttribute("style", "width: 170px;");
-	
-		var formularioLdap = document.createElement("input");
-			formularioLdap.setAttribute("type", "text");
-			formularioLdap.setAttribute("name", cc_attribute_ldapname);
-			formularioLdap.setAttribute("value", "");
-			//formularioLdap.setAttribute("style", "margin: 0px 40px;");
-			formularioLdap.setAttribute("style", "width: 170px;");
+		//INPUT DO NOME
+		var tudoBody1 = document.createElement("TD");
+		tudoBody1.innerHTML = "<input type=\"text\" name=\""+cc_attribute_name+"\" value=\"\" style=\"width:170px;\" />";
+		tudo.appendChild(tudoBody1);
+		
+		//INPUT CORRESPONDENTE
+		var tudoBody2 = document.createElement("TD");
+		tudoBody2.innerHTML = "<input type=\"text\" name=\""+cc_attribute_ldapname+"\" value=\"\" style=\"width:170px;\" />";
+		tudo.appendChild(tudoBody2);
+		
+		//TD SELECT MULTI OR TEXT 
+		var tudoBody3 = document.createElement("TD");
+			//SELECT MULTI OR TEXT 
+			var select1 = document.createElement("SELECT");
+			select1.name = cc_attribute_type;
+			select1.style.width = "86px";
+			select1.style.margin = "0px 0px 0px 8px";
+			//OPTION TEXT
+			var option1 = document.createElement("OPTION");
+			option1.innerHTML = stringTexto;
+			option1.value = "text";
+			//OPTION MULTI
+			var option2 = document.createElement("OPTION");
+			option2.innerHTML = stringMultivalorado;
+			option2.value = "multivalues";
+			//ADD OPTIONs TO SELECT
+			select1.appendChild(option1);
+			select1.appendChild(option2);
+			//ADD SELECT TO TD
+			tudoBody3.appendChild(select1);
+			//ADD TD TO TR
+			tudo.appendChild(tudoBody3);
+			
+		//TD SELECT YES OR NO 
+		var tudoBody4 = document.createElement("TD");
+			//SELECT YES OR NO 
+			var select2 = document.createElement("SELECT");
+			select2.name = cc_attribute_searchable;
+			select2.style.margin = "0px 16px";
+			//OPTION YES
+			var option3 = document.createElement("OPTION");
+			option3.innerHTML = stringYes;
+			option3.value = "true";
+			//OPTION NO
+			var option4 = document.createElement("OPTION");
+			option4.selected = "selected";
+			option4.innerHTML = stringNo;
+			option4.value = "false";
+			//ADD OPTIONs TO SELECT
+			select2.appendChild(option3);
+			select2.appendChild(option4);
+			//ADD SELECT TO TD
+			tudoBody4.appendChild(select2);
+			//ADD TD TO TR
+			tudo.appendChild(tudoBody4);
+		
+		//TD IMG 		
+		var tudoBody5 = document.createElement("TD");
+		tudoBody5.innerHTML = "<img src=\"contactcenter/templates/default/images/cc_x.png\" title=\""+ stringDelete +"\" alt=\""+ stringDelete +"\" style=\"width: 15px; height: 14px; cursor: pointer; position: relative; top: 3px;\" onclick=\"javascript:cc_attribute_delete(this)\">"
+		tudo.appendChild(tudoBody5);
 
-		var selectTipos = document.createElement("select");
-		selectTipos.setAttribute("name", cc_attribute_type);
-		selectTipos.setAttribute("style", "width: 86px; margin: 0px 0px 0px 8px");
-		//selectTipos.setAttribute("style", "margin: 0px 0px 0px 8px");
-			var optionTexto = document.createElement("option");
-			optionTexto.setAttribute("value", "text");
-			optionTexto.setAttribute("selected", "selected");
-			optionTexto.innerHTML = stringTexto + " ";
-		
-			var optionMultivalorado = document.createElement("option");
-			optionMultivalorado.setAttribute("value", "multivalues");
-			optionMultivalorado.innerHTML = stringMultivalorado + " ";
-			
-		selectTipos.appendChild(optionTexto);
-		selectTipos.appendChild(optionMultivalorado);
-				
-		var selectPesquisavel = document.createElement("select");
-		selectPesquisavel.setAttribute("name", cc_attribute_searchable);
-		selectPesquisavel.setAttribute("style", "margin: 0px 16px;");
-			var optionYes = document.createElement("option");
-				optionYes.setAttribute("value", "true");
-				optionYes.innerHTML = "Sim ";
-			var optionNo = 	document.createElement("option");
-				optionNo.setAttribute("value", "false");
-				optionNo.setAttribute("selected", "selected");
-				optionNo.innerHTML = "Não ";
-			
-				
-		selectPesquisavel.appendChild(optionYes);
-		selectPesquisavel.appendChild(optionNo);		
-				
-				
-				
-		var imagem = document.createElement("img");
-			imagem.setAttribute("type", "image");
-			imagem.setAttribute("src", "contactcenter/templates/default/images/cc_x.png");
-			imagem.setAttribute("alt", "Excluir Campo ");
-			imagem.setAttribute("style", "width: 15px; height: 14px; cursor: pointer; position: relative; top: 3px;");
-			imagem.setAttribute("onclick", "javascript:cc_attribute_delete(this)");
-	
-		newDiv.appendChild(formularioNome);
-		newDiv.appendChild(document.createTextNode(" "));
-		newDiv.appendChild(formularioLdap);
-		newDiv.appendChild(document.createTextNode(" "));
-		newDiv.appendChild(selectTipos);
-		newDiv.appendChild(document.createTextNode(" "));
-		newDiv.appendChild(selectPesquisavel);
-		newDiv.appendChild(document.createTextNode(" "));
-		newDiv.appendChild(imagem);
-
-		pool.appendChild(newDiv);
+		pool.appendChild(tudo);
 	}
 	
@@ -170,5 +146,6 @@
 	{
 			var tupla = e.parentNode;
-			
+			tupla = tupla.parentNode;
+			var mom = tupla.parentNode;
 			var inputs = tupla.getElementsByTagName("input");
 
Index: /trunk/contactcenter/js/cc_search.js
===================================================================
--- /trunk/contactcenter/js/cc_search.js	(revision 4548)
+++ /trunk/contactcenter/js/cc_search.js	(revision 5131)
@@ -270,5 +270,5 @@
 			target.appendChild( holder );
 			
-			this.win = new dJSWin({
+			this.win = win = new dJSWin({
 					id: 'ccSearch_Layer2',
 					content_id: 'Layer2',
@@ -380,5 +380,5 @@
 			data['search_for'] = cn;
 
-		    customFilterDiv.style.visibility = 'hidden';
+		    win.close();
 		    document.getElementById('overlay').style.visibility = 'hidden';
 		}
Index: /trunk/contactcenter/js/ccAddGroup.js
===================================================================
--- /trunk/contactcenter/js/ccAddGroup.js	(revision 4769)
+++ /trunk/contactcenter/js/ccAddGroup.js	(revision 5131)
@@ -128,4 +128,5 @@
 			if (data['status'] != 'ok' && data['status'] != 'warning')
 			{
+				showMessage(Element('cc_msg_err_duplicate_group').value);
 				return;
 			}
@@ -205,4 +206,5 @@
 			
 		this.title.value = '';				
+		ccAGSearchTerm.value = '';
 	}
 	
@@ -240,7 +242,7 @@
 
 				for(var j = 0;j < select_in.options.length; j++) {																			
-					if(select_in.options[j].value == select.options[i].value){
+					if((select_in.options[j].value == select.options[i].value) && (select_in.options[j].textContent == select.options[i].textContent)){
 						isSelected = true;						
-						break;	
+						//break;	
 					}
 				}
@@ -346,19 +348,19 @@
 
             var search_for = data['search_for'].split(' ');
-            var greaterThan4 = false;
-            var use_length = v_min;
-
-            for (i = 0; i < search_for.length; i++)
-            {
-                if (search_for[i].length >= use_length)
-                {
-                    greaterThan4 = true;
-                }
-            }
-
-            if (!greaterThan4){
-                alert("Favor fazer a consulta com pelo menos " + v_min + " caracteres!");
-                return;
-            }
+            //var greaterThan4 = false;
+            //var use_length = v_min;
+
+            //for (i = 0; i < search_for.length; i++)
+            //{
+            //    if (search_for[i].length >= use_length)
+            //    {
+            //        greaterThan4 = true;
+            //    }
+            //}
+
+            // if (!greaterThan4){
+            //     alert("Favor fazer a consulta com pelo menos " + v_min + " caracteres!");
+			//     return;
+            // }
 
             var handler = function(data)
@@ -435,4 +437,6 @@
                 {
                    ccAddGroup.clearSourceList();
+				   if (catalogLevel == '0.2')
+						ccAddGroup.search();
                 }
 
Index: /trunk/contactcenter/js/cc.js
===================================================================
--- /trunk/contactcenter/js/cc.js	(revision 4507)
+++ /trunk/contactcenter/js/cc.js	(revision 5131)
@@ -231,5 +231,5 @@
 function openContactDetails(id){
 	// Build the ContactDetails Window.
-	if(!contactdetailsWin && !is_ie) 
+	if((typeof(contactdetailsWin) == 'undefined') && !is_ie) 
 		__cdWin();
 
@@ -996,5 +996,13 @@
         for (var type in CC_contact_full_info['connections']){
             haveConnections = true;
+			var reEmail = /^[a-zA-Z0-9][_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*$/;
             for (var i in CC_contact_full_info['connections'][type]){
+				if(type == 1){
+					if(!reEmail.test(CC_contact_full_info['connections'][type][i]['value'])){
+						showMessage('Endereço para conexão de ' + CC_contact_full_info['connections'][type][i]['name'] + ', não é válido');
+						return false;
+					}
+				}
+				else{
                 if((CC_contact_full_info['connections'][type][i]['value'].length < 4) ||
                     (!comp.test(CC_contact_full_info['connections'][type][i]['value']))){
@@ -1002,4 +1010,5 @@
                     return false;
                 }
+            }
             }
             var _options_default = Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default");
@@ -1009,8 +1018,4 @@
             }
         }
-    }
-    if(!haveConnections){
-        showMessage(Element('cc_msg_tel_or_mail_required').value);
-        return false;
     }
 
@@ -1634,5 +1639,5 @@
 			//'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+
 			'<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px;" align="right"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+'</span></td>' +
-			'<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px;" maxlength="100" type="text">&nbsp;' +
+			'<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" onkeyup="javascript:emailTolower(\'cc_conn_value_' + CC_conn_count + '\')" style="width: 150px;" maxlength="100" type="text">&nbsp;' +
 			'<img align="top" alt="X" src="templates/default/images/x.png" style="width:18px; height:18px" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>';
 		}
@@ -1642,5 +1647,5 @@
 			//'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+
 			'<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px;" align="right"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+'</span></td>' +
-			'<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px;" maxlength="30" type="text" onkeyup="formatPhone(this)">&nbsp;' +
+			'<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" onkeyup="javascript:emailTolower(\'cc_conn_value_' + CC_conn_count + '\')" style="width: 150px;" maxlength="30" type="text" onkeyup="formatPhone(this)">&nbsp;' +
 			'<img align="top" alt="X" src="templates/default/images/x.png" style="width:18px; height:18px" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>';
 		}
@@ -1806,4 +1811,9 @@
 
 	connRemoveLine(id);
+}
+
+function emailTolower(obj){
+	document.getElementById(obj).value = document.getElementById(obj).value.toLowerCase();
+
 }
 
@@ -2308,10 +2318,10 @@
 
 								if(data[3][pos][k] === 'none')
-									data[3][pos][k] = '&nbsp';
+									"Não informado.";
 								break;
 							case 'cc_phone' :
 
 								if(data[3][pos][k] === 'none')
-									data[3][pos][k] = '&nbsp';
+									data[3][pos][k] = "Não informado.";
 								break;
 						}
@@ -2352,5 +2362,8 @@
 								else
 								{
+									if(data[3][pos][k] != "Não informado.")
 									Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>';
+									else
+										Element(id+':'+data[2][k]).innerHTML = data[13] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>';
 								}
 								break;
@@ -2366,9 +2379,16 @@
 									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
 								}
+								if(data[3][pos][k] != " ")
 								Element(id+':cc_phone').innerHTML = (data[3][pos][k].length < 23) ? data[3][pos][k]:data[3][pos][k].substr(0,22)+"<br>"+data[3][pos][k].substr(22,data[3][pos][k].length);
+								else
+									Element(id+':cc_phone').innerHTML = "Não informado.";
 								break;
 
 							case 'cc_title':
-								if (data[3][pos][k].length > 15)
+								if(preferences.departmentShow && ccTree.catalog_perms == 1){
+									if(data[3][pos][k] == " " || data[3][pos][k] == "" || data[3][pos][k] == "undefined"){
+										Element(id+':'+data[2][k]).innerHTML = "Não informado.";
+									}
+									else if (data[3][pos][k].length > 15)
 								{
 									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15);
@@ -2380,5 +2400,7 @@
 								}
 								break;
-
+								}else{
+									break;
+								}
 							case 'cc_id':
 								var id_contact = data[3][pos][k];
@@ -2410,4 +2432,5 @@
 							//Para tratar tamanho do campo "celular" do empregado
 							case 'cc_mobile':
+								if(preferences.cellShow && ccTree.catalog_perms == 1){
 								if (data[3][pos][k].length > 20)
 								{
@@ -2421,7 +2444,10 @@
 								Element(id+':cc_mobile').innerHTML = data[3][pos][k];
 								break;
-
+								}else{
+									break;
+								}		
 							//Para tratar tamanho do campo "matricula" do empregado
 							case 'cc_empNumber':
+								if(preferences.empNumShow && ccTree.catalog_perms == 1){
 								if (data[3][pos][k].length > 20)
 								{
@@ -2435,5 +2461,7 @@
 								Element(id+':cc_empNumber').innerHTML = data[3][pos][k];
 								break;
-
+								}else{
+									break;
+								}
 							//Para tratar tamanho do campo "departamento" do empregado
 							case 'cc_department':
@@ -2461,4 +2489,34 @@
 									Element(id+':'+data[2][k]).innerHTML = data[3][pos][k];
 								}
+						}
+					}else{
+						data[3][pos][k] = unescape(data[3][pos][k]);
+						switch (data[2][k])
+						{
+							case 'cc_mail':
+								Element(id+':'+data[2][k]).innerHTML = data[13] + "Não informado." + '\')">'+ "Não infomardo." +'</span>';
+								break;
+
+							case 'cc_phone':
+								Element(id+':cc_phone').innerHTML = "Não informado.";
+								break;
+							case 'cc_empNumber':
+								if(preferences.empNumShow && ccTree.catalog_perms == 1){
+									var cc_empNumberTD = Element(id+':cc_empNumber').parentNode;
+									cc_empNumberTD.parentNode.removeChild(cc_empNumberTD);
+								}
+								break;
+							case 'cc_mobile':
+								if(preferences.cellShow && ccTree.catalog_perms == 1){
+									var cc_mobileTD = Element(id+':cc_mobile').parentNode;
+									cc_mobileTD.parentNode.removeChild(cc_mobileTD);
+								}
+								break;
+							case 'cc_title':
+								if(preferences.departmentShow && ccTree.catalog_perms == 1){
+									var cc_titleTD = Element(id+':cc_title').parentNode;
+									cc_titleTD.parentNode.removeChild(cc_titleTD);
+								}
+								break;
 						}
 					}
@@ -2515,7 +2573,7 @@
 						{
 							case 'cc_title':
-								if (data[3][pos][k].length > 50)
+								if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20))
 								{
-									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 50);
+									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], (CC_visual == 'table'  ? 50 : 20));
 									Element(id+':'+data[2][k]).title = data[3][pos][k];
 								}
@@ -2663,10 +2721,10 @@
 						'<img title="'+Element('cc_msg_card_remove').value+'" id="' + id + ':cc_card_remove" style="position: absolute; top: 78px; left: 223px; width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' : '') +
 						'<img id="' + id + ':cc_photo" style="position: absolute; top: 15px; left: 7px;" src="" border="0" ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +
-						'<span id="' + id + ':cc_company" style="position: absolute; top: 5px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 14px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_company_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_company_full\').style.visibility=\'hidden\'"></span>' +
+						'<span id="' + id + ':cc_company" style="position: absolute; top: 5px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_company_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_company_full\').style.visibility=\'hidden\'"></span>' +
 						'<span style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 100px; left: 35px"  valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>'+
 						//Para exibir a matricula do empregado nos cartoes
-						'<span id="' + id + ':cc_empNumber" style="position: absolute; top: 15px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' +
+						'<span id="' + id + ':cc_empNumber" style="position: absolute; top: 20px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' +
 						'<span id="' + id + ':cc_name" style="position: absolute; top: 30px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_name_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_name_full\').style.visibility=\'hidden\'"></span>' +
-						'<span id="' + id + ':cc_title" style="position: absolute; top: 50px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 12px; text-align: center; height: 10px;"></span>' +
+						'<span id="' + id + ':cc_title" style="position: absolute; top: 90px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 12px; text-align: center; height: 10px;"></span>' +
 						//Para exibir o setor/lotacao do empregado nos cartoes
 						'<span id="' + id + ':cc_department" style="position: absolute; top: 60px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
@@ -2694,6 +2752,6 @@
 					'<span id="' + id + ':cc_participantes" style="cursor: pointer; cursor: hand; z-index: 1"></span>' +
 					'<span id="' + id + ':cc_title"></span></td>' +
-					'<td width="40%" style="solid #999; font-weight: normal; font-size: 10px; text-align: left; height: 10px"><span onMouseOver="this.title = \''+Element('cc_send_mail').value+'\'"  id="' + id + ':cc_short_name"></span></td>' +
-					'<td align="left" width="55px">'+
+					'<td width="40%" style="solid #999; font-weight: normal; font-size: 10px; text-align: left; height: 10px"><span id="' + id + ':cc_short_name"></span></td>' +
+					'<td align="center" width="10%">'+
 					'<img  title="'+Element('cc_msg_group_edit').value+'" id="' + id + ':cc_card_edit" style=" cursor: pointer; cursor: hand; z-index: 1;width: 18px; height: 18px;"  onclick="editGroup(Element(\'' + id + ':cc_id\').value);" src="templates/default/images/cc_card_edit.png">' +
 					'&nbsp;&nbsp;|&nbsp;&nbsp;'+
@@ -2705,16 +2763,16 @@
 				html_card = '<tr  style="height:20px" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE">' +
 					//Para exibir a matricula do empregado na tabela
-					(preferences.empNumShow && ccTree.catalog_perms == 1 ? '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_empNumber"></span></td>' : '') +
+					(preferences.empNumShow && ccTree.catalog_perms == 1 ? '<td align="center" width="10%" name="cc_name_empNumber" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_empNumber"></span></td>' : '') +
 					'<td width="auto" style="font-weight: normal; font-size: 10px; text-align: left; height: 10px;"><span valign="bottom" id="' + id + ':cc_icon_group">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span id="' + id + ':cc_name"></span></td>' +
-					'<td style="solid #999; font-weight: normal; font-size: 10px; text-align: left; height: 10px"><span onMouseOver="this.title = \''+Element('cc_send_mail').value+' => '+'\'+document.getElementById(\''+id + ':cc_name\').innerHTML" id="' + id + ':cc_mail"></span></td>' +
-					'<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_phone"></span></td>' +
+					'<td width="20%" align="center" name="cc_name_send_mail" style="solid #999; font-weight: normal; font-size: 10px; height: 10px"><span onMouseOver="this.title = \''+Element('cc_send_mail').value+' => '+'\'+document.getElementById(\''+id + ':cc_name\').innerHTML" id="' + id + ':cc_mail"></span></td>' +
+					'<td width="20%" align="center" name="cc_name_phone" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_phone"></span></td>' +
 					//Para exibir o celular empresarial do empregado na tabela
-					(preferences.cellShow && ccTree.catalog_perms == 1 ?	'<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_mobile"></span></td>' : '') +
+					(preferences.cellShow && ccTree.catalog_perms == 1 ?	'<td align="center" name="cc_name_mobile" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_mobile"></span></td>' : '') + 
 					//Para exibir o setor/lotacao do empregado na tabela
-					(preferences.departmentShow && ccTree.catalog_perms == 1 ? '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_department"></span></td>' : '') +
+					(preferences.departmentShow && ccTree.catalog_perms == 1 ? '<td align="center" name="cc_name_title" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_title"></span></td>' : '') +
 					( ccTree.catalog_perms == 1 ?
-					'<td align="left"><span valign="bottom" id="' + id + ':cc_icon_data"></span></td>':'') +					
+					'<td align="center" width="10%"><span valign="bottom" id="' + id + ':cc_icon_data"></span></td>':'') +					
 					(ccTree.catalog_perms & 2 ?
-					'<td align="left" >'+
+					'<td align="center" width="10%" >'+
 					'<img  title="'+Element('cc_msg_card_edit').value+'" id="' + id + ':cc_card_edit" style=" cursor: pointer; cursor: hand; z-index: 1;width: 18px; height: 18px;"  onclick="editContact(Element(\'' + id + ':cc_id\').value);" src="templates/default/images/cc_card_edit.png">' +
 					'&nbsp;&nbsp;|&nbsp;&nbsp;'+
@@ -2722,5 +2780,5 @@
 					'<input id="' + id + ':cc_id" type="hidden">'+
 					'<input type="hidden" id="' + id + ':cc_photo">' +
-					'<span id="' + id + ':cc_title" style="display:none"></span>' +
+					//'<span id="' + id + ':cc_mobile" style="display:none"></span>' +
 					'<span id="' + id + ':cc_alias" style="display:none"></span>' +
 					// Esse campo é necessário se o contato possui dados no campo cc_company
Index: /trunk/contactcenter/js/ccQuickAdd-plugin.js
===================================================================
--- /trunk/contactcenter/js/ccQuickAdd-plugin.js	(revision 4721)
+++ /trunk/contactcenter/js/ccQuickAdd-plugin.js	(revision 5131)
@@ -202,6 +202,6 @@
 		}
 		//Utiliza expressão regular para validar email
-		if (this._fields[4].value != '') {
-			var reEmail = /^[A-Za-z\d_-]+(\.[A-Za-z\d_-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
+		if (this._fields[4].value != ''){
+			var reEmail = /^[a-zA-Z0-9][_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*$/;
 			
 			if (sdata[4] !== "" && !reEmail.test(this._fields[4].value)) {
@@ -211,8 +211,5 @@
 			}
 		}
-		else if(this._fields[3].value=='') {
-			alert(Element('cc_msg_tel_or_mail_required').value);
-			return false;
-		}
+		sdata[4] = sdata[4].toLowerCase();
 		var sdata = 'add='+escape(serialize(sdata));
 
Index: /trunk/contactcenter/js/ccMain.js
===================================================================
--- /trunk/contactcenter/js/ccMain.js	(revision 3795)
+++ /trunk/contactcenter/js/ccMain.js	(revision 5131)
@@ -22,5 +22,5 @@
 		var search_params = new Array();
 		search_params['holder'] = Element('cc_panel_search_call');
-		search_params['total_width'] = (v_label != false &  v_atrib != false)? '485px' : '330px';
+		search_params['total_width'] = (v_label != false &  v_atrib != false)? '485px' : '335px';
 		search_params['input_width'] = '200px';
 		search_params['progress_top'] = '150px';
Index: /trunk/contactcenter/js/ccIEContacts.js
===================================================================
--- /trunk/contactcenter/js/ccIEContacts.js	(revision 3334)
+++ /trunk/contactcenter/js/ccIEContacts.js	(revision 5131)
@@ -47,11 +47,12 @@
 			this.el.style.top = "0px";
 			this.el.style.width = this.wWidth	+ 'px';
-			this.el.style.height = this.wHeight + 'px';
+			this.el.style.height = this.wHeight + 100+'px';
 			if(is_ie) {
-				this.el.style.width = "430";
+				this.el.style.width = "650";
 				this.el.style.overflowY = "auto";	
 				this.el.style.overflowX = "hidden";
 			}													
 			else {									
+				this.el.style.overflowY = "auto";
 				this.el.style.overflow = "-moz-scrollbars-vertical";
 			}
@@ -75,13 +76,14 @@
 			var lang_outl2k_pt = Element('cc_msg_outlook_2k_pt').value;
 			var lang_outl2k_en = Element('cc_msg_outlook_2k_en').value;
+			var lang_outl03 = Element('cc_msg_outlook_2003').value;
 			var lang_expresso_default_csv = Element('cc_msg_expresso_default_csv').value;
 
 		
 			this.el.innerHTML = 
-			'<div align="left" id="divAppbox"><table width="100%" border=0>'+
+			'<div align="left" id="divAppbox" width="90%" ><table width="100%" border=0>'+
 			'<tr><td style="border-bottom:1px solid black"><input onclick="javascript:ccIEContacts.changeOptions(this.value)" id="type" type="radio" name="type" value="i" style="border:0" checked>'+lang_import_contacts+
 			'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input onclick="javascript:ccIEContacts.changeOptions(this.value)" id="type" type="radio" name="type" style="border:0" value="e"/>'+lang_export_contacts+' <br></td></tr>'+
 			'</table>'+
-			'<table border=0 height="208px"  width="100%" id="import_span">'+
+			'<table border=0 height="100%"  width="100%" id="import_span">'+
 			'<tr><td>'+
 			'<font color="DARKBLUE" size="2">'+lang_expresso_info_csv+'</font></td></tr>'+
@@ -91,4 +93,5 @@
 			'<option value="outlook">'+("Outlook Express")+'</option>'+
 			'<option value="outlook2000">'+("Outlook 2000")+'</option>'+
+			'<option value="outlook2003">'+("Outlook 2003")+'</option>'+
 			'<option value="thunderbird">'+("Mozilla Thunderbird")+'</option>'+
 			'<option value="expresso" selected>'+lang_expresso_default+'</option></select><br>'+
@@ -102,5 +105,5 @@
 			'<input type="button" value='+lang_close_win+' onClick="javascript:ccIEContacts.close()"></center></td></tr>'+
 			'<tr><td height="10px" align="center" nowrap><span style="visibility:hidden" id="s_info2"></span></td></tr></table>'+
-			'<table border=0  height="208px"  width="100%" style="display:none" id="export_span">'+
+			'<table border=0  height="100%"  width="100%" style="display:none" id="export_span">'+
 			'<tr><td>'+						
 			'<font color="DARKBLUE" size="2">'+ lang_msg_expresso_info_csv+'</font></td></tr>'+
@@ -112,8 +115,8 @@
 			'<option value="outlook2000_pt-BR">'+lang_outl2k_pt+'</option>'+
 			'<option value="outlook2000_en">'+lang_outl2k_en+'</option>'+
+			'<option value="outlook2003">'+lang_outl03+'</option>'+
 			'<option value="thunderbird">'+lang_moz_tb+'</option>'+
 			'</select>'+			
 			'</td></tr>'+
-			'<tr><td align="center">&nbsp;</td></tr>'+
 			'<tr><td nowrap><center><input id="export_button" type="button" value='+lang_export_contacts+ ' onClick="javascript:ccIEContacts.exportCSV(this)">&nbsp;&nbsp;&nbsp;&nbsp;'+
 			'<input type="button" value='+lang_close_win+ ' onClick="javascript:ccIEContacts.close()"></center></td></tr>'+
@@ -121,4 +124,7 @@
 		}		
 		this.showWindow();
+		if(Element('s_info'))
+			Element('s_info').style.visibility = 'hidden';
+		ccIEContacts.cleanInfo();
 	}
 	
@@ -131,5 +137,5 @@
 				content_id: this.el.id,
 				width: (this.wWidth +(is_ie ? 41 : 0))  +'px',
-				height: this.wHeight +'px',
+				height: this.wHeight +100+'px',
 				title_color: '#3978d6',
 				bg_color: '#eee',
@@ -166,4 +172,5 @@
 		var l_2 	= '<font face="Verdana" size="1" color="RED">['+args[2]+lang_failure+']</font>';
 		var l_3		= '<font face="Verdana" size="1" color="DARKBLUE">['+args[3]+lang_exists+']</font>';
+		if(args[2])
 		var l_4 	= '<br><a font face="Verdana" size="1" href="javascript:ccIEContacts.showFailures(\''+args[4]+'\')">'+lang_show_more_info+'</a>';
 		var l_error	= '<span style="height:15px;background:#cc4444">&nbsp;&nbsp;<font face="Verdana" size="1" color="WHITE">'+lang_import_fail+ '&nbsp;</font></span>';
@@ -172,6 +179,9 @@
 		if(args[0] == 'success') {
 
-			for(i = 1; i < 5; i++) {
+			for(i = 1; i < 4; i++) {
 				status += "&nbsp;"+eval('l_'+i);
+			}
+			if(args[2]){
+				status += "&nbsp;"+eval('l_4');
 			}
 			Element('s_info').innerHTML = '&nbsp;&nbsp;<font face="Verdana" size="1" color="BLACK"><b>'+lang_import_finish+'</b></font><br>&nbsp;'+status;
@@ -200,4 +210,5 @@
 	cIEContacts.prototype.importCSV = function ()
 	{		
+		ccIEContacts.cleanInfo();
 		var lang_msg_invalid_csv = Element('cc_msg_invalid_csv').value;
 		var form = document.formCSV;
@@ -223,5 +234,6 @@
 				args[3] = data._existing ? data._existing : 0;
 				args[4] = data._failure_status
-
+				if(args[1] > 0)
+					ccTree.setCatalog("0.0");
 			}
 			_this.importWriteStatus(args);
Index: /trunk/contactcenter/js/ccListParticipants.js
===================================================================
--- /trunk/contactcenter/js/ccListParticipants.js	(revision 880)
+++ /trunk/contactcenter/js/ccListParticipants.js	(revision 5131)
@@ -55,8 +55,9 @@
 		if(names.length) {
 			for (var d = 0; d < (names.length-1); d++) {																																					
+				var email_valido = email[d] != 'null' ? email[d] : "não informado"																																				
 				el.innerHTML +=	
 				"<font color='DARKBLUE'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+
 					"\"" + names[d]+ "\"" +
-					" &lt;"+email[d]+
+					" &lt;"+email_valido+
 					"&gt;</font>&nbsp;&nbsp;&nbsp;<br>";																	
 			}
Index: /trunk/contactcenter/templates/default/api_common.tpl
===================================================================
--- /trunk/contactcenter/templates/default/api_common.tpl	(revision 1496)
+++ /trunk/contactcenter/templates/default/api_common.tpl	(revision 5131)
@@ -16,4 +16,5 @@
 <input id="cc_msg_err_serialize_data_unknown" type="hidden" value="{cc_msg_err_serialize_data_unknown}" />
 <input id="cc_msg_err_shared" type="hidden" type="hidden" value="{cc_msg_err_shared}" />
+<input id="cc_msg_err_duplicate_group" type="hidden" type="hidden" value="{cc_msg_err_duplicate_group}" />
 
 <input id="cc_msg_err_empty_field" type="hidden" value="{cc_msg_err_empty_field}" />
Index: /trunk/contactcenter/templates/default/preferences.tpl
===================================================================
--- /trunk/contactcenter/templates/default/preferences.tpl	(revision 1600)
+++ /trunk/contactcenter/templates/default/preferences.tpl	(revision 5131)
@@ -20,5 +20,4 @@
 			<td>
 				<select name="personCardEmail" style="width: 200px">
-					<option selected value="_NONE_">{lang_Choose_Email_Type...}</option>
 					{personCardEmail}
 				</select>
@@ -29,5 +28,4 @@
 			<td>
 				<select name="personCardPhone" style="width: 200px">
-					<option selected value="_NONE_">{lang_Choose_Telephone_Type...}</option>
 					{personCardPhone}
 				</select>
Index: /trunk/contactcenter/templates/default/index.tpl
===================================================================
--- /trunk/contactcenter/templates/default/index.tpl	(revision 4548)
+++ /trunk/contactcenter/templates/default/index.tpl	(revision 5131)
@@ -86,4 +86,5 @@
 <input id="cc_msg_outlook_2k_pt" type="hidden" value="{cc_msg_outlook_2k_pt}">
 <input id="cc_msg_outlook_2k_en" type="hidden" value="{cc_msg_outlook_2k_en}">
+<input id="cc_msg_outlook_2003" type="hidden" value="{cc_msg_outlook_2003}">
 <input id="cc_msg_moz_thunderbird" type="hidden" value="{cc_msg_moz_thunderbird}">
 <input id="cc_msg_expresso_default_csv" type="hidden" value="{cc_msg_expresso_default_csv}">
@@ -212,5 +213,5 @@
 									<table bgcolor="#D3DCE3" cellspacing="0" cellpadding="0" border="0">
 										<tr>
-											<td align="left" valign="middle"><span id="cc_panel_arrow_first"><img src="templates/default/images/first-grey.png" border="0" alt="{cc_panel_first_page}" hspace="2" onclick="javascript:false"/></span></td>
+											<td align="left" valign="middle"><span id="cc_panel_arrow_first"><img src="templates/default/images/first-grey.png" border="0" alt="{cc_panel_first_page}" title="{cc_panel_first_page}" hspace="2" onclick="javascript:false"/></span></td>
 										</tr>
 									</table>
@@ -219,5 +220,5 @@
 									<table bgcolor="#D3DCE3" cellspacing="0" cellpadding="0" border="0">
 										<tr>
-											<td align="left" valign="middle"><span id="cc_panel_arrow_previous"><img src="templates/default/images/left-grey.png" border="0" alt="{cc_panel_previous_page}" hspace="2" onclick="" /></span></td>
+											<td align="left" valign="middle"><span id="cc_panel_arrow_previous"><img src="templates/default/images/left-grey.png" border="0" alt="{cc_panel_previous_page}" title="{cc_panel_previous_page}" hspace="2" onclick="" /></span></td>
 										</tr>
 									</table>
@@ -233,5 +234,5 @@
 									<table bgcolor="#D3DCE3" cellspacing="0" cellpadding="0" border="0">
 										<tr>
-											<td align="left" valign="middle"><span id="cc_panel_arrow_next"><img src="templates/default/images/right-grey.png" border="0" alt="{cc_panel_next_page}" hspace="2" /></span></td>
+											<td align="left" valign="middle"><span id="cc_panel_arrow_next"><img src="templates/default/images/right-grey.png" border="0" alt="{cc_panel_next_page}" title="{cc_panel_next_page}" hspace="2" /></span></td>
 										</tr>
 									</table>
@@ -240,5 +241,5 @@
 									<table bgcolor="#D3DCE3" cellspacing="0" cellpadding="0" border="0">
 										<tr>
-											<td align="left" valign="middle"><span id="cc_panel_arrow_last"><img src="templates/default/images/last-grey.png" border="0" alt="{cc_panel_last_page}" hspace="2" /></span></td>
+											<td align="left" valign="middle"><span id="cc_panel_arrow_last"><img src="templates/default/images/last-grey.png" border="0" alt="{cc_panel_last_page}" title="{cc_panel_last_page}" hspace="2" /></span></td>
 										</tr>
 									</table>			
