diff --git a/print.module b/print.module index 6be40f48167fc52e8045cc85ba8c68a4407075b3..c6eb2f269b9f17ddb3afd11a5a537fed84facfb9 100644 --- a/print.module +++ b/print.module @@ -123,16 +123,15 @@ function print_menu() { */ function print_link($type, $node = NULL, $teaser = FALSE) { $print_html_settings = variable_get('print_html_settings', print_html_settings_default()); - static $print_display = FALSE; + static $print_display_comment = FALSE; - if (($print_display == FALSE) && (isset($node->type))) { + if (($print_display_comment == FALSE) && (isset($node->type))) { $node_type = $node->type; $print_display_comment = variable_get('print_display_comment_'. $node->type, 0); $print_display = variable_get('print_display_'. $node->type, 1); } else { $node_type = ''; - $print_display_comment = 0; $print_display = 1; } diff --git a/print_pdf.module b/print_pdf.module index 1f3335df6c2794c75e3be6acd72a4124e4c8a0f2..49ca5f98765fbbb7486baeddd8e8e4901b6e78ff 100644 --- a/print_pdf.module +++ b/print_pdf.module @@ -67,48 +67,55 @@ function print_pdf_menu() { */ function print_pdf_link($type, $node = NULL, $teaser = FALSE) { $print_pdf_settings = variable_get('print_pdf_settings', print_pdf_settings_default()); - static $print_pdf_display = FALSE; + static $print_pdf_display_comment = FALSE; - if ($print_pdf_display == FALSE) { - if (isset($node->type)) { - $node_type = $node->type; - $print_pdf_display_comment = variable_get('print_pdf_display_comment_'. $node->type, 0); - $print_pdf_display = variable_get('print_pdf_display_'. $node->type, 1); - } - else { - $node_type = ''; - $print_pdf_display_comment = 0; - $print_pdf_display = 1; - } + if (($print_pdf_display_comment == FALSE) && (isset($node->type))) { + $node_type = $node->type; + $print_pdf_display_comment = variable_get('print_pdf_display_comment_'. $node->type, 0); + $print_pdf_display = variable_get('print_pdf_display_'. $node->type, 1); + } + else { + $node_type = ''; + $print_pdf_display = 1; } - // No link is shown for several motives... - if ( !($teaser) && - ($print_pdf_settings['show_link']) && user_access('access print') && - (($type == 'comment' && $print_pdf_display_comment) || - ($type == 'node' && $print_pdf_display))) { + if (!$teaser) { $links = array(); - $format = theme('print_pdf_format_link'); + // Show book link + if (($print_pdf_settings['book_link']) && user_access('access printer-friendly version') && + (($node_type == 'book') || isset($node->book))) { + + $links['book_pdf'] = array('href' => PRINTPDF_PATH ."/book/export/html/". $node->nid, + 'title' => strip_tags($format['text']), + 'attributes' => $format['attributes'], + ); - $query_arr = $_GET; - if ($type == 'comment') { - $query_arr['comment'] = $node->cid; + return $links; } - $query = drupal_query_string_encode($query_arr, array('q')); + // No link is shown for several motives... + elseif (($node_type != 'book') && (!isset($node->book)) && + ($print_pdf_settings['show_link']) && user_access('access print') && + (($type == 'comment' && $print_pdf_display_comment) || + ($type == 'node' && $print_pdf_display))) { + + $query_arr = $_GET; + if ($type == 'comment') { + $query_arr['comment'] = $node->cid; + } + $query = drupal_query_string_encode($query_arr, array('q')); - $links['print_pdf'] = array('href' => PRINTPDF_PATH ."/". $node->nid, - 'title' => $format['text'], - 'attributes' => $format['attributes'], - 'html' => $format['html'], - 'query' => $query, - ); + $links['print_pdf'] = array('href' => PRINTPDF_PATH ."/". $node->nid, + 'title' => $format['text'], + 'attributes' => $format['attributes'], + 'html' => $format['html'], + 'query' => $query, + ); - return $links; - } - else { - return; + return $links; + } } + return; } /**