Index: trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php
===================================================================
--- trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php	(revision 383)
+++ trunk/contactcenter/inc/class.bo_global_ldap_catalog.inc.php	(revision 388)
@@ -16,11 +16,11 @@
 	*/
 	include_once('class.abo_catalog.inc.php');
-	
+
 	class bo_global_ldap_catalog extends abo_catalog
 	{
 		var $ldap;
-	
+
 		var $src_info;
-		
+
 		var $trans_table;
 		// used to determine if a catalog is external
@@ -41,5 +41,5 @@
 			'pgp_key'       => true,
 			'notes'         => true,
-			
+
 			/* Array fields */
 			'companies'     => true,
@@ -48,11 +48,11 @@
 			'connections'   => true
 		);
-		
+
 		/*
-		
+
 			@function global_ldap_catalog
 			@abstract Constructor
 			@author Raphael Derosso Pereira
-			@author Mário César Kolling (external catalogs)
+			@author Mï¿œrio Cï¿œsar Kolling (external catalogs)
 
 			@param integer $id_source The ID of the LDAP source
@@ -67,7 +67,7 @@
 				exit('PHP LDAP support Unavailable!');
 			}
-			
+
 			$this->ldap = CreateObject('contactcenter.bo_ldap_manager');
-			
+
 			if ($this->external)
 			{
@@ -92,11 +92,11 @@
 			}
 			else
-			{	
+			{
 				$this->trans_table = $this->ldap->get_ldap_fields_association($id_source);
 			}
 		}
-		
+
 		/*
-		
+
 			@function find
 			@abstract Searches the LDAP directory for the specified fields with
@@ -104,5 +104,5 @@
 				that matches the rules.
 			@author Raphael Derosso Pereira
-			
+
 			@param array $what The fields to be taken
 			@param array $rules The rules to be match. See class.abo_catalog.inc.php
@@ -113,12 +113,12 @@
 					'offset' => (integer) [NOT IMPLEMENTED]
 				)
-		
+
 		*/
 		function find($what, $rules=false, $other=false)
 		{
 			$restric_fields = $this->get_restrictions_without_branch($rules);
-			
+
 			$trans_f = $this->translate_fields($what, $restric_fields);
-			
+
 			foreach($trans_f as $orig => $field_a)
 			{
@@ -128,20 +128,20 @@
 				}
 			}
-			
+
 			$fields = array_unique($fields);
-			
+
 			$filter = $this->process_restrictions($rules, $trans_f);
 
 			if("ou" === strtolower(substr($this->src_info['context'], 0, 2)) ||
-				(trim($rules[4]['value']) != "inetOrgPerson"))	
-			{			
+				(trim($rules[4]['value']) != "inetOrgPerson"))
+			{
 				$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'], $this->src_info['acc'], $this->src_info['pw'], true);
-				$result_r = ldap_search($ldap , $this->src_info['context'], $filter, $fields, 0);
+				$result_r = ldap_search($ldap , $this->src_info['context'], $filter, $fields, 0, $this->src_info['max_results']);
 			}
 			else
-			{				
+			{
 				return false;
 			}
-			
+
 
 			if (!$result_r)
@@ -149,5 +149,5 @@
 				return false;
 			}
-			
+
 			if ($other['order'])
 			{
@@ -163,7 +163,7 @@
 				}
 			}
-			
+
 			$result_u = ldap_get_entries($ldap, $result_r);
-			
+
 			$i = 0;
 			foreach ($result_u as $index => $result_p)
@@ -173,5 +173,5 @@
 					continue;
 				}
-				
+
 				foreach ($trans_f as $orig => $trans)
 				{
@@ -191,23 +191,23 @@
 				$i++;
 			}
-			
+
 			return $return;
 		}
-		
+
 		/*
-		
+
 			@function translate_fields
 			@abstract Return the LDAP objectClass fields that corresponds to the
 				specified parameter fields
 			@author Raphael Derosso Pereira
-			
+
 			@param array $fields The fields in the standard ContactCenter format
 			@param array $rules The rules
-		
+
 		*/
 		function translate_fields ( $fields, &$restric_fields )
 		{
 			$return = array();
-			
+
 			$i = 0;
 			foreach ($fields as $field)
@@ -217,9 +217,9 @@
 					continue;
 				}
