You are here

function state_flow_access in State Machine 7.3

Same name and namespace in other branches
  1. 7 modules/state_flow/state_flow.module \state_flow_access()
  2. 7.2 modules/state_flow/state_flow.module \state_flow_access()

Determine whether a user has permission to transition a node with an event.

2 calls to state_flow_access()
state_flow_events in modules/state_flow/state_flow.pages.inc
Page callback for a node's Workflow page.
state_flow_events_revisions_access in modules/state_flow/state_flow.module
Menu access callback for the node revision workflow transition page.

File

modules/state_flow/state_flow.module, line 385
An implementation of node revision workflow for Drupal based on the State Machine system.

Code

function state_flow_access($node, $event_name, $account = NULL) {
  global $user;

  // If no user account is given, then use the current user.
  if (empty($account)) {
    $account = $user;
  }

  // If the user cannot edit the node, then deny access to any events.
  if (!state_flow_menu_node_access($node, $account)) {
    return FALSE;
  }

  // Load the state machine for the node and test whether the event is allowed.
  $machine = state_flow_entity_load_state_machine($node, 'node');
  $state_event = $machine ? $machine
    ->get_event($event_name) : FALSE;
  return $state_event ? $state_event
    ->validate() : FALSE;
}