Index: trunk/contactcenter/inc/class.ui_data.inc.php
===================================================================
--- trunk/contactcenter/inc/class.ui_data.inc.php	(revision 1517)
+++ trunk/contactcenter/inc/class.ui_data.inc.php	(revision 1599)
@@ -14,5 +14,5 @@
   \***************************************************************************/
 
-	
+
 	class ui_data
 	{
@@ -20,8 +20,8 @@
 			'data_manager' => true,
 		);
-		
+
 		var $bo;
 		var $typeContact;
-		
+
 		var $page_info = array(
 			'n_cards'          => 20,
@@ -34,12 +34,12 @@
 			'actual_catalog'   => false
 		);
-		
+
 		/*!
-		
+
 			@function ui_data
 			@abstract The constructor. Sets the initial parameters and loads
 				the data saved in the session
 			@author Raphael Derosso Pereira
-			
+
 		*/
 		function ui_data()
@@ -47,7 +47,7 @@
 			$temp = $GLOBALS['phpgw']->session->appsession('ui_data.page_info','contactcenter');
 			$temp2 = $GLOBALS['phpgw']->session->appsession('ui_data.all_entries','contactcenter');
-			
+
 			$this->bo = CreateObject('contactcenter.bo_contactcenter');
-			
+
 			if ($temp)
 			{
@@ -59,5 +59,5 @@
 				$this->all_entries = $temp2;
 			}
-			
+
 			if (!$this->page_info['actual_catalog'])
 			{
@@ -65,13 +65,16 @@
 				$this->page_info['actual_catalog'] = $catalogs[0];
 			}
-			
-			$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']);
+
+
 			if($this->page_info['actual_catalog']['class'] == 'bo_group_manager')
 				$this -> typeContact = 'groups';
+/**rev 104**/
 			else if($this->page_info['actual_catalog']['class'] == 'bo_shared_group_manager')
 				$this -> typeContact = 'shared_groups';
 			else if($this->page_info['actual_catalog']['class'] == 'bo_shared_people_manager')
 				$this -> typeContact = 'shared_contacts';
+/******/
 			else
 				$this -> typeContact = 'contacts';
@@ -79,13 +82,13 @@
 
 		/*!
-		
+
 			@function index
 			@abstract Builds the Main Page
 			@author Raphael Derosso Pereira
 			@author Jonas Goes
-			
-		*/		
+
+		*/
 		function index()
-		{	
+		{
 			if(!@is_object($GLOBALS['phpgw']->js))
 			{
@@ -96,11 +99,11 @@
 			$GLOBALS['phpgw']->js->validate_file('venus','jsStructUtil');
 			$GLOBALS['phpgw']->js->validate_file('venus','cssUtil');
-			
+
 //			$GLOBALS['phpgw']->js->set_onload('setTimeout(\'updateCards()\',1000)');
 			$GLOBALS['phpgw']->common->phpgw_header();
-			
+
 			$GLOBALS['phpgw']->template->set_file(array('index' => 'index.tpl'));
 			$GLOBALS['phpgw']->template->set_var('cc_root_dir', $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/');
-			
+
 			/* Quick Add */
 			$GLOBALS['phpgw']->template->set_var('cc_qa_alias',lang('Alias').':');
@@ -113,5 +116,5 @@
 			$GLOBALS['phpgw']->template->set_var('cc_qa_close',lang('Close'));
 			/* End Quick Add */
-			
+
 			$cc_css_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/styles/cc.css';
 			$cc_card_image_file = $GLOBALS['phpgw_info']['server']['webserver_url'].'/contactcenter/templates/default/images/card.png';
@@ -119,11 +122,14 @@
 			$GLOBALS['phpgw']->template->set_var('cc_dtree_css', $cc_dtree_file);
 			$GLOBALS['phpgw']->template->set_var('cc_card_image',$cc_card_image_file);
-			
+
 			$GLOBALS['phpgw']->template->set_var('cc_personal',lang('Personal'));
-			
+
+/***rev 104***/
+			//$GLOBALS['phpgw']->template->set_var('cc_full_add',lang('Full Add'));
 			$GLOBALS['phpgw']->template->set_var('cc_full_add_button',lang('Full Add'));
-			$GLOBALS['phpgw']->template->set_var('cc_full_add_button_sh',lang('Full Add Shared'));
+/******/
+                        $GLOBALS['phpgw']->template->set_var('cc_full_add_button_sh',lang('Full Add Shared'));
 			$GLOBALS['phpgw']->template->set_var('cc_reset',lang('Reset'));
-			
+
 			$GLOBALS['phpgw']->template->set_var('cc_personal_data',lang('Personal Data'));
 			$GLOBALS['phpgw']->template->set_var('cc_addresses',lang('Addresses'));
@@ -134,5 +140,5 @@
 			$GLOBALS['phpgw']->template->set_var('cc_catalogs',lang('Catalogues'));
 			$GLOBALS['phpgw']->template->set_var('cc_group_add',lang('Group Add'));
-			
+
 			/* Panel */
 			$GLOBALS['phpgw']->template->set_var('cc_panel_new',lang('New').'...');
@@ -142,5 +148,5 @@
 			$GLOBALS['phpgw']->template->set_var('cc_btn_import_export', lang('Import/Export'));
 			$GLOBALS['phpgw']->template->set_var('cc_btn_new', lang("New..."));
-			
+
 			$GLOBALS['phpgw']->template->set_var('cc_panel_search_found',lang('Showing found entries'));
 			$GLOBALS['phpgw']->template->set_var('cc_panel_first_page',lang('First Page'));
@@ -150,8 +156,10 @@
 			$GLOBALS['phpgw']->template->set_var('cc_all',lang('all'));
 			/* End Panel */
-			
+
 			/* Messages */
+/**rev 104**/
 			$GLOBALS['phpgw']->template->set_var('cc_msg_not_allowed',lang('Not Allowed'));
-			$GLOBALS['phpgw']->template->set_var('cc_msg_unavailable',lang('Unavailable function'));			
+			$GLOBALS['phpgw']->template->set_var('cc_msg_unavailable',lang('Unavailable function'));
+/*****/
 			$GLOBALS['phpgw']->template->set_var('cc_msg_no_cards',lang('No Cards'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_err_no_room',lang('No Room for Cards! Increase your browser area.'));
@@ -167,5 +175,5 @@
 			$GLOBALS['phpgw']->template->set_var('cc_empty',lang('Empty'));
 			/* End Messages */
-			
+
 			$GLOBALS['phpgw']->template->set_var('cc_results',lang('Results'));
 			$GLOBALS['phpgw']->template->set_var('cc_is_my',lang('Is My'));
@@ -173,5 +181,5 @@
 			$GLOBALS['phpgw']->template->set_var('cc_btn_search',lang('Search'));
 			$GLOBALS['phpgw']->template->set_var('cc_add_relation',lang('Add Relation'));
-			$GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations'));			
+			$GLOBALS['phpgw']->template->set_var('cc_del_relation',lang('Remove Selected Relations'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_group',lang('Group'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_contact_full',lang('Contact [Full]'));
@@ -214,5 +222,5 @@
 			$GLOBALS['phpgw']->template->set_var('cc_msg_corporative_cellphone', lang('Corporative Cellphone'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_corporative_fax', lang('Corporative Fax'));
-			$GLOBALS['phpgw']->template->set_var('cc_msg_corporative_pager', lang('Corporative Pager'));			
+			$GLOBALS['phpgw']->template->set_var('cc_msg_corporative_pager', lang('Corporative Pager'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_work', lang('Work'));
 			$GLOBALS['phpgw']->template->set_var('cc_msg_fax', lang('Fax'));
@@ -234,5 +242,5 @@
 			$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'));
-			
+
 			if($GLOBALS['phpgw_info']['server']['personal_contact_type']=='True'){
 				$GLOBALS['phpgw']->template->set_var('cc_contact_type', 'advanced');
@@ -241,5 +249,5 @@
 			}
 			$GLOBALS['phpgw']->template->parse('out','index');
-			
+
 			$api = CreateObject('contactcenter.ui_api');
 			$main = $api->get_full_add();
@@ -252,12 +260,12 @@
 		}
 
-		
+
 		/*!
-		
+
 			@function data_manager
-			@abstract Calls the right method and passes to it the right 
+			@abstract Calls the right method and passes to it the right
 				parameters
 			@author Raphael Derosso Pereira
-		
+
 		*/
 		function data_manager()
@@ -268,6 +276,6 @@
 				case 'set_n_cards':
 					return $this->set_n_cards((int)$_GET['ncards']);
-					
-				case 'get_cards_data':					
+
+				case 'get_cards_data':
 					$ids = false;
 					// To support ldap catalogs using accentuation
@@ -276,9 +284,10 @@
 						$ids = utf8_decode($this->search($_POST['data']));
 					}
-					
+
 					if(isset($_SESSION['ids']))
 						$ids = $_SESSION['ids'];
-					
-					return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids);						
+
+					return $this->get_cards_data($_POST['letter'], $_POST['page'], $ids);
+
 				case 'get_cards_data_get':
 					return $this->get_cards_data($_GET['letter'], $_GET['page'], unserialize(str_replace('\\"','"',$_GET['ids'])));
@@ -291,9 +300,9 @@
 					echo $this->get_visible_all_ldap();
 					return;
-					
+
 				/* Catalog Methods */
 				case 'set_catalog':
 					return $this->set_catalog($_GET['catalog']);
-					
+
 				case 'get_catalog_tree':
 					echo serialize($this->get_catalog_tree($_GET['level']));
@@ -307,21 +316,24 @@
 					echo serialize($this->get_catalog_participants_list($_POST['id']));
 					return;
-				
+/**rev 104**/
 				case 'get_catalog_participants_group':
 					echo serialize($this->get_catalog_participants_group($_POST['id']));
 					return;
-
+/***/
 				case 'get_catalog_add_contact':
 					// To support ldap catalogs with accentuation
 					echo serialize($this->get_catalog_add_contact(utf8_decode($_POST['id'])));
 					return;
-					
+
 				/* Full Add Methods */
 				case 'get_full_data':
+					//return $this->get_full_data($_GET['id']);
+/**rev 104**/
 					return $this->get_full_data($_GET['id'],$_GET['catalog']);
-				
+/****/
+
 				case 'get_group':
 					return $this->get_group_data($_GET['id'],isset($_GET['shared_from'])?$_GET['shared_from']:null);
-					
+
 				case 'get_contact_full_add_const':
 					return $this->get_contact_full_add_const();
@@ -338,25 +350,25 @@
 				case 'get_states':
 					return $this->get_states($_GET['country']);
-					
+
 				case 'get_cities':
 					return $this->get_cities($_GET['country'], $_GET['state'] ? $_GET['state'] : null);
-					
-					
+
+
 				/* Other Methods */
-				case 'quick_add':															
+				case 'quick_add':
 					return $this->quick_add($_POST['add']);
-				
-				case 'add_group':															
+
+				case 'add_group':
 					return $this->add_group($_POST['add']);
-									
+
 				case 'remove_entry':
 					return $this->remove_entry((int)$_GET['remove']);
-				
+
 				case 'remove_all_entries':
 					return $this->remove_all_entries();
 
 				case 'remove_group':
-					 					
-					return $this->remove_group((int)$_GET['remove']);					
+
+					return $this->remove_group((int)$_GET['remove']);
 
 				case 'search':
@@ -397,11 +409,11 @@
 
 		/*!
-		
+
 			@function set_n_cards
 			@abstract Informs the class the number of cards the page can show
 			@author Raphael Derosso Pereira
-			
+
 			@param integer $n_cards The number of cards
-			
+
 		*/
 		function set_n_cards($n_cards)
@@ -412,17 +424,17 @@
 				echo 1;
 			}
-			
+
 			$this->save_session();
 		}
-				
+
 		/*!
-		
+
 			@function set_catalog
 			@abstract Sets the current catalog selected by the user
 			@author Raphael Derosso Pereira
-			
+
 			@param string $id_catalog The sequence of IDs to reach the catalog
 				separated by commas
-		
+
 		*/
 		function set_catalog($id_catalog)
@@ -430,5 +442,5 @@
 			$id_catalog = str_replace('\\"', '"', $id_catalog);
 			$temp =& $this->bo->set_catalog($id_catalog);
-			
+
 			if ($temp)
 			{
@@ -437,7 +449,7 @@
 				$this->page_info['actual_catalog'] =& $temp;
 				$this->save_session();
-				
+
 				$catalog_info = $this->bo->get_branch_by_level($this->bo->catalog_level[0]);
-				
+
 				if ($catalog_info['class'] === 'bo_global_ldap_catalog' ||
 				    $catalog_info['class'] === 'bo_catalog_group_catalog')
@@ -449,5 +461,5 @@
 					$perms = 15;
 				}
-				
+
 				echo serialize(array(
 					'status' => 'ok',
@@ -457,5 +469,5 @@
 				return;
 			}
-			
+
 			echo serialize(array(
 				'status' => 'ok',
@@ -463,16 +475,16 @@
 			));
 		}
-		
-		
+
+
 		/*!
-		
+
 			@function get_catalog_tree
 			@abstract Returns the JS serialized array to used as the tree
 				level
 			@author Raphael Derosso Pereira
-            @author Mário César Kolling (error messages and timeout)
-			
-			@param (string) $level The level to be taken 
-		
+            @author Mï¿œrio Cï¿œsar Kolling (error messages and timeout)
+
+			@param (string) $level The level to be taken
+
 		*/
 		function get_catalog_tree($level)
@@ -483,5 +495,5 @@
 
 				$parent = '0';
-				
+
 				if (!($tree = $this->bo->get_catalog_tree($level)))
 				{
@@ -515,8 +527,8 @@
 				}
 			}
-			
+
 			$folderImageDir = $GLOBALS['phpgw']->common->image('contactcenter','globalcatalog-mini.png');
 			$folderImageDir = substr($folderImageDir, 0, strpos($folderImageDir, 'globalcatalog-mini.png'));
-			
+
 			// Deals with error messages from the server and returns them to the browser
 			if ($tree['msg'])
@@ -546,7 +558,7 @@
 			}
 		}
-		
+
 		/*!
-		
+
 			@function get_actual_catalog
 			@abstract Returns the actual selected Catalog
@@ -555,7 +567,7 @@
 		*/
 		function get_actual_catalog()
-		{			
+		{
 			$level = $this->bo->get_level_by_branch($this->bo->get_actual_catalog(), $this->bo->tree['branches'], '0');
-			
+
 			if ($level)
 			{
@@ -571,13 +583,13 @@
 			);
 		}
-		
+
 		/*!
-		
+
 			@function get_cards_data
 			@abstract Returns the information that is placed on the cards
 			@author Raphael Derosso Pereira
-			
+
 			@param string $letter The first letter to be searched
-			@param (int)  $page The page to be taken 
+			@param (int)  $page The page to be taken
 			@param (str)  $ids The ids to be taken in case of search
 
@@ -588,5 +600,5 @@
 		{
 			if( $ids )
-				$_SESSION['ids'] = $ids;		   
+				$_SESSION['ids'] = $ids;
 
 			// It's an external catalog?
@@ -594,14 +606,18 @@
 			//echo $page."\n";
 			if ($letter !== 'search' and ($letter != $this->page_info['actual_letter'] or
-			    ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or 
+			    ($letter == $this->page_info['actual_letter'] and $page == $this->page_info['actual_page']) or
 			    $this->page_info['changed']))
 			{
 				unset($ids);
 				$this->page_info['changed'] = false;
+
 				switch ($this->page_info['actual_catalog']['class'])
 				{
+/**rev 104**/
 					case 'bo_shared_people_manager':
+/****/
 					case 'bo_people_catalog':
 						$field_name = 'id_contact';
+
 						if ($letter !== 'number')
 						{
@@ -611,5 +627,12 @@
 									'type'  => 'iLIKE',
 									'value' => $letter !== 'all' ? $letter.'%' : '%'
-								)								
+/**rev 104**/
+	/*							),
+								1 => array(
+									'field' => 'contact.id_owner',
+									'type'  => '=',
+									'value' => $GLOBALS['phpgw_info']['user']['account_id']
+	*/
+								)
 							);
 
@@ -617,6 +640,6 @@
                                 			$so_contact = CreateObject('contactcenter.so_contact',  $GLOBALS['phpgw_info']['user']['account_id']);
                                 			$relacionados = $so_contact->get_relations();
-							
-							$perms_relacao = array();				
+
+							$perms_relacao = array();
 
                         				foreach($relacionados as $uid_relacionado => $tipo_relacionamento) {
@@ -650,7 +673,7 @@
                                         			$n=$this->bo->catalog->src_info['dn'];
                                         			$apenasThese = array("cn","uidnumber","uid");
-                                        			$r = ldap_search($s,$n, $filtro,$apenasThese);                                        
+                                        			$r = ldap_search($s,$n, $filtro,$apenasThese);
                                         			$infos = ldap_get_entries($s, $r);
-                                        			ldap_close($s);                                                                       
+                                        			ldap_close($s);
                                         			for($z = 0; $z < $infos['count']; $z++) {
                                                 			$prop_names[$infos[$z]['uidnumber'][0]] = array("cn" => $infos[$z]['cn'][0], "uid" => $infos[$z]['uid'][0]);
@@ -666,4 +689,6 @@
 								);
 							}
+/****/
+
 						}
 						else
@@ -725,4 +750,12 @@
 										),
 									),