-				
+
 				if (!is_array($this->trans_table[$field]))
 				{
 					$reference = $this->trans_table[$field];
-					
+
 					reset($restric_fields);
 					while(list(,$field_r) = each($restric_fields))
@@ -243,22 +243,22 @@
 				}
 			}
-			
+
 			if (count($return))
 			{
 				return $return;
 			}
-			
+
 			return false;
 		}
-		
+
 		/*
-		
+
 			@function process_restrictions
 			@abstract Returns a LDAP filter string that corresponds to the
 				specified restriction rules
 			@author Raphael Derosso Pereira
-			
+
 			@param string $rules The restriction rules
-		
+
 		*/
 		function process_restrictions( $rules, &$trans_table, $join_type='&' )
@@ -268,5 +268,5 @@
 				return null;
 			}
-			
+
 			foreach($rules as $rule_i => $rule)
 			{
@@ -280,13 +280,13 @@
 								$join = '|';
 								break;
-								
+
 							case 'AND':
 								$join = '&';
 								break;
-								
+
 							case 'NOT':
 								$join = '!';
 								break;
-								
+
 							default:
 								$join = $join_type;
@@ -294,5 +294,5 @@
 						$return_t[] = $this->process_restrictions($rule['sub_branch'], $trans_table, $join);
 						break;
-						
+
 					case '=':
 						if (array_key_exists($rule['field'], $trans_table))
@@ -305,6 +305,6 @@
 						}
 						break;
-					
-					case '!=':	
+
+					case '!=':
 						if (array_key_exists($rule['field'], $trans_table))
 						{
@@ -316,5 +316,5 @@
 						}
 						break;
-					
+
 					case '<=':
 					case '<':
@@ -328,5 +328,5 @@
 						}
 						break;
-					
+
 					case '>':
 					case '>=':
@@ -340,5 +340,5 @@
 						}
 						break;
-						
+
 					case 'NULL':
 						if (array_key_exists($rule['field'], $trans_table))
@@ -351,5 +351,5 @@
 						}
 						break;
-					
+
 					case 'IN':
 						if (array_key_exists($rule['field'], $trans_table))
@@ -371,5 +371,5 @@
 							$value_1 = strtoupper(str_replace('%', '*', $rule['value']));
 							$value_2 = strtolower($value_1);
-							
+
 							foreach($trans_table[$rule['field']] as $field)
 							{
@@ -380,10 +380,10 @@
 						}
 						break;
-						
+
 */					case 'LIKE':
 						if (array_key_exists($rule['field'], $trans_table))
 						{
 							$value = str_replace('%', '*', $rule['value']);
-							
+
 							foreach($trans_table[$rule['field']] as $field)
 							{
@@ -393,5 +393,5 @@
 						}
 						break;
-						
+
 					case 'NOT NULL':
 						if (array_key_exists($rule['field'], $trans_table))
@@ -404,5 +404,5 @@
 						}
 						break;
-					
+
 					case 'NOT IN':
 						if (array_key_exists($rule['field'], $trans_table))
@@ -424,5 +424,5 @@
 							$value_1 = strtoupper(str_replace('%', '*', $rule['value']));
 							$value_2 = strtolower($value_1);
