You are here

function workbench_moderation_state_allowed in Workbench Moderation 7

Same name and namespace in other branches
  1. 7.3 workbench_moderation.module \workbench_moderation_state_allowed()

Checks if a user may change the state of a node.

This check is based on transition and node type. Users with the 'bypass workbench moderation' permission may make any state transition.

Note that we do not use content-type specific moderation by default. To enable that, see the instructions in workbench_moderation_permission().

Parameters

$account: The user account being checked.

$from_state: The original moderation state.

$to_state: The new moderation state.

Return value

Bollean TRUE or FALSE.

See also

workbench_moderation_permission()

1 call to workbench_moderation_state_allowed()
workbench_moderation_states_next in ./workbench_moderation.module
Provides a list of possible next states for this node.

File

./workbench_moderation.module, line 1077
Content moderation for Workbench.

Code

function workbench_moderation_state_allowed($account, $from_state, $to_state, $node_type) {

  // Allow super-users to moderate all content.
  if (user_access("bypass workbench moderation", $account)) {
    return TRUE;
  }

  // Can this user moderate all content for this transition?
  if (user_access("moderate content from {$from_state} to {$to_state}", $account)) {
    return TRUE;
  }

  // Are we using complex node type rules for this transition?
  if (variable_get('workbench_moderation_per_node_type', FALSE) && user_access("moderate {$node_type} state from {$from_state} to {$to_state}", $account)) {
    return TRUE;
  }

  // Default return.
  return FALSE;
}