Commit c8a584b9 authored by jcnventura's avatar jcnventura

Fix visibility so that it works both with the internal and the aliased paths

parent 7d62e7c4
......@@ -120,8 +120,7 @@ function print_link($type, $node = NULL, $teaser = FALSE) {
// No link is shown for several motives...
if ( !($teaser) && ($node_type != 'book') && (!isset($node->book)) &&
($print_html_show_link) && user_access('access print') &&
!(($print_html_node_link_visibility) xor
(drupal_match_path('node/'. $node->nid, $print_html_node_link_pages))) &&
_print_page_match($print_html_node_link_visibility, $print_html_node_link_pages) &&
(($type == 'comment' && $print_display_comment) ||
($type == 'node' && $print_display))) {
$links = array();
......@@ -183,8 +182,7 @@ function print_help($path, $arg) {
$print_html_sys_link_pages = variable_get('print_html_sys_link_pages', PRINT_HTML_SYS_LINK_PAGES_DEFAULT);
if (($print_html_show_link) && user_access('access print') &&
!(($print_html_sys_link_visibility) xor
(drupal_match_path($path, $print_html_sys_link_pages))) &&
_print_page_match($print_html_sys_link_visibility, $print_html_sys_link_pages) &&
(preg_match('!^node/!i', $path) == 0)) {
static $output = FALSE;
......@@ -380,3 +378,30 @@ function print_insert_link($path = NULL) {
return '<span class="print">'. l($format['text'], $path, array('attributes' => $format['attributes'], 'query' => $query, 'absolute' => TRUE, 'html' => $format['html'])) .'</span>';
}
}
/**
* Determine if the current page is enabled according to the visibility settings
*
* @param $visibility
* current visibility settings:
* 0 for show on every page except the listed pages
* 1 for show on only the listed pages
* @param $pages
* list of pages
* @return
* TRUE if it is enabled, FALSE otherwise
*/
function _print_page_match($visibility, $pages) {
if ($pages) {
$path = drupal_get_path_alias($_GET['q']);
$page_match = drupal_match_path($path, $pages);
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $pages);
}
return !($visibility xor $page_match);
}
else {
return TRUE;
}
}
......@@ -102,8 +102,7 @@ function print_mail_link($type, $node = NULL, $teaser = FALSE) {
// No link is shown for several motives...
elseif (($node_type != 'book') && (!isset($node->book)) &&
($print_mail_show_link) && user_access('access print') &&
!(($print_mail_node_link_visibility) xor
(drupal_match_path('node/'. $node->nid, $print_mail_node_link_pages))) &&
_print_page_match($print_mail_node_link_visibility, $print_mail_node_link_pages) &&
(($type == 'comment' && $print_mail_display_comment) ||
($type == 'node' && $print_mail_display))) {
......@@ -135,8 +134,7 @@ function print_mail_help($path, $arg) {
$print_mail_sys_link_pages = variable_get('print_mail_sys_link_pages', PRINT_MAIL_SYS_LINK_PAGES_DEFAULT);
if (($print_mail_show_link) && user_access('access print') &&
!(($print_mail_sys_link_visibility) xor
(drupal_match_path($path, $print_mail_sys_link_pages))) &&
_print_page_match($print_mail_sys_link_visibility, $print_mail_sys_link_pages) &&
(preg_match('!^node/!i', $path) == 0)) {
static $output = FALSE;
......
......@@ -121,8 +121,7 @@ function print_pdf_link($type, $node = NULL, $teaser = FALSE) {
// No link is shown for several motives...
elseif (($node_type != 'book') && (!isset($node->book)) &&
($print_pdf_show_link) && user_access('access print') &&
!(($print_pdf_node_link_visibility) xor
(drupal_match_path('node/'. $node->nid, $print_pdf_node_link_pages))) &&
_print_page_match($print_pdf_node_link_visibility, $print_pdf_node_link_pages) &&
(($type == 'comment' && $print_pdf_display_comment) ||
($type == 'node' && $print_pdf_display))) {
......@@ -154,8 +153,7 @@ function print_pdf_help($path, $arg) {
$print_pdf_sys_link_pages = variable_get('print_pdf_sys_link_pages', PRINT_PDF_SYS_LINK_PAGES_DEFAULT);
if (($print_pdf_show_link) && user_access('access print') &&
!(($print_pdf_sys_link_visibility) xor
(drupal_match_path($path, $print_pdf_sys_link_pages))) &&
_print_page_match($print_pdf_sys_link_visibility, $print_pdf_sys_link_pages) &&
(preg_match('!^node/!i', $path) == 0)) {
static $output = FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment