Changeset 5687
- Timestamp:
- 03/09/12 15:16:09 (12 years ago)
- Location:
- sandbox/webservice/api
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/webservice/api/json-rpc/Catalog.php
r5681 r5687 7 7 public function getUserContacts($params){ 8 8 if($this->isLoggedIn($params)) { 9 if($params && $params['contactID'] > 0) 10 $query_contact = 'A.id_contact='.$params['contactID'].' and'; 11 9 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, '. 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)'; 14 16 15 17 if (!$this->getDb()->query($query)) … … 18 20 $contacts = array(); 19 21 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']; 32 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 ? $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 } 33 40 } 34 $this->result = array ('contacts' => $contacts);41 $this->result = array ('contacts' => array_values($contacts)); 35 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; 36 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 } 37 64 return $this->getResponse(); 38 65 } -
sandbox/webservice/api/webservice.php
r5681 r5687 9 9 "Mail.getUserMessages", 10 10 "Catalog.getUserContacts", 11 "Catalog.getImagePicture" 11 12 ); 12 13
Note: See TracChangeset
for help on using the changeset viewer.