editname.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. function bailOut($msg) {
  11. OCP\JSON::error(array('data' => array('message' => $msg)));
  12. OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG);
  13. exit();
  14. }
  15. function debug($msg) {
  16. OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG);
  17. }
  18. $tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
  19. $id = isset($_GET['id'])?$_GET['id']:'';
  20. debug('id: '.$id);
  21. if($id) {
  22. $vcard = OC_Contacts_App::getContactVCard($id);
  23. $name = array('', '', '', '', '');
  24. if($vcard->__isset('N')) {
  25. $property = $vcard->__get('N');
  26. if($property) {
  27. $name = OC_Contacts_VCard::structureProperty($property);
  28. }
  29. }
  30. $tmpl->assign('name',$name);
  31. $tmpl->assign('id',$id);
  32. } else {
  33. bailOut(OC_Contacts_App::$l10n->t('Contact ID is missing.'));
  34. //$addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser());
  35. //$tmpl->assign('addressbooks', $addressbooks);
  36. }
  37. $tmpl->printpage();
  38. ?>