function workflow_vbo_given_state_action in Workflow 7
Same name and namespace in other branches
- 7.2 workflow_vbo/actions/given.action.inc \workflow_vbo_given_state_action()
Implements a Drupal action. Move a node to a specified state.
File
- workflow_vbo/
workflow_vbo.module, line 76 - Provide workflow actions for VBO. Split out from workflow_actions.
Code
function workflow_vbo_given_state_action($node, array $context) {
global $user;
if (!isset($node->nid)) {
watchdog('workflow_vbo', 'Unable to get current node id state of node - node is not yet saved.');
return;
}
$comment = t($context['workflow_comment'], array(
'%title' => check_plain($node->title),
'%state' => check_plain($context['state_name']),
'%user' => theme('username', array(
'account' => $user,
)),
));
$entity_type = 'node';
$entity = $node;
$current_sid = $node->workflow;
// Fire the transition.
$transition = new WorkflowTransition($entity_type, $entity, $field_name = '', $current_sid, $new_sid = $context['target_sid'], $user->uid, REQUEST_TIME, $comment);
$new_sid = $transition
->execute($force = $context['force']);
}