Index: /branches/2.2/mobile/setup/phpgw_pt-br.lang
===================================================================
--- /branches/2.2/mobile/setup/phpgw_pt-br.lang	(revision 3590)
+++ /branches/2.2/mobile/setup/phpgw_pt-br.lang	(revision 3595)
@@ -105,4 +105,6 @@
 What is the maximum number of messages per page?	mobile	pt-br	Qual o número máximo de mensagens por página?
 Option	mobile	pt-br	Opção
+one or more contacts couldnt be removed	mobile	pt-br	um ou mais contatos não puderam ser removidos
+one or more groups couldnt be removed	mobile	pt-br	um ou mais grupos não puderam ser removidos
 Value	mobile	pt-br	Valor
 your search was by	mobile	pt-br	você buscou por
@@ -115,4 +117,6 @@
 Friday	mobile	pt-br	Sexta-feira
 Saturday	mobile	pt-br	Sábado
+selected contacts were removed successfully	mobile	pt-br	os contatos selecionados foram removidos com sucesso
+selected groups were removed successfully	mobile	pt-br	os grupos selecionados foram removidos com sucesso
 Sunday	mobile	pt-br	Domingo
 short Monday	mobile	pt-br	Seg
Index: /branches/2.2/mobile/inc/class.bo_mobilecc.inc.php
===================================================================
--- /branches/2.2/mobile/inc/class.bo_mobilecc.inc.php	(revision 3574)
+++ /branches/2.2/mobile/inc/class.bo_mobilecc.inc.php	(revision 3595)
@@ -91,9 +91,10 @@
 								'field' => $search,
 								'type' 	=> 'iLIKE',
-								'value'	=> '%'.$name.'%'
+								'value'	=> $name
 							));		
 			}
-													
-			$ids = $this->bo->find($what,$rules);
+			
+			
+			$ids = $this->bo->find($what,$rules,false,false,true);
 
 			if(is_array($ids)) {
@@ -130,4 +131,5 @@
 					 * ordenação atual se tiverem valores antigos desnecessários 
 					 * causando erro de tamanhos inconsistentes */
+					$valor['catalog'] = $this->page_info['actual_catalog'];
 					$default = array(); 
 					$type = array();
@@ -140,4 +142,10 @@
 				}//Fim da ordenação
 			}
+			else {
+					$entries = $this->bo->get_multiple_entries($ids,array("id_group"=>true,"title"=>true,"short_name"=>true));
+					foreach ($entries as &$group) {
+						$group['catalog']=$this->page_info['actual_catalog'];
+					}
+				}
 			if($total_count_search>count($ids))
 				$entries["has_more"] = true;
@@ -197,5 +205,26 @@
 			return $retorno;
 		}
-
+		
+		function remove_multiple_entries($ids) {
+			$errors = array();
+			$return = array();
+			if($this->page_info['actual_catalog']==='bo_group_manager')
+				$soGroup = CreateObject('contactcenter.so_group');
+			foreach($ids as $id) {
+				if($this->page_info['actual_catalog']==='bo_group_manager') {
+					$data = array ('id_group' => $id);
+					$check = $soGroup->delete($data);
+				}
+				else
+					$check = $this->bo->remove_single_entry($id);
+				
+				if(!$check)
+					$errors[] = $id;
+			}
+			$return['success'] = empty($errors)?true:false;
+			$return['errors_ids'] = $errors;
+			return $return;
+		}
+		
  	  }
 ?>
Index: /branches/2.2/mobile/inc/class.mobiletemplate.inc.php
===================================================================
--- /branches/2.2/mobile/inc/class.mobiletemplate.inc.php	(revision 3576)
+++ /branches/2.2/mobile/inc/class.mobiletemplate.inc.php	(revision 3595)
@@ -94,5 +94,5 @@
 			$this-> template->set_var('href_logout', 'login.php?cd=1');
 			$this-> template->set_var('href_back', 'javascript:history.back()');
-			$this-> template->set_var('href_cc', 'index.php?menuaction=mobile.ui_mobilecc.contacts_list');
+			$this-> template->set_var('href_cc', 'index.php?menuaction=mobile.ui_mobilecc.init_cc');
 			$this-> template->set_var('href_email', "index.php?menuaction=mobile.ui_mobilemail.change_folder&folder=0");
 			$this-> template->set_var('href_calendar', "index.php?menuaction=mobile.ui_mobilecalendar.index");
Index: /branches/2.2/mobile/inc/class.ui_home.inc.php
===================================================================
--- /branches/2.2/mobile/inc/class.ui_home.inc.php	(revision 3589)
+++ /branches/2.2/mobile/inc/class.ui_home.inc.php	(revision 3595)
@@ -149,7 +149,13 @@
 			
 			//Contatos			
