vcard_export.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use JeroenDesloovere\VCard\VCard;
  4. /**
  5. * VCard Generator.
  6. *
  7. * @package chamilo.social
  8. *
  9. * @author José Loguercio Silva <jose.loguercio@beeznest.com>
  10. */
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. api_block_anonymous_users();
  13. api_protect_admin_script();
  14. if (isset($_REQUEST['userId'])) {
  15. $userId = intval($_REQUEST['userId']);
  16. } else {
  17. api_not_allowed(true);
  18. }
  19. // Return User Info to vCard Export
  20. $userInfo = api_get_user_info($userId, true, false, true);
  21. if (empty($userInfo)) {
  22. api_not_allowed(true);
  23. }
  24. // Pre-Loaded User Info
  25. $language = get_lang('Language').': '.$userInfo['language'];
  26. // Instance the vCard Class
  27. $vcard = new VCard();
  28. // Adding the User Info to the vCard
  29. $vcard->addName($userInfo['firstname'], $userInfo['lastname']);
  30. if (api_get_setting('show_email_addresses') == 'true') {
  31. $vcard->addEmail($userInfo['email']);
  32. }
  33. $vcard->addPhoneNumber($userInfo['phone'], 'CELL');
  34. $vcard->addNote($language);
  35. // Generate the vCard
  36. return $vcard->download();