You are here

function print_pdf_cache_delete in Printer, email and PDF versions 7.2

Deletes one or more files from the PDF cache directory.

Parameters

int $nid: The node ID of the page for which the cached PDF should be deleted. If not provided, the entire cache directory will be deleted.

4 calls to print_pdf_cache_delete()
print_pdf_cache_clean in print_pdf/print_pdf.module
Removes pdf files for nodes/paths if they are older than the lifetime.
print_pdf_flush_caches in print_pdf/print_pdf.module
Implements hook_flush_caches().
print_pdf_node_delete in print_pdf/print_pdf.module
Implements hook_node_delete().
print_pdf_node_update in print_pdf/print_pdf.module
Implements hook_node_update().

File

print_pdf/print_pdf.module, line 407
Displays Printer-friendly versions of Drupal pages.

Code

function print_pdf_cache_delete($nid = NULL) {
  $directory = print_pdf_cache_dir();
  if ($nid) {
    $filename = $directory . '/' . $nid . '.pdf';
    if (is_file($filename)) {
      file_unmanaged_delete($filename);
    }
  }
  else {

    // If no nid is provided, flush the entire cache.
    if (is_dir($directory)) {
      file_unmanaged_delete_recursive($directory);
    }
  }
}