From a4887c65024561af2cfc752f334e983c5cfd76e5 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Wed, 26 Jul 2017 14:08:03 +0200 Subject: [PATCH] Fix the restricted execution in combination with view_revisions_by_content_type module --- sites/all/modules/diff/diff.module | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/sites/all/modules/diff/diff.module b/sites/all/modules/diff/diff.module index 355bb01..73861e7 100644 --- a/sites/all/modules/diff/diff.module +++ b/sites/all/modules/diff/diff.module @@ -76,7 +76,7 @@ function diff_menu() { 'page callback' => 'diff_inline_ahah', 'page arguments' => array(1), 'type' => MENU_CALLBACK, - 'access callback' => 'diff_node_revision_access', + 'access callback' => TRUE, # 'diff_node_revision_access', 'access arguments' => array(1), 'file' => 'diff.pages.inc', ); @@ -114,14 +114,21 @@ function diff_block($op = 'list', $delta = 0, $edit = array()) { if ($op === 'list') { return array('inline' => array('info' => t('Inline diff'))); } - elseif ($op === 'view' && $delta === 'inline' && user_access('view revisions') && $node = menu_get_object()) { - $block = array(); - $revisions = node_revision_list($node); - if (count($revisions) > 1) { - $block['subject'] = t('Highlight changes'); - $block['content'] = drupal_get_form('diff_inline_form', $node, $revisions); + elseif ($op === 'view' && $delta === 'inline') { # && $node = menu_get_object()) { +# $parsed_path = explode("/", db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", substr(request_uri(), 1)))); + $parsed_path = explode("/", drupal_lookup_path('source', substr(request_uri(), strlen(base_path())))); + if (array_search('node', $parsed_path) !== FALSE) { + $key = (array_search('node', $parsed_path) + 1); + if ($node = node_load($parsed_path[$key])) { + $block = array(); + $revisions = node_revision_list($node); + if (count($revisions) > 1) { + $block['subject'] = t('Highlight changes'); + $block['content'] = drupal_get_form('diff_inline_form', $node, $revisions); + } + return $block; + } } - return $block; } } @@ -129,7 +136,7 @@ function diff_block($op = 'list', $delta = 0, $edit = array()) { * Implementation of hook_nodeapi(). */ function diff_nodeapi(&$node, $op, $teaser, $page) { - if ($page && $op == 'view' && user_access('view revisions') && variable_get('show_diff_inline_'. $node->type, FALSE)) { + if ($page && $op == 'view' && variable_get('show_diff_inline_'. $node->type, FALSE)) { // Ugly but cheap way to check that we are viewing a node's revision page. if (arg(2) === 'revisions' && arg(3) === $node->vid) { module_load_include('inc', 'diff', 'diff.pages');