+/**rev 104**/
+/*								),
+								1 => array(
+									'field' => 'contact.id_owner',
+									'type'  => '=',
+									'value' => $GLOBALS['phpgw_info']['user']['account_id']
+								),
+*/
 								)
 							);
@@ -736,16 +769,20 @@
 							);
 						}
-						
-						
+/*****/
+
 						$find_field[0] = array('contact.id_contact','contact.names_ordered');
-						
+
 						$find_other[0] = array(
+/**rev 104**/
+							//'offset' => (($page-1)*$this->page_info['n_cards']),
+							//'limit'  => $this->page_info['n_cards'],
+/*****/
 							'order'  => 'contact.names_ordered'
 						);
-						
+
 						break;
-					
+
 					case 'bo_global_ldap_catalog':
-					
+
 						$field_name = 'id_contact';
 
@@ -760,4 +797,5 @@
 								/*
 								 * Restrict the returned contacts in a "first letter" search
+/**rev 104
 								 * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus,
 								 * phpgwAccountVisible != -1
@@ -767,15 +805,32 @@
 									'type'  => '=',
 									'value' => 'phpgwAccount'
+/**rev 104**/
+								//),/*
 								),
+/****/
 								2 => array(
 									'field' => 'contact.account_status',
 									'type'  => 'iLIKE',
 									'value' => '%'
+/**rev 104**/
+								//),*/
+								//2 => array(
 								),
 								3 => array(
+/*****/
 									'field' => 'contact.account_visible',
 									'type'  => '!=',
 									'value' => '-1'
+/**rev 104**/
+	/*							),
+								3 => array(
+									'field' => 'contact.object_class',
+									'type'  => '=',
+									'value' => 'inetOrgPerson'
+								),
+	*/
 								)
+/*****/
+
 							);
 							// If not external catalog get only phpgwAccountType = u ou l
@@ -795,9 +850,12 @@
 											'type'  => '=',
 											'value' => 'i'
+/**rev 104**/
 											),
 											2 => array(
 											'field' => 'contact.account_type',
 											'type'  => '=',
+/****/
 											'value' => 'l'
+/**rev 104**/
 											),
 											3 => array(
@@ -805,4 +863,5 @@
 											'type'  => '=',
 											'value' => 'g'
+/***/
 											)
 										)
@@ -815,4 +874,5 @@
 								/*
 								 * Restrict the returned contacts in a "first number" search
+/**rev 104
 								 * to objectClass = phpgwAccount, must have attibute phpgwAccountStatus,
 								 * phpgwAccountVisible != -1
@@ -822,15 +882,30 @@
 									'type'  => '=',
 									'value' => 'phpgwAccount'
+/**rev 104**/
+								//),/*
 								),
+/****/
 								1 => array(
 									'field' => 'contact.account_status',
 									'type'  => 'iLIKE',
 									'value' => '%'
+/**rev 104**/
+								//),*/
+								//1 => array(
 								),
 								2 => array(
+/*****/
 									'field' => 'contact.account_visible',
 									'type'  => '!=',
 									'value' => '-1'
 								),
+/**rev 104**/
+	/*							2 => array(
+									'field' => 'contact.object_class',
+									'type'  => '=',
+									'value' => 'inetOrgPerson'
+								),
+	*/
+/****/
 								3 => array(
 									'type'  => 'branch',
@@ -905,10 +980,16 @@
 										'field' => 'contact.account_type',
 										'type'  => '=',
+/**rev 104**/
+										//'value' => 'g'
+										//);
+										//1 => array(
 										'value' => 'i'
 										),
 										2 => array(
+/****/
 										'field' => 'contact.account_type',
 										'type'  => '=',
 										'value' => 'l'
+/**rev 104**/
 										),
 										3 => array(
@@ -917,5 +998,5 @@
 										'value' => 'g'
 										)
-										
+/****/
 									)
 								);
@@ -928,5 +1009,5 @@
 							// for non-external catalogs, used to restrict the attributes used in filters
 							$find_field[0] = array('contact.id_contact','contact.names_ordered','contact.account_type',
-								'contact.object_class',/*'contact.account_status',*/'contact.account_visible');
+								'contact.object_class','contact.account_visible');
 						}
 						else
@@ -936,5 +1017,5 @@
 							$find_field[0] = array('contact.id_contact','contact.names_ordered');
 						}
-						
+
 						$find_other[0] = array(
 							//'offset' => (($page-1)*$this->page_info['n_cards']),
@@ -942,12 +1023,12 @@
 							'order'  => 'contact.names_ordered'
 						);
-						
+
 						break;
-					
+
 					case 'bo_company_manager':
 						$field_name = 'id_company';
-	
+
 						$find_field[0] = array('company.id_company','company.company_name');
-						
+
 						$find_other[0] = array(
 							//'offset' => (($page-1)*$this->page_info['n_cards']),
@@ -955,5 +1036,5 @@
 							'order'  => 'company.company_name'
 						);
-	
+
 						$find_restric[0] = array(
 							0 => array(
@@ -963,14 +1044,16 @@
 							)
 						);
-							
+
 						break;
 
 					case 'bo_group_manager':
+/**rev 104**/
 					case 'bo_shared_group_manager':
-												
+/****/
+
 						$field_name = 'id_group';
-						
+
 						if ($letter !== 'number')	{
-							
+
 							$find_restric[0] = array(
 								0 => array(
@@ -982,39 +1065,40 @@
 						}
 						 else {
-							
+
 							$find_restric[0] = array(
 								0 => array(
 											'field' => 'group.title',
 											'type'  => 'LIKE',
-											'value' => '0%'										
+											'value' => '0%'
 								)
-							);						
+							);
 						}
-						
+/**rev 104**/
 						if($this->page_info['actual_catalog']['class'] == 'bo_group_manager'){
+/****/
 							array_push($find_restric[0],  array(
 											'field' => 'group.owner',
 											'type'  => '=',
-											'value' => $GLOBALS['phpgw_info']['user']['account_id']										
+											'value' => $GLOBALS['phpgw_info']['user']['account_id']
 									)
 							);
 						}
-						
-						$find_field[0] = array('group.id_group','group.title','group.short_name');						
+
+						$find_field[0] = array('group.id_group','group.title','group.short_name');
 						$find_other[0] = array(
 							'order'  => 'group.title'
-						);						
+						);
 						break;
-					
+
 					case 'bo_catalog_group_catalog':
 						$this->page_info['actual_entries'] = false;
-						
+
 						$this->page_info['actual_letter'] = $letter;
 						$this->page_info['actual_page'] = 0;
-						
+
 						$this->save_session();
 						$final[0] = 0;
 						$final[1] = $this->typeContact;
-						echo serialize($final);						
+						echo serialize($final);
 						return;
 
@@ -1023,5 +1107,5 @@
 				$result = $this->bo->find($find_field[0],$find_restric[0],$find_other[0]);
 				$n_entries = count($result);
-				
+
 				if ($n_entries)
 				{
@@ -1036,14 +1120,13 @@
 				if (!$result)
 				{
-					
 					$this->page_info['actual_entries'] = false;
-					
+
 					$this->page_info['actual_letter'] = $letter;
 					$this->page_info['actual_page'] = 0;
-					
-					$this->save_session();				
+
+					$this->save_session();
 					$final[0] = 0;
 					$final[1] = $this->typeContact;
-					echo serialize($final);											
+					echo serialize($final);
 					return;
 				}
@@ -1053,9 +1136,13 @@
 					foreach ($result as $id => $value)
 					{
+/**rev 104**/
+					//	$this->page_info['actual_entries'][] = $value[$field_name];
+					//}
 						if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager')
 							$this->page_info['actual_entries'][] = $value[$field_name];
 						else
 							$this->page_info['actual_entries'][] = array(0=>$value[$field_name],1=>$value['perms'],2=>$value['owner']);
-					} 
+					}
+/****/
 					//print_r($this->page_info['actual_entries']);
 				}
@@ -1066,14 +1153,16 @@
 				if (!$ids)
 				{
+/**rev 104**/
 					//error_log('!$ids e $this->page_info[\'actual_letter\'] != search');
+/*****/
 					$this->page_info['actual_entries'] = false;
-					
+
 					$this->page_info['actual_letter'] = $letter;
 					$this->page_info['actual_page'] = 0;
-					
+
 					$this->save_session();
 					$final[0] = 0;
 					$final[1] = $this -> typeContact;
-					echo serialize($final);					
+					echo serialize($final);
 					return;
 				}
@@ -1092,5 +1181,5 @@
 				}
 				else if ($ids)
-				{				
+				{
 					$this->page_info['actual_letter']  = $letter;
 					$this->page_info['actual_entries'] = $ids;
@@ -1109,5 +1198,5 @@
 					$page = $this->page_info['n_pages'];
 				}
-				
+
 				$final = array(
 					0 => (int)$this->page_info['n_pages'],
@@ -1121,40 +1210,51 @@
 						5 => 'cc_alias',
 						6 => 'cc_id',
-						7 => 'cc_forwarding_address'						
+						7 => 'cc_forwarding_address',
+						8 => 'cc_empNumber',
+						9 => 'cc_department',
+						10 => 'cc_mobile'
 					)
 				);
-				
+
 				//echo 'Page: '.$page.'<br>';
 				$id_i = (($page-1)*$this->page_info['n_cards']);
 				$id_f = $id_i + $this->page_info['n_cards'];
 				$n_entries = count($this->page_info['actual_entries']);
-				
+
 				//echo 'ID_I: '.$id_i.'<br>';
 				//echo 'ID_F: '.$id_f.'<br>';
-				
+				///---------------- Correï¿œï¿œo Temporï¿œria PHP5 -----------------------///
+
 				$ids = array();
+/**rev 104**/
 				$perms = array();
 				$owners = array();
-				$array_temp = array();			
-				
+/****/
+				$array_temp = array();
+
 				foreach($this->page_info['actual_entries'] as $key=>$tmp){
-						$array_temp[] = $tmp;				
-				}
-			
+					$array_temp[] = $tmp;
+				}
+
 				for($i = $id_i; $i < $id_f and $i < $n_entries; $i++)
 				{
+/**rev 104**/
 					if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager')
+					{
+/****/
 						$ids[] = $array_temp[$i];
-					else {
+/**rev 104**/
+					}else {
 						$ids[] = $array_temp[$i][0];
 						$perms[] = $array_temp[$i][1];
 						$owners[] = $array_temp[$i][2];
+/****/
 					}
-					//$perms[] = $array_temp[$i];
-				}
-				
+				}
+
+/**rev 104**/
 				// Carrega o nome completo dos donos dos objetos (contatos e grupos);
 				$owner_names = array();
-							
+
 				if($owners) {
 					$filter = "(|";
@@ -1168,14 +1268,18 @@
 						$this->bo->catalog->src_info = $ldap->srcs[1];
 					}
-					$ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false);				
+					$ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], false);
 					$dn=$this->bo->catalog->src_info['dn'];
 					$justThese = array("cn","uidnumber","uid");
-					$sr = ldap_search($ds,$dn, $filter,$justThese);								
+					$sr = ldap_search($ds,$dn, $filter,$justThese);
 					$info = ldap_get_entries($ds, $sr);
-					ldap_close($ds);											
+					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]);
-					}				
-				}
+					}
+				}
+
+/*****/
+
+
 				/// Original
 				//for($i = $id_i; $i < $id_f and $i < $n_entries; $i++)
@@ -1184,6 +1288,10 @@
 				//}
 				///
+
 				$fields = $this->bo->catalog->get_fields(false);
+/**rev 104**/
+				//if( $this->typeContact == 'groups') {
 				if( $this->typeContact == 'groups' || $this->typeContact == 'shared_groups') {
+/****/
 					$final = array(
 						0 => (int)$this->page_info['n_pages'],
@@ -1194,16 +1302,17 @@
 							2 => 'cc_id',
 							3 => 'cc_contacts'
-						)						
-					);					
+						)
+					);
+
 					$groups =& $this->bo->catalog->get_multiple_entries($ids,$fields);
-															
+
 					$i = 0;
 					// contatos do grupo
-					$boGroups = CreateObject('contactcenter.bo_group');					
+					$boGroups = CreateObject('contactcenter.bo_group');
 					$contacts = array();
-					
-					foreach($groups as $group)		{	
+					foreach($groups as $group)		{
+
 						$final[3][$i][0] = $group['title'] ? $group['title'] : 'none';
-						$final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none';						
+						$final[3][$i][1] = $group['short_name'] ? $group['short_name'] : 'none';
 						$final[3][$i][2] = $group['id_group'] ? $group['id_group'] : 'none';
 						$contacts = $boGroups -> get_contacts_by_group($group['id_group']);
@@ -1217,19 +1326,24 @@
 						$i++;							
 					}
-					
+
 					$this->page_info['actual_letter'] = $letter;
-					$this->page_info['actual_page'] = $page;					
-					
-					
+					$this->page_info['actual_page'] = $page;
+
+
 					$lnk_compose = "location.href=('../expressoMail1_2/index.php?to=";
-					
-					$final[5] = '<span class="link"  onclick="'.$lnk_compose;					
-					$final[10] = $this->typeContact;																										
-					$this->save_session();					
+
+					$final[5] = '<span class="link"  onclick="'.$lnk_compose;
+/**rev 104**/
+					//$final[10] = 'groups';
+					$final[10] = $this->typeContact;
+/******/
+					$this->save_session();
 					echo serialize($final);
-					return;					
-				}
+					return;
+				}
+/**rev 104**/
 				$final[10] = $this -> typeContact;
-				
+/*****/
+
 				$fields['photo'] = true;
 				$fields['names_ordered'] = true;
@@ -1238,11 +1352,20 @@
 				$fields['companies'] = 'default';
 				$fields['connections'] = 'default';
+
+/**rev 104**/
+				// ?aqui alterar a chamada desse mï¿œtodo para receber o base dn?
+				//$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields);
+
 				// ?aqui alterar a chamada desse método para receber o base dn?
 				if($external)
+				{
 					$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields,false,true);
-				else
+				} else{
 					$contacts = &$this->bo->catalog->get_multiple_entries($ids,$fields);
-				
-				
+				}
+
+/*******/
+
+
 				if (!is_array($contacts) or !count($contacts))
 				{
@@ -1252,14 +1375,18 @@
 					return;
 				}
-				
+
 				$i = 0;
 				foreach($contacts as $index => $contact)
 				{
 					/*
-					 * TODO: Os timeouts de conexão foram retirados, ver se será necessário retornar essa funcionalidade, e,
-					 * neste caso, terminar a implementação das mensagens de retorno.
+					 * TODO: Os timeouts de conexï¿œo foram retirados, ver se serï¿œ necessï¿œrio retornar essa funcionalidade, e,
+					 * neste caso, terminar a implementaï¿œï¿œo das mensagens de retorno.
 					 */
 					if ($index !== 'error'){
 						$final[3][$i][0] = $contact['companies']['company1']['company_name']?$contact['companies']['company1']['company_name']:'none';
+
+/**rev 104**/
+						//$final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered'] : 'none';
+
 						if($this->page_info['actual_catalog']['class']!='bo_global_ldap_catalog'){
 							$final[3][$i][1] = $contact['names_ordered'] ? urldecode($contact['names_ordered'])  : 'none';
@@ -1269,9 +1396,23 @@
 							$final[3][$i][1] = $contact['names_ordered'] ? $contact['names_ordered']  : 'none';
 						}
+
+/********/
+
 						$final[3][$i][2] = $contact['companies']['company1']['title']? urldecode( $contact['companies']['company1']['title'] ) :'none';
+
+						//Para exibir a matricula do empregado
+						$final[3][$i][8] = $contact['companies']['company1']['empNumber']?$contact['companies']['company1']['empNumber']:'none';
+						//Para exibir o setor/lotacao do empregado
+						$final[3][$i][9] = $contact['companies']['company1']['department']?$contact['companies']['company1']['department']:'none';
+						//Para exibir o celular empresarial do empregado
+						$final[3][$i][10] = $contact['companies']['company1']['celPhone']?$contact['companies']['company1']['celPhone']:'none';
+
+						//Para exibir o celular empresarial do empregado
+						if ($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && !$external && $final[3][$i][10] != 'none')
+                                                            $final[3][$i][10] = "<a title=\"".lang("Call Mobile")."\" href=\"#\" onclick=\"connectVoip('".$final[3][$i][10]."', 'mob')\">".$final[3][$i][10]."</a>";
 
 						/* Select the correct Email and Telephone to be shown */
 						$preferences = ExecMethod('contactcenter.ui_preferences.get_preferences');
-						
+
 						if (!is_array($preferences))
 						{
@@ -1299,6 +1440,13 @@
 										$default_phone_found = true;
 									}
+
+/**rev 104**/
+									//if ($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && !$external){
+									//	$conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'ramal')\">".$conn_info['connection_value']."</a>";
+
 									if (!($_SESSION['phpgw_info']['user']['preferences']['contactcenter']['telephone_number'] == $conn_info['connection_value']) && $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['voip_enabled'] && $conn_info['connection_value'] && preg_match('/^\([0-9]{2}\)[0-9]{4}\-[0-9]{4}$/',$conn_info['connection_value'])==1 && !$external){
 										$conn_info['connection_value'] = "<a title=\"".lang("Call Extension")."\" href=\"#\" onclick=\"connectVoip('".$conn_info['connection_value']."', 'com')\">".$conn_info['connection_value']."</a>";
+ 									
+/*****/
 									}
 									$final[3][$i][3] = $conn_info['connection_value'] ? $conn_info['connection_value'] : 'none';
@@ -1306,5 +1454,5 @@
 							}
 						}
