Commit 5d9572d7 authored by jcnventura's avatar jcnventura

Fix #599840: use the real page path and not the current URL when determining link visibility

parent 8f55ca8d
...@@ -124,7 +124,7 @@ function print_menu() { ...@@ -124,7 +124,7 @@ function print_menu() {
'file' => 'print.pages.inc', 'file' => 'print.pages.inc',
); );
$items[PRINT_PATH . '/' . PRINT_PATH] = array( $items[PRINT_PATH . '/' . PRINT_PATH] = array(
'page callback' => 'drupal_access_denied', 'access callback' => FALSE,
); );
$items['admin/settings/print'] = array( $items['admin/settings/print'] = array(
'title' => 'Printer, e-mail and PDF versions', 'title' => 'Printer, e-mail and PDF versions',
...@@ -691,7 +691,7 @@ function print_insert_link($path = NULL, $node = NULL) { ...@@ -691,7 +691,7 @@ function print_insert_link($path = NULL, $node = NULL) {
} }
/** /**
* Determine if the current page is enabled according to the visibility settings * Determine if the provided page is enabled according to the visibility settings
* *
* @param $visibility * @param $visibility
* current visibility settings: * current visibility settings:
...@@ -702,7 +702,7 @@ function print_insert_link($path = NULL, $node = NULL) { ...@@ -702,7 +702,7 @@ function print_insert_link($path = NULL, $node = NULL) {
* @return * @return
* TRUE if it is enabled, FALSE otherwise * TRUE if it is enabled, FALSE otherwise
*/ */
function _print_page_match($visibility, $pages) { function _print_page_match($visibility, $path, $pages) {
if ($pages) { if ($pages) {
if ($visibility == 2) { if ($visibility == 2) {
if (module_exists('php')) { if (module_exists('php')) {
...@@ -712,10 +712,10 @@ function _print_page_match($visibility, $pages) { ...@@ -712,10 +712,10 @@ function _print_page_match($visibility, $pages) {
return FALSE; return FALSE;
} }
} }
$path = drupal_get_path_alias($_GET['q']); $alias = drupal_get_path_alias($path);
$page_match = drupal_match_path($path, $pages); $page_match = drupal_match_path($path, $pages);
if ($path != $_GET['q']) { if ($alias != $path) {
$page_match = $page_match || drupal_match_path($_GET['q'], $pages); $page_match = $page_match || drupal_match_path($alias, $pages);
} }
return !($visibility xor $page_match); return !($visibility xor $page_match);
...@@ -758,7 +758,7 @@ function print_link_allowed($args) { ...@@ -758,7 +758,7 @@ function print_link_allowed($args) {
$print_html_node_link_visibility = variable_get('print_html_node_link_visibility', PRINT_HTML_NODE_LINK_VISIBILITY_DEFAULT); $print_html_node_link_visibility = variable_get('print_html_node_link_visibility', PRINT_HTML_NODE_LINK_VISIBILITY_DEFAULT);
$print_html_node_link_pages = variable_get('print_html_node_link_pages', PRINT_HTML_NODE_LINK_PAGES_DEFAULT); $print_html_node_link_pages = variable_get('print_html_node_link_pages', PRINT_HTML_NODE_LINK_PAGES_DEFAULT);
if (!_print_page_match($print_html_node_link_visibility, $print_html_node_link_pages)) { if (!_print_page_match($print_html_node_link_visibility, "node/". $node->nid, $print_html_node_link_pages)) {
// Page not in visibility list // Page not in visibility list
return FALSE; return FALSE;
} }
...@@ -802,7 +802,7 @@ function print_link_allowed($args) { ...@@ -802,7 +802,7 @@ function print_link_allowed($args) {
$print_html_sys_link_visibility = variable_get('print_html_sys_link_visibility', PRINT_HTML_SYS_LINK_VISIBILITY_DEFAULT); $print_html_sys_link_visibility = variable_get('print_html_sys_link_visibility', PRINT_HTML_SYS_LINK_VISIBILITY_DEFAULT);
$print_html_sys_link_pages = variable_get('print_html_sys_link_pages', PRINT_HTML_SYS_LINK_PAGES_DEFAULT); $print_html_sys_link_pages = variable_get('print_html_sys_link_pages', PRINT_HTML_SYS_LINK_PAGES_DEFAULT);
return _print_page_match($print_html_sys_link_visibility, $print_html_sys_link_pages); return _print_page_match($print_html_sys_link_visibility, $_GET['q'], $print_html_sys_link_pages);
} }
return FALSE; return FALSE;
} }
......
...@@ -68,7 +68,7 @@ function print_mail_menu() { ...@@ -68,7 +68,7 @@ function print_mail_menu() {
'file' => 'print_mail.inc', 'file' => 'print_mail.inc',
); );
$items[PRINTMAIL_PATH . '/' . PRINTMAIL_PATH] = array( $items[PRINTMAIL_PATH . '/' . PRINTMAIL_PATH] = array(
'page callback' => 'drupal_access_denied', 'access callback' => FALSE,
); );
$items['admin/settings/print/email'] = array( $items['admin/settings/print/email'] = array(
'title' => 'e-mail', 'title' => 'e-mail',
...@@ -459,7 +459,7 @@ function print_mail_link_allowed($args) { ...@@ -459,7 +459,7 @@ function print_mail_link_allowed($args) {
$print_mail_node_link_visibility = variable_get('print_mail_node_link_visibility', PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT); $print_mail_node_link_visibility = variable_get('print_mail_node_link_visibility', PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT);
$print_mail_node_link_pages = variable_get('print_mail_node_link_pages', PRINT_MAIL_NODE_LINK_PAGES_DEFAULT); $print_mail_node_link_pages = variable_get('print_mail_node_link_pages', PRINT_MAIL_NODE_LINK_PAGES_DEFAULT);
if (!_print_page_match($print_mail_node_link_visibility, $print_mail_node_link_pages)) { if (!_print_page_match($print_mail_node_link_visibility, "node/". $node->nid, $print_mail_node_link_pages)) {
// Page not in visibility list // Page not in visibility list
return FALSE; return FALSE;
} }
...@@ -503,7 +503,7 @@ function print_mail_link_allowed($args) { ...@@ -503,7 +503,7 @@ function print_mail_link_allowed($args) {
$print_mail_sys_link_visibility = variable_get('print_mail_sys_link_visibility', PRINT_MAIL_SYS_LINK_VISIBILITY_DEFAULT); $print_mail_sys_link_visibility = variable_get('print_mail_sys_link_visibility', PRINT_MAIL_SYS_LINK_VISIBILITY_DEFAULT);
$print_mail_sys_link_pages = variable_get('print_mail_sys_link_pages', PRINT_MAIL_SYS_LINK_PAGES_DEFAULT); $print_mail_sys_link_pages = variable_get('print_mail_sys_link_pages', PRINT_MAIL_SYS_LINK_PAGES_DEFAULT);
return _print_page_match($print_mail_sys_link_visibility, $print_mail_sys_link_pages); return _print_page_match($print_mail_sys_link_visibility, $_GET['q'], $print_mail_sys_link_pages);
} }
return FALSE; return FALSE;
} }
...@@ -96,7 +96,7 @@ function print_pdf_menu() { ...@@ -96,7 +96,7 @@ function print_pdf_menu() {
'file' => 'print_pdf.pages.inc', 'file' => 'print_pdf.pages.inc',
); );
$items[PRINTPDF_PATH . '/' . PRINTPDF_PATH] = array( $items[PRINTPDF_PATH . '/' . PRINTPDF_PATH] = array(
'page callback' => 'drupal_access_denied', 'access callback' => FALSE,
); );
$items['admin/settings/print/pdf'] = array( $items['admin/settings/print/pdf'] = array(
'title' => 'PDF', 'title' => 'PDF',
...@@ -501,7 +501,7 @@ function print_pdf_link_allowed($args) { ...@@ -501,7 +501,7 @@ function print_pdf_link_allowed($args) {
$print_pdf_node_link_visibility = variable_get('print_pdf_node_link_visibility', PRINT_PDF_NODE_LINK_VISIBILITY_DEFAULT); $print_pdf_node_link_visibility = variable_get('print_pdf_node_link_visibility', PRINT_PDF_NODE_LINK_VISIBILITY_DEFAULT);
$print_pdf_node_link_pages = variable_get('print_pdf_node_link_pages', PRINT_PDF_NODE_LINK_PAGES_DEFAULT); $print_pdf_node_link_pages = variable_get('print_pdf_node_link_pages', PRINT_PDF_NODE_LINK_PAGES_DEFAULT);
if (!_print_page_match($print_pdf_node_link_visibility, $print_pdf_node_link_pages)) { if (!_print_page_match($print_pdf_node_link_visibility, "node/". $node->nid, $print_pdf_node_link_pages)) {
// Page not in visibility list // Page not in visibility list
return FALSE; return FALSE;
} }
...@@ -545,7 +545,7 @@ function print_pdf_link_allowed($args) { ...@@ -545,7 +545,7 @@ function print_pdf_link_allowed($args) {
$print_pdf_sys_link_visibility = variable_get('print_pdf_sys_link_visibility', PRINT_PDF_SYS_LINK_VISIBILITY_DEFAULT); $print_pdf_sys_link_visibility = variable_get('print_pdf_sys_link_visibility', PRINT_PDF_SYS_LINK_VISIBILITY_DEFAULT);
$print_pdf_sys_link_pages = variable_get('print_pdf_sys_link_pages', PRINT_PDF_SYS_LINK_PAGES_DEFAULT); $print_pdf_sys_link_pages = variable_get('print_pdf_sys_link_pages', PRINT_PDF_SYS_LINK_PAGES_DEFAULT);
return _print_page_match($print_pdf_sys_link_visibility, $print_pdf_sys_link_pages); return _print_page_match($print_pdf_sys_link_visibility, $_GET['q'], $print_pdf_sys_link_pages);
} }
return FALSE; return 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