You are here

function workflow_admin_ui_types_form in Workflow 6.2

Same name and namespace in other branches
  1. 6 workflow_admin_ui/workflow_admin_ui.module \workflow_admin_ui_types_form()

Form builder. Allow administrator to map workflows to content types and determine placement.

1 string reference to 'workflow_admin_ui_types_form'
workflow_admin_ui_overview in workflow_admin_ui/workflow_admin_ui.module
Menu callback. Create the main workflow page, which gives an overview of workflows and workflow states.

File

workflow_admin_ui/workflow_admin_ui.module, line 754
Provides administrative UI for workflow. Why it's own module? Lower code footprint and better performance. Additional creadit 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_form() {
  $form = array();
  $workflows = array(
    '<' . t('None') . '>',
  ) + workflow_get_all();
  if (count($workflows) == 0) {
    return $form;
  }
  $type_map = array();
  $result = db_query("SELECT wid, type FROM {workflow_type_map}");
  while ($data = db_fetch_object($result)) {
    $type_map[$data->type] = $data->wid;
  }
  $form['#theme'] = 'workflow_admin_ui_types_form';
  $form['#tree'] = TRUE;
  $form['help'] = array(
    '#type' => 'item',
    '#value' => t('Each content type may have a separate workflow. The form for changing workflow state can be displayed when editing a node, editing a comment for a node, or both.'),
  );
  foreach (node_get_types('names') as $type => $name) {
    $form[$type]['workflow'] = array(
      '#type' => 'select',
      '#title' => check_plain($name),
      '#options' => $workflows,
      '#default_value' => isset($type_map[$type]) ? $type_map[$type] : 0,
    );
    $form[$type]['placement'] = array(
      '#type' => 'checkboxes',
      '#options' => array(
        'node' => t('Post'),
        'comment' => t('Comment'),
      ),
      '#default_value' => variable_get('workflow_' . $type, array(
        'node',
      )),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save workflow mapping'),
  );
  return $form;
}