-						
+
 						if (!$final[3][$i][3])
 						{
@@ -1320,16 +1468,21 @@
 						$final[3][$i][6] = $ids[$i];
 
-					//	If contact is a public list or a group, then load the forwarding addresses.
+/**rev 104**/
+	/*				//	If contact is a public list, then load the forwarding addresses.
+						if($contact['account_type'][0] == 'l')
+							$final[3][$i][7] = array();
+	*/
+
+						//If contact is a public list or a group, then load the forwarding addresses.
 						if($contact['account_type'][0] == 'l' || $contact['account_type'][0] == 'g')
 							$final[3][$i][7] = ($contact['account_type'][0] == 'l' ? 'list' : 'group');
 							
 						if($this->page_info['actual_catalog']['class']=='bo_shared_people_manager') {
-							$final[3][$i][8] = $perms[$i];
-							$final[3][$i][9] = lang('Shared').": ".$owner_names[$owners[$i]]['cn'];
+							$final[3][$i][11] = $perms[$i];
+							$final[3][$i][12] = lang('Shared').": ".$owner_names[$owners[$i]]['cn'];
 						}
+/******/
 
 						$final[4][$i] = $contact['photo'] ? 1  : 0;
-					//	print_r($final[3][$i]);
-					//	exit;
 						$i++;
 					}
@@ -1338,5 +1491,4 @@
 						// coloca mensagem de erro no vetor que retorna para o browser
 					}
-					
 				}
 				$lnk_compose = "location.href=('../expressoMail1_2/index.php?to=";
@@ -1347,39 +1499,40 @@
 				$final[9] = $count;
 
+
 				$this->page_info['actual_letter'] = $letter;
 				$this->page_info['actual_page'] = $page;
-				
-				$this->save_session();				
+
+				$this->save_session();
 				echo serialize($final);
 				return;
 			}
-			
+
 			$this->page_info['actual_letter'] = $letter;
 			$this->page_info['actual_page'] = $page;
-			
+
 			$this->save_session();
-			
+
 			$final[0] = 0;
 			$final[1] = $this -> typeContact;
 			echo serialize($final);
 		}
-		
+
 		function get_visible_all_ldap()
 		{
 			$bo = CreateObject('contactcenter.bo_ldap_manager');
 			$ldap_query = $bo->srcs;
-			return $ldap_query[1]['visible'];	
+			return $ldap_query[1]['visible'];
 		}
 
- 
+
 		/*!
-		
+
 			@function get_group_data
 			@abstract Returns all the information of a given Group
 			@author Nilton Emilio Buhrer Neto
-			
+
 			@param (integer) $id The id to get information
-		
-		*/		
+
+		*/
 		function get_group_data($id,$shared_from=null)
 		{
@@ -1394,5 +1547,5 @@
 			
 			$boGroup = CreateObject('contactcenter.bo_group');
-						
+
 			$all_contacts = $boGroup->get_all_contacts('only_email',$shared_from);
 			
@@ -1403,23 +1556,27 @@
 				}
 			}
-			$data['contact_list'] = $contact_options;			
-			$data['result'] = 'ok';
-											
+			$data['contact_list'] = $contact_options;
+			$data['result'] = 'ok';								
 			echo serialize($data);			
 		}		
 		
 		/*!
-		
+
 			@function get_full_data
 			@abstract Returns all the information of a given Entry
 			@author Raphael Derosso Pereira
-			
+
 			@param (integer) $id The id to get information
-		
+
 		*/
+/**rev 104**/
+		//function get_full_data($id)
 		function get_full_data($id,$catalog='bo_people_catalog')
 		{
 			$dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-			$this->bo->catalog = CreateObject('contactcenter.'.$catalog);		
+/**rev 104**/
+			//$this->bo->catalog = CreateObject('contactcenter.bo_people_catalog');
+			$this->bo->catalog = CreateObject('contactcenter.'.$catalog);
+/****/
 			$fields = $this->bo->catalog->get_fields(true);
 			$fields['photo'] = false;
@@ -1454,5 +1611,5 @@
 			}
 			$datecount = 0;
-			
+
 			$data['result'] = 'ok';
 			$data['cc_full_add_contact_id'] = $id;
@@ -1493,5 +1650,6 @@
 				}
 			}
-			
+//			print_r($data);
+//OBSERVAR cc_department
 			/*Corporative*/
 			$data['personal']['cc_name_corporate'] = $entry['corporate_name'];
@@ -1500,8 +1658,8 @@
 			$data['personal']['cc_name_corporate'] = $entry['corporate_name'];
 			$data['personal']['cc_web_page'] = $entry['web_page'];
-			
-			
+
+
 			/* Relations */
-			
+
 			echo serialize($data);
 		}
@@ -1540,26 +1698,26 @@
 				return;
 			}
-			
+
 			echo 0;
 		}
-		
+
 		/*!
-		
+
 			@function quick_add
 			@abstract Adds a new Contact using the Quick Add interface
 			@author Raphael Derosso Pereira
-			
+
 			@param string $sdata Serialized data
 		*/
 		function quick_add($sdata)
 		{
-			
+
 			$sdata = str_replace('\\"', '"', $sdata);
 			$new_array = unserialize($sdata);
 			$tdata = array();
-			
+
 			foreach($new_array as $tmp)
 				$tdata[] = $tmp;
-			
+
 			if (!$tdata)
 			{
@@ -1568,22 +1726,22 @@
 					'status' => 'abort'
 				));
-				
+
 				return;
 			}
-			
-			// verifica se email já existe!
+
+			// 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);
-				
+
 				echo serialize(array(
 					'msg'    => lang('Problems on adding your Contact. The email "%1" already exists in: %2',$tdata[4], $str_contact),
 					'status' => 'alreadyExists'
 				));
-				
-				return;			
+
+				return;
 			}
 
@@ -1600,7 +1758,7 @@
 
 			if ($boPeople ->quick_add($data))
-			{				
+			{
 				$this->page_info['changed'] = true;
-				
+
 				echo serialize(array(
 					'msg'    => lang('Entry added with success!'),
@@ -1616,14 +1774,14 @@
 			}
 
-			$this->save_session();	
-			
+			$this->save_session();
+
 		}
 
 		/*!
-		
+
 			@function add_group
 			@abstract Adds a new Group using the Add Group interface
 			@author Nilton Emilio Buhrer Neto
-			
+
 			@param string $sdata Serialized data
 		*/
@@ -1633,5 +1791,5 @@
 			$tdata = unserialize($sdata);
 			$new_tdata = array();
-			
+
 			if (!$tdata)
 			{
@@ -1640,22 +1798,22 @@
 					'status' => 'abort'
 				));
-				
+
 				return;
 			}
-			
+
 			foreach($tdata as $tmp)
 				$new_tdata[] = $tmp;
-			
-			$data['title'] = $new_tdata[0];			
+
+			$data['title'] = $new_tdata[0];
 			$data['contact_in_list'] = $new_tdata[1];
 			$data['id_group'] = $new_tdata[2];
-						
+
 			$boGroup = CreateObject('contactcenter.bo_group_manager');
 			$id = $boGroup -> add_group($data);
-			
+
 			if ($id)
 			{
 				$this->page_info['changed'] = true;
-				
+
 				echo serialize(array(
 					'msg'    => lang('Entry added with success!'),
@@ -1675,14 +1833,14 @@
 
 		/*!
-		
+
 			@function remove_group
 			@abstract Removes a group if the user has the right to do it
-			@author Nilton Emilio Buhrer Neto			
+			@author Nilton Emilio Buhrer Neto
 			@param (integer) $id The id to be removed
-				
+
 		*/
 		function remove_group($id)
-		{				
-				$soGroup = CreateObject('contactcenter.so_group');				
+		{
+				$soGroup = CreateObject('contactcenter.so_group');
 				$data = array ('id_group' => $id);
 				if($soGroup -> delete($data)) {
@@ -1690,5 +1848,5 @@
 						'msg'    => lang('Removed Entry ID '.$id.'!'),
 						'status' => 'ok'
-					));							
+					));
 				}
 				else {
@@ -1699,10 +1857,10 @@
 				}
 
-			$this->save_session();				
+			$this->save_session();
 		}
 
 
 		function remove_all_entries (){
-		
+
 			$error = false;
 			$this->all_entries = $this->bo->catalog->get_all_entries_ids();
@@ -1712,5 +1870,5 @@
 				if(!$result) {
 					$error = true;
-					break;		
+					break;
 				}
 			}
@@ -1721,5 +1879,5 @@
 					'status' => 'ok'
 				));
-			} 
+			}
 			else {
 				echo serialize(array(
@@ -1733,11 +1891,11 @@
 
 		/*!
-		
+
 			@function remove_entry
 			@abstract Removes an entry if the user has the right to do it
 			@author Raphael Derosso Pereira
-			
+
 			@param (integer) $id The id to be removed
-				
+
 		*/
 		function remove_entry ($id)
@@ -1748,8 +1906,8 @@
 				return;
 			}
-			
+
 			$this->page_info['changed'] = true;
 			$result = $this->bo->catalog->remove_single_entry($id);
-			
+
 			if ($result)
 			{
@@ -1758,5 +1916,5 @@
 					unset($this->page_info['actual_entries'][$pos]);
 				}
-				
+
 				$temp = false;
 				reset($this->page_info['actual_entries']);
@@ -1765,5 +1923,5 @@
 					$temp[] = $t;
 				}
-				
+
 				$this->page_info['actual_entries'] = $temp;
 
@@ -1780,11 +1938,11 @@
 				));
 			}
-			
+
 			$this->save_session();
 		}
 
-		
+
 		/*!
-		
+
 			@function post_full_add
 			@abstract Saves all the information altered/entered in the Full Add
@@ -1796,5 +1954,5 @@
 		{
 			$data =  $_POST['data'];
-			// Exceptions!!! utf8 special chars. 
+			// Exceptions!!! utf8 special chars.
 			$data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data);
 			$data = unserialize(str_replace('\\"', '"', $data));
@@ -1823,5 +1981,5 @@
 					'status' => 'fatal'
 				));
-				
+
 				return;
 			}
@@ -1837,7 +1995,7 @@
 				$id_photo = '_new_';
 			}
-			
-			/* 
-			 * Process Photo, if available 
+
+			/*
+			 * Process Photo, if available
 			 */
 			$sleep_count = 0;
@@ -1856,5 +2014,5 @@
 			}
 			$GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n'));
-			
+
 			if (isset($this->page_info['photos'][$id_photo]))
 			{
@@ -1873,11 +2031,11 @@
 				$this->save_session();
 			}
-			
+
 			/*
 			 * Arrange Date so it gets inserted correctly
 			 */
-			 
+
 			$dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-		
+
 			$j = 0;
 			for ($i = 0; $i < 5; $i+=2)
@@ -1912,5 +2070,5 @@
 					continue;
 				}
-				
+
 				switch($field)
 				{
@@ -1929,5 +2087,5 @@
 						/* Do Nothing. This is just to make sure no invalid field is passed */
 						break;
-					
+
 					case 'id_status':
 					case 'id_prefix':
@@ -1938,9 +2096,9 @@
 						}
 						break;
-					
+
 					case 'birthdate_0':
 					case 'birthdate_1':
 					case 'birthdate_2':
-					
+
 						switch($date[$datecount]['digit'])
 						{
@@ -1964,5 +2122,5 @@
 							break;
 						}
-						
+
 						if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2]))
 						{
@@ -1973,5 +2131,5 @@
 							return;
 						}
-						
+
 						$data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1];
 						break;
@@ -1996,5 +2154,5 @@
 							{
 								$index = 'address'.$type;
-								
+
 								$id_state = $this->bo->catalog->add_state($state_info);
 								$data['addresses'][$index]['id_state'] = $id_state;
@@ -2014,5 +2172,5 @@
 							{
 								$index = 'address'.$type;
-								
+
 								$id_city = $this->bo->catalog->add_city($city_info);
 								$data['addresses'][$index]['id_city'] = $id_city;
@@ -2055,5 +2213,5 @@
 				);
 			}
-			
+
 			eval($code);
 
@@ -2074,5 +2232,5 @@
 		{
 			$data =  $_POST['data'];
-			// Exceptions!!! utf8 special chars. 
+			// Exceptions!!! utf8 special chars.
 			$data = preg_replace("/\%u2(\d+)(\d+)(\d+)/","-",$data);
 			$data = unserialize(str_replace('\\"', '"', $data));
@@ -2101,5 +2259,5 @@
 					'status' => 'fatal'
 				));
-				
+
 				return;
 			}
@@ -2121,6 +2279,6 @@
 				unset($data['owner']);
 			}
-			/* 
-			 * Process Photo, if available 
+			/*
+			 * Process Photo, if available
 			 */
 			$sleep_count = 0;
@@ -2139,5 +2297,5 @@
 			}
 			$GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'n'));
-			
+
 			if (isset($this->page_info['photos'][$id_photo]))
 			{
@@ -2156,11 +2314,11 @@
 				$this->save_session();
 			}
-			
+
 			/*
 			 * Arrange Date so it gets inserted correctly
 			 */
-			 
+
 			$dateformat = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
-		
+
 			$j = 0;
 			for ($i = 0; $i < 5; $i+=2)
@@ -2195,5 +2353,5 @@
 					continue;
 				}
-				
+
 				switch($field)
 				{
@@ -2208,5 +2366,5 @@
 						/* Do Nothing. This is just to make sure no invalid field is passed */
 						break;
-					
+
 					case 'id_status':
 					case 'id_prefix':
@@ -2217,9 +2375,9 @@
 						}
 						break;
-					
+
 					case 'birthdate_0':
 					case 'birthdate_1':
 					case 'birthdate_2':
-					
+
 						switch($date[$datecount]['digit'])
 						{
@@ -2243,5 +2401,5 @@
 							break;
 						}
-						
+
 						if (!checkdate($date['value'][0], $date['value'][1], $date['value'][2]))
 						{
@@ -2252,5 +2410,5 @@
 							return;
 						}
-						
+
 						$data['birthdate'] = $date['value'][2].'-'.$date['value'][0].'-'.$date['value'][1];
 						break;
@@ -2275,5 +2433,5 @@
 							{
 								$index = 'address'.$type;
-								
+
 								$id_state = $this->bo->catalog->add_state($state_info);
 								$data['addresses'][$index]['id_state'] = $id_state;
@@ -2293,5 +2451,5 @@
 							{
 								$index = 'address'.$type;
-								
+
 								$id_city = $this->bo->catalog->add_city($city_info);
 								$data['addresses'][$index]['id_city'] = $id_city;
@@ -2334,5 +2492,5 @@
 				);
 			}
-			
+
 			eval($code);
 