-							
+
 							foreach($trans_table[$rule['field']] as $field)
 							{
@@ -438,5 +438,5 @@
 						{
 							$value = str_replace('%', '*', $rule['value']);
-							
+
 							foreach($trans_table[$rule['field']] as $field)
 							{
@@ -448,5 +448,5 @@
 				}
 			}
-			
+
 			if (count($return_t))
 			{
@@ -466,12 +466,12 @@
 
 		/*!
-		
+
 			@function get_restrictions_without_branch
 			@abstract Returns an array containing the restrictions ignoring the
 				branches
 			@author Raphael Derosso Pereira
-			
+
 			@param array $restrictions The restrictions
-		
+
 		*/
 		function get_restrictions_without_branch(&$restrictions)
@@ -481,7 +481,7 @@
 				return null;
 			}
-			
+
 			$fields = array();
-			
+
 			foreach ($restrictions as $restrict_data)
 			{
@@ -491,7 +491,7 @@
 						$fields = array_merge($fields, $this->get_restrictions_without_branch($restrict_data['sub_branch']));
 						break;
-						
+
 					case '=':
-					case '!=':	
+					case '!=':
 					case '<=':
 					case '<':
@@ -508,35 +508,35 @@
 						array_push($fields, $restrict_data);
 						break;
-						
+
 					default:
-						exit('Error in '.__FILE__.' on '.__LINE__.'<br>The restriction type passed was: '.$restrict_data['type']);					
-				}
-			}
-			
+						exit('Error in '.__FILE__.' on '.__LINE__.'<br>The restriction type passed was: '.$restrict_data['type']);
+				}
+			}
+
 			return $fields;
 		}
-		
-		
+
+
 		/*********************************************************************\
 		 *                        Methods to Get Data                        *
 		\*********************************************************************/
-		
-	
+
+
 		/*!
-		
+
 		 @function get_single_entry
 		 @abstract Returns all information requested about one contact
 		 @author Raphael Derosso Pereira
-		     
+
 		 @param integer $id_contact The contact ID
 		 @param array $fields The array returned by get_fields with true
 		 	on the fields to be taken.
-		 	
+
 		*/
 		function get_single_entry ( $id_contact, $fields )
 		{
-			if (!is_array($fields)) 
-			{
-				if (is_object($GLOBALS['phpgw']->log)) 
+			if (!is_array($fields))
+			{
+				if (is_object($GLOBALS['phpgw']->log))
 				{
 					$GLOBALS['phpgw']->log->message(array(
@@ -544,15 +544,15 @@
 						'line' => __LINE__,
 						'file' => __FILE__));
-					
+
 					$GLOBALS['phpgw']->log->commit();
 				}
-				else 
+				else
 				{
 					exit('Argument Error on: <br>File:'.__FILE__.'<br>Line:'.__LINE__.'<br>');
 				}
 			}
-			
+
 			$ldap = $GLOBALS['phpgw']->common->ldapConnect($this->src_info['host'],$this->src_info['acc'],$this->src_info['pw'],true);
-			
+
 			if (!$ldap)
 			{
@@ -566,15 +566,15 @@
 				return false;
 			}
-			
+
 			$first_entry = ldap_first_entry($ldap, $resource);
 			$contact = ldap_get_attributes($ldap,$first_entry);
-			if($contact['jpegPhoto']){	
-				$contact['jpegPhoto'] = ldap_get_values_len ($ldap, $first_entry, "jpegPhoto"); 
+			if($contact['jpegPhoto']){
+				$contact['jpegPhoto'] = ldap_get_values_len ($ldap, $first_entry, "jpegPhoto");
 			}
 
 //			print_r($contact);
-			
+
 		//	$contact_data = $this->fields;
-			
+
 			foreach($fields as $field => $trueness)
 			{
@@ -584,5 +584,5 @@
 					continue;
 				}
-				
+
 				switch ($field)
 				{
@@ -593,5 +593,5 @@
 						$l_fields['department']    = $this->trans_table['contact.business_info.department'];
 						$l_fields['company_notes'] = $this->trans_table['contact.company.company_notes'];
-						
+
 						$contact_data['companies'] = array();
 						foreach($l_fields as $l_field => $l_value)
@@ -601,8 +601,8 @@
 								continue;
 							}
-							
+
 							$contact_data['companies']['company1'][$l_field] = utf8_decode($contact[$l_value[0]][0]);
 						}
-						
+
 						if (!(count($contact_data['companies'])))
 						{
@@ -610,5 +610,5 @@
 						}
 						break;
-					
+
 					case 'relations':
 						unset($l_fields);
@@ -617,5 +617,5 @@
 							unset($contact_data['relations']);
 						}
-						
+
 						$contact_data['relations'] = array();
 						if (!is_array($this->trans_table['contact.contact_related.names_ordered']))
@@ -625,5 +625,5 @@
 								continue;
 							}
