index.php 1.6 KB

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