Changeset 5681


Ignore:
Timestamp:
03/08/12 18:44:26 (12 years ago)
Author:
niltonneto
Message:

Ticket #2507 - Implementada primeira parte do método Catalog.getUserContacts().

Location:
sandbox/webservice/api
Files:
3 edited

Legend:

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

    r5595 r5681  
    44 
    55class Catalog extends Expresso {         
    6         var $ldap; 
    7         var $db; 
    8                      
    9         private function getLdap(){ 
    10                 if($this->ldap == null) { 
    11                          
    12                 } 
    13                                  
    14                 return $this->ldap; 
    15         } 
    16          
    17         private function getDb(){ 
    18                 if($this->ldap == null) { 
    19                          
    20                 }        
    21                 return $this->db;                
    22         } 
    23          
    246         
    257        public function getUserContacts($params){ 
    268                if($this->isLoggedIn($params)) { 
     9                        $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)'; 
    2714                         
     15                        if (!$this->getDb()->query($query)) 
     16                                return false; 
     17                         
     18                        $contacts = array(); 
     19                        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                                ); 
     32                                 
     33                        } 
     34                        $this->result = array ('contacts' => $contacts);                                 
    2835                } 
    29                          
    30                 $this->result = array ( 
    31                         'contacts' => $contacts 
    32                 ); 
    33                          
     36 
    3437                return $this->getResponse(); 
    3538        }        
     
    3841                 
    3942                if($this->isLoggedIn($params)) { 
    40                          
     43                        $this->result = array ('contacts' => $contacts); 
    4144                } 
    42                          
    43                 $this->result = array ( 
    44                         'contacts' => $contacts 
    45                 ); 
    46                          
    4745                return $this->getResponse(); 
    4846        } 
  • sandbox/webservice/api/json-rpc/Expresso.php

    r5633 r5681  
    44 
    55        protected $expressoVersion; 
     6        protected $ldap; 
    67        var $result; 
    78        var $error; 
     
    2425        }        
    2526                 
     27        protected function getUserId(){ 
     28                return $GLOBALS['phpgw_info']['user']['account_id']; 
     29        } 
     30         
     31        protected function getLdap(){ 
     32                if($this->ldap == null) { 
     33                        $this->ldap = $GLOBALS['phpgw']->common->ldapConnect(); 
     34                } 
     35         
     36                return $this->ldap; 
     37        } 
     38         
     39        protected function getDb(){ 
     40                return $GLOBALS['phpgw']->db; 
     41        } 
     42         
    2643         
    2744        protected function isLoggedIn($params){ 
  • sandbox/webservice/api/webservice.php

    r5633 r5681  
    77        "Expresso.getExpressoVersion", 
    88        "Mail.getUserFolders", 
    9         "Mail.getUserMessages" 
     9        "Mail.getUserMessages", 
     10        "Catalog.getUserContacts", 
    1011); 
    1112 
Note: See TracChangeset for help on using the changeset viewer.