You are here

function workbench_moderation_trigger_transition in Workbench Moderation 7

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

transition trigger: Run actions associated with an arbitrary event.

This function is executed after a transition takes place.

Parameters

$node: The node undergoing the transition.

$from_state: The previous workbench moderation state.

$state: The new workbench moderation state.

1 call to workbench_moderation_trigger_transition()
workbench_moderation_workbench_moderation_transition in ./workbench_moderation.module
Implementation of hook_workbench_moderation_transition().

File

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

Code

function workbench_moderation_trigger_transition($node, $from_state, $state, $a3 = NULL, $a4 = NULL) {

  // Ask the trigger module for all actions enqueued for the 'transition' trigger.
  $aids = trigger_get_assigned_actions('workbench_moderation_transition');

  // prepare a basic context, indicating group and "hook", and call all the
  // actions with this context as arguments.
  $context = array(
    'group' => 'workbench_moderation',
    'hook' => 'transition',
    'from_state' => $from_state,
    'state' => $state,
  );
  actions_do(array_keys($aids), $node, $context, $a3, $a4);

  // Ask the trigger module for all actions enqueued for this specific transition.
  $transition_string = 'wmt_' . $from_state . '__' . $state;

  // Hash this string if it's longer than the db field size
  if (strlen($transition_string) > 32) {
    $transition_string = md5($transition_string);
  }
  $aids = trigger_get_assigned_actions($transition_string);
  $context['hook'] = $transition_string;
  actions_do(array_keys($aids), $node, $context, $a3, $a4);
}