function _content_language_access_node_access in Content Language Access 6
Access callback for node/%node.
Wrapper around node_access() or another callback with additional checks for language permissions.
@global object $user @global object $language
Parameters
string $op: The operation to be performed on the node. Possible values are:
- "view"
- "update"
- "delete"
- "create"
object $node: The node object (or node array) on which the operation is to be performed, or node type (e.g. 'forum') for "create" operation.
object $account: Optional, a user object representing the user for whom the operation is to be performed. Determines access for a user other than the current user.
string $old_callback: Optional, a function name containing the old callback.
Return value
bool TRUE if the operation may be performed, or FALSE otherwise.
See also
1 string reference to '_content_language_access_node_access'
- content_language_access_menu_alter in ./
content_language_access.module - Implements hook_menu_alter().
File
- ./
content_language_access.module, line 100 - This module provides access checking of the current language of the site with the language of the content (language neutral are not considered).
Code
function _content_language_access_node_access($op, $node, $account = NULL, $old_callback = NULL) {
global $user;
global $language;
// If no user object is supplied, the access check is for the current user.
if (empty($account)) {
$account = $user;
}
// User #1 has all privileges:
if ($account->uid == 1) {
return TRUE;
}
// Convert the node to an object if necessary:
if ($op != 'create') {
$node = (object) $node;
}
if ($old_callback != NULL && function_exists($old_callback)) {
$access = $old_callback($op, $node, $account);
}
else {
$access = node_access($op, $node, $account);
}
// Bypass completely if access returns false.
if (!$access) {
return FALSE;
}
// Only checks for view permission.
if ($op != 'view') {
return TRUE;
}
if ($node->language) {
// Verifies if the current language is the same of the content.
if ($node->language == $language->language) {
return TRUE;
}
else {
// 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) {
return TRUE;
}
}
}
else {
// Language neutral are always allowed.
return TRUE;
}
return FALSE;
}