function hosting_client_node_grants in Hosting 7.3
Same name and namespace in other branches
- 6.2 client/hosting_client.access.inc \hosting_client_node_grants()
- 7.4 client/hosting_client.access.inc \hosting_client_node_grants()
Implements hook_node_grants().
File
- client/
hosting_client.access.inc, line 218 - Control client node access.
Code
function hosting_client_node_grants($account, $op) {
$grants =& drupal_static(__FUNCTION__);
if (!isset($grants)) {
$grants = array();
}
$cache_id = $account->uid . $op;
if (!isset($grants[$cache_id])) {
$account->client_id = hosting_get_client_from_user($account->uid);
$types = hosting_feature_node_types();
foreach ($types as $type) {
if (user_access('administer ' . $type . 's', $account)) {
$grants[$cache_id]['hosting ' . $type] = array(
1,
);
}
elseif (user_access($op . ' ' . $type, $account)) {
// TODO: restrict access to certain op-type based on the user relationship to this client - see content of $client_relations
$grants[$cache_id]['hosting ' . $type] = array_keys($account->client_id);
}
elseif ($op == 'update' && user_access('edit ' . $type, $account)) {
$grants[$cache_id]['hosting ' . $type] = array_keys($account->client_id);
}
elseif ($op == 'view' && !user_access('view ' . $type, $account)) {
$grants[$cache_id]['hosting ' . $type] = array_keys($account->client_id);
}
}
}
return isset($grants[$cache_id]) ? $grants[$cache_id] : array();
}