You are here

function workflow_update_transitions in Workflow 6

Same name and namespace in other branches
  1. 5.2 workflow.module \workflow_update_transitions()
  2. 5 workflow.module \workflow_update_transitions()
  3. 6.2 workflow.module \workflow_update_transitions()

Update the transitions for a workflow.

Parameters

array $transitions: Transitions, for example: 18 => array( 20 => array( 'author' => 1, 1 => 0, 2 => 1, ) ) means the transition from state 18 to state 20 can be executed by the node author or a user in role 2. The $transitions array should contain ALL transitions for the workflow.

1 call to workflow_update_transitions()
workflow_admin_ui_edit_form_submit in workflow_admin_ui/workflow_admin_ui.module
Submit handler for the workflow editing form.

File

./workflow.module, line 575
Support workflows made up of arbitrary states.

Code

function workflow_update_transitions($transitions = array()) {

  // Empty string is sometimes passed in instead of an array.
  if (!$transitions) {
    return;
  }
  foreach ($transitions as $from => $to_data) {
    foreach ($to_data as $to => $role_data) {
      foreach ($role_data as $role => $can_do) {
        if ($can_do) {
          workflow_transition_add_role($from, $to, $role);
        }
        else {
          workflow_transition_delete_role($from, $to, $role);
        }
      }
    }
  }
  db_query("DELETE FROM {workflow_transitions} WHERE roles = ''");
}