index.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. if (
  13. api_get_configuration_value('hide_certificate_export_link') ||
  14. (api_is_student() && api_get_configuration_value('hide_certificate_export_link_students'))
  15. ) {
  16. api_not_allowed(true);
  17. }
  18. $certificate->generate(array('hide_print_button' => true));
  19. if ($certificate->html_file_is_generated()) {
  20. $certificatePathList[] = $certificate->html_file;
  21. $pdfParams = array(
  22. 'orientation' => 'landscape',
  23. 'top' => 0,
  24. 'right' => 0,
  25. 'bottom' => 0,
  26. 'left' => 0
  27. );
  28. $pdfParams['orientation'] = 'landscape';
  29. $pageFormat = $pdfParams['orientation'] == 'landscape' ? 'A4-L' : 'A4';
  30. $userInfo = api_get_user_info($certificate->user_id);
  31. $pdfName = api_replace_dangerous_char(get_lang('Certificate') . ' ' . $userInfo['username']);
  32. $pdf = new PDF($pageFormat, $pdfParams['orientation'], $pdfParams);
  33. $pdf->html_to_pdf($certificatePathList, $pdfName, null, false, false);
  34. }
  35. break;
  36. default:
  37. //Show certificate HTML
  38. $certificate->show();
  39. }