You are here

function state_flow_access in State Machine 7

Same name and namespace in other branches
  1. 7.3 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.

4 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_revision in modules/state_flow/state_flow.pages.inc
Form builder for the node revision workflow transition form.
state_flow_events_revisions_access in modules/state_flow/state_flow.module
Menu access callback for the node revision workflow transition page.
state_flow_handler_field_events::render in modules/state_flow/includes/views/state_flow_handler_field_events.inc
Render the field.

File

modules/state_flow/state_flow.module, line 257
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.
  $state_flow = state_flow_load_state_machine($node);
  $state_event = $state_flow ? $state_flow
    ->get_event($event_name) : FALSE;
  return $state_event ? $state_event
    ->validate() : FALSE;
}