Changeset 5694


Ignore:
Timestamp:
03/09/12 17:26:41 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Adicionado algumas melhorias no método Catalog.getUserContacts().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/webservice/api/json-rpc/Catalog.php

    r5691 r5694  
    1010                                $query_contact = 'A.id_contact='.$params['contactID'].' and'; 
    1111                         
    12                         $query = 'select A.id_contact, A.alias, A.given_names, A.family_names, A.names_ordered, A.birthdate, A.notes, C.connection_value from phpgw_cc_contact A, '. 
     12                        $query = 'select B.id_typeof_contact_connection, A.photo, A.id_contact, A.alias, A.given_names, A.family_names, A.names_ordered, A.birthdate, A.notes, C.connection_value from phpgw_cc_contact A, '. 
    1313                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
    14                                 'and B.id_typeof_contact_connection = 1 and '.$query_contact.' A.id_owner='.$this -> getUserId().' group by '. 
    15                                 ' A.id_contact, A.alias, A.given_names, A.family_names,A.names_ordered,A.birthdate, A.notes,C.connection_value  order by lower(A.names_ordered)'; 
     14                                ' and '.$query_contact.' A.id_owner='.$this -> getUserId().' group by '. 
     15                                ' B.id_typeof_contact_connection, A.photo, A.id_contact, A.alias, A.given_names, A.family_names,A.names_ordered,A.birthdate, A.notes,C.connection_value order by lower(A.names_ordered)'; 
    1616                         
    1717                        if (!$this->getDb()->query($query)) 
     
    2222                                $row = $this->getDb()->row(); 
    2323                                $id = $row['id_contact']; 
     24                                $contactType = ($row['id_typeof_contact_connection'] == 1 ? 'contactPhones' : 'contactMails');                           
    2425                                 
    2526                                if($contacts[$id] != null){ 
    26                                         $contacts[$id]['MailAddress'][] = $row['connection_value']; 
     27                                        $contacts[$id][$contactType][] = $row['connection_value']; 
    2728                                }        
    2829                                else{ 
    2930                                        $contacts[$id] = array( 
    3031                                                'contactID'             => $row['id_contact'], 
    31                                                 'MailAddress'   => array($row['connection_value']), 
    32                                                 'AliasName'             => ($row['alias'] != null ?  mb_convert_encoding($row['alias'],"UTF8", "ISO_8859-1") : ""), 
    33                                                 'FirstName'             => ($row['given_names'] != null ?  mb_convert_encoding($row['given_names'],"UTF8", "ISO_8859-1") : ""), 
    34                                                 'LastName'              => ($row['family_names'] != null ?  mb_convert_encoding($row['family_names'],"UTF8", "ISO_8859-1") : ""), 
    35                                                 'FullName'              => ($row['names_ordered'] != null ? mb_convert_encoding($row['names_ordered'],"UTF8", "ISO_8859-1") : ""), 
    36                                                 'BirthDate'             => ($row['birthdate'] != null ? $row['birthdate'] : ""), 
    37                                                 'Notes'                 => ($row['notes'] != null ?  mb_convert_encoding($row['notes'],"UTF8", "ISO_8859-1") : "")                               
     32                                                $contactType    => array($row['connection_value']),                                              
     33                                                'contactAlias' => ($row['alias'] != null ?  mb_convert_encoding($row['alias'],"UTF8", "ISO_8859-1") : ""), 
     34                                                'contactFirstName'      => ($row['given_names'] != null ?  mb_convert_encoding($row['given_names'],"UTF8", "ISO_8859-1") : ""), 
     35                                                'contactLastName'       => ($row['family_names'] != null ?  mb_convert_encoding($row['family_names'],"UTF8", "ISO_8859-1") : ""), 
     36                                                'contactFullName'       => ($row['names_ordered'] != null ? mb_convert_encoding($row['names_ordered'],"UTF8", "ISO_8859-1") : ""), 
     37                                                'contactBirthDate'      => ($row['birthdate'] != null ? $row['birthdate'] : ""), 
     38                                                'contactNotes'          => ($row['notes'] != null ?  mb_convert_encoding($row['notes'],"UTF8", "ISO_8859-1") : ""), 
     39                                                'contactHasImagePicture' => ($row['photo'] != null ? 1 : 0), 
    3840                                        ); 
    3941                                }                                
     
    5658                                        $contact[] = array( 
    5759                                                'contactID'             => $row['id_contact'], 
    58                                                 'ImagePicture'  => ($row['photo'] != null ? base64_encode($row['photo']) : "") 
     60                                                'contactImagePicture'   => ($row['photo'] != null ? base64_encode($row['photo']) : "") 
    5961                                        ); 
    6062                                }                        
Note: See TracChangeset for help on using the changeset viewer.