@@ -2349,5 +2507,5 @@
 }
 		/*!
-		
+
 			@function post_photo
 			@abstract Wrapper to post a photo without reload a page.
@@ -2359,10 +2517,10 @@
 			//print_r($_FILES);
 			$GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('wait', 'y'));
-			
+
 			if (!is_array($_FILES) and is_array(!$_FILES['cc_pd_photo']))
 			{
 				$this->page_info['photos'][$id]['status'] = 'no_upload';
 				$this->page_info['photos'][$id]['msg'] = lang('No Photos uploaded to Server.');
-				
+
 				$this->save_session();
 				$GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y'));
@@ -2374,5 +2532,5 @@
 				$this->page_info['photos'][$id]['status'] = 'no_GD_lib';
 				$this->page_info['photos'][$id]['msg'] = lang('Cannot manipulate Image. No Image added. Please, if you want to use images, ask the Administrator to install GD library.');
-				
+
 				$this->save_session();
 				$GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y'));
@@ -2400,5 +2558,5 @@
 				return;
 			}
-			
+
 			switch($_FILES['cc_pd_photo']['type'])
 			{
@@ -2430,5 +2588,5 @@
 
 				default:
-					
+
 					$this->page_info['photos'][$id]['status'] = 'invalid_image';
 					$this->page_info['photos'][$id]['msg'] = lang('The file must be an JPEG, PNG or GIF Image.');
@@ -2443,23 +2601,23 @@
 					$this->page_info['photos'][$id]['status'] = 'invalid_file';
 					$this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.');
-					
+
 					$this->save_session();
 					$GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y'));
 					return;
 			}
-			
+
 			$img_size = getimagesize($_FILES['cc_pd_photo']['tmp_name']);
 			$dst_img = imagecreatetruecolor(60, 80);
-			
+
 			if (!imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, 60, 80, $img_size[0], $img_size[1]))
 			{
 				$this->page_info['photos'][$id]['status'] = 'invalid_file';
 				$this->page_info['photos'][$id]['msg'] = lang('Couldn\'t open Image. It may be corrupted or internal library doesn\'t support this format.');
-				
+
 				$this->save_session();
 				$GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y'));
 				return;
 			}
-			
+
 			ob_start();
 			imagepng($dst_img);
@@ -2471,5 +2629,5 @@
 
 			$this->save_session();
-		
+
 			$GLOBALS['phpgw']->session->appsession('ui_data.photo','contactcenter', array('ok', 'y'));
 
@@ -2492,5 +2650,5 @@
 			$fields = $this->bo->catalog->get_fields(false);
 			$fields['photo'] = true;
-			
+
 			$contact = $this->bo->catalog->get_single_entry($id, $fields);
 
@@ -2501,5 +2659,5 @@
 				return;
 			}
-			
+
 			header('Content-type: image/jpeg');
 			$photo = imagecreatefromstring ($contact['photo']);
@@ -2513,7 +2671,7 @@
 			return;
 		}
-		
+
 		/*!
-		
+
 			@function get_states
 			@abstract Echos a serialized array containing all the states for the given country
@@ -2537,10 +2695,10 @@
 				return;
 			}
-			
+
 			$result = array(
 				'msg'    => lang('States Successfully retrieved!'),
 				'status' => 'ok'
 			);
-			
+
 			foreach ($states as $state_info)
 			{
@@ -2581,15 +2739,15 @@
 				return;
 			}
-			
+
 			$result = array(
 				'msg'    => lang('Cities Successfully retrieved!'),
 				'status' => 'ok'
 			);
-			
+
 			foreach ($cities as $city_info)
 			{
 				$result['data'][$city_info['id_city']] = $city_info['name'];
 			}
-			
+
 			echo serialize($result);
 		}
@@ -2597,10 +2755,10 @@
 
 		/*!
-		
+
 			@function search
 			@abstract Echos a serialized array containing the IDs
 				of the entries that matches the search argument
 			@author Raphael Derosso Pereira
-			@author Mário César Kolling (external catalogs)
+			@author Mï¿œrio Cï¿œsar Kolling (external catalogs)
 
 			@param string $str_data A serialized array with two informations:
@@ -2617,16 +2775,16 @@
 			// It's an external catalog?
 			$external = $this->bo->is_external($this->page_info['actual_catalog']);
-			
-            if (!is_array($data) || !$data['search_for'] || !is_array($data['fields']))
-            {
-                echo serialize(array(                                                                                                   
-                   'msg'    => lang('Invalid parameters'),                                                                             
-                    'status' => 'abort'
-                ));
-            
-                return array('error' => lang('Invalid parameters'));                                                                                                                 
-            }   
-
-            
+
+			if (!is_array($data) || !$data['search_for'] || !is_array($data['fields']))
+			{
+				echo serialize(array(
+					'msg'    => lang('Invalid parameters'),
+					'status' => 'abort'
+				));
+
+				return array('error' => lang('Invalid parameters'));
+			}
+
+
 			/*
 			 * TODO: look into the database to discover the database's encoding and convert the search_for field accordingly
@@ -2634,42 +2792,47 @@
 			// Support search parameters with accentuation
 			if ($this->page_info['actual_catalog']['class'] != 'bo_people_catalog' &&
+/**rev 104**/
+				//$this->page_info['actual_catalog']['class'] != 'bo_group_manager')
 				$this->page_info['actual_catalog']['class'] != 'bo_group_manager' &&
 				$this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' &&
 				$this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager')
+/****/
 			{
 
 				$data['search_for'] = utf8_encode($data['search_for']);
 			}
-            
-            $rules  = array();                                                                                                          
-            
-            
-            if ($data['search_for'] === '*')                                                                                            
-            {
-                $rules = array(                                                                                                         
-                    0 => array(                                                                                                         
-                        'field' => $data['fields']['search'],                                                                           
-                        'type'  => 'LIKE',
-                        'value' => '%'
-                    )   
-                );  
-            }   
-            else                                                                                                                        
-            {
-                $names = explode(' ', $data['search_for']);                                                                             
-                
-                if (!is_array($names))                                                                                                  
-                {
-                    echo serialize(array(                                                                                               
-                        'msg'    => lang('Invalid Search Parameter'),                                                                   
-                        'status' => 'abort'
-                    ));
- 
-                }
+
+			$rules  = array();
+
+			if ($data['search_for'] === '*')
+			{
+				$rules = array(
+					0 => array(
+						'field' => $data['fields']['search'],
+						'type'  => 'LIKE',
+						'value' => '%'
+					)
+				);
+			}
+			else
+			{
+				$names = explode(' ', $data['search_for']);
+
+				if (!is_array($names))
+				{
+					echo serialize(array(
+						'msg'    => lang('Invalid Search Parameter'),
+						'status' => 'abort'
+					));
+
+				}
 
 				if (!$external && $this->page_info['actual_catalog']['class'] != 'bo_people_catalog' &&
+/**rev 104**/
+					//$this->page_info['actual_catalog']['class'] != 'bo_group_manager')
 					$this->page_info['actual_catalog']['class'] != 'bo_group_manager' &&
-					$this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' &&					
+					$this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' &&
 					$this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager' )
+/*****/
 				{
 					/*
@@ -2688,29 +2851,45 @@
 							'value' => '%'
 						),
+/**rev 104**/
+						///
+						//1 => array(
 						2 => array(
+/*****/
 							'field' => 'contact.account_visible',
 							'type'  => '!=',
 							'value' => '-1'
+/**rev 104**/
+	/*					),
+						2 => array(
+							'field' => 'contact.object_class',
+							'type'  => '=',
+							'value' => 'inetOrgPerson'
+/****/
 						),
 					);
 				}
-                
-                foreach ($names as $name)
-                {
-                    if ($name != '')
-                    {
-                        array_push($rules, array(
-                            'field' => $data['fields']['search'],
-                            'type'  => 'iLIKE',
-                            'value' => '%'.$name.'%'
-                        ));
-                    }
-                }
-            }
+
+				foreach ($names as $name)
+				{
+					if ($name != '')
+					{
+						array_push($rules, array(
+							'field' => $data['fields']['search'],
+							'type'  => 'iLIKE',
+							'value' => '%'.$name.'%'
+						));
+					}
+				}
+			}
 
 			if ($external || $this->page_info['actual_catalog']['class'] == 'bo_people_catalog' ||
+/**rev 104**/
+				//$this->page_info['actual_catalog']['class'] == 'bo_group_manager')
 				$this->page_info['actual_catalog']['class'] == 'bo_group_manager' ||
 				$this->page_info['actual_catalog']['class'] == 'bo_shared_people_manager' ||
-				$this->page_info['actual_catalog']['class'] == 'bo_shared_group_manager'	)
+				$this->page_info['actual_catalog']['class'] == 'bo_shared_group_manager')
+
+
+/***/
 			{
 				// Get only this attributes: dn, cn for external catalogs,
@@ -2728,29 +2907,34 @@
 					//'contact.account_status',
 					'contact.account_visible'
-					), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'));
-			}
-
-            if (!is_array($ids) || !count($ids))
-            {
+					), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'), $data['search_for_area'] );
+			}
+
+			if (!is_array($ids) || !count($ids))
+			{
 				$this->last_search_ids = null;
 				$this->save_session();
 				return null;
-            }
-
-            $id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1);
-			
-            $ids_f = array();
-
-            foreach ($ids as $e_info)
-            {
+			}
+
+			$id_field = substr($data['fields']['id'], strrpos($data['fields']['id'], '.')+1);
+
+			$ids_f = array();
+
+			foreach ($ids as $e_info)
+			{
+/**rev 104**/
+				//$ids_f[] = $e_info[$id_field];
 				if($this->page_info['actual_catalog']['class'] != 'bo_shared_people_manager' && $this->page_info['actual_catalog']['class'] != 'bo_shared_group_manager')
-                	$ids_f[] = $e_info[$id_field];
-                else
-                	$ids_f[] = array(0=>$e_info[$id_field],1=>$e_info['perms']);
-            }
+				{
+					$ids_f[] = $e_info[$id_field];
+				} else{
+					$ids_f[] = array(0=>$e_info[$id_field],1=>$e_info['perms']);
+				}
+/****/
+			}
 
 			return $ids_f;
 		}
-		
+
 		// CELEPAR
 		/*
@@ -2791,8 +2975,8 @@
                         'status' => 'abort'
                     ));
-                    
+
                     return;
                 }
-                
+
                 foreach ($names as $name)
                 {
@@ -2808,8 +2992,8 @@
             }
 
-            
-            
+
+
             //$catalog = $this->bo->get_branch_by_level($this->bo->catalog_level[0]);
-            
+
             //if ($catalog['class'] === 'bo_people_catalog')
             //{
@@ -2820,6 +3004,6 @@
             //    ));
             //}
-            
-            
+
+
             $ids = $this->bo->find(array($data['fields']['id'], $data['fields']['search']), $rules, array('order' => $data['fields']['search'], 'sort' => 'ASC'));
 
@@ -2846,5 +3030,5 @@
                 'status' => 'ok'
             ));
-			
+
 			return;
         }*/
@@ -2856,5 +3040,5 @@
 			@author Raphael Derosso Pereira
 
-			@param array str_data A serialized array containing the ID's of the entries 
+			@param array str_data A serialized array containing the ID's of the entries
 				to be taken, the fields to be taken and the rules to be used on the
 				retrieval:
