You are here

function print_pdf_nodeapi in Printer, email and PDF versions 5.x

Same name and namespace in other branches
  1. 5.4 print_pdf/print_pdf.module \print_pdf_nodeapi()
  2. 5.3 print_pdf/print_pdf.module \print_pdf_nodeapi()
  3. 6 print_pdf/print_pdf.module \print_pdf_nodeapi()

Implementation of hook_nodeapi().

File

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

Code

function print_pdf_nodeapi(&$node, $op = 'view', $teaser, $page) {
  switch ($op) {
    case 'view':

      // Insert content corner links
      $print_pdf_link_pos = variable_get('print_pdf_link_pos', array(
        PRINT_PDF_LINK_POS_DEFAULT => PRINT_PDF_LINK_POS_DEFAULT,
      ));
      if ($teaser === FALSE && !empty($print_pdf_link_pos['corner']) && isset($node->build_mode) && $node->build_mode === NODE_BUILD_NORMAL) {
        $node->content['print_links']['#value'] .= print_pdf_insert_link(NULL, $node);
      }
      break;
    case 'load':
      _print_pdf_set_node_fields($node);
      break;
    case 'insert':
    case 'update':
      if (user_access('administer print') || user_access('node-specific print configuration')) {
        if ($node->print_pdf_display === NULL) {
          $node->print_pdf_display = variable_get('print_pdf_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
        }
        if ($node->print_pdf_display_comment === NULL) {
          $node->print_pdf_display_comment = variable_get('print_pdf_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
        }
        if ($node->print_pdf_display_urllist === NULL) {
          $node->print_pdf_display_urllist = variable_get('print_pdf_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
        }
        _print_pdf_node_conf_modify($node->nid, $node->print_pdf_display, $node->print_pdf_display_comment, $node->print_pdf_display_urllist);
      }
      break;
    case 'delete':
      db_query("DELETE FROM {print_pdf_node_conf} WHERE nid = %d", $node->nid);
      db_query("DELETE FROM {print_pdf_page_counter} WHERE path = 'node/%d'", $node->nid);
      break;
  }
}