Index: branches/2.2/expressoMail1_2/inc/class.ldap_functions.inc.php
===================================================================
--- branches/2.2/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 3163)
+++ branches/2.2/expressoMail1_2/inc/class.ldap_functions.inc.php	(revision 3388)
@@ -88,4 +88,9 @@
 		$ID			= $params['ID'];
 		
+		if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info'])
+		    $extendedinfo=true;
+		else
+		    $extendedinfo=false;
+
 		$search_for	= explode(" ",$search_for);
 		$aux="";
@@ -113,5 +118,4 @@
 		$contacts_result['field'] = $field;
 		$contacts_result['ID'] = $ID;
-
 		// follow the referral
 		$this->ldapConnect(true);
@@ -121,11 +125,17 @@
 			if (($field != 'null') && ($ID != 'null'))
 			{
-				$filter="(& (&(|(phpgwAccountType=u)(phpgwAccountType=g)(phpgwAccountType=l)(phpgwAccountType=i)(phpgwAccountType=s))(mail=*)) (|(cn=*$search_for*)(mail=*$search_for*)) (!(phpgwaccountvisible=-1)) )";
+				$filter="(& (&(|(phpgwAccountType=u)(phpgwAccountType=g)(phpgwAccountType=l))(mail=*)) (|(cn=*$search_for*)(mail=*$search_for*)) (!(phpgwaccountvisible=-1)) )";
+				if($extendedinfo)
 				$justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid", "employeeNumber", "ou");
+				else
+				    $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid");
 			}
 			else
 			{
 				$filter="(& (phpgwAccountType=u)(cn=*$search_for*) (!(phpgwaccountvisible=-1)) )";
+				if($extendedinfo)
 				$justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid", "employeeNumber", "ou");
+				else
+				    $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible","jpegPhoto", "uid");
 			}
 			$sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result + 1);
@@ -178,5 +188,8 @@
 						$this->ldapConnect(true,$i);
 						$filter="(|(cn=*$search_for*)(mail=*$search_for*))";
+						if($extendedinfo)
 						$justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid","employeeNumber", "ou");
+						else
+						    $justthese = array("cn", "mail", "telephoneNumber", "mobile", "phpgwAccountVisible", "uid");
 						$sr=@ldap_search($this->ds, $this->ldap_context, $filter, $justthese, 0, $this->max_result+1);
 						if(!$sr)
@@ -305,5 +318,10 @@
 		$contacts_result = array();
 		$contacts_result["cn"] = $cn;
-		list ($contacts_result["mail"], $contacts_result["phone"], $contacts_result["mobile"], $contacts_result["uid"], $contacts_result["jpegphoto"]) = split ('%', $info);
+		if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info'])
+		    $extendedinfo=true;
+		else
+		    $extendedinfo=false;
+
+		list ($contacts_result["mail"], $contacts_result["phone"], $contacts_result["mobile"], $contacts_result["uid"], $contacts_result["jpegphoto"], $contacts_result["employeenumber"], $contacts_result["ou"]) = split ('%', $info);
 
 		if ($contacts_result['jpegphoto'])
@@ -320,4 +338,19 @@
 			}
 		}
+		//verifica de existe o celular do funcionario ($contacts_result["mobile"]), se nao, $phoneUser fica vazia;
+
+		    $mobileUser = $contacts_result["mobile"];
+		    if($mobileUser && !$voipMobile) {
+			    $phoneUser .= " / $mobileUser";
+		    }
+		    $empNumber = $contacts_result["employeenumber"];
+		    if($empNumber) {
+			    $empNumber = "$empNumber - ";
+		    }
+		    $ou = $contacts_result["ou"];
+		    if($ou) {
+			    $ou = "<br/>$ou" ;
+		    }
+
 		// Begin: nickname, firstname and lastname for QuickAdd.
 		$fn = $contacts_result["cn"];
@@ -337,6 +370,6 @@
 				'</td>' .
 				'<td class="cc">' .
