function workflow_workflow in Workflow 5.2
Same name and namespace in other branches
- 5 workflow.module \workflow_workflow()
Implementation of hook_workflow().
File
- ./
workflow.module, line 817
Code
function workflow_workflow($op, $old_state, $new_state, $node) {
switch ($op) {
case 'transition pre':
break;
case 'transition post':
// A transition has occurred; fire off actions associated with this transition.
// Can't fire actions if actions module is not enabled.
if (!function_exists('actions_do')) {
break;
}
$tid = workflow_get_transition_id($old_state, $new_state);
$op = 'workflow-' . $node->type . '-' . $tid;
$aids = _actions_get_hook_aids('workflow', $op);
if ($aids) {
$context = array(
'hook' => 'workflow',
'op' => $op,
);
// We need to get the expected object if the action's type is not 'node'.
// We keep the object in $objects so we can reuse it if we have multiple actions
// that make changes to an object.
foreach ($aids as $aid => $action_info) {
if ($action_info['type'] != 'node') {
if (!isset($objects[$action_info['type']])) {
$objects[$action_info['type']] = _actions_normalize_node_context($action_info['type'], $node);
}
// Since we know about the node, we pass that info along to the action.
$context['node'] = $node;
$result = actions_do($aid, $objects[$action_info['type']], $context);
}
else {
actions_do($aid, $node, $context);
}
}
}
break;
}
}