contacts.php 868 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. OCP\JSON::checkLoggedIn();
  9. OCP\JSON::checkAppEnabled('contacts');
  10. $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
  11. $allcontacts = OC_Contacts_VCard::all($ids);
  12. $contacts = array();
  13. foreach($allcontacts as $contact) { // try to conserve some memory
  14. $contacts[] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'fullname' => $contact['fullname']);
  15. }
  16. unset($allcontacts);
  17. $addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
  18. $tmpl = new OCP\Template("contacts", "part.contacts");
  19. $tmpl->assign('contacts', $contacts);
  20. $page = $tmpl->fetchPage();
  21. OCP\JSON::success(array('data' => array( 'page' => $page )));
  22. ?>