You are here

function workflow_admin_ui_edit_form in Workflow 7.2

Same name and namespace in other branches
  1. 6.2 workflow_admin_ui/workflow_admin_ui.module \workflow_admin_ui_edit_form()
  2. 6 workflow_admin_ui/workflow_admin_ui.module \workflow_admin_ui_edit_form()
  3. 7 workflow_admin_ui/workflow_admin_ui.pages.inc \workflow_admin_ui_edit_form()

Menu callback. Edit a workflow's properties.

Parameters

Workflow $worflow: The workflow object.

Return value

array HTML form and permissions table.

1 call to workflow_admin_ui_edit_form()
workflow_form in workflow_admin_ui/workflow_admin_ui.module

File

workflow_admin_ui/workflow_admin_ui.page.workflow.inc, line 17
Provides an Admin UI page for the Workflow Properties.

Code

function workflow_admin_ui_edit_form($form, &$form_state, $workflow = NULL, $op) {
  $noyes = array(
    t('No'),
    t('Yes'),
  );
  $fieldset_options = array(
    0 => t('No fieldset'),
    1 => t('Collapsible fieldset'),
    2 => t('Collapsed fieldset'),
  );
  $form = array();
  $form['workflow'] = array(
    '#type' => 'value',
    '#value' => $workflow,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#submit' => array(
      'workflow_admin_ui_edit_form_submit',
    ),
    '#validate' => array(
      'workflow_admin_ui_edit_form_validate',
    ),
    '#weight' => 15,
  );
  $form['label'] = array(
    '#title' => t('Label'),
    '#type' => 'textfield',
    '#default_value' => isset($workflow->label) ? $workflow->label : $workflow->name,
    '#description' => t('The human-readable name of this content type.'),
    '#required' => TRUE,
    '#maxlength' => '254',
    '#size' => 30,
  );
  $form['name'] = array(
    '#type' => 'machine_name',
    '#default_value' => $workflow
      ->getName(),
    '#maxlength' => '254',
    // $todo D8 : '#maxlength' => 32,
    '#required' => TRUE,
    '#disabled' => !empty($workflow->locked),
    '#machine_name' => array(
      'exists' => 'workflow_load',
      'source' => array(
        'label',
      ),
    ),
    '#description' => t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores.'),
  );

  // All other settings are only for workflow_node.
  if (!module_exists('workflownode')) {
    return $form;

    // <==== exit !
  }
  $form['basic'] = array(
    '#type' => 'fieldset',
    '#title' => t('Workflow form settings'),
  );
  $form['basic']['fieldset'] = array(
    '#type' => 'select',
    '#options' => $fieldset_options,
    '#title' => t('Show the form in a fieldset?'),
    '#default_value' => isset($workflow->options['fieldset']) ? $workflow->options['fieldset'] : 0,
    '#description' => t("The Widget can be wrapped in a visible fieldset. You'd\n      do this when you use the widget on a Node Edit page."),
  );
  $form['basic']['options'] = array(
    '#type' => 'select',
    '#title' => t('How to show the available states'),
    '#required' => FALSE,
    '#default_value' => isset($workflow->options['options']) ? $workflow->options['options'] : 'radios',
    // '#multiple' => TRUE / FALSE,
    '#options' => array(
      // These options are taken from options.module
      'select' => 'Select list',
      'radios' => 'Radio buttons',
      // This option does not work properly on Comment Add form.
      'buttons' => 'Action buttons',
    ),
    '#description' => t("The Widget shows all available states. Decide which\n      is the best way to show them."),
  );
  $form['basic']['name_as_title'] = array(
    '#type' => 'radios',
    '#options' => $noyes,
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#title' => t('Use the workflow name as the title of the workflow form?'),
    '#default_value' => isset($workflow->options['name_as_title']) ? $workflow->options['name_as_title'] : 0,
    '#description' => t('The workflow section of the editing form is in its own
      fieldset. Checking the box will add the workflow name as the title of workflow section of the editing form.'),
  );
  $form['schedule'] = array(
    '#type' => 'fieldset',
    '#title' => t('Scheduling for Workflow'),
  );
  $form['schedule']['schedule'] = array(
    '#type' => 'radios',
    '#options' => $noyes,
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#title' => t('Allow scheduling of workflow transitions?'),
    '#default_value' => isset($workflow->options['schedule']) ? $workflow->options['schedule'] : 1,
    '#description' => t('Workflow transitions may be scheduled to a moment in the future.
      Soon after the desired moment, the transition is executed by Cron.'),
  );
  $form['schedule']['schedule_timezone'] = array(
    '#type' => 'radios',
    '#options' => $noyes,
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#title' => t('Show a timezone when scheduling a transition?'),
    '#default_value' => isset($workflow->options['schedule_timezone']) ? $workflow->options['schedule_timezone'] : 1,
  );
  $form['comment'] = array(
    '#type' => 'fieldset',
    '#title' => t('Comment for Workflow Log'),
  );
  $form['comment']['comment_log_node'] = array(
    '#type' => 'select',
    '#required' => FALSE,
    '#options' => array(
      // Use 0/1/2 to stay compatible with previous checkbox.
      0 => t('hidden'),
      1 => t('optional'),
      2 => t('required'),
    ),
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#title' => t('Show a comment field in the workflow section of the editing form?'),
    '#default_value' => isset($workflow->options['comment_log_node']) ? $workflow->options['comment_log_node'] : 0,
    '#description' => t('On the node editing form, a Comment form can be shown so that the person
      making the state change can record reasons for doing so. The comment is
      then included in the node\'s workflow history.'),
  );
  $form['comment']['comment_log_tab'] = array(
    '#type' => 'select',
    '#required' => FALSE,
    '#options' => array(
      // Use 0/1/2 to stay compatible with previous checkbox.
      0 => t('hidden'),
      1 => t('optional'),
      2 => t('required'),
    ),
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#title' => t('Show a comment field in the workflow section of the workflow tab form?'),
    '#default_value' => isset($workflow->options['comment_log_tab']) ? $workflow->options['comment_log_tab'] : 0,
    '#description' => t('On the workflow tab, a Comment form can be shown so that the person
      making the state change can record reasons for doing so. The comment
      is then included in the node\'s workflow history.'),
  );
  $form['watchdog'] = array(
    '#type' => 'fieldset',
    '#title' => t('Watchdog Logging for Workflow'),
  );
  $form['watchdog']['watchdog_log'] = array(
    '#type' => 'radios',
    '#options' => $noyes,
    '#attributes' => array(
      'class' => array(
        'container-inline',
      ),
    ),
    '#title' => t('Log informational watchdog messages when a transition is executed (state of a node is changed)?'),
    '#default_value' => isset($workflow->options['watchdog_log']) ? $workflow->options['watchdog_log'] : 0,
    '#description' => t('Optionally log transition state changes to watchdog.'),
  );
  $form['tab'] = array(
    '#type' => 'fieldset',
    '#title' => t('Workflow tab permissions'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['tab']['history_tab_show'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use the workflow history, and show it on a separate tab.'),
    '#required' => FALSE,
    '#default_value' => isset($workflow->options['history_tab_show']) ? $workflow->options['history_tab_show'] : 1,
    '#description' => t("Every state change is recorded in table\n      {workflow_node_history}. If checked and user has proper permission, a\n      tab 'Workflow' is shown on the entity view page, which gives access to\n      the History of the workflow."),
  );
  $form['tab']['tab_roles'] = array(
    '#type' => 'checkboxes',
    '#options' => workflow_get_roles(),
    '#default_value' => array_keys($workflow->tab_roles),
    '#description' => t('Select any roles that should have access to the workflow tab on nodes that have a workflow.'),
  );
  return $form;
}