function invoice_node_access in Invoice 7
Implements hook_node_access()
Parameters
object $node:
string $op:
object $account:
Return value
boolean
File
- ./
invoice.module, line 243 - Invoice module
Code
function invoice_node_access($node, $op, $account) {
$type = is_string($node) ? $node : $node->type;
if ($type == 'invoice') {
if ($op == 'view') {
if (user_access('access invoices', $account)) {
return NODE_ACCESS_ALLOW;
}
}
if ($op == 'create') {
if (user_access('administer invoices', $account) || user_access('administer own invoices', $account)) {
return NODE_ACCESS_ALLOW;
}
}
if ($op == 'update') {
if (user_access('administer invoices', $account) || user_access('administer own invoices', $account) && $account->uid == $node->uid) {
return NODE_ACCESS_ALLOW;
}
}
if ($op == 'delete') {
if (user_access('administer invoices', $account) || user_access('administer own invoices', $account) && $account->uid == $node->uid) {
return NODE_ACCESS_ALLOW;
}
}
return NODE_ACCESS_DENY;
}
}