Commit bed46fcc authored by das-peter's avatar das-peter

Merge branch 'inactive-published-revisions' into 7.x-2.x

parents fa9038eb b9aeb947
This diff is collapsed.
......@@ -190,9 +190,17 @@ function workbench_moderation_node_access($node, $op, $account) {
if (!$node->status && user_access('view all unpublished content', $account)) {
return NODE_ACCESS_ALLOW;
}
// Check if user has specific access to the workflow state the node has.
if (($machine = state_flow_entity_load_state_machine($node, 'node')) && ($state = $machine->get_current_state()) && user_access('view all content in state ' . $state, $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;
......@@ -206,12 +214,26 @@ function workbench_moderation_node_access($node, $op, $account) {
* based on the workflow state of a node.
*/
function workbench_moderation_revision_access($node, $op = 'view', $account = NULL) {
// Normal behavior for unmoderated nodes.
if (state_flow_entity_load_state_machine($node, 'node')->ignore()) {
return _node_revision_access($node, $op);
}
// View access is controlled in detail by our hook_node_access implementation.
if ($op == 'view') {
return node_access('view', $node, $account);
}
// Run access check by state_flow.
return state_flow_menu_node_access($node, $account);
}
/**
* Implements hook_state_flow_menu_node_access_alter().
*/
function workbench_moderation_state_flow_menu_node_access_alter(&$access, $node, $account) {
// Simplify state flow access down to match node edit access.
$access = node_access('update', $node, $account);
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
......@@ -406,14 +428,6 @@ function workbench_moderation_messages($context, $node = NULL) {
}
}
/**
* Implements hook_state_flow_menu_node_access_alter().
*/
function workbench_moderation_state_flow_menu_node_access_alter(&$access, $node, $account) {
// Simplify state flow access down to match node edit access.
$access = node_access('update', $node, $account);
}
/**
* Prepare variables for the state_flow_history_entity template.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment