You are here

function workflow_admin_ui_types_save in Workflow 7

Save mapping of workflow to node type. E.g., the story node type is using the Foo workflow.

Parameters

$form_state['values']:

1 call to workflow_admin_ui_types_save()
workflow_admin_ui_type_map_form_submit in workflow_admin_ui/workflow_admin_ui.pages.inc
Submit handler for workflow type mapping form.

File

workflow_admin_ui/workflow_admin_ui.module, line 254
Provides administrative UI for workflow. Why it's own module? Lower code footprint and better performance. Additional credit to gcassie ( http://drupal.org/user/80260 ) for the initial push to split UI out of core workflow. We're moving…

Code

function workflow_admin_ui_types_save($form_values) {

  // Empty the table so that types no longer under workflow go away.
  workflow_delete_workflow_type_map_all();
  $node_types = node_type_get_names();
  foreach ($node_types as $type => $name) {
    $data = array(
      'type' => $type,
      'wid' => $form_values[$type]['workflow'],
    );
    workflow_insert_workflow_type_map($data);
    variable_set('workflow_' . $type, array_keys(array_filter($form_values[$type]['placement'])));

    // If this type uses workflow, make sure pre-existing nodes are set
    // to the workflow's creation state.
    if ($form_values[$type]['workflow']) {
      _workflow_node_initialize_nodes($type, $name);
    }
  }
}