You are here

function certificate_preview in Certificate 7.2

Same name and namespace in other branches
  1. 8.3 certificate.pages.inc \certificate_preview()
  2. 6.2 certificate.pages.inc \certificate_preview()
  3. 6 certificate.pages.inc \certificate_preview()
  4. 7.3 certificate.pages.inc \certificate_preview()
  5. 3.x certificate.pages.inc \certificate_preview()

Preview certificate template as PDF.

1 string reference to 'certificate_preview'
certificate_menu in ./certificate.module
Implements hook_menu().

File

./certificate.pages.inc, line 169
certificate.pages.inc Functions for generating certificates.

Code

function certificate_preview($template_id) {
  global $user;
  $template = node_load($template_id);
  if ($template) {
    $output = '<html><head><meta charset="utf-8"/></head><body>' . theme('certificate_certificate', array(
      'node' => NULL,
      'account' => $user,
      'template' => $template,
    )) . '</body></html>';
  }
  $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', '');
  if ($print_pdf_pdf_tool == '') {
    drupal_set_message(t('Certificate cannot be displayed because you have not selected a PDF generation tool in !link.', array(
      '!link' => l('Printer, e-mail and PDF versions', 'admin/config/user-interface/print/pdf'),
    )) . '.', 'error');
    return '';
  }
  certificate_print_pdf_wrapper($template->title . '.pdf', $output, $template->certificate['orientation']);
}