editaddress.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. $id = $_GET['id'];
  11. $checksum = isset($_GET['checksum'])?$_GET['checksum']:'';
  12. $vcard = OC_Contacts_App::getContactVCard($id);
  13. $adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
  14. $tmpl = new OCP\Template("contacts", "part.edit_address_dialog");
  15. if($checksum) {
  16. $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
  17. $element = $vcard->children[$line];
  18. $adr = OC_Contacts_VCard::structureProperty($element);
  19. $types = array();
  20. if(isset($adr['parameters']['TYPE'])) {
  21. if(is_array($adr['parameters']['TYPE'])) {
  22. $types = array_map('htmlspecialchars', $adr['parameters']['TYPE']);
  23. $types = array_map('strtoupper', $types);
  24. } else {
  25. $types = array(strtoupper(htmlspecialchars($adr['parameters']['TYPE'])));
  26. }
  27. }
  28. $tmpl->assign('types', $types, false);
  29. $adr = array_map('htmlspecialchars', $adr['value']);
  30. $tmpl->assign('adr', $adr, false);
  31. }
  32. $tmpl->assign('id', $id);
  33. $tmpl->assign('adr_types', $adr_types);
  34. $page = $tmpl->fetchPage();
  35. OCP\JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum)));