Index: trunk/contactcenter/inc/class.bo_ldap_manager.inc.php
===================================================================
--- trunk/contactcenter/inc/class.bo_ldap_manager.inc.php	(revision 1419)
+++ trunk/contactcenter/inc/class.bo_ldap_manager.inc.php	(revision 1600)
@@ -45,5 +45,5 @@
 						'acc'    => $data['cc_ldap_browse_dn0'],
 						'pw'     => $data['cc_ldap_pw0'],
-						'obj'    => 'phpgwAccount',
+						'obj'    => 'inetOrgPerson',
 						'branch' => strtolower('ou'),
 						'visible' => $data['cc_ldap_query_automatic']
@@ -83,5 +83,5 @@
 		/*
 		* @function get_external_ldap_sources
-		* @author Mário César Kolling <mario.kolling@serpro.gov.br>
+		* @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br>
 		* @abstract returns an array with the external sources
 		* @return (array) the external sources
@@ -104,5 +104,5 @@
 			
 			$op_iop = array(
-				'contact.uidnumber'				   => array('uidNumber'),
+				'contact.uidnumber'		   => array('uidNumber'),
 				'contact.id_contact'               => array('dn'),
 				'contact.photo'                    => array('jpegPhoto'),
@@ -123,6 +123,10 @@
 				'contact.object_class'             => array('objectClass'),
 				'contact.business_info.title'      => array('title'),
-				'contact.business_info.department' => array('ou'),
-				'contact.company.company_name'     => array('o'),
+				'contact.business_info.department' => array('ou'), // Setor do empregado...
+				'contact.business_info.empNumber'  => array('employeeNumber'), // Matricula do empregado
+
+				'contact.business_info.celPhone'   => array('mobile'), // Celular empresarial do empregado
+
+                          	'contact.company.company_name'     => array('o'),
 				'contact.company.company_notes'    => array('businessCategory'),
 				
@@ -162,7 +166,10 @@
 					'email'  => array('mail'),
 					'phone'  => array('telephoneNumber'),
-					'mobile' => array('mobile'),
-					'pager'  => array('pager'),
-					'fax'    => array('facsimileTelephoneNumber'),
+				//	'mobile' => array('mobile'),
+				//	'pager'  => array('pager'), // idem ao comentario abaixo, do atributo fax;
+				//	'fax'    => array('facsimileTelephoneNumber'), //linha comentada para nao trazer
+				// o atributo fax do Ldap; correcao temporaria para nao exibir o fax no ContactCenter
+				//(estava sobrepondo o telefone do usuario)
+
 					'telex'  => array('telexNumber')
 				),
@@ -174,5 +181,5 @@
 		/*
 		 * @function get_external_ldap_fields_association
-		 * @author Mário César Kolling <mario.kolling@serpro.gov.br>
+		 * @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br>
 		 * @abstract get the fields association for an external ldap_source
 		 * @return an array with attribute mappings
@@ -187,5 +194,5 @@
 		/*
 		 * @function test_connection
-		 * @author Mário César Kolling <mario.kolling@serpro.gov.br>
+		 * @author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br>
 		 * @abstract Test if we can bind to a ldap server in a reasonable time
 		 * @param (string) $host ldap server's hostname
@@ -250,5 +257,5 @@
 			}
 			
-			$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], true);
+			$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->srcs[$id_source]['host'], $this->srcs[$id_source]['acc'],$this->srcs[$id_source]['pw'], false);
 			if (!$ldap)
 			{
@@ -272,5 +279,5 @@
 			@function get_external_ldap_tree
 			@abstract Returns the LDAP external tree corresponding to the specified level
-			@author Mário César Kolling <mario.kolling@serpro.gov.br>
+			@author Mï¿œrio Cï¿œsar Kolling <mario.kolling@serpro.gov.br>
 			@param (integer) $id_source The ID of the external LDAP source
 			@param (string)  $context The context to be used as root branch
@@ -285,10 +292,10 @@
 			include(PHPGW_INCLUDE_ROOT . '/contactcenter/setup/external_catalogs.inc.php' );
 			//include('external_catalogs.inc.php' );
-			
+
 			if (!$external_srcs[$id_source])
 			{
 				return null;
 			}
-			
+
 			// calls test_connection first. If succeeded continue, return error message otherwise.
 			if (!($response = $this->test_connection($external_srcs[$id_source]['host'], $external_srcs[$id_source]['acc'], $external_srcs[$id_source]['pw'], 10)))
@@ -411,6 +418,4 @@
 			else 
 				return false;
-			
-			
 		}
 
@@ -441,6 +446,6 @@
 		{
 			/*
-			 * Esta operação resolve o problema causado pela conversão de caracteres acentuados realizada
-			 * pela função ldap_explode_dn().
+			 * Esta operaï¿œï¿œo resolve o problema causado pela conversï¿œo de caracteres acentuados realizada
+			 * pela funï¿œï¿œo ldap_explode_dn().
 			 */
 
