diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-06-20 20:57:34 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-06-20 21:00:49 +0200 |
commit | 426ed27be2dc5df34cc036cc87337837288156ec (patch) | |
tree | a54ef381685175e3d51c4bc8460cd41a4db740b7 /apps/contacts/ajax/contacts.php | |
parent | 0f1fe0b505b57e1fec3171a57ea41ec41d9692ee (diff) | |
download | nextcloud-server-426ed27be2dc5df34cc036cc87337837288156ec.tar.gz nextcloud-server-426ed27be2dc5df34cc036cc87337837288156ec.zip |
Make sure address books are shown even if empty.
Diffstat (limited to 'apps/contacts/ajax/contacts.php')
-rw-r--r-- | apps/contacts/ajax/contacts.php | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php index bf4d5deb2e0..16730ec9474 100644 --- a/apps/contacts/ajax/contacts.php +++ b/apps/contacts/ajax/contacts.php @@ -17,14 +17,25 @@ function cmp($a, $b) OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -$ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser()); -$contacts_alphabet = OC_Contacts_VCard::all($ids); $active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser()); +error_log('active_addressbooks: '.print_r($active_addressbooks, true)); -// Our new array for the contacts sorted by addressbook $contacts_addressbook = array(); +$ids = array(); +foreach($active_addressbooks as $addressbook) { + $ids[] = $addressbook['id']; + if(!isset($contacts_addressbook[$addressbook['id']])) { + $contacts_addressbook[$addressbook['id']] = array('contacts' => array()); + $contacts_addressbook[$addressbook['id']]['displayname'] = $addressbook['displayname']; + } +} +error_log('ids: '.print_r($ids, true)); +$contacts_alphabet = OC_Contacts_VCard::all($ids); +error_log('contacts_alphabet: '.print_r($contacts_alphabet, true)); + +// Our new array for the contacts sorted by addressbook foreach($contacts_alphabet as $contact) { - if(!isset($contacts_addressbook[$contact['addressbookid']])) { + if(!isset($contacts_addressbook[$contact['addressbookid']])) { // It should never execute. $contacts_addressbook[$contact['addressbookid']] = array('contacts' => array()); } $display = trim($contact['fullname']); @@ -38,14 +49,6 @@ foreach($contacts_alphabet as $contact) { $contacts_addressbook[$contact['addressbookid']]['contacts'][] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'displayname' => htmlspecialchars($display)); } -foreach($contacts_addressbook as $addressbook_id => $contacts) { - foreach($active_addressbooks as $addressbook) { - if($addressbook_id == $addressbook['id']) { - $contacts_addressbook[$addressbook_id]['displayname'] = $addressbook['displayname']; - } - } -} - uasort($contacts_addressbook, 'cmp'); $tmpl = new OCP\Template("contacts", "part.contacts"); |