function content_language_access_node_access in Content Language Access 7
Same name and namespace in other branches
- 8 content_language_access.module \content_language_access_node_access()
Implements hook_node_access().
@global object $language
File
- ./
content_language_access.module, line 32 - Include language permissions to modify content.
Code
function content_language_access_node_access($node, $op, $account) {
global $language;
// Only checks for view permission.
if (is_object($node) && $op == 'view') {
$translation_enabled = locale_multilingual_node_type($node->type);
// Ignoring when node is not translatable or the language is neutral.
if ($translation_enabled && $node->language && $node->language != LANGUAGE_NONE) {
// Verifies if the current language is the same of the content.
if ($node->language != $language->language) {
// Ignore verification while translating content. Drupal passes the
// translation and target parameters during the translation.
// Example: node/add/article?translation=8&target=pt-br
if (drupal_match_path(drupal_get_path_alias(), 'node/add/*') && isset($_GET['translation']) && isset($_GET['target'])) {
return NODE_ACCESS_IGNORE;
}
// Checks the configuration defined in admin page.
$config = _content_language_access_get_config();
$actual_language_permission = isset($config[$language->language][$node->language]) ? $config[$language->language][$node->language] : FALSE;
if (!$actual_language_permission && !user_access('bypass content_language_access', $account)) {
return NODE_ACCESS_DENY;
}
}
}
}
return NODE_ACCESS_IGNORE;
}