function noderelationships_backref_access in Node Relationships 6
Access callback for the node relationships tab.
See also
1 string reference to 'noderelationships_backref_access'
- _noderelationships_menu in ./
noderelationships.system.inc - Implementation of hook_menu().
File
- ./
noderelationships.module, line 48 - This is the main script for the noderelationships module. It merely contains the implementation of hooks invoked by Drupal core, CCK, Views, etc. All common functions are externalized into several scripts that are included on demand.
Code
function noderelationships_backref_access($referred_node) {
// Deny access if the user does not have access to view the referred node.
if (!node_access('view', $referred_node)) {
return FALSE;
}
// Include common module functions.
module_load_include('inc', 'noderelationships');
// Obtain back reference settings for this type.
$backref_settings = noderelationships_settings_load($referred_node->type, 'backref');
// Deny access (meaning the tab is not visible) when the node type
// does not have back references enabled for this region.
if (empty($backref_settings['regions'][NODERELATIONSHIPS_BACKREF_REGION_TAB])) {
return FALSE;
}
// Allow external modules deny access to the Relationships tab for this node.
$access = (array) module_invoke_all('noderelationships_backref_access', $referred_node);
foreach ($access as $value) {
if ($value === FALSE) {
return FALSE;
}
}
// Ok, the user is allowed to view the node and this type has potential
// back references, so we can grant access to the relationships tab.
// @todo: Find out a way to hide the relationships tab if THIS node does
// not have real back references. The problem here is that a series of
// SELECT COUNT(*) queries would affect performance, so we would have to
// use a summary field or something similar. But this information would
// have to be updated when a nodereference is added, changed or removed
// from the database.
return TRUE;
}