mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-12-03 15:24:09 +01:00
properly convert the json serialized data to the format as expected by the public contacts search
This commit is contained in:
parent
23056e8c05
commit
7065c9be05
@ -116,6 +116,7 @@ class AddressbookProvider implements \OCP\IAddressBook {
|
||||
foreach($ids as $id){
|
||||
$contact = $this->addressBook->getChild($id);
|
||||
$j = JSONSerializer::serializeContact($contact);
|
||||
$j['data']['id'] = $id;
|
||||
if (isset($contact->PHOTO)) {
|
||||
$url =\OCP\Util::linkToRoute('contacts_contact_photo',
|
||||
array(
|
||||
@ -126,7 +127,7 @@ class AddressbookProvider implements \OCP\IAddressBook {
|
||||
$url = \OC_Helper::makeURLAbsolute($url);
|
||||
$j['data']['PHOTO'] = "VALUE=uri:$url";
|
||||
}
|
||||
$results[]= $j['data'];
|
||||
$results[]= $this->convertToSearchResult($j);
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,4 +241,29 @@ class AddressbookProvider implements \OCP\IAddressBook {
|
||||
}
|
||||
return VCard::delete($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $j
|
||||
* @return array
|
||||
*/
|
||||
private function convertToSearchResult($j) {
|
||||
$data = $j['data'];
|
||||
$result = array();
|
||||
foreach( $data as $key => $d) {
|
||||
$d = $data[$key];
|
||||
if (in_array($key, Properties::$multiProperties)) {
|
||||
$result[$key] = array_map(function($v){
|
||||
return $v['value'];
|
||||
}, $d);
|
||||
} else {
|
||||
if (is_array($d)) {
|
||||
$result[$key] = $d[0]['value'];
|
||||
} else {
|
||||
$result[$key] = $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user