source: sandbox/webservice/api/json-rpc/Catalog.php @ 5699

Revision 5699, 3.1 KB checked in by niltonneto, 12 years ago (diff)

Ticket #2507 - Corrigido condição invertida do tipo de conexão para emails e telefones.

  • Property svn:executable set to *
Line 
1<?php
2
3include_once("Expresso.php");
4
5class Catalog extends Expresso {       
6       
7        public function getUserContacts($params){
8                if($this->isLoggedIn($params)) {
9                        if($params && $params['contactID'] > 0)
10                                $query_contact = 'A.id_contact='.$params['contactID'].' and';
11                       
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, '.
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 '.$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)';
16                       
17                        if (!$this->getDb()->query($query))
18                                return false;
19                       
20                        $contacts = array();
21                        while($this->getDb()->next_record()) {
22                                $row = $this->getDb()->row();
23                                $id = $row['id_contact'];
24                                $contactType = ($row['id_typeof_contact_connection'] == 2 ? 'contactPhones' : 'contactMails');                         
25                               
26                                if($contacts[$id] != null){
27                                        $contacts[$id][$contactType][] = $row['connection_value'];
28                                }       
29                                else{
30                                        $contacts[$id] = array(
31                                                'contactID'             => $row['id_contact'],
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),
40                                        );
41                                }                               
42                        }
43                        $this->result = array ('contacts' => array_values($contacts));
44                }
45                return $this->getResponse();
46        }       
47       
48        public function getImagePicture($params){               
49                if($this->isLoggedIn($params) && $params['contactID'] > 0) {                   
50                        $query = 'select A.id_contact, A.photo from phpgw_cc_contact A where A.id_contact='.$params['contactID'].' and A.id_owner='.$this -> getUserId();               
51                        if (!$this->getDb()->query($query))
52                                return false;
53
54                        $contact = array();
55                        if($this->getDb()->next_record()) {
56                                $row = $this->getDb()->row();
57                                if($row['photo'] != null) {
58                                        $contact[] = array(
59                                                'contactID'             => $row['id_contact'],
60                                                'contactImagePicture'   => ($row['photo'] != null ? base64_encode($row['photo']) : "")
61                                        );
62                                }                       
63                        }
64                        $this->result = array ('contacts' => $contact);
65                }
66                return $this->getResponse();
67        }       
68       
69        public function getGlobalContacts($params){
70               
71                if($this->isLoggedIn($params)) {
72                        $this->result = array ('contacts' => $contacts);
73                }
74                return $this->getResponse();
75        }
76}
Note: See TracBrowser for help on using the repository browser.