-							
+
 							$i = 1;
 							foreach($trans as $l_type => $l_type_fields)
@@ -633,5 +633,5 @@
 									continue;
 								}
-								
+
 								$contact_data['relations']['relation'.$i]['type'] = $l_type;
 								$contact_data['relations']['relation'.$i]['names_ordered'] = utf8_decode($contact[$l_type_fields[0]][0]);
@@ -639,5 +639,5 @@
 							}
 						}
-						
+
 						if (!(count($contact_data['relations'])))
 						{
@@ -645,5 +645,5 @@
 						}
 						break;
-					
+
 					case 'addresses':
 						unset($l_fields);
@@ -674,5 +674,5 @@
 									continue;
 								}
-								
+
 								$i = 1;
 								foreach($trans as $l_type => $l_type_fields)
@@ -682,5 +682,5 @@
 										continue;
 									}
-									
+
 									$contact_data['addresses']['address'.$i]['type'] = $l_type;
 									$contact_data['addresses']['address'.$i][$l_field] = utf8_decode($contact[$l_type_fields[0]][0]);
@@ -693,5 +693,5 @@
 							}
 						}
-						
+
 						if (!(count($contact_data['addresses'])))
 						{
@@ -699,5 +699,5 @@
 						}
 						break;
-					
+
 					case 'connections':
 	                    $preferences = ExecMethod('contactcenter.ui_preferences.get_preferences');
@@ -720,5 +720,5 @@
 									continue;
 								}
-								
+
 								$i = 1;
 								foreach($trans as $l_type => $l_type_fields)
@@ -728,5 +728,5 @@
 										continue;
 									}
-									
+
 									switch ($l_type)
 									{
@@ -748,5 +748,5 @@
 							}
 						}
-						
+
 						if (!(count($contact_data['connections'])))
 						{
@@ -754,5 +754,5 @@
 						}
 						break;
-					
+
 					case 'prefix':
 						unset($l_fields);
@@ -763,8 +763,8 @@
 							continue;
 						}
-						
+
 						$contact_data['prefix'] = utf8_decode($contact[$l_fields[0]][0]);
 						break;
-						
+
 					case 'suffix':
 						unset($l_fields);
@@ -775,8 +775,8 @@
 							continue;
 						}
-						
+
 						$contact_data['suffix'] = utf8_decode($contact[$l_fields[0]][0]);
 						break;
-						
+
 					case 'status':
 						unset($l_fields);
@@ -787,8 +787,8 @@
 							continue;
 						}
-						
+
 						$contact_data['status'] = utf8_decode($contact[$l_fields[0]][0]);
 						break;
-						
+
 						case 'photo':
 						unset($l_fields);
@@ -799,7 +799,7 @@
 							continue;
 						}
-						
+
 						$contact_data['photo'] = $contact[$l_fields[0]][0];
-						break;											
+						break;
 
 					default:
@@ -811,5 +811,5 @@
 							continue;
 						}
-						
+
 						if(count($contact[$l_fields[0]]) > 1)
 						{
@@ -828,10 +828,10 @@
 				}
 			}
-			
+
 			if (!is_array($contact_data))
 			{
 				return false;
 			}
-			
+
 			return $contact_data;
 		}
@@ -842,5 +842,5 @@
 		 @abstract Returns all information requested about a bunch of contacts, usually a page
 		 @author Raphael Derosso Pereira
-		 @author Mário César Kolling
+		 @author Mï¿œrio Cï¿œsar Kolling
 
 		 @param string $filter Filter (returned by generate_filter).
@@ -1158,10 +1158,10 @@
 			return $contacts;
 		}
