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

Revision 5691, 2.9 KB checked in by niltonneto, 12 years ago (diff)

Ticket #2507 - Corrigido getUserContacts() problema de acentuação.

  • 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 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 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)';
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                               
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 ?  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") : "")                             
38                                        );
39                                }                               
40                        }
41                        $this->result = array ('contacts' => array_values($contacts));
42                }
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;
51
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                }
64                return $this->getResponse();
65        }       
66       
67        public function getGlobalContacts($params){
68               
69                if($this->isLoggedIn($params)) {
70                        $this->result = array ('contacts' => $contacts);
71                }
72                return $this->getResponse();
73        }
74}
Note: See TracBrowser for help on using the repository browser.