@@ -450,10 +455,16 @@
 		function get_ldap_tree_level($id_source, $resource, $context, $objectClass, $branch_dn, $external = 0)
 		{
-						
+			if(strstr($context, "ldap://")){
+				$refer_context = str_replace("??base","",preg_replace('!^(ldap://[^/]+)/(.*$)!', '\\2', $context));
+				$host	= preg_replace('!^(ldap://[^/]+)/.*$!', '\\1', $context);
+				$resource = ldap_connect($host);
+				ldap_bind($resource);
+			}
+
 			/*
 			 * TODO: Search timeouts
 			 */
-			
-			$dn_parts = ldap_explode_dn($context,1);
+
+			$dn_parts = ldap_explode_dn(($refer_context ? $refer_context : $context),1);
 			//$filter = '(!(objectClass='.$objectClass.'))';
 			// Don't show OU's whith phpgwAccountVisible equal to '-1'
@@ -468,22 +479,23 @@
 				// and whose attribute phpgwAccountVisible value is different from -1
 				$filter = '(&(!(objectClass='.$objectClass.')) (!(phpgwAccountVisible=-1)))';
-				$context = preg_replace("/dc=(.*)/i",$this->srcs[$id_source]['dn'],$context);	
-			}
-			
-			$result_res = @ldap_list($resource,  $context, $filter, array(), 0, 0);
-			if (!$result_res)
+			}
+			$result_res = @ldap_list($resource,  ($refer_context ? $refer_context : $context), $filter, array(), 0, 0);
+			@ldap_sort($resource, $result_res, 'ou');
+
+			// Timeouts commented out
+			/*
+			if ($result_res === false)
+			{
 				return null;
-			
-			@ldap_sort($resource, $result_res, 'ou');
+			}
+			*/
+
 			$count = ldap_count_entries($resource,$result_res);
-			
+
 			if ( $count == 0 )
 			{
 				$filter = '(objectClass='.$objectClass.')';
 				// Get only one attribute of the source's objectClass
-				$result_res2 = @ldap_list($resource, $context, $filter, Array('cn'), 0, 1);
-				if (!$result_res2)
-					return null;
-
+				$result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1);
 				$entries_count = ldap_count_entries($resource, $result_res2);
 
@@ -509,5 +521,5 @@
 				}
 			}
-			
+
 			$sub_branch_found = false;
 			$i = 0;
@@ -521,5 +533,5 @@
 				list($group) = explode('=',$dn_parts_full[0]);
 
-				//Faz a comparação do branch como case insensitive
+				//Faz a comparaï¿œï¿œo do branch como case insensitive
 				if (strtolower($group) == strtolower($branch_dn) or $branch_dn === 'all')
 				{
@@ -527,5 +539,5 @@
 						'name'  => $this->translate_accentuation($dn_parts_1[0]),
 						'type'  => 'unknown',
-						'value' =>  $dn,
+						'value' =>  ($refer_context ? $host."/" : "").$dn,
 						'sub_branch' => false
 					);
@@ -534,7 +546,14 @@
 				$i++;
 			}
-						
+
+			if(! $refer_context) {
+				$array_referral = $this -> get_ldap_sub_branches_referrals($resource, $context,'(objectClass=organizationalUnit)');
+				for($z = 0; $z < count($array_referral); $z++) {
+					$tree['sub_branch'][$i++] = $array_referral[$z];
+				}
+			}
+
 			$filter = 'objectClass='.$objectClass;
-			$result_res2 = @ldap_list($resource, $context, $filter, Array('cn'), 0, 1);
+			$result_res2 = @ldap_list($resource, ($refer_context ? $refer_context : $context), $filter, Array('cn'), 0, 1);
 			$entries_count = ldap_count_entries($resource, $result_res2);
 
Index: trunk/contactcenter/inc/class.ui_preferences.inc.php
===================================================================
--- trunk/contactcenter/inc/class.ui_preferences.inc.php	(revision 285)
+++ trunk/contactcenter/inc/class.ui_preferences.inc.php	(revision 1600)
@@ -79,4 +79,31 @@
 			}
 			
+			if ($actual['empNum'])
+			{
+				$GLOBALS['phpgw']->template->set_var('empNum', 'checked');
+			}
+			else
+			{
+				$GLOBALS['phpgw']->template->set_var('empNum', '');
+			}
+
+			if ($actual['cell'])
+			{
+				$GLOBALS['phpgw']->template->set_var('cell', 'checked');
+			}
+			else
+			{
+				$GLOBALS['phpgw']->template->set_var('cell', '');
+			}
+
+			if ($actual['department'])
+			{
+				$GLOBALS['phpgw']->template->set_var('department', 'checked');
+			}
+			else
+			{
+				$GLOBALS['phpgw']->template->set_var('department', '');
+			}
+
 			$GLOBALS['phpgw']->template->set_var('personCardEmail', $options_email);
 			$GLOBALS['phpgw']->template->set_var('personCardPhone', $options_phone);
@@ -130,4 +157,31 @@
 				}
 				
+				if($_POST['empNum'])
+				{
+					$GLOBALS['phpgw']->preferences->add('contactcenter', 'empNum', '1');
+				}
+				else
+				{
+					$GLOBALS['phpgw']->preferences->add('contactcenter', 'empNum', '0');
+				}
+				
+				if($_POST['cell'])
+				{
+					$GLOBALS['phpgw']->preferences->add('contactcenter', 'cell', '1');
+				}
+				else
+				{
+					$GLOBALS['phpgw']->preferences->add('contactcenter', 'cell', '0');
+				}
+				
+				if($_POST['department'])
+				{
+					$GLOBALS['phpgw']->preferences->add('contactcenter', 'department', '1');
+				}
+				else
+				{
+					$GLOBALS['phpgw']->preferences->add('contactcenter', 'department', '0');
+				}
+				
 				$GLOBALS['phpgw']->preferences->save_repository();
 			}
