function print_pdf_nodeapi in Printer, email and PDF versions 6
Same name and namespace in other branches
- 5.4 print_pdf/print_pdf.module \print_pdf_nodeapi()
- 5.3 print_pdf/print_pdf.module \print_pdf_nodeapi()
- 5.x print_pdf/print_pdf.module \print_pdf_nodeapi()
Implementation of hook_nodeapi().
File
- print_pdf/
print_pdf.module, line 373 - 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', unserialize(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':
$res = db_fetch_object(db_query("SELECT link, comments, url_list FROM {print_pdf_node_conf} WHERE nid = %d", $node->nid));
$node->print_pdf_display = $res ? intval($res->link) : variable_get('print_pdf_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
$node->print_pdf_display_comment = $res ? intval($res->comments) : variable_get('print_pdf_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
$node->print_pdf_display_urllist = $res ? intval($res->url_list) : variable_get('print_pdf_display_urllist_' . $node->type, PRINT_TYPE_URLLIST_DEFAULT);
break;
case 'insert':
case 'update':
if (user_access('administer print') || user_access('node-specific print configuration')) {
if (!isset($node->print_pdf_display)) {
$node->print_pdf_display = variable_get('print_pdf_display_' . $node->type, PRINT_TYPE_SHOW_LINK_DEFAULT);
}
if (!isset($node->print_pdf_display_comment)) {
$node->print_pdf_display_comment = variable_get('print_pdf_display_comment_' . $node->type, PRINT_TYPE_COMMENT_LINK_DEFAULT);
}
if (!isset($node->print_pdf_display_urllist)) {
$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;
}
}