function hosting_client_node_access_records in Hosting 5
Same name and namespace in other branches
- 6.2 client/hosting_client.access.inc \hosting_client_node_access_records()
- 7.4 client/hosting_client.access.inc \hosting_client_node_access_records()
- 7.3 client/hosting_client.access.inc \hosting_client_node_access_records()
Implementation of hook_node_access_records().
All node access modules must implement this hook. If the module is interested in the privacy of the node passed in, return a list of node access values for each grant ID we offer. Since this example module only offers 1 grant ID, we will only ever be returning one record.
File
- client/
hosting_client.access.inc, line 171 - Control client node access
Code
function hosting_client_node_access_records($node) {
if (hosting_client_disabling()) {
return;
}
$base_grant = array(
'realm' => 'hosting ' . $node->type,
'grant_view' => TRUE,
'grant_update' => TRUE,
'grant_delete' => FALSE,
'priority' => 1,
);
// tasks inherit from their parent
if ($node->type == 'task') {
$node = node_load($node->rid);
$base_grant['grant_update'] = FALSE;
}
switch ($node->type) {
case 'site':
$base_grant['gid'] = $node->client;
break;
case 'client':
$base_grant['gid'] = $node->nid;
break;
case 'package':
$base_grant['grant_update'] = FALSE;
case 'task':
case 'platform':
case 'web_server':
case 'db_server':
// The rest of the node types are configuration, so only admin should see them.
$base_grant['gid'] = HOSTING_DEFAULT_CLIENT;
break;
default:
//Not hosting node, don't change access.
return;
}
if ($base_grant['gid']) {
if ($base_grant['gid'] != HOSTING_DEFAULT_CLIENT) {
$grants[] = $base_grant;
}
// Also give full access to the administrator user.
$base_grant['gid'] = 1;
$grants[] = $base_grant;
return $grants;
}
}