Changeset 6191


Ignore:
Timestamp:
05/15/12 14:52:57 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Corrigida query SQL para permitir pesquisar por email.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/rest/catalog/ContactsResource.php

    r6165 r6191  
    88                if($this-> isLoggedIn())  
    99                {                        
    10                         $search = ""; 
    1110                         
    1211                        if($this->getParams()) { 
    1312                                $search = trim($this->getParam('search')); 
     13                                $search = ($search ? mb_convert_encoding($search,"ISO_8859-1", "UTF8") : ""); 
    1414                                 
    15                                 if($search != "") { 
    16                                         $search = mb_convert_encoding($search,"ISO_8859-1", "UTF8"); 
    17                                 } 
    18                  
    19                                 if($this->getParam('contactID') > 0 && $this->getParam('contactType') == 1){ 
    20                                         $query_contact = 'A.id_contact='.$this->getParam('contactID').' and'; 
     15                                if($this->getParam('contactType') == 1) { 
     16                                        if($search != "") { 
     17                                                $query_contact = "(A.alias ilike '%$search%' or A.names_ordered ilike '%$search%' or C.connection_value ilike '%$search%') and"; 
     18                                        } 
     19                                        elseif($this->getParam('contactID') > 0){ 
     20                                                $query_contact = 'A.id_contact='.$this->getParam('contactID').' and'; 
     21                                        } 
    2122                                } 
    2223                                elseif($this->getParam('contactType') == 2){ 
     
    5859                                                        'contactHasImagePicture' => ($row['photo'] != null ? 1 : 0), 
    5960                                        ); 
    60                                         if($search != null && 
    61                                                         stristr($contacts[$id]['contactAlias'], $search) == null && 
    62                                                         stristr($contacts[$id]['contactFirstName'], $search) == null && 
    63                                                         stristr($contacts[$id]['contactLastName'], $search) == null && 
    64                                                         stristr($contacts[$id]['contactFullName'], $search) == null && 
    65                                                         stristr($contacts[$id]['contactBirthDate'], $search) == null && 
    66                                                         stristr($contacts[$id]['contactNotes'], $search) == null){ 
    67                                                 unset($contacts[$id]); 
    68                                         } 
    6961                                } 
    7062                        } 
Note: See TracChangeset for help on using the changeset viewer.