summaryrefslogtreecommitdiffstats
path: root/apps/contacts/ajax
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-06-27 02:10:02 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-06-27 02:12:53 +0200
commitafd9705283c177fc12892e9edb2425ae380fcfa1 (patch)
tree1df7001251bbdec403bf7e88f76b47e2e200dad1 /apps/contacts/ajax
parent153ee9dcfa62fa7efaf365890884c516d8bc11a1 (diff)
downloadnextcloud-server-afd9705283c177fc12892e9edb2425ae380fcfa1.tar.gz
nextcloud-server-afd9705283c177fc12892e9edb2425ae380fcfa1.zip
Add check for return value.
Diffstat (limited to 'apps/contacts/ajax')
-rw-r--r--apps/contacts/ajax/contacts.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php
index 4bb7801cb2d..07b442159c9 100644
--- a/apps/contacts/ajax/contacts.php
+++ b/apps/contacts/ajax/contacts.php
@@ -31,19 +31,21 @@ foreach($active_addressbooks as $addressbook) {
$contacts_alphabet = OC_Contacts_VCard::all($ids);
// Our new array for the contacts sorted by addressbook
-foreach($contacts_alphabet as $contact) {
- if(!isset($contacts_addressbook[$contact['addressbookid']])) { // It should never execute.
- $contacts_addressbook[$contact['addressbookid']] = array('contacts' => array());
- }
- $display = trim($contact['fullname']);
- if(!$display) {
- $vcard = OC_Contacts_App::getContactVCard($contact['id']);
- if(!is_null($vcard)) {
- $struct = OC_Contacts_VCard::structureContact($vcard);
- $display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
+if($contacts_alphabet) {
+ foreach($contacts_alphabet as $contact) {
+ if(!isset($contacts_addressbook[$contact['addressbookid']])) { // It should never execute.
+ $contacts_addressbook[$contact['addressbookid']] = array('contacts' => array());
+ }
+ $display = trim($contact['fullname']);
+ if(!$display) {
+ $vcard = OC_Contacts_App::getContactVCard($contact['id']);
+ if(!is_null($vcard)) {
+ $struct = OC_Contacts_VCard::structureContact($vcard);
+ $display = isset($struct['EMAIL'][0])?$struct['EMAIL'][0]['value']:'[UNKNOWN]';
+ }
}
+ $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display));
}
- $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display));
}
unset($contacts_alphabet);
uasort($contacts_addressbook, 'cmp');