Last active
February 8, 2016 16:34
-
-
Save Renrhaf/bcd23b0cdcb706792d13 to your computer and use it in GitHub Desktop.
AFOUND-611
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/custom/arte_language/arte_language.module b/modules/custom/arte_language/arte_language.module | |
index 7c64efd..d610555 100755 | |
--- a/modules/custom/arte_language/arte_language.module | |
+++ b/modules/custom/arte_language/arte_language.module | |
@@ -388,6 +388,7 @@ function _arte_language_http_request($url, array $options = array()) { | |
*/ | |
function arte_language_node_access($node, $node_op, $account) { | |
global $language; | |
+ $langcode = $language->language; | |
// This node_access rule is only for anonymous users, so skip if not anonymous | |
if (!user_is_anonymous()) { | |
@@ -402,9 +403,15 @@ function arte_language_node_access($node, $node_op, $account) { | |
return NODE_ACCESS_ALLOW; | |
} | |
- // Deny access to unpublished or unavailable translations | |
- if (isset($node->translations) && empty($node->translations->data[$language->language]['status'])) { | |
- return NODE_ACCESS_DENY; | |
+ // Deny access to view unpublished or unavailable translations. | |
+ // Only acts if the entity_translation is enabled for this content type. | |
+ if ($node_op == 'view' && module_exists('entity_translation') && entity_translation_enabled('node', $node)) { | |
+ $handler = entity_translation_get_handler('node', $node); | |
+ if ($translations = $handler->getTranslations()->data) { | |
+ if (!isset($translations[$langcode]) || !entity_translation_access('node', $translations[$langcode])) { | |
+ return NODE_ACCESS_DENY; | |
+ } | |
+ } | |
} | |
return NODE_ACCESS_IGNORE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment