categoriesfor.php 932 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /**
  3. * Copyright (c) 2012 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 = isset($_GET['id'])?$_GET['id']:null;
  11. if(is_null($id)) {
  12. OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('No ID provided'))));
  13. exit();
  14. }
  15. $vcard = OC_Contacts_App::getContactVCard( $id );
  16. foreach($vcard->children as $property){
  17. //OCP\Util::writeLog('contacts','ajax/categories/checksumfor.php: '.$property->name, OCP\Util::DEBUG);
  18. if($property->name == 'CATEGORIES') {
  19. $checksum = md5($property->serialize());
  20. OCP\JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum)));
  21. exit();
  22. }
  23. }
  24. OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
  25. ?>