@@ -2869,5 +3053,5 @@
 		{
 			$data = unserialize($str_data);
-			
+
 			if (!is_array($data) or !count($data) or !count($data['fields']) or !count($data['ids']))
 			{
@@ -2879,5 +3063,5 @@
 
 			$entries = $this->bo->catalog->get_multiple_entries($data['ids'], $data['fields']);
-			
+
 			if (!is_array($entries) or !count($entries))
 			{
@@ -2898,9 +3082,9 @@
 
 			@function get_all_entries
-			@abstract Returns the specified fields for all catalog's entries 
+			@abstract Returns the specified fields for all catalog's entries
 				in the default CC UI format
 			@author Raphael Derosso Pereira
 
-			@params array str_data A serialized array containing the fields to 
+			@params array str_data A serialized array containing the fields to
 				be grabbed, the maximum number of entries to be returned and a
 				boolean specifying if the calls refers to a new grab or to an
@@ -2911,8 +3095,8 @@
 		{
 			$data = unserialize($str_data);
-			
-			if (!is_array($data) or 
-			    !count($data) or 
-				!count($data['fields']) or 
+
+			if (!is_array($data) or
+			    !count($data) or
+				!count($data['fields']) or
 				!$data['maxlength'] or
 				(!$data['new'] and !$data['offset']))
@@ -2940,5 +3124,5 @@
 				$data['offset'] = 0;
 			}
-			
+
 			if ($data['maxlength'] != -1)
 			{
@@ -2951,5 +3135,5 @@
 
 			$prefs = ExecMethod('contactcenter.ui_preferences.get_preferences');
-			
+
 			$jsCode = array();
 			$count = 0;
@@ -2961,21 +3145,21 @@
 				}
 
-				if($this-> typeContact == 'groups') {				
-					
+				if($this-> typeContact == 'groups') {
+
 					foreach ($each as $field => $value)	{
-										
+
 						if ($field === 'title')	{
 							$optionName = '\\"'.$value.'\\"';
-							 
+
 						}
 						else if ($field === 'short_name')	{
-							
+
 							$jsCode[] = '_this.entries.options[_this.entries.options.length] = new Option("'.$optionName.' ('.$value.')", "'.$count.'");';
-							$count++;																					
-						}					
+							$count++;
+						}
 					}
 				}
-				
-				else  {	
+
+				else  {
 					foreach ($each as $field => $value)	{
 						if ($field === 'names_ordered')	{
@@ -2985,5 +3169,5 @@
 						}
 						else if ($field === 'connections')	{
-							
+
 							foreach ($value as $connection)		{
 								if ($connection['id_type'] == $prefs['personCardEmail'])	{
@@ -2998,7 +3182,7 @@
 
 			$jsCodeFinal = implode("\n", $jsCode);
-			
+
 			$nEntries = count($result);
-			
+
 			if (!$nEntries)
 			{
@@ -3018,5 +3202,5 @@
 			);
 		}
-		
+
 		/*********************************************************************\
 		 *                      Auxiliar Methods                             *
@@ -3024,9 +3208,9 @@
 
 		/*!
-		
+
 			@function save_session
 			@abstract Saves the data on the session
 			@author Raphael Derosso Pereira
-		
+
 		*/
 		function save_session()
@@ -3037,10 +3221,10 @@
 
 		/*!
-		
+
 			@function convert_tree
 			@abstract Converts the tree array in the BO format to a JS tree array compatible
 				with the one available in eGW
 			@author Raphael Derosso Pereira
-		
+
 			@param (array)  $tree    The tree in the BO format
 			@param (string) $name    The tree name
@@ -3076,5 +3260,5 @@
 					'caption' => $value['name']
 				);
-				
+
 				switch($value['type'])
 				{
@@ -3099,12 +3283,12 @@
 				$this->bo->catalog->src_info = $ldap->srcs[1];
 			}
-			
-			$ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);				
+
+			$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'];
 			$justThese = array("givenname","givenname","sn","telephonenumber","mail");
-			$sr = ldap_read($ds,$id, "objectClass=*",$justThese);							
-			$info = ldap_get_entries($ds, $sr);							
+			$sr = ldap_read($ds,$id, "objectClass=*",$justThese);
+			$info = ldap_get_entries($ds, $sr);
 			for($z = 0; $z < 5; $z++) {
-				$participant = $info[0][$justThese[$z]];													
+				$participant = $info[0][$justThese[$z]];
 				array_push($array_participants, $participant);
 			}
@@ -3112,22 +3296,22 @@
 			ldap_close($ds);
 			echo serialize($array_participants);
-		}	
-		
-		function get_catalog_participants_group($id) 
+		}
+
+		function get_catalog_participants_group($id)
 		{
 			if(!$this->bo->catalog->src_info) {
 				$ldap = CreateObject('contactcenter.bo_ldap_manager');
 				$this->bo->catalog->src_info = $ldap->srcs[1];
-			}			
-			$ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);			
-			$justThese = array("description","memberuid");			
-			$sr = ldap_read($ds,$id, "objectClass=*",$justThese);							
+			}
+			$ds = $GLOBALS['phpgw']->common->ldapConnect($this->bo->catalog->src_info['host'], $this->bo->catalog->src_info['acc'], $this->bo->catalog->src_info['pw'], true);
+			$justThese = array("description","memberuid");
+			$sr = ldap_read($ds,$id, "objectClass=*",$justThese);
 			$info = ldap_get_entries($ds, $sr);
 			$member_uids = $info[0]['memberuid'];
 			$contact['names_ordered'] = $info[0]['description'];
-			$filter = "";			
+			$filter = "";
 			for($z = 0; $z < count($member_uids); $z++) {
 				if($member_uids[$z])
-					$filter.="(uid=".$member_uids[$z].")";	
+					$filter.="(uid=".$member_uids[$z].")";
 			}
 			$array_participants = array();
@@ -3138,45 +3322,45 @@
 				$dn = implode(',',$valarray);
 				$justThese = array("cn","mail");
-				$sr = ldap_search($ds,$dn, $filter,$justThese);								
-				$info = ldap_get_entries($ds, $sr);							
+				$sr = ldap_search($ds,$dn, $filter,$justThese);
+				$info = ldap_get_entries($ds, $sr);
 				for($z = 0; $z < $info['count']; $z++) {
 					$participant =  '<font color=\'DARKBLUE\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;'.$info[$z]['cn'][0].'&quot; &lt;'.$info[$z]['mail'][0].'&gt;</font><br>';
-					$array_emails[$info[$z]['mail'][0]] = null; 								
-					array_push($array_participants, $participant);					
+				    $array_emails[$info[$z]['mail'][0]] = null;
+					array_push($array_participants, $participant);
 				}
 				ldap_close($ds);
-			}			
+			}
 			sort($array_participants);
-			$innerHTML = '';			
+			$innerHTML = '';
 			foreach($array_participants as $index => $participant){
 				$innerHTML .= $participant;
 			}
-			$return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);			 
+			$return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);
 			echo serialize($return);
 		}
 
-		function get_catalog_participants_list($id) 
+		function get_catalog_participants_list($id)
 		{
-			
-			$fields = $this->bo->catalog->get_fields(false);			
+
+			$fields = $this->bo->catalog->get_fields(false);
 			$fields['names_ordered'] = true;
-			$fields['mail_forwarding_address'] = true;			
-			$contact = $this->bo->catalog->get_single_entry($id,$fields);			
-			
+			$fields['mail_forwarding_address'] = true;
+			$contact = $this->bo->catalog->get_single_entry($id,$fields);
+
 			$array_participants = array();
 			$array_emails = array();
 
 			$filter = null;
-			for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) {			
+			for($z = 0; $z < $contact['mail_forwarding_address']['count']; $z++) {
 					if(strstr($contact['mail_forwarding_address'][$z],'@')) {
 						$filter.="(mail=".$contact['mail_forwarding_address'][$z].")";
 						$array_emails[$contact['mail_forwarding_address'][$z]] = "<font color=black>".$contact['mail_forwarding_address'][$z]."</font>";
-					}																
-					else 
+					}
+					else
 						$array_participants[$z] = "<font color=red>".$contact['mail_forwarding_address'][$z]."</font>";
-			}					
-			
+			}
+
 			if($filter) {
-				$filter = "(|".$filter.")";							
+				$filter = "(|".$filter.")";
 				if(!$this->bo->catalog->src_info) {
 					$ldap = CreateObject('contactcenter.bo_ldap_manager');
@@ -3184,30 +3368,29 @@
 				}
 				$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'];
 				$justThese = array("cn","mail");
-				$sr = ldap_search($ds,$dn, $filter,$justThese);								
-				$info = ldap_get_entries($ds, $sr);							
+				$sr = ldap_search($ds,$dn, $filter,$justThese);
+				$info = ldap_get_entries($ds, $sr);
 				for($z = 0; $z < $info['count']; $z++) {
 					$participant =  '<font color=\'DARKBLUE\'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;'.$info[$z]['cn'][0].'&quot; &lt;'.$info[$z]['mail'][0].'&gt;</font><br>';
-					$array_emails[$info[$z]['mail'][0]] = null; 								
-					array_push($array_participants, $participant);					
-				}
-				
+					$array_emails[$info[$z]['mail'][0]] = null;
+					array_push($array_participants, $participant);
+				}
+
 				foreach($array_emails as $index => $email)
-					if($email) 
-						array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>");				
-												
+					if($email)
+						array_push($array_participants, "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$email."<br>");
+
 				ldap_close($ds);
 			}
 			sort($array_participants);
-			$innerHTML = '';			
+			$innerHTML = '';
 			foreach($array_participants as $index => $participant){
 				$innerHTML .= $participant;
 			}
-			$return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);			 
+			$return = array('size' => count($array_participants), 'names_ordered'=> $contact['names_ordered'], 'inner_html' => $innerHTML);
 			echo serialize($return);
-		}	
-		
+		}
+
 		function export_contacts($typeExport){
 
@@ -3218,51 +3401,82 @@
 			if(!count($contacts))
 				echo null;
-			
+
+/**rev 104**/
+			// Essa iteraï¿œï¿œo transforma uma esturuta com contatos redundantes e separados por email ou tel.
+			// em outra com apenas 1 elemento pra cada contato
+	/*		$i=0;
+			foreach($contacts as $object){
+				$i=($object['id_contact'] - 1);
+				$all_contacts[$i]['name']=$object['names_ordered'];
+				if ($object['id_typeof_contact_connection'] == 1)
+					$all_contacts[$i]['email']=$object['connection_value'];
+				else
+					$all_contacts[$i]['phone']=$object['connection_value'];
+			}
+	*/
+/*****/
+
 			switch($typeExport) {
 
 				case 'outlook_en':
 					$streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;".
+/**rev 104**/
+	/*						"Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";
+					foreach($all_contacts as $index => $object){
+						$streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n";
+					}
+	*/
 							"Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";							
 					foreach($contacts as $index => $object){
 						$streamBuffer.= $object['names_ordered'].";".$object['connection_value'].";;;;;;".$object['phone'].";;;\r\n";
 					}
+/*****/
 				break;
-				
+
 				case 'outlook_pt-BR':
-					$streamBuffer = "Nome;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;".
-					"Rua do endereço comercial;Cidade do endereço comercial;".
-					"CEP do endereço comercial;Estado do endereço comercial;".
-					"País/região do endereço comercial;Telefone comercial;Empresa;Cargo\r\n";							
+					$streamBuffer = "Nome;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;".
+					"Rua do endereï¿œo comercial;Cidade do endereï¿œo comercial;".
+					"CEP do endereï¿œo comercial;Estado do endereï¿œo comercial;".
+					"Paï¿œs/regiï¿œo do endereï¿œo comercial;Telefone comercial;Empresa;Cargo\r\n";
+/**rev 104**/
+				//	foreach($all_contacts as $index => $object){
+				//		$streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n";
 					foreach($contacts as $index => $object){
 						$streamBuffer.= $object['names_ordered'].";".$object['connection_value'].";;;;;;".$object['phone'].";;;;;;;;\r\n";
+/******/
 					}
 				break;
-				
+
 				case 'outlook2000_pt-BR':
 					$streamBuffer = "\"Tratamento\",\"Nome\",\"Segundo Nome\",\"Sobrenome\",\"Sufixo\",".
-					"\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereço comercial\",\"Rua do endereço comercial 2\",".
-					"\"Rua do endereço comercial 3\",\"Cidade do endereço comercial\",\"Estado do endereço comercial\",".
-					"\"CEP do endereço comercial\",\"País do endereço comercial\",\"Endereço residencial\",\"Rua residencial 2\",".
-					"\"Rua 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\",".
+					"\"Empresa\",\"Departamento\",\"Cargo\",\"Rua do endereï¿œo comercial\",\"Rua do endereï¿œo comercial 2\",".
+					"\"Rua do endereï¿œo comercial 3\",\"Cidade do endereï¿œo comercial\",\"Estado do endereï¿œo comercial\",".
+					"\"CEP do endereï¿œo comercial\",\"Paï¿œs do endereï¿œo comercial\",\"Endereï¿œo residencial\",\"Rua residencial 2\",".
+					"\"Rua 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\",\"Aniversário\",\"Anotações\",\"Caixa postal\",\"Categorias\",".
-					"\"Código da empresa\",\"Código do governo\",\"Cônjuge\",\"Conta\",\"Endereço de correio eletrônico\",".
-					"\"Nome de exibição do correio eletr.\",\"Endereço de correio eletrônico 2\",".
-					"\"Nome de exibição do correio eletr.2\",\"Endereço de correio eletrônico 3\",".
-					"\"Nome de exibição do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",".
-					"\"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\",".
+					"\"Radiofone\",\"Telefone TTY/TDD\",\"Telex\",\"Aniversï¿œrio\",\"Anotaï¿œï¿œes\",\"Caixa postal\",\"Categorias\",".
+					"\"Cï¿œdigo da empresa\",\"Cï¿œdigo do governo\",\"Cï¿œnjuge\",\"Conta\",\"Endereï¿œo de correio eletrï¿œnico\",".
+					"\"Nome de exibiï¿œï¿œo do correio eletr.\",\"Endereï¿œo de correio eletrï¿œnico 2\",".
+					"\"Nome de exibiï¿œï¿œo do correio eletr.2\",\"Endereï¿œo de correio eletrï¿œnico 3\",".
+					"\"Nome de exibiï¿œï¿œo do correio eletr.3\",\"Datas especiais\",\"Disponibilidade da Internet\",".
+					"\"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\"\r\n";
+
+/**rev 104**/
+					//foreach($all_contacts as $index => $object){
+					//	$streamBuffer.= ",\"".$object['name']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,\"".$object['email']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
 					foreach($contacts as $index => $object){
 						$streamBuffer.= ",\"".$object['names_ordered']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,\"".$object['connection_value']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
+/******/
 					}
 				break;
-				
+
 				case 'outlook2000_en':
 					$streamBuffer = "Title,First Name,Middle Name,Last Name,Suffix,Company,Department,Job Title,".
@@ -3276,23 +3490,40 @@
 					"Gender,Government ID Number,Hobby,Initials,Internet Free Busy,Keywords,Language,Location,Manager's Name,Mileage,Notes,".
 					"Office Location,Organizational ID Number,PO Box,Priority,Private,Profession,Referred By,Sensitivity,Spouse,User 1,User 2,User 3,User 4,Web Page\r\n";
+
+/**rev 104**/
+					//foreach($all_contacts as $index => $object){
+					//	$streamBuffer.= ",".$object['name'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,".$object['email'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
 					foreach($contacts as $index => $object){
 						$streamBuffer.= ",".$object['names_ordered'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,".$object['connection_value'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
+/*******/
 					}
 				break;
-					
+
 				case 'thunderbird':
-					$streamBuffer = "\n";							
+					$streamBuffer = "\n";
+
+/**rev 104**/
+					//foreach($all_contacts as $index => $object){
+					//	$streamBuffer.= ",,".$object['name'].",,".$object['email'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
 					foreach($contacts as $index => $object){
 						$streamBuffer.= ",,".$object['names_ordered'].",,".$object['connection_value'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n";
+
+/******/
 					}
 				break;
-				
+
 				case 'expresso':
 					$streamBuffer = "Nome,Email,Telefone\r\n";
+
+/**rev 104**/
+					//foreach($all_contacts as $index => $object){
+					//	$streamBuffer.= $object['name'].",".$object['email'].",".$object['phone']."\r\n";
 					foreach($contacts as $index => $object){
 						$streamBuffer.= $object['names_ordered'].",".$object['connection_value'].",".$object['phone']."\r\n";
+ 
+/******/
 					}
 				break;
-				
+
 			}
 
@@ -3302,5 +3533,5 @@
 			if(!$f)
 				echo null;
-		
+
 			fputs($f,$streamBuffer);
 			fclose($f);
@@ -3315,5 +3546,5 @@
        			 $re_d = '\x' . dechex(ord($delimiter));            //format for regexp
         		$re_tq = '\x' . dechex(ord($text_qualifier));    //format for regexp
-        		
+
         		$fields = array();
         		$field_num = 0;
@@ -3321,15 +3552,15 @@
             		if($text{0} == $text_qualifier) {
                 		preg_match('/^' . $re_tq . '((?:[^' . $re_tq . ']|(?<=\x5c)' . $re_tq . ')*)' . $re_tq . $re_d . '?(.*)$/', $text, $matches);
-		               
+
         		        $value = str_replace('\\' . $text_qualifier, $text_qualifier, $matches[1]);
              			$text = trim($matches[2]);
-               
+
                 		$fields[$field_num++] = $value;
             		} else {
                 		preg_match('/^([^' . $re_d . ']*)' . $re_d . '?(.*)$/', $text, $matches);
-		               
+
         		        $value = $matches[1];
                			$text = trim($matches[2]);
-               
+
               		  	$fields[$field_num++] = $value;
             	}
@@ -3340,13 +3571,19 @@
 		}
 
+		//funcao alterada para importar outros campos alem de nome, telefone e email, de arquivo csv (Outlook 2000)
+		//em 08/04/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br);
+		//Foi adicionada uma funcao (escapesheelcmd()) nas variaveis para que caracteres especiais sejam ignorados
+		//durante a importacao dos contatos; o processo estava travando por causa de caracteres em campos como nome,
+		//sobrenome, notas e e-mail;
+		//em 19/06/2009 - Rommel Cysne (rommel.cysne@serpro.gov.br);
 		function import_contacts($typeImport){
 
-			if($file = $_SESSION['contactcenter']['importCSV']) {				
-				unset($_SESSION['contactcenter']['importCSV']);				
+			if($file = $_SESSION['contactcenter']['importCSV']) {
+				unset($_SESSION['contactcenter']['importCSV']);
 				$len = filesize($file);
 				$count = 0;
 				$return = array('error' => false, '_new' => 0, '_existing' => 0, '_failure' => 0);
    				$handle = @fopen($file, "r") or die(serialize($return['error'] = true));
-   				
+
 				$input_header = fgets($handle);
 				if ($typeImport == 'outlook')
@@ -3354,10 +3591,10 @@
 				else if ($typeImport == 'auto')
 				$delim = strstr($input_header,',') ? ',' : ';';
-				else  
+				else
 					$delim = ',';
 				$csv_header = $this->parse_line($input_header,$delim);
 				$firstContact = fgets($handle);
 				preg_match("/\"(.+)\"[,;]/sU",$firstContact,$matches); // yahoo csv
-   				rewind($handle);	   			
+   				rewind($handle);
 
    				$header = @fgetcsv($handle, $len, $delim) or die(serialize($return['error'] = true));
@@ -3368,8 +3605,8 @@
    					return;
    				}
-   				
+
    				if ($matches[0][strlen($matches[0])-1] == ';')
 					$delim = ';';
-   				
+
 			$boGroup = CreateObject('contactcenter.bo_group');
 			$boPeople = CreateObject('contactcenter.bo_people_catalog');
@@ -3377,11 +3614,32 @@
 					case 'outlook2000':
 						$name_pos=1;
+						$name2_pos=2;
+						$name3_pos=3;
+						$addr1_pos=8;
+						$cep_pos=13;
+						$addr2_pos=22;
+						$fax_pos=30;
+						$phone_pos=31;
+						$resPhone_pos=37;
+						$cellPhone_pos=40;
+						$pager_pos=43;
+						$birth_pos=48;
+						$notes_pos=49;
 						$email_pos=56;
-						$phone_pos=44;
+						$altEmail_pos=59;
+
 						break;
 					case 'outlook':
-						$name_pos=0;
-						$email_pos=1;
+						$name_pos=3;
+						$email_pos=4;
 						$phone_pos=7;
+						$resPhone_pos=10;
+						$cellPhone_pos=12;
+						$addr1_pos=13;
+						$cep_pos=15;
+						$phone_pos=18;
+						$fax_pos=19;
+						$pager_pos=20;
+						$notes_pos=25;
 						break;
 					case 'thunderbird':
@@ -3398,23 +3656,68 @@
 						foreach($csv_header as $index => $fieldName)
 						{
-							switch(strtoupper($fieldName)){
-							case 'NAME':
-							case 'NOME':
-							case 'FIRST NAME':
+							switch($fieldName){
+							case 'Name':
+							case 'Nome':
+							case 'First Name':
 								$name_pos = $index;
 								break;
-							case 'E-MAIL':
-							case 'EMAIL':
-							case 'E-MAIL ADDRESS':
-							case 'ENDEREÇO DE CORREIO ELETRÔNICO':
-							case 'END. DE EMAIL':
+							case 'Second name':
+							case 'Segundo nome':
+								$name2_pos = $index;
+								break;
+							case 'Sobrenome':
+							case 'Surname':
+								$name3_pos = $index;
+								break;
+							case 'Business Street':
+							case 'Rua do endereÃ§o comercial':
+								$addr1_pos = $index;
+								break;
+							case 'Rua do endereÃ§o comercial 2':
+							case 'Outro endereÃ§o':
+								$addr2_pos = $index;
+								break;
+							case 'Business Postal Code':
+							case 'CEP do endereÃ§o comercial':
+								$cep_pos = $index;
+								break;
+							case 'Business Fax':
+							case 'Fax comercial':
+							case 'Fax':
+								$fax_pos = $index;
+								break;
+							case 'Home Phone':
+							case 'Telefone residencial':
+								$resPhone_pos = $index;
+								break;
+							case 'Mobile phone':
+							case 'Telefone celular':
+								$cellPhone_pos = $index;
+								break;
+							case 'Pager':
+								$pager_pos = $index;
+								break;
+							case 'Phone':
+							case 'Business Phone':
+							case 'Telefone':
+							case 'Telefone principal':
+							case 'Telefone comercial':
+								$phone_pos = $index;
+								break;
+							case 'AniversÃ¡rio':
+							case 'Birthdate':
+								$birth_pos = $index;
+							case 'AnotaÃ§Ãµes':
+							case 'Notes':
+								$notes_pos = $index;
+							case 'E-mail':
+							case 'Email':
+							case 'E-mail Address':
+							case 'Endereï¿œo de correio eletrï¿œnico':
+							case 'End. de email':
 								$email_pos = $index;
 								break;
-							case 'HOME PHONE':
-							case 'PHONE':
-							case 'TELEFONE':
-							case 'TELEFONE PRINCIPAL':
-							case 'TELEFONE COMERCIAL':
-								$phone_pos = $index;
+							case 'Endereï¿œo de correio eletrï¿œnico 2':
+								$altEmail_pos = $index;
 								break;
 							}
@@ -3422,48 +3725,95 @@
 						break;
 				}
-				
 
 				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]]);
+					$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]]);
+
+					$addr1		= trim($row[$header[$addr1_pos]]);
+					$addr2		= trim($row[$header[$addr2_pos]]);
+					$cep		= trim($row[$header[$cep_pos]]);
+					$fax		= trim($row[$header[$fax_pos]]);
+					$resPhone	= trim($row[$header[$resPhone_pos]]);
+					$cellPhone	= trim($row[$header[$cellPhone_pos]]);
+					$pager		= trim($row[$header[$pager_pos]]);
+					$birth		= trim($row[$header[$birth_pos]]);
+					$notes		= trim($row[$header[$notes_pos]]);
+					$altEmail	= trim($row[$header[$altEmail_pos]]);
+
+					$full_name = escapeshellcmd($full_name);
 					$array_name = explode(' ', str_replace('"','',(str_replace('\'','',$full_name))));
-					$sdata['given_names'] = $array_name[0];
+					$sdata['given_names'] = escapeshellcmd($array_name[0]);
 					$array_name[0] = null;
 					$sdata['family_names'] = trim(implode(' ',$array_name));
+					if($sdata['family_names'] == '')
+					{
+						$sdata['family_names'] = escapeshellcmd($name2) . " " . escapeshellcmd($name3);
+					}
+
 					$sdata['connections']['default_email']['connection_name'] = lang('Main');
-					$sdata['connections']['default_email']['connection_value'] = $email;
+					$sdata['connections']['default_email']['connection_value'] = escapeshellcmd($email);
 
 					$sdata['connections']['default_phone']['connection_name'] = lang('Main');
+					$sdata['connections']['default_phone']['connection_value'] = escapeshellcmd($phone);
+
+					$sdata['connections']['fax']['connection_name'] = lang('Fax');
+					$sdata['connections']['fax']['connection_value'] = escapeshellcmd($fax);
+
+					$sdata['connections']['residencial_phone']['connection_name'] = lang('Residencial');
+					$sdata['connections']['residencial_phone']['connection_value'] = escapeshellcmd($resPhone);
+
+					$sdata['connections']['cellular_phone']['connection_name'] = lang('Cellphone');
+					$sdata['connections']['cellular_phone']['connection_value'] = escapeshellcmd($cellPhone);
+
+					$sdata['connections']['pager']['connection_name'] = lang('Pager');
+					$sdata['connections']['pager']['connection_value'] = escapeshellcmd($pager);
+
+					$sdata['connections']['alternative_email']['connection_name'] = lang('Alternative');
+					$sdata['connections']['alternative_email']['connection_value'] = escapeshellcmd($altEmail);
+
+					$sdata['addresses']['addr1']['address_value'] = escapeshellcmd($addr1);
+					$sdata['addresses']['addr2']['address_value'] = escapeshellcmd($addr2);
+					$sdata['addresses']['cep']['address_value'] = escapeshellcmd($cep);
+
+					$array_birth = explode("/",$birth);
+
+					$sdata['birthdate'] = escapeshellcmd(date('Y-m-d', mktime(0,0,0,$array_birth[1],$array_birth[0],$array_birth[2])));
+
+					$sdata['notes'] = escapeshellcmd($notes);
+					$sdata['is_quick_add'] = true;
 					$sdata['connections']['default_phone']['connection_value'] = $phone;
-					$sdata['is_quick_add'] = true;
-					
+
 					// 	verifica se email já existe!
+					$email = escapeshellcmd($email);
 					$contact = $boGroup->verify_contact($email);
-										
+
 					if(!$sdata['given_names'] && $email){
 							$a_email = explode("@",$email);
-							$sdata['given_names'] = $a_email[0];
+							$sdata['given_names'] = escapeshellcmd($a_email[0]);
 					}
 
-					$line_iteration = $return['_failure'] + $return['_existing'] + $return['_new']; 
+					$line_iteration = $return['_failure'] + $return['_existing'] + $return['_new'];
+
 					if($contact){
 						$return['_existing']++;
-					}														
-					else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
+					}
+					else if(!eregi("^[/_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
 						$return['_failure']++;
 						$return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid E-Mail address: " . $email ."<br>";
 					}
 					else if (!$sdata['given_names'] || !$email || !$boPeople ->quick_add($sdata)){
-						$return['_failure']++;							
+						$return['_failure']++;
 						$return['_failure_status'] .= "Line: " . ($line_iteration + 2) . ", Invalid Name: " . $sdata['given_names'] ."<br>";
 					}
 					else
 						$return['_new']++;
-       			}       			
+       			}
    				fclose($handle);
 				unlink($file);
@@ -3474,46 +3824,4 @@
 			echo serialize($return);
 		}
-/*
-		function convert_tree($tree, $name, &$iconDir, $parent='0')
-		{
-			$new = null;
-			$code = null;
-			
-			if ($parent === '0')
-			{
-
-				$code .= $name.".add(new dNode({id:'0', caption: '".lang('Catalogues')."'}),'none');\n";
-			}
-			
-			foreach ($tree as $id => $value)
-			{
-				$title = $value['name'];
-
-				switch ($value['type'])
-				{					
-					case 'unknown':
-						$code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption:'{$value['name']}', onFirstOpen: 'getCatalogTree(\\'{$parent}.{$id}\\');', onClick: 'getCatalogTree(\\'{$parent}.{$id}\\'); waitForTree(\\'{$parent}.{$id}\\', 0)'}),'$parent');\n"; 
-						break;
-					
-					case 'catalog_group':
-						$code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}'}),'$parent');\n"; 
-						$code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id);
-						break;
-
-					case 'mixed_catalog_group':
-						$code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}', onClick: 'setCatalog(\\'{$parent}.{$id}\\')'}),'$parent');\n";
-
-						$code .= $this->convert_tree($value['sub_branch'],$name,$iconDir,$parent.'.'.$id);
-						break;
-					
-					case 'catalog':
-						$code .= $name.".add(new dNode({id: '{$parent}.{$id}', caption: '{$value['name']}', onClick: 'setCatalog(\\'{$parent}.{$id}\\')'}),'$parent');\n";
-						
-				}
-			}
-			
-			return $code;
-		}
-*/
 	}
 
Index: trunk/contactcenter/js/cc.js
===================================================================
--- trunk/contactcenter/js/cc.js	(revision 1517)
+++ trunk/contactcenter/js/cc.js	(revision 1599)
@@ -61,5 +61,5 @@
 var CC_full_add_const = false;
 var CC_full_add_photo = false;
-	
+
 var CC_last_height = window.innerHeight;
 var CC_last_width = window.innerWidth;
@@ -94,5 +94,5 @@
 		 photo_input = photo_frame.contentDocument.createElement('input');
 	}
-	
+
 	photo_frame.id = 'cc_photo_frame';
 	photo_frame.style.position = 'absolute';
@@ -100,12 +100,12 @@
 	photo_frame.style.top = '600px';
 	photo_frame.style.left = '0px';
-	
+
 	photo_form.id = 'cc_photo_form';
 	photo_form.method = 'POST';
 	photo_form.enctype = 'multipart/form-data';
-	
+
 	photo_input.id = 'cc_photo_input';
 	photo_input.type = 'file';
-	
+
 	if (is_ie)
 	{
@@ -117,5 +117,5 @@
 	}
 	photo_form.appendChild(photo_input);
-	
+
 }
 
@@ -125,5 +125,5 @@
 	var obj = Element(id);
 	var max = obj.options.length;
-	
+
 	if (option == undefined)
 	{
@@ -165,5 +165,5 @@
 function openFullAdd(){
 	// Build the FullAdd Window.
-	if(!fullAddWin && !is_ie) 
+	if(!fullAddWin && !is_ie)
 		__f();
 
@@ -172,5 +172,5 @@
 	fullAddWin.open();
 	tabs._showTab('cc_contact_tab_0');
-	Element("cc_conn_type_1").checked = false;	
+	Element("cc_conn_type_1").checked = false;
 	Element("cc_conn_type_2").checked = false;
 	Element("cc_conn_type_sel").disabled = true;
@@ -243,5 +243,6 @@
 /************ Edit Group *************/
 function editGroup(id){
-	populateEditGroup(id);	
+	populateEditGroup(id);
+	ccAddGroup.window.open();
 }
 
@@ -253,5 +254,5 @@
 	Updates all the constant fields in the
 	full add window, like Prefixes, Suffixes,
-	Countries, Types and Shared catalogs
+	Countries and Types
 */
 
@@ -268,5 +269,5 @@
                         return;
                 }
-		
+
 		if (typeof(data[3]) == 'object')
                 {
@@ -298,5 +299,5 @@
 {
 	CC_full_add_const = false;
-	
+
 	setTimeout('populateFullAddConstAsync()', 10);
 }
@@ -306,9 +307,9 @@
 	var handler = function(responseText)
 	{
-		//Element('cc_debug').innerHTML = responseText;		
+		//Element('cc_debug').innerHTML = responseText;
 		var data = unserialize(responseText);
 		var i = 1;
 		var j;
-		
+
 		if (typeof(data) != 'object')
 		{
@@ -316,5 +317,5 @@
 			return;
 		}
-		
+
 		/* Populate Prefixes */
 		for (j in data[0])
@@ -323,5 +324,5 @@
 			i++;
 		}
-		
+
 		/* Populate Suffixes */
 		i = 1;
@@ -345,13 +346,13 @@
 		{
 			Element('cc_addr_countries').options[i] = new Option(data[3][j], j);
-			
+
 			if (j == 'BR' || j == 'br')
 			{
 				CC_br_index = i;
 			}
-			
+
 			i++;
 		}
-		
+
 		/* Populate Connection Types */
 		i = 1;
@@ -361,5 +362,5 @@
 			i++;
 		}
-		
+
 		/* Populate Relations Types */
 		i = 0;
@@ -369,5 +370,5 @@
 			i++;
 		}
-		
+
 		CC_full_add_const = true;
 
@@ -397,5 +398,4 @@
 		//populateRelations(data['relations']);
 	};