-		
+
 		function get_multiple_entries ( $id_contacts, $fields, $other_data = false )
 		{
 			if (!is_array($id_contacts) or !is_array($fields) or ($other_data != false and !is_array($other_data)))
 			{
-				if (is_object($GLOBALS['phpgw']->log)) 
+				if (is_object($GLOBALS['phpgw']->log))
 				{
 					$GLOBALS['phpgw']->log->message(array(
@@ -1169,5 +1169,5 @@
 						'line' => __LINE__,
 						'file' => __FILE__));
-					
+
 					$GLOBALS['phpgw']->log->commit();
 				}
@@ -1176,16 +1176,16 @@
 				}
 			}
-			 
+
 			foreach ($id_contacts as $id)
 			{
 				$contacts[$id] = $this->get_single_entry($id,$fields);
 			}
-			
+
 			return $contacts;
 
 			// SERPRO
-						
+
 			/*$contacts = array();
-	
+
 			if ($other_data)
 			{
@@ -1198,5 +1198,5 @@
 
 			return $this->get_all_entries($filter, $fields);*/
-			
+
 		}
 
@@ -1208,8 +1208,8 @@
 				$contacts[$id] = $this->get_single_entry($id,$fields);
 			}
-			
+
 			return $contacts;
 		}
-		
+
 		// SERPRO
 		/*
@@ -1222,13 +1222,13 @@
 				{
 
-					// 
-					//  Não utiliza mais a função ldap_explode, usa a expressão regular a seguir para pegar o primeiro
+					//
+					//  Nï¿œo utiliza mais a funï¿œï¿œo ldap_explode, usa a expressï¿œo regular a seguir para pegar o primeiro
 					//  componente da dn
-					// 
+					//
 					preg_match('/^(\w*=[^,]*),.*$/', $id_contacts[$i], $cn);
 
     				//
     				// Adicionados os str_replace para adicionar caracteres de escape em frente aos caracteres '(' e ')',
-    				// posteriormente poderá ser necessário substituir por uma expressão regular mais genérica.
+    				// posteriormente poderï¿œ ser necessï¿œrio substituir por uma expressï¿œo regular mais genï¿œrica.
     				//
 
@@ -1236,7 +1236,7 @@
 					{
 						//
-						// Esta operação resolve o problema causado pela conversão de caracteres acentuados realizada
-						// pela função ldap_explode_dn(). Talvez seja necessário utilizar esta tradução em outros lugares,
-						// neste caso é mais apropriado colocar dentro de uma função.
+						// Esta operaï¿œï¿œo resolve o problema causado pela conversï¿œo de caracteres acentuados realizada
+						// pela funï¿œï¿œo ldap_explode_dn(). Talvez seja necessï¿œrio utilizar esta traduï¿œï¿œo em outros lugares,
+						// neste caso ï¿œ mais apropriado colocar dentro de uma funï¿œï¿œo.
 						//
 						//foreach($cn as $key=>$value){
@@ -1282,60 +1282,60 @@
 			return null;
 		}
-		
+
 		function get_relations ($id_contact,$extra=false)
 		{
 		}
-		
+
 		function get_addresses ( $id_contact,$extra=false )
 		{
 		}
-		
+
 		function get_connections ( $id_contact,$extra=false )
 		{
 		}
-		
+
 		function get_companies ( $id_contact, $extra=false )
 		{
 		}
-		
+
 		function get_all_prefixes (  )
 		{
 		}
-		
+
 		function get_all_suffixes (  )
 		{
 		}
-		
+
 		function get_all_status (  )
 		{
 		}
-		
+
 		function get_all_relations_types (  )
 		{
 		}
-		
+
 		function get_all_addresses_types (  )
 		{
 		}
-		
+
 		function get_all_connections_types (  )
 		{
 		}
-		
+
 		function get_vcard ( $id_contact )
 		{
 		}
-		
-		
-		
-		
+
+
+
+
 		function get_global_tree ( $root )
 		{
 		}
-	
+
 		function get_actual_brach (  )
 		{
 		}
-	
+
 		function set_actual_branch ( $branch )
 		{
