function hosting_client_node_access in Hosting 7.4
Same name and namespace in other branches
- 7.3 client/hosting_client.module \hosting_client_node_access()
Implements hook_node_access().
File
- client/
hosting_client.module, line 97
Code
function hosting_client_node_access($node, $op, $account) {
if (!hosting_feature('client')) {
// Multiple client support has been disabled for this site.
return FALSE;
}
$type = is_string($node) ? $node : $node->type;
if ($type != 'client') {
return NODE_ACCESS_IGNORE;
}
if (user_access('administer clients', $account)) {
return TRUE;
}
else {
switch ($op) {
case 'create':
return user_access('create client', $account);
case 'view':
// TODO shoudn't this SQL query be covered by node_grants?
return user_access('view client', $account) && db_query("SELECT user FROM {hosting_client_user} WHERE user = :user and client = :client", array(
':user' => $account->uid,
':client' => $node->nid,
))
->fetchAssoc();
case 'update':
if (user_access('edit own client', $account) && $account->uid == $node->uid) {
return TRUE;
}
break;
case 'delete':
if (user_access('delete own client', $account) && $account->uid == $node->uid) {
return TRUE;
}
break;
default:
break;
}
}
}