-					'<span name="cn">' . $contacts_result['cn'] . '</span>' . '<br>' .
-					'<a title="'.$this->functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' .
+					'<span name="cn">' . $empNumber . $contacts_result['cn'] . '</span>' . '<br>' .
+					'<a title="'.$functions->getLang("Write message").'" onClick="javascript:QuickSearchUser.create_new_message(\''.$contacts_result["cn"].'\', \''.$contacts_result["mail"].'\')">' .
 						'<font color=blue>' .
 						'<span name="mail">' . $contacts_result['mail'] . '</span></a></font>'.
@@ -344,4 +377,5 @@
 					'<br>' .
 					$phoneUser .
+					$ou .
 				'</td>' .
 				'</tr>';
@@ -402,5 +436,4 @@
 		return $organizations;
 	}
-	
 	//Busca usuarios de um contexto e ja retorna as options do select - usado por template serpro;
 	function search_users($params)
@@ -468,4 +501,9 @@
 		$catalog = $params['catalog'];
 		$error = False;
+		if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info'])
+		    $extendedinfo=true;
+		else
+		    $extendedinfo=false;
+
 
 		$this->ldapConnect(true,$catalog);
@@ -476,10 +514,17 @@
 			if ($catalog == 0){
 				//os atributos "employeeNumber" e "ou" foram adicionado ao vetor de busca;
+				if($extendedinfo)
 				$justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible", "employeeNumber", "ou");
+				else
+				    $justthese = array("cn", "mail", "phpgwaccounttype", "phpgwAccountVisible");
+
 				$filter="(&(|(phpgwAccountType=u)(phpgwAccountType=l))(cn=".$cn."))";
 				//$user_context = "ou=".$params['organization'].",".$this->ldap_context;
 			}else {
 				//os atributos "employeeNumber" e "ou" foram adicionado ao vetor de busca;
+				if($extendedinfo)
 				$justthese = array("cn", "mail", "employeeNumber", "ou");
+				else
+				    $justthese = array("cn", "mail");
 				$filter="(&(objectClass=".$this->object_class.")(cn=".$cn."))";
 				//$user_context = $this->branch."=".$params['organization'].",".$external_srcs[$catalog]['dn'];
@@ -765,5 +810,13 @@
 		$filter="(&(phpgwAccountType=u)(mail=" . $params['email'] . "))";
 		$ldap_context = $_SESSION['phpgw_info']['expressomail']['ldap_server']['dn'];
-		$justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile");
+		if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['extended_info'])
+		    $extendedinfo=true;
+		else
+		    $extendedinfo=false;
+
+		if($extendedinfo)
+		    $justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile","ou","employeeNumber");
+		else
+		    $justthese = array("cn","uid","telephoneNumber","jpegPhoto","mobile");
 
 		// Follow the referral
@@ -784,5 +837,7 @@
 						  "type" => "global",
 						  "mobile" =>  @ldap_get_values($ds, $entry, "mobile"),
-						  "telefone" =>  @ldap_get_values($ds, $entry, "telephonenumber")
+						  "telefone" =>  @ldap_get_values($ds, $entry, "telephonenumber"),
+						  "ou" =>  @ldap_get_values($ds, $entry, "ou"),
+						  "employeeNumber" =>  @ldap_get_values($ds, $entry, "employeeNumber")
 					);
 
Index: branches/2.2/expressoMail1_2/inc/hook_settings.inc.php
===================================================================
--- branches/2.2/expressoMail1_2/inc/hook_settings.inc.php	(revision 3365)
+++ branches/2.2/expressoMail1_2/inc/hook_settings.inc.php	(revision 3388)
@@ -92,4 +92,5 @@
 create_check_box('Preview message text within a tool-tip box','preview_msg_tip','this exhibits a sample of message within a tool-tip box');
 
+create_check_box('View extended information about users','extended_info','This exhibits employeenumber and ou from LDAP in searchs');
 
 create_check_box('Save deleted messages in trash folder?','save_deleted_msg','When delete message, send it automatically to trash folder');