-
 	Connector.newRequest('populateFullEdit', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_full_data&id=' + id + "&catalog="+catalog, 'GET', handler);
 }
@@ -416,7 +416,7 @@
 		select_contact_list += data['contact_list'] + "</select>";
 		options_contact_list.innerHTML = select_contact_list;
-
-		if(data['id_group']) {		
-			Element('title').value =  data['title'];
+		
+		if(data['id_group']) {
+			Element('title').value =  data['title'];	
 			if(data['contact_in_list']) {					
 				for(i = 0; i < data['contact_in_list'].length; i++) {				
@@ -425,6 +425,8 @@
 					option.text = data['contact_in_list'][i]['names_ordered']+' ('+data['contact_in_list'][i]['connection_value']+')';				
 					Element('contact_in_list').options[Element('contact_in_list').options.length] = option;
-				}		
-			}
+				}
+			}		
+			
+			Element('title').value =  data['title'];
 		}
 				
@@ -439,5 +441,5 @@
 	id = typeof(id) == 'undefined' ? id = 0 :  id;
 	
-	ccAddGroup.clear(true);				
+	ccAddGroup.clear(true);			
 	if(!shared)
 		Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id, 'GET', handler);
@@ -445,4 +447,5 @@
 		Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id+'&shared_from='+shared, 'GET', handler);
 }
+
 
 
@@ -478,5 +481,5 @@
 		return false;
 	}
-	
+
 	/* First thing: Send Photo */
 	if (Element('cc_pd_select_photo').value != '' && !is_ie)
@@ -496,5 +499,5 @@
 			frame = old_frame;
 		}
-		
+
 		frame.id = 'cc_photo_frame';
 		frame.style.visibility = 'hidden';
@@ -505,5 +508,5 @@
 
 		form = frame.contentDocument.createElement('form');
-		
+
 		var id_contact = Element('cc_full_add_contact_id').value;
 		form.id = 'cc_form_photo';
@@ -511,8 +514,8 @@
 		form.enctype = 'multipart/form-data';
 		form.action = 'http://'+ document.domain + Element('cc_root_dir').value+'../index.php?menuaction=contactcenter.ui_data.data_manager&method=post_photo&id='+(id_contact != '' && id_contact != 'null' ? id_contact : '');
-		
+
 		var input_clone = Element('cc_pd_select_photo').cloneNode(false);
 		form.appendChild(input_clone);
-		
+
 		frame.contentDocument.body.appendChild(form);
 		form.submit();
@@ -535,5 +538,5 @@
 	}
 	if (Element('cc_contact_sharing').style.display == 'none')
-		setTimeout('postFullAddInfo()', 100);
+    	setTimeout('postFullAddInfo()', 100);
 	else
 		setTimeout('postFullAddInfoShared()', 100);
@@ -561,4 +564,5 @@
 		updateCards();
 	};
+
 	Connector.newRequest('postFullAddInfo', CC_url+'post_full_add', 'POST', handler, getFullAddData());
 }
@@ -594,5 +598,5 @@
 
 	data['commercialAnd'] = replacer;
-	
+
 	if (Element('cc_full_add_contact_id').value != '' && Element('cc_full_add_contact_id').value != 'null')
 	{
@@ -600,16 +604,16 @@
 		data.length++;
 	}
-	
+
 	/* Owner do contato (Para o caso de adicao de contato compartilhado) */
 	if (Element('cc_contact_sharing').style.display == 'block')
 	{
 		var index = Element('cc_contact_shared_types').selectedIndex;
-		data['owner'] = replaceComAnd(owners[index], replacer); 
+		data['owner'] = replaceComAnd(owners[index], replacer);
 		data.length++;
 	}
-	
+
 	/* Status: Full Added */
 	data['id_status'] = CC_STATUS_FULL_ADD;
-	
+
 	/* Personal Data */
 	data['alias']         = replaceComAnd(Element('cc_pd_alias').value, replacer);
@@ -631,11 +635,8 @@
 		data['corporate_name'] = replaceComAnd(Element('cc_name_corporate').value, replacer);
 		data['job_title'] = replaceComAnd(Element('cc_job_title').value, replacer);
-		data['department'] = replaceComAnd(Element('cc_department').value, replacer);
+		data['department'] = replaceComAnd(Element('cc_dept').value, replacer);
 		data['web_page'] = replaceComAnd(Element('cc_web_page').value, replacer);
 		data.length += 18;
 	}
-
-		
-	
 
 	/* Addresses */
@@ -660,5 +661,5 @@
 				data['connections'] = new Array();
 			}
-			
+
 			for (var i in CC_contact_full_info['connections'][type])
 			{
@@ -672,5 +673,5 @@
 					data['connections']['connection'+connNumber] = new Array(5);
 				}
-				
+
 				data['connections']['connection'+connNumber]['id_connection'] = CC_contact_full_info['connections'][type][i]['id'];
 				data['connections']['connection'+connNumber]['id_typeof_connection'] = type;
@@ -681,10 +682,10 @@
 						data['connections']['connection'+connNumber]['connection_is_default']  = 'TRUE';
 					}
-					else 
+					else
 						data['connections']['connection'+connNumber]['connection_is_default']  = 'FALSE';
 				}
 
 //				data['connections']['connection'+connNumber].length = 5;
-				
+
 				empty = false;
 				connNumber++;
@@ -693,5 +694,5 @@
 
 		}
-		
+
 		if (!empty)
 		{
@@ -700,9 +701,9 @@
 		}
 	}
