function workbench_moderation_node_access in Workbench Moderation 7.2
Same name and namespace in other branches
- 8.2 workbench_moderation.module \workbench_moderation_node_access()
- 8 workbench_moderation.module \workbench_moderation_node_access()
- 7.3 workbench_moderation.module \workbench_moderation_node_access()
- 7 workbench_moderation.module \workbench_moderation_node_access()
Implements hook_node_access().
Allows users with the 'view all unpublished content' permission to do so.
File
Code
function workbench_moderation_node_access($node, $op, $account) {
if ($op == 'view') {
if (!$node->status && user_access('view all unpublished content', $account)) {
return NODE_ACCESS_ALLOW;
}
$machine = state_flow_entity_load_state_machine($node, 'node');
if ($machine && !$machine
->ignore()) {
// Check if user has specific access to the workflow state the node has.
if (($state = $machine
->get_current_state()) && user_access('view all content in state ' . $state, $account)) {
return NODE_ACCESS_ALLOW;
}
// Check if this is a formerly published version - if so user doesn't have
// access if no explicit state access above is given.
if ($node->status && !$machine
->isActivePublishedRevision()) {
return NODE_ACCESS_DENY;
}
}
}
return NODE_ACCESS_IGNORE;
}