index.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net>
  4. * Copyright (c) 2011 Jakob Sack mail@jakobsack.de
  5. * This file is licensed under the Affero General Public License version 3 or
  6. * later.
  7. * See the COPYING-README file.
  8. */
  9. // Check if we are a user
  10. OCP\User::checkLoggedIn();
  11. OCP\App::checkAppEnabled('contacts');
  12. // Get active address books. This creates a default one if none exists.
  13. $ids = OC_Contacts_Addressbook::activeIds(OCP\USER::getUser());
  14. $allcontacts = OC_Contacts_VCard::all($ids);
  15. $contacts = array();
  16. foreach($allcontacts as $contact) { // try to conserve some memory
  17. $contacts[] = array('id' => $contact['id'], 'addressbookid' => $contact['addressbookid'], 'fullname' => $contact['fullname']);
  18. }
  19. unset($allcontacts);
  20. $addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
  21. // Load the files we need
  22. OCP\App::setActiveNavigationEntry( 'contacts_index' );
  23. // Load a specific user?
  24. $id = isset( $_GET['id'] ) ? $_GET['id'] : null;
  25. $details = array();
  26. if(is_null($id) && count($contacts) > 0) {
  27. $id = $contacts[0]['id'];
  28. }
  29. if(!is_null($id)) {
  30. $vcard = OC_Contacts_App::getContactVCard($id);
  31. $details = OC_Contacts_VCard::structureContact($vcard);
  32. }
  33. $property_types = OC_Contacts_App::getAddPropertyOptions();
  34. $phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
  35. $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
  36. $categories = OC_Contacts_App::getCategories();
  37. $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
  38. $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
  39. $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
  40. $freeSpace=OC_Filesystem::free_space('/');
  41. $freeSpace=max($freeSpace,0);
  42. $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
  43. OCP\Util::addscript('','jquery.multiselect');
  44. OCP\Util::addscript('','oc-vcategories');
  45. OCP\Util::addscript('contacts','contacts');
  46. OCP\Util::addscript('contacts','expanding');
  47. OCP\Util::addscript('contacts','jquery.combobox');
  48. OCP\Util::addscript('contacts','jquery.inview');
  49. OCP\Util::addscript('contacts','jquery.Jcrop');
  50. OCP\Util::addscript('contacts','jquery.multi-autocomplete');
  51. OCP\Util::addStyle('','jquery.multiselect');
  52. OCP\Util::addStyle('contacts','jquery.combobox');
  53. OCP\Util::addStyle('contacts','jquery.Jcrop');
  54. OCP\Util::addStyle('contacts','contacts');
  55. $tmpl = new OCP\Template( "contacts", "index", "user" );
  56. $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
  57. $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
  58. $tmpl->assign('property_types', $property_types);
  59. $tmpl->assign('phone_types', $phone_types);
  60. $tmpl->assign('email_types', $email_types);
  61. $tmpl->assign('categories', $categories);
  62. $tmpl->assign('addressbooks', $addressbooks);
  63. $tmpl->assign('contacts', $contacts);
  64. $tmpl->assign('details', $details );
  65. $tmpl->assign('id',$id);
  66. $tmpl->printPage();
  67. ?>