You are here

function _workbench_moderation_access in Workbench Moderation 7.3

Same name and namespace in other branches
  1. 7 workbench_moderation.module \_workbench_moderation_access()

Custom access handler for node operations.

Parameters

$op: The operation being requested.

$node: The node being acted upon.

Return value

Boolean TRUE or FALSE.

4 calls to _workbench_moderation_access()
workbench_moderation_handler_field_history_link::render_link in includes/workbench_moderation_handler_field_history_link.inc
workbench_moderation_iib_entity_item in ./workbench_moderation.iib.inc
Implements hook_iib_entity_item().
workbench_moderation_messages in ./workbench_moderation.module
Sets status messages for a node.
_workbench_moderation_access_current_draft in ./workbench_moderation.module
Checks if the user can view the current node revision.
1 string reference to '_workbench_moderation_access'
workbench_moderation_menu in ./workbench_moderation.module
Implements hook_menu().

File

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

Code

function _workbench_moderation_access($op, $node) {
  global $user;

  // If we do not control this node type, deny access.
  if (workbench_moderation_node_type_moderated($node->type) === FALSE) {
    return FALSE;
  }
  $access = TRUE;

  // The user must be able to view the moderation history.
  $access &= user_access('view moderation history');

  // The user must be able to edit this node.
  $access &= node_access('update', $node);
  if ($op == 'unpublish') {

    // workbench_moderation_states_next() checks transition permissions.
    $next_states = workbench_moderation_states_next(workbench_moderation_state_published(), $user, $node);
    $access &= !empty($next_states);
  }

  // Allow other modules to change our rule set.
  drupal_alter('workbench_moderation_access', $access, $op, $node);
  return $access;
}