-	
+
 	if (CC_contact_full_info['removed_conns'])
 	{
 		empty = false;
-		
+
 		if (typeof(data['connections']) != 'object')
 		{
@@ -727,5 +728,5 @@
 	{
 		if (Element('cc_contact_shared_types').disabled == true)
-		{	
+		{
 			showMessage('Nenhum catálogo compartilhado existente');
 			return false;
@@ -737,6 +738,7 @@
 		}
 	}
-	
+
 	/* Check Personal Data */
+
 	if (Element('cc_pd_given_names').value == '')
 	{
@@ -756,5 +758,5 @@
 			for (var i in CC_contact_full_info['connections'][type]){
 				if((CC_contact_full_info['connections'][type][i]['value'].length < 4) ||
-					(!comp.test(CC_contact_full_info['connections'][type][i]['value']))){ 
+					(!comp.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;
@@ -767,5 +769,5 @@
 			}
 		}
-		
+
 	}
 
@@ -776,5 +778,5 @@
 
 /********* Personal Data Functions *********/
-/* 
+/*
  * data[0] => cc_pd_select_photo
  * data[1] => cc_pd_alias
@@ -788,8 +790,4 @@
  * data[9] => cc_pd_gpg_finger_print
  * data[10] => cc_pd_notes
- * data[11] => cc_name_corporate
- * data[12] => cc_job_title
- * data[13] => cc_department
- * data[14] => cc_we_page
  */
 
@@ -828,8 +826,8 @@
 {
 	Element('cc_addr_types').selectedIndex = 0;
-	
+
 	Element('cc_addr_countries').selectedIndex = 0;
 	Element('cc_addr_countries').disabled = true;
-	
+
 	Element('cc_addr_states').selectedIndex = 0;
 	Element('cc_addr_states').disabled = true;
@@ -882,7 +880,7 @@
 	var type = Element('cc_addr_types');
 	var oldSelected = type.value;
-	
+
 	saveAddressFields();
-	
+
 	if (oldSelected == '_NONE_')
 	{
@@ -890,13 +888,13 @@
 		return true;
 	}
-	
+
 	CC_addr_last_selected = type.selectedIndex;
-	
+
 	Element('cc_addr_countries').disabled = false;
-	
+
 	var data = CC_contact_full_info['addresses'];
 	var addrIndex  = 'address'+Element('cc_addr_types').value;
-	
-	if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object') 
+
+	if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object')
 	{
 		resetAddressFields();
@@ -907,9 +905,9 @@
 		return true;
 	}
-	
+
 	var addrTypeID = Element('cc_addr_types').value;
-	
+
 	data = CC_contact_full_info['addresses'][addrIndex];
-	
+
 	Element('cc_addr_id').value          			 = data['id_address']		? data['id_address']			: '';
 	Element('cc_addr_1').value            			= data['address1']			? data['address1']				: '';
@@ -933,5 +931,5 @@
 		states.selectedIndex = 0;
 		clearSelectBox(states, 4);
-		updateAddrCities();	
+		updateAddrCities();
 		return;
 	}
@@ -948,11 +946,11 @@
 	{
 		var data = unserialize(responseText);
-		
+
 		clearSelectBox(states, 1);
-			
+
 		if (typeof(data) != 'object')
 		{
 			showMessage(Element('cc_msg_err_contacting_server').value);
-	
+
 			return;
 		}
@@ -961,5 +959,5 @@
 		{
 			states.disabled = true;
-			cities.disabled = true;			
+			cities.disabled = true;
 			states.selectedIndex = 0;
 			cities.selectedIndex = 0;
@@ -1001,5 +999,5 @@
 		}
 	};
-	
+
 	Connector.newRequest('populateStates', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_states&country='+Element('cc_addr_countries').value, 'GET', handler);
 }
@@ -1029,5 +1027,5 @@
 			newState.disabled = false;
 			updateAddrNewStateOnMouseOut();
-			
+
 			cities.disabled = false;
 			clearSelectBox(cities, 3);
@@ -1040,11 +1038,11 @@
 		case '_NOSTATE_':
 			clearSelectBox(cities, 3);
-			
+
 			cities.disabled = false;
 			cities.selectedIndex = 0;
-			
+
 			requestStr = 'country='+Element('cc_addr_countries').value;
 			break;
-		
+
 		default:
 			requestStr = 'country='+Element('cc_addr_countries').value+'&state='+states.value;
@@ -1061,15 +1059,15 @@
 {
 	var cities = Element('cc_addr_cities');
-	
+
 	var handler = function (responseText)
 	{
 		var data = unserialize(responseText);
-		
+
 		clearSelectBox(cities, 1);
-		
+
 		if (typeof(data) != 'object')
 		{
 			showMessage(Element('cc_msg_err_contacting_server').value);
-			
+
 			return;
 		}
@@ -1116,5 +1114,5 @@
 		}
 	};
-	
+
 	Connector.newRequest('populateCities', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cities&'+requestStr, 'GET', handler);
 }
@@ -1122,5 +1120,5 @@
 function updateAddrNewStateOnMouseOver ()
 {
-	if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1) 
+	if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1)
 	{
 		Element('cc_addr_states_new').value = '';
@@ -1130,5 +1128,5 @@
 function updateAddrNewStateOnMouseOut ()
 {
-	if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1) 
+	if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1)
 	{
 		Element('cc_addr_states_new').value = Element('cc_msg_type_state').value;
@@ -1150,5 +1148,5 @@
 		return;
 	}
-	
+
 	Element('cc_addr_1').readonly = false;
 	Element('cc_addr_1').disabled = false;
@@ -1180,5 +1178,5 @@
 
 			//resetAddrFillingFields();
-			
+
 			return;
 
@@ -1188,5 +1186,5 @@
 			newCity.disabled = false;
 			updateAddrNewCityOnMouseOut();
-			
+
 			break;
 
@@ -1202,5 +1200,5 @@
 function updateAddrNewCityOnMouseOver ()
 {
-	if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1) 
+	if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1)
 	{
 		Element('cc_addr_cities_new').value = '';
@@ -1210,5 +1208,5 @@
 function updateAddrNewCityOnMouseOut ()
 {
-	if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1) 
+	if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1)
 	{
 		Element('cc_addr_cities_new').value = Element('cc_msg_type_city').value;
@@ -1224,10 +1222,10 @@
 		return true;
 	}
-	
-	var addrFields = new Array('cc_addr_1', 
-	                           'cc_addr_2', 
-							   'cc_addr_complement', 
+
+	var addrFields = new Array('cc_addr_1',
+	                           'cc_addr_2',
+							   'cc_addr_complement',
 							   'cc_addr_other',
-							   'cc_addr_postal_code', 
+							   'cc_addr_postal_code',
 							   'cc_addr_po_box',
 							   'cc_addr_countries',
@@ -1236,5 +1234,5 @@
 
 	var empty = true;
-	
+
 	for (var i = 0; i < 8; i++)
 	{
@@ -1245,5 +1243,5 @@
 		}
 	}
-				
+
 	if (empty)
 	{
@@ -1274,5 +1272,5 @@
 		default:
 			addrInfo['id_country'] = Element('cc_addr_countries').value;
-		
+
 	}
 
@@ -1288,5 +1286,5 @@
 		default:
 			addrInfo['id_state'] = Element('cc_addr_states').value;
-		
+
 	}
 
@@ -1301,6 +1299,6 @@
 		default:
 			addrInfo['id_city'] = Element('cc_addr_cities').value;
-		
-	}	
+
+	}
 
 	addrInfo['id_typeof_address']  = Element('cc_addr_types').options[lastIndex].value;
@@ -1315,15 +1313,15 @@
 	CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value] = addrInfo;
 
-	if (Element('cc_addr_cities').value == '_NEW_' && 
+	if (Element('cc_addr_cities').value == '_NEW_' &&
 	    Element('cc_msg_type_city').value !=  Element('cc_addr_cities_new').value &&
 		Element('cc_addr_cities_new').value != '')
 	{
 		var addrRootInfo = CC_contact_full_info['addresses']['new_cities'];
-		
+
 		if (!addrRootInfo)
 		{
 			addrRootInfo = new Array();
 		}
-		
+
 		var i = addrRootInfo.length;
 		addrRootInfo[addrInfo['id_typeof_address']] = new Array();
@@ -1334,15 +1332,15 @@
 	}
 
-	if (Element('cc_addr_states').value == '_NEW_' && 
-	    Element('cc_msg_type_state').value !=  Element('cc_addr_states_new').value && 
+	if (Element('cc_addr_states').value == '_NEW_' &&
+	    Element('cc_msg_type_state').value !=  Element('cc_addr_states_new').value &&
 		Element('cc_addr_states_new').value != '')
 	{
 		var addrRootInfo = CC_contact_full_info['addresses']['new_states'];
-		
+
 		if (!addrRootInfo)
 		{
 			addrRootInfo = new Array();
 		}
-		
+
 		var i = addrRootInfo.length;
 		addrRootInfo[addrInfo['id_typeof_address']] = new Array();
@@ -1374,16 +1372,27 @@
 	for(idx_conn; idx_conn < cc_conn_default.options.length; idx_conn++)
 		if(cc_conn_default.options[idx_conn].value == _label)
-			break;	
-	
+			break;
+
 	if(idx_conn == cc_conn_default.options.length)
 		cc_conn_default.options[idx_conn] = new Option (_label,_label, false,false);
-			
+
 	if (!document.all)
 	{
-		return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+
-		//'<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;" 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>';
+		if (Element("cc_conn_type_1").checked)
+		{
+			return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+
+			//'<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;' +
+			'<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>';
+		}
+		else if (Element("cc_conn_type_2").checked)
+		{
+			return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+
+			//'<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="50" 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>';
+		}
 	}
 	else
@@ -1409,5 +1418,5 @@
 		img.align = 'top';
 		img.onclick = function(e){ removeConnField(remove_id);};
-		
+
 		for (var i = 0; i < 3; i++)
 		{
@@ -1420,5 +1429,5 @@
 
 		inputs[1].id = 'cc_conn_name_'+CC_conn_count;
-		inputs[1].type = 'hidden';		
+		inputs[1].type = 'hidden';
 
 		inputs[2].id = 'cc_conn_value_'+CC_conn_count;
@@ -1449,19 +1458,19 @@
 		|| typeof(CC_contact_full_info['connections'][CC_conn_last_selected]) == 'undefined'
 		|| typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) == 'undefined');
-	
-	if(_emptyLine) {	
-		
+
+	if(_emptyLine) {
+
 		if(Element("cc_conn_type_sel").value == '-1'){
-				return false;	
-		}
-		
+				return false;
+		}
+
 		for(k = 0; k < CC_conn_count; k++) {
 			if(Element("cc_conn_name_"+k) && Element("cc_conn_name_"+k).value != "" && Element("cc_conn_name_"+k).value == Element("cc_conn_type_sel").value) {
 				alert('Você já possui uma entrada para o tipo "'+Element("cc_conn_type_sel").value+'"!');
-				Element("cc_conn_type_sel").options.selectedIndex = 0;				
+				Element("cc_conn_type_sel").options.selectedIndex = 0;
 				return false;
 			}
 		}
-	}	
+	}
 	if (!document.all)
 	{
@@ -1490,5 +1499,5 @@
 
 function connRemoveLine(id)
-{	
+{
 	var p = Element(id).parentNode;
 	var cc_conn_default = Element("cc_phone_default").style.display == '' ? Element("cc_phone_default") : Element("cc_email_default");
@@ -1529,5 +1538,5 @@
 		}
 	}
-	
+
 	CC_conn_count = 0;
 }
@@ -1551,5 +1560,5 @@
 function updateConnFields()
 {
-	
+
 	var connID;
 	var i;
@@ -1560,18 +1569,18 @@
 	var cc_conn_is_default = '';
 	var selected_index = '';
-	
+
 	cc_conn_type_sel.disabled = false;
 	div_cc_conn_is_default.style.display = "";
-	
+
 	for(var i = 0;i < cc_conn_type_sel.options.length; i++)
-		cc_conn_type_sel.options[i--] = null;	
-		
+		cc_conn_type_sel.options[i--] = null;
+
 	if(Element('cc_conn_type_1').checked) {
 	    var lang_new_email = Element('cc_msg_new_email').value;
 	    var lang_main = Element('cc_msg_main').value;
-	    var lang_alternative = Element('cc_msg_alternative').value;	
-	    cc_conn_type_sel[0] = new Option(lang_new_email,'-1');	
+	    var lang_alternative = Element('cc_msg_alternative').value;
+	    cc_conn_type_sel[0] = new Option(lang_new_email,'-1');
 	    cc_conn_type_sel[1] = new Option(lang_main,lang_main);
-	    cc_conn_type_sel[2] = new Option(lang_alternative,lang_alternative);	
+	    cc_conn_type_sel[2] = new Option(lang_alternative,lang_alternative);
 		connID = 1;
 		selected_index = cc_email_default.options.selectedIndex;
@@ -1581,7 +1590,7 @@
 
 		var lang_select_email = Element('cc_msg_select_email').value;
-		cc_email_default.options[0] = new Option(lang_select_email,'-1');		
+		cc_email_default.options[0] = new Option(lang_select_email,'-1');
 		cc_phone_default.style.display = 'none';
-		cc_email_default.style.display = '';			
+		cc_email_default.style.display = '';
 		cc_conn_is_default = cc_email_default;
 	}
@@ -1596,8 +1605,8 @@
 		var lang_corporative_fax = Element('cc_msg_corporative_fax').value;
 		var lang_corporative_pager = Element('cc_msg_corporative_pager').value;
-		
-	    cc_conn_type_sel[0] = new Option(lang_new_telephone,'-1');	
+
+	    cc_conn_type_sel[0] = new Option(lang_new_telephone,'-1');
 	    cc_conn_type_sel[1] = new Option(lang_home,lang_home);
-	    cc_conn_type_sel[2] = new Option(lang_cellphone,lang_cellphone);	
+	    cc_conn_type_sel[2] = new Option(lang_cellphone,lang_cellphone);
 	    cc_conn_type_sel[3] = new Option(lang_work,lang_work);
 	    cc_conn_type_sel[4] = new Option(lang_fax,lang_fax);
@@ -1608,5 +1617,5 @@
 			cc_conn_type_sel[8] = new Option(lang_corporative_pager, lang_corporative_pager);
 		}
-		
+
 		connID = 2;
 		selected_index = cc_phone_default.options.selectedIndex;
@@ -1615,5 +1624,5 @@
 		}
 
-		var lang_choose_phone = Element('cc_msg_choose_phone').value;		
+		var lang_choose_phone = Element('cc_msg_choose_phone').value;
 		cc_phone_default.options[0] = new Option(lang_choose_phone,'-1');
 		cc_email_default.style.display = 'none';
@@ -1621,5 +1630,5 @@
 		cc_conn_is_default = cc_phone_default;
 	}
-			
+
 	Element("cc_conn_type_sel").options.selectedIndex = 0;
 	/* First save the data */
@@ -1627,12 +1636,12 @@
 
 	CC_conn_last_selected = connID;
-	
+
 	clearConn();
-	
+
 	if (connID == '_NONE_')
 	{	cc_conn_is_default.disabled = true;
 		return;
 	}
-	
+
 	/* If no data already available, return */
 	if (!CC_contact_full_info['connections'])
@@ -1658,5 +1667,5 @@
 			}
 		}
-	}	
+	}
 	if(cc_conn_is_default.options.length > selected_index)
 		cc_conn_is_default.options.selectedIndex = (selected_index == "-1" ? 0 : selected_index);
@@ -1679,5 +1688,5 @@
 			CC_contact_full_info['connections'][CC_conn_last_selected] = new Array();
 		}
-		else 
+		else
 		{
 			delete CC_contact_full_info['connections'][CC_conn_last_selected];
@@ -1691,8 +1700,8 @@
 				var subNodes = nodes[i].childNodes;
 				var found = false;
-				
+
 				for (var j = 0; j < subNodes.length; j++)
 				{
-					if (subNodes[j].childNodes.length > 0 && 
+					if (subNodes[j].childNodes.length > 0 &&
 					    subNodes[j].childNodes[0].id)
 					{
@@ -1702,5 +1711,5 @@
 							CC_contact_full_info['connections'][CC_conn_last_selected][k] = new Array();
 						}
-						
+
 					    if (subNodes[j].childNodes[0].id.indexOf('cc_conn_name') != -1)
 						{
@@ -1722,5 +1731,5 @@
 							else
 							{
-								CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = ''; 
+								CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = '';
 							}
 						}
@@ -1733,5 +1742,5 @@
 					}
 				}
-				
+
 				if (found)
 				{
@@ -1750,5 +1759,5 @@
 			delete CC_contact_full_info['connections'][CC_conn_last_selected];
 		}
-		
+
 	}
 
@@ -1776,5 +1785,5 @@
 	var number = randomString().toLowerCase();
 	var result = '';
-	
+
 	if(!is_ie)
 		result = prompt("Essa operação removerá TODOS os seus \ncontatos pessoais,  e  NÃO  PODERÁ  ser \ndesfeita. Digite o código abaixo:\n\tCódigo de confirmação: "+number);
@@ -1787,5 +1796,5 @@
 		else
 			alert('Código Incorreto');
-	}	
+	}
 }
 
@@ -1808,5 +1817,5 @@
 			return;
 		}
-		
+
 		if (data['status'] != 'ok')
 		{
@@ -1814,10 +1823,10 @@
 			return;
 		}
-		
+
 		setTimeout('updateCards()',80);;
 	};
-		
+
 	typeArg = (type == 'groups' ? 'group' : 'entry');
-		
+
 	Connector.newRequest('removeEntry', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_'+typeArg+'&remove=' + id, 'GET', handler);
 }
@@ -1842,5 +1851,5 @@
 	var w_height = 0;
 	var w_extra = 200;
-	
+
 	if (document.body.clientHeight)
 	{
@@ -1881,4 +1890,5 @@
 	}
 }
+
 function getActualPage ()
 {
@@ -1945,10 +1955,10 @@
 				final_page = 1;
 			}
-			
+
 			html_pages += '<a href="javascript:setPages('+npages+', '+ actual_page +', '+ final_page +')">...</a> ';
 
 			page = showing_page ? showing_page : actual_page;
 		}
-		
+
 		for (; page <= npages; page++)
 		{
@@ -2010,5 +2020,5 @@
 		Element('cc_panel_arrow_last').style.cursor = 'hand';
 	}
-	
+
 	Element('cc_panel_pages').innerHTML = html_pages;
 }
@@ -2022,13 +2032,13 @@
 			for (j = 0; j < 3; j++)
 				document.getElementById("cc_card:"+j+":"+i).innerHTML = '';
-		return false;
-	}
-	
-	if(type == 'groups' || type == 'shared_groups')
+			return false;
+	}
+
+	if(type == 'groups' || type =='shared_groups')
 		return populateGroupsInCards(data,type);
-	
+
 	var pos = 0;
 	var ncards = data[3].length;
-	
+
 	if (typeof(data[3]) == 'object' && ncards > 0)
 	{
@@ -2038,5 +2048,5 @@
 			{
 				id = 'cc_card:'+j+':'+i;
-			
+
 				for (var k = 0; k < data[2].length; k++)
 				{
@@ -2056,13 +2066,13 @@
 								break;
 						}
-						
+
 					}
-					
-					
+
+
 					/*if(data[2][k] ==  'cc_mail' && data[3][pos][k] == 'none' && !(ccTree.catalog_perms & 2) ) {
 						Element(id).style.display = 'none';
 						continue;
 					}*/
-				
+
 					if(data[3][pos][k] != 'none')
 					{
@@ -2079,10 +2089,9 @@
 									Element(id+':'+data[2][k]).innerHTML = data[3][pos][k];
 								}
-								if(data[3][pos][9]){
-									Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][9]+"</i></font></span>";	}
+								if(data[3][pos][12])
+									Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][12]+"</i></font></span>";	
 								break;
