properly return empty array if nothing was found in lookup
This commit is contained in:
parent
1836075735
commit
1aa874e8d3
1 changed files with 15 additions and 12 deletions
|
@ -168,23 +168,26 @@ class abook_carddav extends addressbook_backend {
|
||||||
*/
|
*/
|
||||||
function lookup($value, $field=SM_ABOOK_FIELD_NICKNAME) {
|
function lookup($value, $field=SM_ABOOK_FIELD_NICKNAME) {
|
||||||
|
|
||||||
if (empty($value)) {
|
if (empty($value)) { return array(); }
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$abook_uri_len=strlen($this->abook->getUriPath());
|
$abook_uri_len=strlen($this->abook->getUriPath());
|
||||||
if($field == SM_ABOOK_FIELD_NICKNAME) {
|
if($field == SM_ABOOK_FIELD_NICKNAME) {
|
||||||
// TODO: edit this if we use different nick-naming scheme
|
// TODO: edit this if we use different nick-naming scheme
|
||||||
$uri = $this->abook->getUriPath() . $value;
|
$uri = $this->abook->getUriPath() . $value;
|
||||||
$one = $this->abook->getCard($uri);
|
try {
|
||||||
/* returns Associative array with keys:
|
$one = $this->abook->getCard($uri);
|
||||||
etag(string): Entity tag of the returned card
|
/* returns Associative array with keys:
|
||||||
vcf(string): VCard as string
|
etag(string): Entity tag of the returned card
|
||||||
vcard(VCard): VCard as Sabre/VObject VCard
|
vcf(string): VCard as string
|
||||||
*/
|
vcard(VCard): VCard as Sabre/VObject VCard
|
||||||
$vcard = $one['vcard'];
|
*/
|
||||||
// TODO: verify that something was returned
|
$vcard = $one['vcard'];
|
||||||
return $this->vcard2sq($uri, $vcard);
|
return $this->vcard2sq($uri, $vcard);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// no card was returned
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if($field == SM_ABOOK_FIELD_FIRSTNAME) { } // TODO: this will be harder
|
if($field == SM_ABOOK_FIELD_FIRSTNAME) { } // TODO: this will be harder
|
||||||
if($field == SM_ABOOK_FIELD_LASTNAME) { $filter=['N' => "/$value;/^", 'EMAIL' => "//"]; }
|
if($field == SM_ABOOK_FIELD_LASTNAME) { $filter=['N' => "/$value;/^", 'EMAIL' => "//"]; }
|
||||||
|
|
Loading…
Reference in a new issue