index.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Show specified user certificate
  5. * @package chamilo.certificate
  6. */
  7. /**
  8. * Initialization
  9. */
  10. $language_file= array('admin', 'gradebook', 'document');
  11. require_once '../main/inc/global.inc.php';
  12. require_once api_get_path(LIBRARY_PATH).'certificate.lib.php';
  13. $action = isset($_GET['action']) ? $_GET['action'] : null;
  14. $certificate = new Certificate($_GET['id']);
  15. switch ($action) {
  16. case 'export':
  17. if (
  18. api_get_configuration_value('hide_certificate_export_link') ||
  19. (api_is_student() && api_get_configuration_value('hide_certificate_export_link_students'))
  20. ) {
  21. api_not_allowed(true);
  22. }
  23. $certificate->generate(array('hide_print_button' => true));
  24. if ($certificate->html_file_is_generated()) {
  25. $certificatePathList[] = $certificate->html_file;
  26. $pdfParams = array(
  27. 'orientation' => 'landscape',
  28. 'top' => 0,
  29. 'right' => 0,
  30. 'bottom' => 0,
  31. 'left' => 0
  32. );
  33. $pdfParams['orientation'] = 'landscape';
  34. $pageFormat = $pdfParams['orientation'] == 'landscape' ? 'A4-L' : 'A4';
  35. $userInfo = api_get_user_info($certificate->user_id);
  36. $pdfName = replace_dangerous_char(get_lang('Certificate') . ' ' . $userInfo['username']);
  37. $pdf = new PDF($pageFormat, $pdfParams['orientation'], $pdfParams);
  38. $pdf->html_to_pdf($certificatePathList, $pdfName, null, false, false);
  39. }
  40. break;
  41. default:
  42. //Show certificate HTML
  43. $certificate->show();
  44. }