Index: /trunk/services/class.db.php
===================================================================
--- /trunk/services/class.db.php	(revision 5072)
+++ /trunk/services/class.db.php	(revision 5072)
@@ -0,0 +1,266 @@
+<?php
+/**
+*
+* Copyright (C) 2011 Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU Affero General Public License version 3 as published by
+* the Free Software Foundation with the addition of the following permission
+* added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
+* WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE
+* WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program; if not, see www.gnu.org/licenses or write to
+* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+* MA 02110-1301 USA.
+*
+* This code is based on the OpenXchange Connector and on the Prognus pSync
+* Connector both developed by the community and licensed under the GPL
+* version 2 or above as published by the Free Software Foundation.
+*
+* You can contact Prognus Software Livre headquarters at Av. Tancredo Neves,
+* 6731, PTI, Bl. 05, Esp. 02, Sl. 10, Foz do Iguaçu - PR - Brasil or at
+* e-mail address prognus@prognus.com.br.
+*
+* Serviço de banco de dados
+*
+* Serviço que faz a busca no banco de dados para retornar os usuários, de acordo com o parâmetro de busca.
+*
+* @package    <services>
+* @license    http://www.gnu.org/copyleft/gpl.html GPL
+* @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
+* @version    1.0
+* @sponsor    Caixa Econômica Federal
+*/
+
+    if(!isset($_SESSION['phpgw_info']['expressomail']['server']['db_name'])) { 
+	include_once('../header.inc.php'); 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name'];  
+	$_SESSION['phpgw_info']['expressomail']['server']['db_host'] = $GLOBALS['phpgw_info']['server']['db_host']; 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_port'] = $GLOBALS['phpgw_info']['server']['db_port']; 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_user'] = $GLOBALS['phpgw_info']['server']['db_user']; 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass']; 
+	$_SESSION['phpgw_info']['expressomail']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type']; 
+    } 
+    else{ 
+	define('PHPGW_INCLUDE_ROOT','../');      
+	define('PHPGW_API_INC','../phpgwapi/inc');       
+	include_once(PHPGW_API_INC.'/class.db.inc.php'); 
+    } 
+
+
+class DBService
+{    
+    var $connection;
+    var $db;
+    var $user_id;
+
+    function DBService()
+    {
+        $this->db = new db();		
+        $this->db->Halt_On_Error = 'no';
+        $this->db->connect(
+            $_SESSION['phpgw_info']['expressomail']['server']['db_name'], 
+            $_SESSION['phpgw_info']['expressomail']['server']['db_host'],
+            $_SESSION['phpgw_info']['expressomail']['server']['db_port'],
+            $_SESSION['phpgw_info']['expressomail']['server']['db_user'],
+            $_SESSION['phpgw_info']['expressomail']['server']['db_pass'],
+            $_SESSION['phpgw_info']['expressomail']['server']['db_type']
+        );		
+        $this -> user_id = $_SESSION['phpgw_info']['expressomail']['user']['account_id'];
+    }
+
+    function search_contacts($search_for)
+    { 
+        $result = array();
+        $query = 'select'
+        
+						. ' C.id_connection,'
+						. ' A.id_contact,'
+						. ' A.names_ordered,'
+						. ' A.alias,'
+						. ' A.birthdate,'
+						. ' A.sex,'
+						. ' A.pgp_key,'
+						. ' A.notes,'
+						. ' A.web_page,'
+						. ' A.corporate_name,'
+						. ' A.job_title,'
+						. ' A.department,'
+						. ' C.connection_name,'
+						. ' C.connection_value,'
+						. ' B.id_typeof_contact_connection,'
+						. ' phpgw_cc_contact_addrs.id_typeof_contact_address,'
+						. ' phpgw_cc_addresses.address1,'
+						. ' phpgw_cc_addresses.address2,'
+						. ' phpgw_cc_addresses.complement,'
+						. ' phpgw_cc_addresses.postal_code,'
+						. ' phpgw_cc_city.city_name,'
+						. ' phpgw_cc_state.state_name,'
+						. ' phpgw_cc_addresses.id_country'
+						;
+
+		$query .= ' from'
+                        . ' phpgw_cc_contact A'
+                        . ' inner join phpgw_cc_contact_conns B on ( A.id_contact = B.id_contact )'
+                        . ' inner join phpgw_cc_connections C on ( B.id_connection = C.id_connection )'
+                        . ' left join phpgw_cc_contact_addrs on ( A.id_contact = phpgw_cc_contact_addrs.id_contact )'
+						. ' left join phpgw_cc_addresses on ( phpgw_cc_contact_addrs.id_address = phpgw_cc_addresses.id_address )'
+						. ' left join phpgw_cc_city on ( phpgw_cc_addresses.id_city = phpgw_cc_city.id_city )'
+						. ' left join phpgw_cc_state on ( phpgw_cc_addresses.id_state = phpgw_cc_state.id_state)'
+						;
+
+				$query .= ' where '
+                                        . 'A.id_owner=' . $_SESSION['phpgw_info']['expressomail']['user']['account_id']
+                                        . ' and names_ordered LIKE \'%' . $search_for . '%\'';                         
+                                
+        if (!$this->db->query($query))
+             return null;
+         
+         while($this->db->next_record())
+            $result[] = $this->db->row();
+
+         
+         
+         $all_contacts = array(); 
+			foreach( $result as $i => $object )
+			{
+				if ( ! array_key_exists( $object[ 'id_contact' ], $all_contacts ) )
+					$all_contacts[ $object[ 'id_contact' ] ] = array(
+						'connection_value' => '',
+						'telephonenumber' => '',
+						'mobile' => '',
+						'cn' => '',
+						'id_contact' => '',
+						'id_connection' => '',
+						'alias' => '',
+						'birthdate' => '',
+						'sex' => '',
+						'pgp_key' => '',
+						'notes' => '',
+						'web_page' => '',
+						'corporate_name' => '',
+						'job_title' => '',
+						'department' => '',				
+						'mail' => '',
+						'aternative-mail' => '',
+						'business-phone' => '',
+						'business-address' => '',
+						'business-complement' => '',
+						'business-postal_code' => '',
+						'business-city_name' => '',
+						'business-state_name' => '',
+						'business-id_country' => '',
+						'business-fax' => '',
+						'business-pager' => '',
+						'business-mobile' => '',
+						'business-address-2' => '',
+						'home-phone' => '',
+						'home-address' => '',
+						'home-complement' => '',
+						'home-postal_code' => '',
+						'home-city_name' => '',
+						'home-state_name' => '',
+						'home-fax' => '',
+						'home-pager' => '',
+						'home-address-2' => ''
+						
+						
+					);
+
+				switch( $object[ 'id_typeof_contact_connection' ] )
+				{
+					case 1 :
+						$all_contacts[ $object[ 'id_contact' ] ][ 'connection_value' ] = $object[ 'connection_value' ];
+						switch ( strtolower( $object[ 'connection_name' ] ) )
+						{
+							case 'alternativo' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'alternative-mail' ] = $object[ 'connection_value' ];
+								break;
+							case 'principal' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'mail' ] = $object[ 'connection_value' ];
+								break;
+						}
+						break;
+					case 2 :
+						$all_contacts[ $object[ 'id_contact' ] ][ 'telephonenumber' ] = $object[ 'connection_value' ];
+						switch ( strtolower( $object[ 'connection_name' ] ) )
+						{
+							case 'casa' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'home-phone' ] = $object[ 'connection_value' ];
+								break;
+							case 'celular' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'mobile' ] = $object[ 'connection_value' ];
+								break;
+							case 'trabalho' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'business-phone' ] = $object[ 'connection_value' ];
+								break;								
+							case 'fax' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'home-fax' ] = $object[ 'connection_value' ];
+								break;
+							case 'pager' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'home-pager' ] = $object[ 'connection_value' ];
+								break;
+							case 'celular corporativo' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'business-mobile' ] = $object[ 'connection_value' ];
+								break;								
+							case 'pager corporativo' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'business-pager' ] = $object[ 'connection_value' ];
+								break;
+							case 'fax corporativo' :
+								$all_contacts[ $object[ 'id_contact' ] ][ 'business-fax' ] = $object[ 'connection_value' ];
+								break;
+						}
+						break;
+				}
+
+				$all_contacts[ $object[ 'id_contact' ] ][ 'cn' ] = $object[ 'names_ordered' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'id_contact' ]    = $object[ 'id_contact' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'id_connection' ] = $object[ 'id_connection' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'alias' ]         = $object[ 'alias' ];				
+				$all_contacts[ $object[ 'id_contact' ] ][ 'birthdate' ] 	= $object[ 'birthdate' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'sex' ]    		= $object[ 'sex' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'pgp_key' ] 		= $object[ 'pgp_key' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'notes' ]         = $object[ 'notes' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'web_page' ] 		= $object[ 'web_page' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'corporate_name' ]= $object[ 'corporate_name' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'job_title' ] 	= $object[ 'job_title' ];
+				$all_contacts[ $object[ 'id_contact' ] ][ 'department' ]    = $object[ 'department' ];
+
+				switch( $object[ 'id_typeof_contact_address' ] )
+				{
+					case 1 :
+						$all_contacts[ $object[ 'id_contact' ] ][ 'business-address' ]     = $object[ 'address1' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'business-address-2' ]   = $object[ 'address2' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'business-complement' ]  = $object[ 'complement' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'business-postal_code' ] = $object[ 'postal_code' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'business-city_name' ]   = $object[ 'city_name' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'business-state_name' ]  = $object[ 'state_name' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'business-id_country' ]  = $object[ 'id_country' ];
+						break;
+					case 2 :
+						$all_contacts[ $object[ 'id_contact' ] ][ 'home-address' ]     = $object[ 'address1' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'home-address-2' ]   = $object[ 'address2' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'home-complement' ]  = $object[ 'complement' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'home-postal_code' ] = $object[ 'postal_code' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'home-city_name' ]   = $object[ 'city_name' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'home-state_name' ]  = $object[ 'state_name' ];
+						$all_contacts[ $object[ 'id_contact' ] ][ 'home-id_country' ]  = $object[ 'id_country' ];
+						break;
+				}
+			}
+
+			return array_values($all_contacts);
+	}
+
+}
+
+ServiceLocator::register( 'db', new DBService() );
+
+?>
Index: /trunk/expressoMail1_2/templates/default/quick_search.css
===================================================================
--- /trunk/expressoMail1_2/templates/default/quick_search.css	(revision 5072)
+++ /trunk/expressoMail1_2/templates/default/quick_search.css	(revision 5072)
@@ -0,0 +1,58 @@
+/* Estilos da tela de busca rápida de contatos */
+
+                body { font-size:11px;} 
+                fieldset, div {margin:0;}
+                .ui-autocomplete-input { height:22px; width:200px; margin-right:-1px; }
+                #wrap-progressbar { height:22px; width:122px;  float:left; }
+                #wrap-progressbar #inner-progressbar { text-align:center; width:100px; }
+                #wrap-progressbar #inner-progressbar span { font-size:10px; line-height:12px; }
+                #wrap-progressbar #inner-progressbar #progressbar { width:100px; height:10px; }
+                .clear {clear:both;}
+                #fieldset1 label {width:495px;display:inline-block; border:4px solid #72A9D3;}
+                fieldset { border:1px solid #AAA; border-radius:5px; margin:5px; }
+                ul {list-style:none; margin:0; padding:0;}
+                
+                #list-acc-users li, #search-result-users li {margin-right:5px;border-radius:3px;}
+                #list-acc-mails li {margin-right:5px;padding-bottom:4px;border-radius:3px;}
+                #list-acc-users li:hover, #list-acc-mails li:hover, #search-result-users li:hover {background-color:#DDD;}
+                #list-acc-users li span.ui-icon, #list-acc-mails li span.ui-icon, #search-result-users li span.ui-icon {display:none; margin:2px;}
+                #list-acc-users li input, #list-acc-mails li input, #search-result-users li input {margin-top:5px;}
+                #list-acc-users li label, #list-acc-mails li label, #search-result-users li label {margin-top:-5px;}
+                #list-acc-users li:hover span, #list-acc-mails li:hover span, #search-result-users li:hover span {display:inline;}
+                #search-result-users li span.ui-icon {display:none;}
+                .ui-icon {float:right;}
+                #icon-bar1 .ui-icon {float:left; margin:0 3px;}
+                 #icon-bar1 span {float:left; margin:2px 3px 0 0;}
+                .ui-icon-trash, .ui-icon-edit, .ui-icon-close, .ui-icon-plus, .ui-icon-pencil {background-color:#EEE;}
+                .ui-icon-trash:hover, .ui-icon-edit:hover, .ui-icon-close:hover, .ui-icon-plus:hover, .ui-icon-pencil:hover {background-color:#BBB;}
+                .ui-autocomplete-input {width:170px;}
+                .ui-accordion .ui-accordion-content{padding:5px;}
+
+                .foot-note {width:905px; padding:5px;margin-top:20px;border-top:1px solid #ddd;}
+                .acc-list {font-family: "Trebuchet MS", Tahoma, Verdana, Arial, sans-serif; font-size:11px; color:#555; }
+                .acc-list h3{font-family: "Trebuchet MS", Tahoma, Verdana, Arial, sans-serif; font-size:11px; color:#555; margin:0; padding:5px 3px; background-color:#fff;}
+                .acc-list ul{ margin:5px 0;}
+                .acc-list ul li{ border-radius:3px; padding:10px;}
+                .acc-list ul li:hover {background-color:#DDD;}
+                .acc-list ul li.active {background-color:#EB8F00;}
+                .acc-list ul li strong {display:block;}
+                .acc-list ul li em {display:block;}
+
+                /*Específico do selectable*/
+                #feedback { font-size: 1.4em; }
+                #selectable .ui-selecting { background: #DDECF7; }
+                /* #selectable .ui-selected { background: #F39814; color: white; }   Aqui eu troquei a cor de quando era selecionada a linha */
+                #selectable .ui-selected { background: #72A9D3; color: white; }
+                
+                #selectable { list-style-type: none; margin: 0; padding: 0; width: 100%; }
+                ul#selectable { overflow: hidden; width: 370px;}
+                ul#selectable li { width: 315px; overflow:hidden; }
+                ul#selectable li.ui-selected { width: 81%;  }
+                ul#selectable li div { width: 6000px; }
+                .ui-button-icon-only { width: 1.2em; }
+                .ui-icon { margin-left: -8px; }
+                .ui-widget button { border: 0 solid; } 
+            
+                #dialog-modal { height: 416px; }
+
+ 
