From 0a82b3e88ee80a29a3d1a16ceb8b781f17aa41cc Mon Sep 17 00:00:00 2001 From: Joao Ventura Date: Sun, 17 Jul 2011 23:11:22 +0200 Subject: [PATCH] Issue #1191596: don't display links block when the user can't access the node. --- print.module | 35 ++++++++++++++++++++--------------- 1 files changed, 20 insertions(+), 15 deletions(-) diff --git a/print.module b/print.module index f95d3c8..35b552f 100644 --- a/print.module +++ b/print.module @@ -242,11 +242,16 @@ function print_block_info() { * Implements hook_block_view(). */ function print_block_view($delta = '') { - switch ($delta) { - case 'print-links': + switch ($delta) { + case 'print-links': $nid = preg_replace('!^node/!', '', $_GET['q']); if (ctype_digit($nid)) { $node = node_load($nid); + if (!node_access('view', $node)) { + // If the user doesn't have access to the node, don't show any links + $block['content'] == ''; + return; + } } else { $node = NULL; @@ -261,21 +266,21 @@ function print_block_view($delta = '') { } } } - break; - case 'print-top': - $block['subject'] = t('Most printed'); - $result = db_query_range("SELECT path FROM {print_page_counter} ORDER BY totalcount DESC", 0, 3) - ->fetchAll(); - if (count($result)) { - $block['content'] = '
'; + break; + case 'print-top': + $block['subject'] = t('Most printed'); + $result = db_query_range("SELECT path FROM {print_page_counter} ORDER BY totalcount DESC", 0, 3) + ->fetchAll(); + if (count($result)) { + $block['content'] = '
'; } - return $block; + break; + } + return $block; } /** -- 1.7.4.1