You are here

function print_pdf_node_update in Printer, email and PDF versions 7.2

Same name and namespace in other branches
  1. 7 print_pdf/print_pdf.module \print_pdf_node_update()

Implements hook_node_update().

1 call to print_pdf_node_update()
print_pdf_node_insert in print_pdf/print_pdf.module
Implements hook_node_insert().

File

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

Code

function print_pdf_node_update($node) {

  // If no global user object, the user_access call will fail.
  if (!isset($GLOBALS['user']) || !is_object($GLOBALS['user'])) {
    return;
  }
  if (user_access('administer print') || user_access('node-specific print configuration')) {
    $link = print_pdf_print_link();
    $size = 'print_' . $link['format'] . '_size';
    $orientation = 'print_' . $link['format'] . '_orientation';
    if (!isset($node->{$size})) {
      $node->{$size} = variable_get($size . '_' . $node->type);
    }
    if (!isset($node->{$orientation})) {
      $node->{$orientation} = variable_get($orientation . '_' . $node->type);
    }
    db_merge('print_pdf_node_conf')
      ->key(array(
      'nid' => $node->nid,
    ))
      ->fields(array(
      'size' => $node->{$size},
      'orientation' => $node->{$orientation},
    ))
      ->execute();
  }

  //For a book page, not only delete the PDF file for the page but also delete the caching PDF file for the entire book.
  if (isset($node->book) && isset($node->book['bid'])) {

    //Delete the book PDF file.
    print_pdf_cache_delete($node->book['bid']);
  }
  print_pdf_cache_delete($node->nid);
}