vcard_export.php 966 B

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