-			if($params["contacts_search"]==="1") {
+			if(($params["contacts_search"]==="1") || 
+					(isset($params["catalog_to_search"]))) {
 				$bo_cc =  CreateObject('mobile.bo_mobilecc');
-				$catalogs = $bo_cc->get_all_catalogs();
+				
+				if(isset($params["catalog_to_search"]))
+					$catalogs = array(0=>array("catalog"=>$params["catalog_to_search"],
+											"label" => $params["catalog_to_search"]));
+				else 
+					$catalogs = $bo_cc->get_all_catalogs();
 	
 				$max_contacts = isset($params['max_contacts'])?$params['max_contacts']:10;
@@ -160,7 +166,9 @@
 				
 				foreach($catalogs as $catalog) {
+					if($catalog['catalog']==="bo_group_manager")
+						continue;
 					if(count($contacts_result)>=$max_contacts) {
 						$bo_cc->set_catalog($catalog['catalog']);
-						$partial_result = $bo_cc->search($params['name'],"1");
+						$partial_result = $bo_cc->search("%".$params['name']."%","1");
 						if(count($partial_result)>1) {
 							$p->set_var('show_more_contacts',"block");
@@ -170,5 +178,5 @@
 					$max_to_search = $max_contacts - count($contacts_result);//Só posso pedir no máximo o número máximo a ser visto menos o que já foi achado.
 					$bo_cc->set_catalog($catalog['catalog']);
-					$partial_result = $bo_cc->search($params['name'],$max_to_search);
+					$partial_result = $bo_cc->search("%".$params['name']."%",$max_to_search);
 					if($partial_result["has_more"]) {
 						$p->set_var('show_more_contacts',"block");
Index: /branches/2.2/mobile/inc/class.ui_mobilecc.inc.php
===================================================================
--- /branches/2.2/mobile/inc/class.ui_mobilecc.inc.php	(revision 3573)
+++ /branches/2.2/mobile/inc/class.ui_mobilecc.inc.php	(revision 3595)
@@ -6,10 +6,19 @@
 		var $page_info = array (
 				'actual_catalog' => false,
-				'is_external_catalog' => false
+				'actual_letter' => null,
+				'actual_max_contacts' => null,
+				'request_from' => null
 			);
 		
 		var $public_functions = array(
-			'contacts_list' => true,
+			'index' => true,
+			'change_max_results' => true,
+			'change_catalog' => true,
+			'delete_contacts' => true,
+			'change_letter' => true,
+			'choose_contact' => true,
+			'init_cc' => true
 		);
+		var $template;
 		
 		/**
@@ -18,106 +27,83 @@
 		 */
 		public function ui_mobilecc() {
-			$this->nextmatchs	= CreateObject('phpgwapi.nextmatchs');
-		}
-		
-		/**
-		 * Inicia um BO de catálogo do módulo de contactcenter.
+			$this->template = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
+			$this->bo = CreateObject('mobile.bo_mobilecc');
+			$page_info = $GLOBALS['phpgw']->session->appsession('mobilecc.page_info','mobile');
+			
+			if($page_info) {
+				$this->page_info = $page_info;
+			}
+			else {
+				$this->set_page_info_to_default();
+			}
+			
+			//if()
+
+		}
+		
+		private function set_page_info_to_default() { //Valores default para iniciar o módulo de contatos
+			$this->page_info['actual_catalog'] = 'bo_people_catalog';
+			$this->page_info['actual_letter'] = 'a';
+			$this->page_info['actual_max_contacts'] = 10;
+			$this->page_info['request_from'] = null;
+		}
+		
+		private function save_session() {
+			$GLOBALS['phpgw']->session->appsession('mobilecc.page_info','mobile',$this->page_info);
+		}
+		
+		public function index($params) {
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_error_msg($params["error_message"]);
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_success_msg($params["success_message"]);
+			$this->contacts_list();
+		}
+		
+		public function change_max_results($params) {
+			$this->page_info['actual_max_contacts'] = $params['results'];
+			$this->contacts_list();
+			$this->save_session();
+		}
+		
+		public function change_letter($params) {
+			$this->page_info['actual_letter'] = $params['letter'];
+			$this->page_info['actual_max_contacts'] = 10;
+			$this->contacts_list();
+			$this->save_session();
+		}
+		
+		public function change_catalog($params) {
+
+			$this->page_info['actual_catalog'] = $params['catalog'];
+			$this->page_info['actual_max_contacts'] = 10;
+			$this->page_info['actual_letter'] = 'a';
+			
+			$this->contacts_list();
+			
+			$this->save_session();
+		}
+		
+		/**
+		 * Função de inicio do módulo para escolha de um contato para outro módulo.
+		 * 
 		 * @return 
-		 * @param $catalog String com o catálogo
-		 */
-		private function set_catalog($catalog) {
-			if(strpos($catalog,'bo_global_ldap_catalog')===false) //Ldap?
-				$this->bo= CreateObject("contactcenter.".$catalog);
-			else {
-				$exploded = explode("#",$catalog);
-				$this->bo= CreateObject("contactcenter.bo_global_ldap_catalog",$exploded[1],$exploded[2],$exploded[3]);
-				if($exploded[3]==1)
-					$this->page_info['is_external_catalog'] = true;
-				else {
-					$this->page_info['is_external_catalog'] = false;
-				}
-					
-			}
-			$this->page_info['actual_catalog'] = $catalog;
-		}
-		
-		/**
-		 * Busca um nome a partir do catálogo. Se nenhum for informado previamente,
-		 * retorna um array vazio.
-		 * 
-		 * Caso o catálogo atual seja grupos, a busca será por títulos, caso seja
-		 * contatos pessoais, será por names_ordered, se for contato no ldap, será
-		 * por cn.
-		 * 
-		 * @return array, com os ids relativos a busca
-		 * @param $name string com o nome à ser buscado.
-		 */
-		public function find($name) {
-			if(!$this->page_info["actual_catalog"])
-				return array();
-			
-			if($this->page_info['actual_catalog']=="bo_group_manager") { //parametros de busca para grupos
-				$id = 'group.id_group';
-				$what = array('group.title',$id);
-				$search = "group.title";
-			}
-			else { //parametros de busca para pessoas
-				$id = 'contact.id_contact';
-				$search = "contact.names_ordered";
-				$what = array('contact.names_ordered',$id);
-			}
-			
-			if ((strpos($this->page_info["actual_catalog"],'bo_global_ldap_catalog')!==false) &&
-					(!$this->page_info['is_external_catalog'])) { //Ldap do expresso, leva em conta alguns atributos do expresso
-
-				array_push($what,'contact.object_class',
-						'contact.account_visible',
-						'contact.account_status'
-						);
-				
-				$rules = array(
-							0 => array(
-								'field' => 'contact.object_class',
-								'type'  => '=',
-								'value' => 'phpgwAccount'
-							),
-							1 => array(
-								'field' => 'contact.account_status',
-								'type'  => 'iLIKE',
-								'value' => '%'
-							),
-							2 => array(
-								'field' => 'contact.account_visible',
-								'type'  => '!=',
-								'value' => '-1'
-							),
-							3 => array(
-								'field' => 'contact.object_class',
-								'type'  => '=',
-								'value' => 'inetOrgPerson'
-							)
-						);
-			}
-			else{
-				$rules = array();
-			}
-
-			
-			
-			if ($name != '') { //String em branco, não preciso adicionar essa regra
-				array_push($rules,array(
-								'field' => $search,
-								'type' 	=> 'iLIKE',
-								'value'	=> '%'.$name.'%'
-							));		
-			}
-														
-			$ids = $this->bo->find($what,$rules);
-
-			if(is_array($ids)) foreach($ids as $id_r) { //Quero apenas os ids, como valores nas posições do array
-				$retorno[] = $id_r[substr($id,strpos($id,".")+1)];
-			}
-			
-			return $retorno;
+		 * @param $params Object
+		 */
+		public function choose_contact($params) {
+			$this->set_page_info_to_default();
+			$this->page_info['request_from'] = $params['request_from']; //Para escolher contato vindo de outro modulo, mudo apenas o request_from
+			$this->contacts_list();
+			$this->save_session();
+		}
+		
+		/**
+		 * Função de inicio do módulo de cc
+		 * 
+		 * @return 
+		 * @param $params Object
+		 */
+		public function init_cc($params) {
+			$this->set_page_info_to_default();
+			$this->contacts_list();
+			$this->save_session();
 		}
 		
@@ -129,336 +115,118 @@
 		 */
 		
-		function contacts_list($from_calendar=false) {
-
-			$entries = array();
-			$actual_page = 0;
-
-			if(isset($_POST['name']) && strlen($_POST['name'])<4) //Busca apenas para nomes com mais de 4 palavras
-				$ids = false;
-			else {
-				/////////////// Pego os ids referente a consulta, se a mesma foi feita
-				if(isset($_POST['name'])) {
-					$this->set_catalog($_POST['catalog']);
-					$ids = $this->find($_POST['name']);
-					if(is_array($ids)) {
-						$actual_page = 1;
-						$_SESSION["mobile_search_ids"] = $ids;
-						$_SESSION["mobile_search_catalog"] = $_POST['catalog'];
-						$ids = array_slice($ids,0,10); //Apenas a primeira página
-					}
+		function contacts_list() {
+			
+			$this->template->set_file(
+				Array(
+					'contacts_list' => 'cc_main.tpl'
+				)
+			);
+			$this->template->set_block("contacts_list","catalog_row");
+			$this->template->set_block("contacts_list","main_body");
+			$this->template->set_block("contacts_list","pagging_block");
+
+			//Langs gerais da página
+			$this->template->set_var("lang_back",lang("back"));
+			$this->template->set_var("lang_more",lang("more"));
+			$this->template->set_var("lang_contacts",ucfirst(lang("contacts")));
+			$this->template->set_var("actual_catalog",$this->page_info["actual_catalog"]);
+			$this->template->set_var("next_max_results",$this->page_info["actual_max_contacts"]+10);
+			
+			//Combo de catálogos
+			$catalogs = $this->bo->get_all_catalogs();
+			foreach($catalogs as $catalog) {
+				$this->template->set_var("catalog_value",$catalog["catalog"]);
+				$this->template->set_var("catalog_name",$catalog["label"]);
+				if($this->page_info['actual_catalog']==$catalog['catalog'])
+					$this->template->set_var("selected","selected");
+				else
+					$this->template->set_var("selected"," ");
+				$this->template->fp("catalogs","catalog_row",true);
+			}
+			$this->bo->set_catalog($this->page_info["actual_catalog"]);
+			$contacts = $this->bo->search($this->page_info["actual_letter"]."%",
+											$this->page_info["actual_max_contacts"]);
+				
+			
+			//Letras da paginação
+			$max_letters = 5;
+			if ( in_array($this->page_info['actual_letter'],
+						  range("a","c"))){ //Letras de A à C iniciam sempre com A		
+  	
+				$this->template->set_var('show_back','none');
+				$this->template->set_var('show_next','inline');
+				$first_letter = "a";
+				$this->template->set_var('href_next',"index.php?menuaction=mobile.".
+										 "ui_mobilecc.change_letter&letter=f");
+			}
+			else if ( in_array($this->page_info['actual_letter'],
+						  range("x","z"))) { //Letras de X à Z terminam sempre no Z
+				$this->template->set_var('show_back','inline');
+				$this->template->set_var('show_next','none');
+				$first_letter = "v";
+				$this->template->set_var('href_back',"index.php?menuaction=mobile.".
+										 "ui_mobilecc.change_letter&letter=u");
 				}
-				else if(isset($_GET['page'])) { 
-					$this->set_catalog($_SESSION["mobile_search_catalog"]);
-					$ids = array_slice($_SESSION["mobile_search_ids"],($_GET['page']-1)*10,10); //Página solicitada
-					$actual_page = $_GET['page'];
-				}
-				else 
-					$ids = false;
-			}
-
-			///////////// Pego os dados dos ids da página em questão.
-			if(!is_array($ids) || count($_SESSION["mobile_search_ids"])>100 || (isset($_POST["name"]) && strlen($_POST['name'])<4)) { 
-				$entries = array();
-			}
-			else { //Só pego os dados completos caso haja resultado na busca
-				if($this->page_info['actual_catalog']!="bo_group_manager") { //Se não for grupo, tenho que ordenar as connections
-
-                                    $display = "none";
-                                    if(isset($GLOBALS['phpgw_info']['user']['preferences']['contactcenter']['cell']) && $GLOBALS['phpgw_info']['user']['preferences']['contactcenter']['cell'] == 1)
-                                    {
-                                        $_SESSION['phpgw_info']['user']['preferences']['contactcenter']['cellShow'] = true;
-                                        $display = "inline";
-					$entries = $this->bo->get_multiple_entries($ids,array("names_ordered"=>true,"uidnumber"=>true,"id_contact"=>true,"companies"=>true,"connections"=>true));
-                                    }else {
-                                        $entries = $this->bo->get_multiple_entries($ids,array("names_ordered"=>true,"uidnumber"=>true,"id_contact"=>true,"connections"=>true));
-                                    }
-					/**
-					 * As entradas vindas de get_multiple_entries não vem com as connections
-					 * ordenadas. Abaixo eu ordeno o array connections de cada entrada para ter
-					 * sempre na frente os valores defaults, primeiro o default de email, depois
-					 * o de telefone.
-					 */
-					foreach($entries as &$valor) {
-						/* Sempre iniciar os arrays, pois pode interferir na 
-						 * ordenação atual se tiverem valores antigos desnecessários 
-						 * causando erro de tamanhos inconsistentes */
-						$default = array(); 
-						$type = array();
+			else { //Letras do meio
+				$this->template->set_var('show_back','inline');
+				$this->template->set_var('show_next','inline');
+				
+				$first_letter = chr(ord($this->page_info["actual_letter"])-3);//Inicio 3 letras antes
+				$last_letter = chr(ord($first_letter)+($max_letters+1));//A ultima é a máxima quantidade de letras mais 1 do next_letter
+				
+				$this->template->set_var('href_back',"index.php?menuaction=mobile.".
+										 "ui_mobilecc.change_letter&letter=".$first_letter);
+				$this->template->set_var('href_next',"index.php?menuaction=mobile.".
+										 "ui_mobilecc.change_letter&letter=".$last_letter);
+				$first_letter++;
+			}
+			
+			for($i=1;$i<=$max_letters;$i++) { //Roda as letras
+					$this->template->set_var("href","index.php?menuaction=mobile.".
+											"ui_mobilecc.change_letter&letter=".$first_letter);
+					$this->template->set_var("letter",strtoupper($first_letter));
+					if($first_letter===$this->page_info["actual_letter"])
+						$this->template->set_var("class_button","letter-contact-selected");
+					else
+						$this->template->set_var("class_button","btn_off");
+					$this->template->set_var("letter",strtoupper($first_letter));
+					$this->template->fp("pagging_letters","pagging_block",true);
+					$first_letter++;
+			}
+			
+
+			if($contacts['has_more'])
+				$this->template->set_var("show_more","block");
+			else
+				$this->template->set_var("show_more","none");
+			unset($contacts['has_more']);
 						
-						foreach($valor['connections'] as $key => $value) {
-							$default[$key] = $value['connection_is_default'];
-							$type[$key] = $value['id_type'];
-						}
-						array_multisort($default, SORT_DESC, $type, SORT_ASC, $valor['connections']);
-					}//Fim da ordenação
-				}
-				else {
-					$entries = $this->bo->get_multiple_entries($ids,array("id_group"=>true,"title"=>true,"short_name"=>true));
-				}
-
-			}
-			
-			///////////////// Monto os dados gerais da página no template.
-			$p = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-			
-			if(!$from_calendar)
-				$p->set_file(Array('entries' => 'cc_main.tpl'));
-			else if($from_calendar =='mobilecalendar')
-				$p->set_file(Array('entries' => 'add_participants.tpl'));
-			else	
-				$p->set_file(Array('entries' => 'add_recipients.tpl'));
-				
-			$p->set_block('entries','body');
-			$p->set_block('entries','people_header');
-			$p->set_block('entries','group_header');
-			$p->set_block('entries','row');
-			$p->set_block('entries','row_group');
-			$p->set_block('entries','row_empty');
-			$p->set_block('entries','option');
-			$p->set_block('entries','page');
-			$p->set_block('entries','page_no_link');
-			$p->set_block('entries','row_addeds');
-			
-			
-			$texts = array(
-				'lang_name' => lang("Name"),
-				'lang_catalog' => lang("Catalog"),
-				'lang_search' => lang("Search")
-				);
-			$p->set_var($texts);
-
-			$p->set_var('lang_already_addeds:',lang('already_addeds:'));
-
-			if($from_calendar == 'mobilecalendar')
-				$p->set_var('lang_continue_scheduling',lang('continue scheduling'));
-			else if($from_calendar == 'mobilemail'){
-				$p->set_var('lang_continue',lang('continue'));
-			}
-
-			/////////// Preenche o combo de catálogos
-			
-			$bo_cc = CreateObject("contactcenter.bo_contactcenter");
-			$branchs = $bo_cc->get_catalog_tree();
-			
-			if(!$from_calendar || $from_calendar == 'mobilemail') {
-				foreach($branchs as $branch) { //Pego apenas a estrutura dos ramos vindos do banco, pois as do ldap estão confusas e com dados aparentemente inconsistentes.
-					if($branch['class']!="bo_global_ldap_catalog" && $branch['class']!="bo_catalog_group_catalog") {
-						$p->set_var(array('option_value'=>$branch['class'],'option_text'=>$branch['name']));
-	
-						if($this->page_info['actual_catalog']==$branch['class'])
-							$p->set_var('selected','selected');
-						else
-							$p->set_var('selected','');
-						$p->parse('options','option',True);
-					}
-						
-				}
-			}
-			
-			/////////// Preenche o combo, com dados do ldap
-			$bo_ldap_manager = CreateObject("contactcenter.bo_ldap_manager");
-			$branchs = $bo_ldap_manager->get_all_ldap_sources();
-			
-			foreach($branchs as $id=>$branch) { //Ldaps expresso
-				$p->set_var(array('option_value'=>"bo_global_ldap_catalog#".
-						$id."#".
-						$branch['dn']."#".
-						0,
-						'option_text'=>$branch['name'])); //No value eu passo também o id, o contexto e se é externo, quando é um ldap
-
-				if($this->page_info['actual_catalog']=="bo_global_ldap_catalog#".$id."#".$branch['dn']."#". 0)
-					$p->set_var('selected','selected');
-				else
-					$p->set_var('selected','');
-				$p->parse('options','option',True);	
-			}
-			
-			if(!$from_calendar  || $from_calendar == 'mobilemail') {
-				$branchs = $bo_ldap_manager->get_external_ldap_sources();
-				if(is_array($branchs)) foreach($branchs as $id=>$branch) { //Ldaps externos
-					$p->set_var(array('option_value'=>"bo_global_ldap_catalog#".
-							$id."#".
-							$branch['dn']."#".
-							1,
-							'option_text'=>$branch['name'])); //No value eu passo também o id, o contexto e se é externo, quando é um ldap
-	
-					if($this->page_info['actual_catalog']=="bo_global_ldap_catalog#".$id."#".$branch['dn']."#". 1)
-						$p->set_var('selected','selected');
-					else
-						$p->set_var('selected','');
-					$p->parse('options','option',True);	
-				}
-			}
-
-			/////////// Monta o resultado da pesquisa
-			$p->set_var('th_theme',$GLOBALS['phpgw_info']['theme']['th_bg']);
-						
-			if(empty($entries) && isset($_POST["name"]) && count($_SESSION["mobile_search_ids"])<=100 && strlen($_POST['name'])>=4) { //Se foi feita a busca e não teve resultados...
-				$p->set_var('message',lang('No matches found'));
-				$p->parse('rows','row_empty',True);
-			}
-			else if(count($_SESSION["mobile_search_ids"])>100) { //Muitos resultados...
-				$p->set_var('message',lang('too many results'));
-				$p->parse('rows','row_empty',True);			
-			}
-			else if(isset($_POST["name"]) && strlen($_POST['name'])<4) { //Muitos resultados...
-				$p->set_var('message',lang('the search argument must have at least 4 digits'));
-				$p->parse('rows','row_empty',True);			
-			}
-			else if((isset($_POST["name"])) || (isset($_GET["page"]))){ //Renderizar...
-				
-				/////////// Preenche o cabeçalho da consulta
-				if($this->page_info['actual_catalog']!="bo_group_manager") {
-					$p->set_var(
-							array('lang_people_name'	=> lang("Name"),
-								'lang_phone'		=> lang("Phone"),
-								'lang_mobile'		=> "Celular", //lang("Mobile"),
-                                                                'display'               => $display,
-								'lang_mail'		=> lang("Email")));
-					$p->parse('header','people_header',True);
-				}
-				else {
-					$p->set_var(
-							array('lang_group_name' => lang("Name"),
-								'lang_title' => lang("Title")
-								));
-					$p->parse('header','group_header',True);
-				}
-				
-				/////////// Preencho as linhas do resultado
-				foreach($entries as $id => $entry) {
-					$this->nextmatchs->template_alternate_row_color($p);
-					if(($this->page_info['actual_catalog']!="bo_group_manager") &&
-							 (strpos($this->page_info['actual_catalog'],'bo_global_ldap_catalog')===false)){ //People
-						$var = array(
-								'row_nome'	=> $entry['names_ordered'],
-								'row_mobile'	=> $entry['companies']['company1']['celPhone']
-							);
-						$conn1 = array_shift($entry['connections']);
-						if(($conn1==NULL)||($conn1['connection_is_default']!=1)) {
-							$var['row_telefone'] = '&nbsp;';
-							$var['row_email'] = '&nbsp;';
-						}
-						else if($conn1['id_type']==1) {
-							$var['row_email'] = $conn1['connection_value'];
-							$conn2=array_shift($entry['connections']);
-							if(($conn2==NULL)||($conn2['connection_is_default']!=1))
-								$var['row_telefone'] = '&nbsp';
-							else
-								$var['row_telefone'] = $conn2['connection_value'];
-						}
-						else if($conn1['id_type']==2) {
-							$var['row_email'] = '&nbsp;';
-							$var['row_telefone'] = $conn1['connection_value'];
-						}
-						$var['form_action'] = "index.php?menuaction=mobile.ui_mobilemail.new_msg";
-						$p->set_var($var);
-						$p->parse('rows','row',True);
-					}
-					else if($this->page_info['actual_catalog']=="bo_group_manager"){ //Grupos
-						$var = array(
-								'row_group_name'=>$entry['short_name'],
-								'row_title' => $entry['title']
-								);
-						
-						$p->set_var($var);
-						$p->parse('rows','row_group',True);
-					}
-					else { //Ldap
-						$var = array('row_nome'=>$entry['names_ordered'][0],'row_mobile'=> $entry['companies']['company1']['celPhone']);
-						$conn1 = array_shift($entry['connections']);
-						if(($conn1==NULL)) {
-							$var['row_telefone'] = '&nbsp;';
-							$var['row_email'] = '&nbsp;';
-						}
-						else if($conn1['id_type']==1) {
-							$var['row_email'] = $conn1['connection_value'];
-							$conn2=array_shift($entry['connections']);
-							if($conn2==NULL)
-								$var['row_telefone'] = '&nbsp';
-							else
-								$var['row_telefone'] = $conn2['connection_value'];
-						}
-						else if($conn1['id_type']==2) {
-							$var['row_email'] = '&nbsp;';
-							$var['row_telefone'] = $conn1['connection_value'];
-						}
-						if(!$from_calendar)
-							$var['form_action'] = "index.php?menuaction=mobile.ui_mobilemail.new_msg";
-						else if($from_calendar == 'mobilecalendar'){
-							$var['id_contact'] = $entry['uidnumber'][0].'U';
-							$var['form_action'] = "index.php?menuaction=mobile.ui_mobilecalendar.add_participant";
-						}else{
-							$var['id_contact'] = $entry['uidnumber'][0].'U';
-							$var['form_action'] = "index.php?menuaction=mobile.ui_mobilemail.add_recipient";
-						}
-						$var['lang_select'] = lang("select");
-						$p->set_var($var);
-						$p->parse('rows','row',True);
-					}
-				}
-			}
-			
-			if($from_calendar == 'mobilemail') {
-				$p->set_var('lang_choose_the_recipients',lang("choose the recipients"));
-				$participants = $_SESSION['mobile_mail'];
-				reset($participants);
-				while (($participant = current($participants))!==false) {
-					$p->set_var('row_contact_name',$participant);
-					if(next($participants)!==false)
-						$p->set_var('row_separate',',');
-					else
-						$p->set_var('row_separate','.');
-					$p->parse('rows_addeds','row_addeds',True);
-				}
-			}else if($from_calendar == 'mobilecalendar'){
-				$p->set_var('lang_choose_the_participants',lang("choose the participants"));
-				$participants = $_SESSION['mobile_calendar'];
-				reset($participants);
-				while (($participant = current($participants))!==false) {
-					$p->set_var('row_contact_name',$participant);
-					if(next($participants)!==false)
-						$p->set_var('row_separate',',');
-					else
-						$p->set_var('row_separate','.');
-					$p->parse('rows_addeds','row_addeds',True);
-				}				
-			}
-			
-			////////////////// Monto a paginação
-			if(!empty($entries) && count($_SESSION["mobile_search_ids"])<=100) {
-				$num_pages = count($_SESSION["mobile_search_ids"])/10;
-				
-				if((count($_SESSION["mobile_search_ids"])%10!=0) || ($num_pages<1))
-					$num_pages++;
-				if($actual_page!=0) {
-					for($i=1;$i<=$num_pages;$i++) {
-						$p->set_var('num_page',$i);
-						$p->set_var('display_page',$i);
-						if($i!=$actual_page)
-							$p->parse('pages','page',True);
-						else
-							$p->parse('pages','page_no_link',True);
-					}
-				}
-				
-				if($actual_page>1) {
-					$p->set_var('num_page',$actual_page-1);
-					$p->set_var('display_page','<');
-					$p->parse('back','page',True);
-				}
-				
-				if(($actual_page!=floor($num_pages)) && (floor($num_pages)>1) && ($actual_page!=0)) {
-					$p->set_var('num_page',$actual_page+1);
-					$p->set_var('display_page','>');
-					$p->parse('next','page',True);
-				}	
-			}			
-			
-			//$p->pfp('out','body');
-			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($p->fp('out','body'));
-		}
-		
-		static function print_contacts($contacts) {
+			$this->template->set_var("contacts",$this->print_contacts($contacts,true,$this->page_info['request_from']));
+			
+
+			$GLOBALS['phpgw_info']['mobiletemplate']->set_content($this->template->fp('out','main_body'));
+		}
+		
+		/**
+		 * Remove os contatos selecionados
+		 * 
+		 * @return 
+		 * @param $contacts Object
+		 * @param $show_checkbox Object[optional]
+		 */
+		
+		function delete_contacts($params) {
+			$this->bo->set_catalog($params['catalog']);
+			$status = $this->bo->remove_multiple_entries($params['contacts']);
+			
+			$type = $this->page_info['actual_catalog']==='bo_people_catalog'?"contacts":"groups";
+			
+			if($status['success'])
+				header("Location: index.php?menuaction=mobile.ui_mobilecc.index&success_message=".lang("selected $type were removed successfully"));
+			else
+				header("Location: index.php?menuaction=mobile.ui_mobilecc.index&error_message=".lang("one or more $type couldnt be removed"));
+		}
+		
+		static function print_contacts($contacts,$show_checkbox=false,$request_from = null) {
 			$functions = CreateObject('mobile.common_functions');
 			$p = CreateObject('phpgwapi.Template', PHPGW_SERVER_ROOT . '/mobile/templates/'.$GLOBALS['phpgw_info']['server']['template_set']);
@@ -470,27 +238,58 @@
 			$p->set_block('cc_t', 'rows_contacts');
 			$p->set_block('cc_t', 'row_contacts');
+			$p->set_block('cc_t', 'row_groups');
 			$p->set_block('cc_t', 'no_contacts');
-			
+
 			$bg = "par";
 			if(!empty($contacts)) {
 				foreach($contacts as $id => $contact) {
 					
-					$p->set_var('bg',$bg=="par"?$bg="reset-dt":$bg="par");							
-					$p->set_var('lang_tel',lang("tel"));
-					$p->set_var('show_tel',$contact["connections"]["connection2"]["connection_value"]!=null?"inline":"none");
-					$p->set_var('lang_see_details',strtoupper(lang("see details")));
-					$p->set_var('contact_name',$functions->strach_string(is_array($contact["names_ordered"])?
-									$contact["names_ordered"][0]:$contact["names_ordered"],20));
-					$p->set_var('email',
-								$functions->strach_string(
-									($contact["connections"]["connection1"]["connection_value"]!=null && 
-									$contact["connections"]["connection1"]["id_type"]==="1")?
-										$contact["connections"]["connection1"]["connection_value"]:"&nbsp;",20));
-					$p->set_var('tel',$functions->strach_string($contact["connections"]["connection1"]["id_type"]==="2"?
-										$contact["connections"]["connection1"]["connection_value"]:
-										$contact["connections"]["connection2"]["connection_value"],19));
+					$p->set_var('show_check',$show_checkbox?"inline":"none");
+					$p->set_var('bg',$bg=="par"?$bg="reset-dt":$bg="par");
+										
+					if($contact["catalog"]!=="bo_group_manager") {	//Contatos		
+						$id=$contact["catalog"]==="bo_people_catalog"?$contact["id_contact"]:$contact['uidnumber'][0];
 						
-					$p->fp('rows','row_contacts',True);
+						$mail = $contact["connections"]["connection1"]["connection_value"];//Preciso o mail depois
+						$cn = is_array($contact["names_ordered"])?
+										$contact["names_ordered"][0]:$contact["names_ordered"];
+						if(($contact["connections"]["connection1"]["connection_value"]==null || 
+										$contact["connections"]["connection1"]["id_type"]!=="1")
+										&& isset($request_from)) //Se vier de outro módulo e não possuir e-mail, não mostre.
+							continue;
+
+						$p->set_var('contact_id',$id);		
+						$p->set_var('lang_tel',lang("tel"));
+						$p->set_var('show_tel',$contact["connections"]["connection2"]["connection_value"]!=null?"inline":"none");
+						$p->set_var('contact_name',$functions->strach_string($cn,17));
+						$p->set_var('email',
+									$functions->strach_string(
+										($contact["connections"]["connection1"]["connection_value"]!=null && 
+										$contact["connections"]["connection1"]["id_type"]==="1")?
+											$contact["connections"]["connection1"]["connection_value"]:"&nbsp;",20));
+						$p->set_var('tel',$functions->strach_string($contact["connections"]["connection1"]["id_type"]==="2"?
+											$contact["connections"]["connection1"]["connection_value"]:
+											$contact["connections"]["connection2"]["connection_value"],19));
+							
+						$p->fp('rows','row_contacts',True);
+					}
+					else { //Grupos
+						$id=$contact["id_group"];
+						$mail = $cn = $contact["title"];
+						$p->set_var('group_id',$contact["id_group"]);
+						$p->set_var('group_name',$contact["title"]);
+						$p->fp('rows','row_groups',True);
+					}
+					
+					if($request_from==null) {
+						$p->set_var('lang_see_details',strtoupper(lang("see details")));
+						$p->set_var('href_details',"ui_mobilecc.contact_view&id=$id&catalog=".$contact["catalog"]);
+					}
+					else {
+						$p->set_var('lang_see_details',strtoupper(lang("select")));
+						$p->set_var('href_details','ui_mobilemail.add_recipient&mail=$mail&cn=$cn');
+					}
 				}
+				
 			}
 			else {
Index: /branches/2.2/mobile/templates/default/cc_main.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/cc_main.tpl	(revision 3571)
+++ /branches/2.2/mobile/templates/default/cc_main.tpl	(revision 3595)
@@ -1,96 +1,62 @@
-<!-- BEGIN body -->
-<h1>Contatos</h1>
-<hr /><br />
-<form action="index.php?menuaction=mobile.ui_mobilecc.contacts_list" method="post">
+<!-- BEGIN main_body -->
+<div class="menu-contexto">
+<form id="form_catalog" action="index.php" method="post">
+			<span><a name="voltar" href="javascript:history.back()">{lang_back}</a></span><span class="titulo-secao">{lang_contacts}</span>
+			
+			<input type="hidden" name="menuaction" value="mobile.ui_mobilecc.change_catalog">
+			<select name="catalog" onChange="document.getElementById('form_catalog').submit();">
+			
+			{catalogs}
+			</select>
+		</form>
+		</div>
+		
+		<div class="busca"> <form id="formu_busca" action="index.php" method="post">
+		<input type="hidden" name="menuaction" value="mobile.ui_home.search">
+		<input type="hidden" name="catalog_to_search" value="{actual_catalog}">
+		<input type="text" name="name"> 
+		<button name="buscar_contato" class="btn-generico" onClick="document.getElementById('formu_busca').submit()">buscar contato</button>
+		</form>
+		</div>
 
-<table border="0" width="250">
-	<tr>
-		<td width="70"><label for="name">{lang_name}:</label></td>
-		<td><input type="text" id="name" name="name" size="30"/></td>
-	</tr>	
-	<tr>
-		<td width="70"><label for="catalog">{lang_catalog}:</label></td>
-		<td>
-			<select id="catalog" name="catalog">
-				{options}
-			</select>
-		</td>
-	</tr>	
-	<tr>
-		<td align="right" colspan="2"><input type="submit" value="{lang_search}"/></td>
-	</tr>	
+		<dl id="lista_miolo">
+			
+			<dt class="menu-diverso">
+			<div>	
+			<a href="{href_back}" style="display:{show_back};"> < </a>
+			{pagging_letters}
+			<a href="{href_next}" class="btn_off" style="display:{show_next};"> > </a>
+			</div>
+			
+			</dt>
+			<form method="post" action="index.php" id="formu_contacts">
+			<input type="hidden" id="menuaction" name="menuaction" value="mobile.ui_mobilecc.delete_contacts">
+			<input type="hidden" id="catalog" name="catalog" value="{actual_catalog}">			
+			{contacts}
+			</form>
+				
+				
+		</dl>
+
+		<div class="menu-contexto" style="display:{show_more};">
+			<button name="more_messages" title="{lang_more_messages}" class="btn-contexto" onClick="location.href='index.php?menuaction=mobile.ui_mobilecc.change_max_results&results={next_max_results}'">{lang_more} 10 {lang_contacts}</button>
+		</div>
+		
+		<div id="operacao_lista">
+			Selecionados:
+			<button id="remover" class="btn-generico" onClick="document.getElementById('menuaction').value='mobile.ui_mobilecc.delete_contacts';document.getElementById('formu_contacts').submit();">remover</button>
+			<button id="adicionar_contato" class="btn-generico" >adicionar contato</button>
+			
+		</div>
+		
+<!-- END main_body -->	
+		
+<!-- BEGIN catalog_row -->
+ <option value='{catalog_value}' {selected}>{catalog_name}</option>
+<!-- END catalog_row -->
+
+<!-- BEGIN pagging_block -->
 	
-</table>
-</form>
-<!-- TABELA PRINCIPAL DO RESULTADO DA BUSCA -->
-<table border="0" width="90%">
-			<tr bgcolor="{th_theme}">
-				{header}
-			</tr>
-                                {rows}
-</table>
-<table border="0" width="45%">
-	<tr>
-		<td>
-			{back}{pages}{next}
-		</td>
-	</tr>
-</table>
-<!-- FIM TABELA PRINCIPAL DO RESULTADO DA BUSCA -->
-<!-- END body -->
-
-<!-- BEGIN people_header -->
-				<td width="40%" align="center">{lang_people_name}</td>
-				<td width="20%" align="center">{lang_phone}</td>
-				<td width="20%" align="center">{lang_mobile}</td>
-				<td width="20%" align="center">{lang_mail}</td>
-<!-- END people_header -->
-
-<!-- BEGIN group_header -->
-				<td width="60%" align="center">{lang_group_name}</td>
-				<td width="20%" align="center">{lang_title}</td>
-<!-- END group_header -->
-
-<!-- BEGIN row -->
-<form id="cc_form" name="cc_form" method="POST" action="{form_action}">
-	<tr bgcolor="{tr_color}">
-		<td><a href="{form_action}&input_to={row_nome}&input_to_mail={row_email}&type=cc_mob">{row_nome}</a></td>
-		<td align="center">{row_telefone}</td>
-		<td align="center">{row_mobile}</td>
-		<td align="center">{row_email}</td>
-
-	</tr>
-		<input type="hidden" id="input_to" name="input_to" value="{row_nome}" style="display: none;"/>
-		<input type="hidden" id="input_to_mail" name="input_to_mail" value="{row_email}" style="display: none;"/>
-		<input type="hidden" id="input_subject" name="input_subject" value="" style="display: none;"/>
-		<input type="hidden" id="body" name="body" value="" style="display: none;"/>
-		<input type="hidden" id="cc_mob" name="cc_mob" value="1" style="display: none;"/>
-</form>	
-<!-- END row -->
-
-<!-- BEGIN row_group -->
-	<tr bgcolor="{tr_color}">
-		<td>{row_group_name}</td>
-		<td align="center">{row_title}</td>
-	</tr>
-<!-- END row_group -->
-
-<!-- BEGIN row_empty -->
-	<tr>
-		<td align="center"><font color="red"><b>{message}</b></font></td>
-	</tr>
-<!-- END row_empty -->
-
-<!-- BEGIN option -->
-		<option value="{option_value}" {selected}>{option_text}</option>
-<!-- END option -->
-
-<!-- BEGIN page -->
-		<a href="index.php?menuaction=mobile.ui_mobilecc.contacts_list&page={num_page}">
-		{display_page}
-		</a>&nbsp;
-<!-- END page -->
-
-<!-- BEGIN page_no_link -->
-		{num_page}&nbsp;
-<!-- END page_no_link -->
+<a href="{href}" class="{class_button}"> {letter} </a>
+	
+<!-- END pagging_block -->
Index: /branches/2.2/mobile/templates/default/contacts_list.tpl
===================================================================
--- /branches/2.2/mobile/templates/default/contacts_list.tpl	(revision 3574)
+++ /branches/2.2/mobile/templates/default/contacts_list.tpl	(revision 3595)
@@ -4,5 +4,5 @@
 <!-- BEGIN row_contacts -->
 				<dt class="titulo_mensagem {bg}">
-					<div class="nome-item">{contact_name}
+					<div class="nome-item"><input type="checkbox" name="contacts[]" style="display:{show_check};" value="{contact_id}"> {contact_name}
 					</div>
 				</dt>
@@ -13,8 +13,14 @@
 						<p style="display:{show_tel};"><span>{lang_tel}:</span>{tel}</p>
 					</div> 
-					<a href="{href_contato}" class="btn-anexo">{lang_see_details}</a>
+					<a href="index.php?menuaction=mobile.{href_details}" class="btn-anexo">{lang_see_details}</a>
 					
 				</dd>
 <!-- END row_contacts -->
+<!-- BEGIN row_groups -->
+	<dt class="titulo_mensagem {bg}">
+		<div class="nome-item"><input type="checkbox" name="contacts[]" style="display:{show_check};" value="{group_id}"> {group_name}
+		<a href="index.php?menuaction=mobile.{href_details}" class="btn-anexo">{lang_see_details}</a></div>
+	</dt>
+<!-- END row_groups -->
 <!-- BEGIN no_contacts -->
 	<dt class="titulo_mensagem reset-dt">
Index: /branches/2.2/mobile/templates/css/mobile.css
===================================================================
--- /branches/2.2/mobile/templates/css/mobile.css	(revision 3590)
+++ /branches/2.2/mobile/templates/css/mobile.css	(revision 3595)
@@ -57,5 +57,5 @@
 .menu-diverso{ height:35px;}
 .menu-diverso a{ margin-right:3px; padding:5px; font-size:110%; background-color:#EEF7FA; color:#434343;}
-.menu-diverso a:hover{color:#FFFFFF;background-color:#3399CC;}
+.menu-diverso a:hover,.menu-diverso a.letter-contact-selected {color:#FFFFFF;background-color:#3399CC;}
 dt.menu-diverso div{margin-top:8px;}
 
