index.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. $contacts = OC_Contacts_VCard::all($ids);
  15. $addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
  16. // Load the files we need
  17. OCP\App::setActiveNavigationEntry( 'contacts_index' );
  18. // Load a specific user?
  19. $id = isset( $_GET['id'] ) ? $_GET['id'] : null;
  20. $details = array();
  21. if(is_null($id) && count($contacts) > 0) {
  22. $id = $contacts[0]['id'];
  23. }
  24. if(!is_null($id)) {
  25. $vcard = OC_Contacts_App::getContactVCard($id);
  26. $details = OC_Contacts_VCard::structureContact($vcard);
  27. }
  28. $property_types = OC_Contacts_App::getAddPropertyOptions();
  29. $phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
  30. $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
  31. $categories = OC_Contacts_App::getCategories();
  32. $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
  33. $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
  34. $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
  35. $freeSpace=OC_Filesystem::free_space('/');
  36. $freeSpace=max($freeSpace,0);
  37. $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
  38. OCP\Util::addscript('','jquery.multiselect');
  39. OCP\Util::addscript('','oc-vcategories');
  40. OCP\Util::addscript('contacts','contacts');
  41. OCP\Util::addscript('contacts','expanding');
  42. OCP\Util::addscript('contacts','jquery.combobox');
  43. OCP\Util::addscript('contacts','jquery.inview');
  44. OCP\Util::addscript('contacts','jquery.Jcrop');
  45. OCP\Util::addscript('contacts','jquery.multi-autocomplete');
  46. OCP\Util::addStyle('','jquery.multiselect');
  47. OCP\Util::addStyle('contacts','jquery.combobox');
  48. OCP\Util::addStyle('contacts','jquery.Jcrop');
  49. OCP\Util::addStyle('contacts','contacts');
  50. $tmpl = new OCP\Template( "contacts", "index", "user" );
  51. $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
  52. $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
  53. $tmpl->assign('property_types', $property_types);
  54. $tmpl->assign('phone_types', $phone_types);
  55. $tmpl->assign('email_types', $email_types);
  56. $tmpl->assign('categories', $categories);
  57. $tmpl->assign('addressbooks', $addressbooks);
  58. $tmpl->assign('contacts', $contacts, false);
  59. $tmpl->assign('details', $details );
  60. $tmpl->assign('id',$id);
  61. $tmpl->printPage();
  62. ?>