print_pdf_wkhtmltopdf.install 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the print_pdf_wkhtmltopdf module.
  5. *
  6. * @ingroup print
  7. */
  8. /**
  9. * Implements hook_uninstall().
  10. */
  11. function print_pdf_wkhtmltopdf_uninstall() {
  12. variable_del('print_pdf_wkhtmltopdf_options');
  13. variable_del('print_pdf_wkhtmltopdf_use_input_file');
  14. variable_del('print_pdf_wkhtmltopdf_version');
  15. }
  16. /**
  17. * Implements hook_requirements().
  18. */
  19. function print_pdf_wkhtmltopdf_requirements($phase) {
  20. $requirements = array();
  21. $t = get_t();
  22. switch ($phase) {
  23. // On status report page, make sure that a PDF generation tool is selected.
  24. case 'runtime':
  25. $print_pdf_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT);
  26. if (!empty($print_pdf_pdf_tool)) {
  27. $tool = explode('|', $print_pdf_pdf_tool);
  28. if (is_file($tool[1]) && is_readable($tool[1])) {
  29. if (drupal_substr(basename($tool[1], '.exe'), 0, 11) == 'wkhtmltopdf') {
  30. if (function_exists('is_executable') && !is_executable($tool[1])) {
  31. $requirements['print_pdf_wkhtmltopdf'] = array(
  32. 'title' => $t('wkhtmltopdf library'),
  33. 'value' => $t('Non-executable permissions'),
  34. 'description' => $t('You must modify the permissions of the wkhtmltopdf file (%file) to make it executable.', array('%file' => $tool[1])),
  35. 'severity' => REQUIREMENT_ERROR,
  36. );
  37. }
  38. }
  39. }
  40. }
  41. break;
  42. }
  43. return $requirements;
  44. }