index.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. $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 = 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. }