editname.php 929 B

1234567891011121314151617181920212223242526272829303132333435
  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. require_once 'loghandler.php';
  11. $tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
  12. $id = isset($_GET['id'])?$_GET['id']:'';
  13. if($id) {
  14. $vcard = OC_Contacts_App::getContactVCard($id);
  15. $name = array('', '', '', '', '');
  16. if($vcard->__isset('N')) {
  17. $property = $vcard->__get('N');
  18. if($property) {
  19. $name = OC_Contacts_VCard::structureProperty($property);
  20. }
  21. }
  22. $name = array_map('htmlspecialchars', $name['value']);
  23. $tmpl->assign('name', $name, false);
  24. $tmpl->assign('id', $id, false);
  25. } else {
  26. bailOut(OC_Contacts_App::$l10n->t('Contact ID is missing.'));
  27. }
  28. $page = $tmpl->fetchPage();
  29. OCP\JSON::success(array('data' => array('page'=>$page)));