-							
+
 							case 'cc_mail':
-								
 								if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20))
 								{
@@ -2092,8 +2101,8 @@
 								else
 								{
-									Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>';									
+									Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>';
 								}
 								break;
-							
+
 							case 'cc_phone':
 								if (data[3][pos][k].length > 20)
@@ -2131,9 +2140,51 @@
 							case 'cc_forwarding_address':
 								var account_type = data[3][pos][k];
-															
+
 								if( !account_type)
 									break;
-																																																					
+
 								Element(id+':cc_icon_group').innerHTML =  '<span title="'+Element('cc_participants').value+'"  onmouseout="window.status=\'\';" onclick="ccListParticipants.showList(\''+ Element(id+':cc_id').value + '\',null,null,null,\''+account_type+'\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/people-mini.png" align="center">&nbsp;&nbsp;</span>';
+								break;
+
+							//Para tratar tamanho do campo "celular" do empregado
+							case 'cc_mobile':
+								if (data[3][pos][k].length > 20)
+								{
+									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
+									Element(id+':'+data[2][k]).title = data[3][pos][k];
+								}
+								else
+								{
+									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
+								}
+								Element(id+':cc_mobile').innerHTML = data[3][pos][k];
+								break;
+
+							//Para tratar tamanho do campo "matricula" do empregado
+							case 'cc_empNumber':
+								if (data[3][pos][k].length > 20)
+								{
+									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
+									Element(id+':'+data[2][k]).title = data[3][pos][k];
+								}
+								else
+								{
+									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20);
+								}
+								Element(id+':cc_empNumber').innerHTML = data[3][pos][k];
+								break;
+
+							//Para tratar tamanho do campo "departamento" do empregado
+							case 'cc_department':
+								if (data[3][pos][k].length > 15)
+								{
+									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15);
+									Element(id+':'+data[2][k]).title = data[3][pos][k];
+								}
+								else
+								{
+									Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15);
+								}
+								Element(id+':cc_department').innerHTML = data[3][pos][k];
 								break;
 
@@ -2146,11 +2197,13 @@
 								else
 								{
+									if (Element(id+':'+data[2][k]) == null) alert('É nulo');
 									Element(id+':'+data[2][k]).innerHTML = data[3][pos][k];
 								}
 						}
 					}
-				}				
+				}
+				
 				if (type == "shared_contacts") {
-					if (data[3][pos][8] & 4) 
+					if (data[3][pos][11] & 4) 
 						eval("document.getElementById(id + ':cc_card_edit').onclick = function(){editSharedContact(Element('"+id+"' + ':cc_id').value);};");
 					else 
@@ -2158,5 +2211,5 @@
 							alert(Element('cc_msg_not_allowed').value);
 						};
-					if (data[3][pos][8] & 8) 
+					if (data[3][pos][11] & 8) 
 						eval("document.getElementById(id + ':cc_card_remove').onclick = function(){removeEntry(Element('" + id + "' + ':cc_id').value);};");
 					else 
@@ -2165,7 +2218,5 @@
 						};
 				}
-				
-				
-				
+
 				if (--ncards == 0)
 				{
@@ -2173,5 +2224,5 @@
 					i = CC_max_cards[1];
 				}
-	
+
 				pos++;
 			}
@@ -2181,9 +2232,9 @@
 
 function populateGroupsInCards(data,type)
-{	
+{
 	var pos = 0;
-	var contacts = data[5];		
+	var contacts = data[5];
 	var ncards = data[3].length;
-	
+
 	if (typeof(data[3]) == 'object' && ncards > 0)
 	{
@@ -2193,13 +2244,13 @@
 			{
 				id = 'cc_card:'+j+':'+i;
-			
+
 				for (var k = 0; k < data[2].length; k++)
 				{
-				
+
 					if(data[3][pos][k] != 'none')
-					{	
-											
+					{
+
 						switch (data[2][k])
-						{							
+						{
 							case 'cc_title':
 								if (data[3][pos][k].length > 50)
@@ -2215,5 +2266,5 @@
 									Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][5]+"</i></font></span>";
 								break;
-							
+
 							case 'cc_short_name':
 								if (data[3][pos][k].length > (CC_visual == 'table'  ? 50 : 20))
@@ -2227,5 +2278,5 @@
 								}
 								break;
-							
+
 							case 'cc_contacts':
 
@@ -2236,23 +2287,23 @@
 								var email = "";
 
-								for (var d = 0; d < contacts.length; d++) {																																					
+								for (var d = 0; d < contacts.length; d++) {
 									contact += contacts[d]['names_ordered']+ ",";
 									email += contacts[d]['connection_value']+",";
 								}
-								
+
 								Element(id+':cc_participantes').innerHTML = '<span title="Ver Participantes" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccListParticipants.showList(\''+ Element(id+':cc_id').value+'value\', \''+contact+'\', \''+email+'\', \''+title+'\', \''+id_group+'\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img title="Ver participantes" align="center" src="templates/default/images/people-mini.png">&nbsp;&nbsp</span>';
-																					
+
 								break;
-							
+
 							case 'cc_id':
 								var id_contact = data[3][pos][k];
 								Element(id+':'+data[2][k]).value = data[3][pos][k];
-								 							
+
 								break;
-								
+
 						}
 					}
 				}
-	
+
 				if (type == "shared_groups") {
 					
@@ -2269,6 +2320,5 @@
 						};
 				}				
-				
-				
+
 				if (--ncards == 0)
 				{
@@ -2276,5 +2326,5 @@
 					i = CC_max_cards[1];
 				}
-	
+
 				pos++;
 			}
@@ -2305,5 +2355,5 @@
 	};
 
-	Connector.newRequest('setMaxCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=set_n_cards&ncards=' + ncards, 'GET'); 
+	Connector.newRequest('setMaxCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=set_n_cards&ncards=' + ncards, 'GET');
 }
 
@@ -2311,5 +2361,5 @@
 {
 	var coord = new Array();
-	
+
 	//Element('cc_card_space').innerHTML = '';
 	//return;
@@ -2318,5 +2368,5 @@
 	//card_space_width = parseInt(is_ie ? document.body.offsetWidth : window.innerWidth) - parseInt(Element('cc_left').offsetWidth) - parseInt(CC_card_extra) - 40;
 	card_space_height = parseInt(Element('cc_card_space').offsetHeight) - parseInt(CC_card_extra);
-	
+
 	card_width = CC_card_image_width + CC_card_extra;
 	card_height = CC_card_image_height + CC_card_extra;
@@ -2324,5 +2374,5 @@
 	ncols = parseInt(card_space_width / card_width);
 	nlines = parseInt(card_space_height / card_height);
-	
+
 	coord[0] = ncols;
 	//coord[1] = nlines;
@@ -2339,8 +2389,8 @@
 		if(type == 'groups' || type == 'shared_groups') {
 			html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' +
-            '<div style="border: 0px solid #999; position: relative;">' + 
+            '<div style="border: 0px solid #999; position: relative;">' +
 				'<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +
 				'<img title="'+Element('cc_msg_group_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editGroup(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' +
-				'<img title="'+Element('cc_msg_group_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,\'groups\');" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' + 
+				'<img title="'+Element('cc_msg_group_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,\'groups\');" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' +
 				'<span id="' + id + ':cc_title" 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_participantes" style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 15px; left: 15px"></span>' +
@@ -2348,10 +2398,10 @@
 				'<input id="' + id + ':cc_id" type="hidden">' +
 			'</div>' + '</td>';
-		
+
 		}
 		else {
 			html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' +
 				'<div style="border: 0px solid #999; position: relative;">' +
-					'<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' + 
+					'<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +
 						( ccTree.catalog_perms == 1 ?
 						'<span id="' + id + ':cc_icon_data" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1"></span>':'') +
@@ -2359,16 +2409,33 @@
 						'<img title="'+Element('cc_msg_card_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editContact(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' +
 						'<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);">' + 
+						'<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 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>'+ 
-						'<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: 60px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 12px; text-align: center; height: 10px;"></span>' + 
-						'<span id="' + id + ':cc_phone" style="position: absolute; top: 90px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + 
-						'<span id="' + id + ':cc_mail" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + 
-						'<span id="' + id + ':cc_alias" style="position: absolute; top: 95px; left: 10px; width: 60px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></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_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>' +
+						//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>' +
+						'<span id="' + id + ':cc_phone" style="position: absolute; top: 75px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
+						//Para exibir o celular empresarial do empregado na tabela
+						'<span id="' + id + ':cc_mobile" style="position: absolute; top: 90px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
+						'<span id="' + id + ':cc_mail" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
+						'<span id="' + id + ':cc_alias" style="position: absolute; top: 95px; left: 10px; width: 60px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' +
 					'<input id="' + id + ':cc_id" type="hidden">' +
 				'</div>' + '</td>';
-		}
-	
+
+		/*} else {
+                        html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' +
+            '<div style="border: 0px solid #999; position: relative;">' +
+                                '<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' +
+                                '<img title="'+Element('cc_msg_group_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editGroup(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' +
+                                '<img title="'+Element('cc_msg_group_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,\'groups\');" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' +
+                                '<span id="' + id + ':cc_title" 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_participantes" style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 15px; left: 15px"></span>' +
+                                '<span onMouseOver="this.title = \''+Element('cc_send_mail').value+'\'" id="' + id + ':cc_short_name" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' +
+                                '<input id="' + id + ':cc_id" type="hidden">' +
+                        '</div>' + '</td>';*/
+		}
 
 	return html_card;
@@ -2391,14 +2458,22 @@
 					'&nbsp;&nbsp;|&nbsp;&nbsp;'+
 					'<img  title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" src="templates/default/images/cc_x.png">'  +
-					'<input id="' + id + ':cc_id" type="hidden">'+										
+					'<input id="' + id + ':cc_id" type="hidden">'+
 					'</td></tr>';
-						
-			
-			}
-			else {
-				html_card = '<tr  style="height:20px" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE"><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+'\'" 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>' +		
+
+	//		if(type != 'groups'||type=='shared_groups') {
+            }
+            else {
+				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
+					'<td align="center" 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>' +
+					//Para exibir o celular empresarial do empregado na tabela
+					'<td align="center" 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
+					'<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_department"></span></td>' +
+					'<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_mobile"></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>' +
 					( ccTree.catalog_perms == 1 ?
 					'<td align="left"><span valign="bottom" id="' + id + ':cc_icon_data"></span></td>':'') +
@@ -2416,4 +2491,16 @@
 					'</td></tr>';
 			}
+			/*else {
+				html_card = '<tr width="40%" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE"><td width="auto" style="font-weight: normal; font-size: 10px; text-align: left; height: 10px;">' +
+					'<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+' => '+'\'+document.getElementById(\''+id + ':cc_title\').innerHTML"  id="' + id + ':cc_short_name"></span></td>' +
+					'<td align="left" width="55px">'+
+					'<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;'+
+					'<img  title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" src="templates/default/images/cc_x.png">'  +
+					'<input id="' + id + ':cc_id" type="hidden">'+
+					'</td></tr>';
+			}*/
 
 	return html_card;
@@ -2423,7 +2510,7 @@
 {
 	var pos;
-	
+
 	html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1"><table width="100%" border="0" cellpadding="0" cellspacing="3">';
-	
+
 	if (ncards > 0)
 	{
@@ -2445,5 +2532,5 @@
 		if((ccTree.catalog_perms & 2) && type != 'groups' && type !='shared_contacts' && type !='shared_groups')
 			html_cards += '<tr><td colspan=4 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>';
-	}	
+	}
 	else if (CC_max_cards != 0)
 	{
@@ -2465,5 +2552,5 @@
 	html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1">';
 	html_cards += '<table  border="0" cellpadding="0" cellspacing="' + CC_card_extra + '">';
-	
+
 	if (ncards > 0)
 	{
@@ -2484,5 +2571,5 @@
 		if((ccTree.catalog_perms & 2) && type != 'groups' && type !='shared_contacts' && type !='shared_groups')
 			html_cards += '<tr><td colspan=3 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>';
-	}	
+	}
 	else if (CC_max_cards != 0)
 	{
@@ -2521,9 +2608,8 @@
 		else if(CC_visual == 'table')
 			drawTable(0);
-			
+
 		setPages(0,0);
 		return;
 	}
-
 
 	var handler = function (responseText)
@@ -2532,6 +2618,6 @@
 		data = unserialize(responseText);
 		if (data[0] == '0')
-		{				
-			Element('cc_type_contact').value = data[1];			
+		{
+			Element('cc_type_contact').value = data[1];
 			CC_npages = 0;
 			CC_actual_page = 1;
@@ -2545,7 +2631,7 @@
 		else
 		Element('cc_type_contact').value = data[10];
-		
-//		Element('cc_debug').innerHTML = responseText;						
-		
+
+//		Element('cc_debug').innerHTML = responseText;
+
 		if (typeof(data) != 'object')
 		{
@@ -2553,5 +2639,5 @@
 			return;
 		}
-		
+
 		if (typeof(data[3]) == 'object')
 		{
@@ -2566,5 +2652,5 @@
 			qtd_compartilhado = data[9];
 			CC_npages = parseInt(data[0]);
-			CC_actual_page = parseInt(data[1]);			
+			CC_actual_page = parseInt(data[1]);
 			if(CC_visual == 'cards')
 				drawCards(data[3].length, data[10]);
@@ -2574,5 +2660,9 @@
 			populateCards(data, data[10]);
 			setPages(data[0], data[1]);
-			
+
+		}
+		else if (data['error'])
+		{
+			showMessage(data['error']);
 		}
 		else
@@ -2586,4 +2676,5 @@
 	Connector.newRequest('showCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cards_data', 'POST', handler, info);
 }
+
 
 function clearCards()
@@ -2610,5 +2701,5 @@
 	var table_h = Element('cc_panel_table');
 	var cards_h = Element('cc_panel_cards');
-	
+
 	switch (type)
 	{
@@ -2623,14 +2714,14 @@
 			break;
 	}
-	
+
 	CC_visual = type;
 	showCards(getActualLetter(), getActualPage());
 }
 
-function ccSearchUpdate(ids)
+/*function ccSearchUpdate(ids)
 {
 	Element('cc_panel_letters').style.display = 'none';
 	Element('cc_panel_search').style.display  = 'inline';
-	
+
 	if(CC_visual == 'cards')
 		drawCards(0);
@@ -2640,8 +2731,8 @@
 	if (!ids)
 	{
-		ccSearchHide();
+		//ccSearchHide();
 		return;
 	}
-	
+
 	var sIds = serialize(ids);
 
@@ -2651,4 +2742,22 @@
 	}
 	showCards('search', '1', sIds);
+}
+*/
+
+function ccSearchUpdate()
+{
+	Element('cc_panel_letters').style.display = 'none';
+	Element('cc_panel_search').style.display  = 'inline';
+
+	if(CC_visual == 'cards')
+		drawCards(0);
+	else if(CC_visual == 'table')
+		drawTable(0);
+
+	if (CC_actual_letter != 'search')
+	{
+		CC_last_letter = CC_actual_letter;
+	}
+	//showCards('search', '1', sIds);
 }
 
@@ -2693,29 +2802,30 @@
 	data[3] = Element('cc_qa_phone').value;
 	data[4] = Element('cc_qa_email').value;
+
+	return data;
+}
+
+function sendQuickAdd ()
+{
+	var data = getQuickAdd();
+
+	var str = serialize(data);
+
+	if (!str)
+	{
+		return false;
+	}
+
+	var handler = function (responseText)
+	{
+		setTimeout('updateCards()',100);;
+	}
+
+	resetQuickAdd();
+
+	Connector.newRequest('quickAdd', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=quick_add', 'POST', handler, 'add='+escape(str));
+}
+
 	
-	return data;
-}
-
-function sendQuickAdd ()
-{
-	var data = getQuickAdd();
-	
-	var str = serialize(data);
-
-	if (!str)
-	{
-		return false;
-	}
-
-	var handler = function (responseText)
-	{
-		setTimeout('updateCards()',100);;
-	}
-
-	resetQuickAdd();
-
-	Connector.newRequest('quickAdd', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=quick_add', 'POST', handler, 'add='+escape(str));
-}
-
 function connectVoip (phoneUser, typePhone){
 	var handler_voip = function (responseText){
@@ -2724,7 +2834,7 @@
 		}
 		else{
-			data = unserialize(responseText);
+		    data = unserialize(responseText);
 			alert("Requisitando chamada para o ramal: "+data);
-		}
+        }
 	}
 	Connector.newRequest('voip', "../../expressoMail1_2/controller.php?action=expressoMail1_2.functions.callVoipconnect&to="+phoneUser+"&typePhone="+typePhone, 'POST', handler_voip);
