1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-19 08:52:22 +01:00

Merge pull request #569 from owncloud/fix-search-master

properly convert the json serialized data to the format as expected by t...
This commit is contained in:
Jan-Christoph Borchardt 2014-07-30 17:18:05 +02:00
commit 105c150fab

View File

@ -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;
}
}