Changeset 5687


Ignore:
Timestamp:
03/09/12 15:16:09 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Adicionado getImagePicture() e finalizado getUserContacts().

Location:
sandbox/webservice/api
Files:
2 edited

Legend:

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

    r5681 r5687  
    77        public function getUserContacts($params){ 
    88                if($this->isLoggedIn($params)) { 
     9                        if($params && $params['contactID'] > 0)  
     10                                $query_contact = 'A.id_contact='.$params['contactID'].' and'; 
     11                         
    912                        $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, '. 
    10                                         'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
    11                                         'A.id_contact = B.id_contact and B.id_connection = C.id_connection '. 
    12                                         'and B.id_typeof_contact_connection = 1 and A.id_owner='.$this -> getUserId().' group by '. 
    13                                         ' 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)'; 
     13                                '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)'; 
    1416                         
    1517                        if (!$this->getDb()->query($query)) 
     
    1820                        $contacts = array(); 
    1921                        while($this->getDb()->next_record()) { 
    20                                 $row = $this->getDb()->row();                            
    21                                 $contacts[] = array( 
    22                                         'contactID'             => $row['id_contact'], 
    23                                         'MailAddress'   => $row['connection_value'], 
    24                                         'AliasName'             => $row['alias'], 
    25                                         'FirstName'             => $row['given_names'], 
    26                                         'LastName'              => $row['family_names'], 
    27                                         'FullName'              => $row['names_ordered'], 
    28                                         'BirthDate'             => $row['birthdate'], 
    29                                         'Notes'                 => $row['notes'], 
    30                                 //      'ImagePicture'  => null                          
    31                                 ); 
     22                                $row = $this->getDb()->row(); 
     23                                $id = $row['id_contact']; 
    3224                                 
     25                                if($contacts[$id] != null){ 
     26                                        $contacts[$id]['MailAddress'][] = $row['connection_value']; 
     27                                }        
     28                                else{ 
     29                                        $contacts[$id] = array( 
     30                                                'contactID'             => $row['id_contact'], 
     31                                                'MailAddress'   => array($row['connection_value']), 
     32                                                'AliasName'             => ($row['alias'] != null ? $row['alias'] : ""), 
     33                                                'FirstName'             => ($row['given_names'] != null ? $row['given_names'] : ""), 
     34                                                'LastName'              => ($row['family_names'] != null ? $row['family_names'] : ""), 
     35                                                'FullName'              => ($row['names_ordered'] != null ? $row['names_ordered'] : ""), 
     36                                                'BirthDate'             => ($row['birthdate'] != null ? $row['birthdate'] : ""), 
     37                                                'Notes'                 => ($row['notes'] != null ? $row['notes'] : "")                          
     38                                        ); 
     39                                }                                
    3340                        } 
    34                         $this->result = array ('contacts' => $contacts);                                 
     41                        $this->result = array ('contacts' => array_values($contacts)); 
    3542                } 
     43                return $this->getResponse(); 
     44        }        
     45         
     46        public function getImagePicture($params){                
     47                if($this->isLoggedIn($params) && $params['contactID'] > 0) {                     
     48                        $query = 'select A.id_contact, A.photo from phpgw_cc_contact A where A.id_contact='.$params['contactID'].' and A.id_owner='.$this -> getUserId();                
     49                        if (!$this->getDb()->query($query)) 
     50                                return false; 
    3651 
     52                        $contact = array(); 
     53                        if($this->getDb()->next_record()) { 
     54                                $row = $this->getDb()->row(); 
     55                                if($row['photo'] != null) { 
     56                                        $contact[] = array( 
     57                                                'contactID'             => $row['id_contact'], 
     58                                                'ImagePicture'  => ($row['photo'] != null ? base64_encode($row['photo']) : "") 
     59                                        ); 
     60                                }                        
     61                        } 
     62                        $this->result = array ('contacts' => $contact); 
     63                } 
    3764                return $this->getResponse(); 
    3865        }        
  • sandbox/webservice/api/webservice.php

    r5681 r5687  
    99        "Mail.getUserMessages", 
    1010        "Catalog.getUserContacts", 
     11        "Catalog.getImagePicture" 
    1112); 
    1213 
Note: See TracChangeset for help on using the changeset viewer.