You are here

function workflow_admin_ui_edit_form in Workflow 7

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.2 workflow_admin_ui/workflow_admin_ui.page.workflow.inc \workflow_admin_ui_edit_form()

Menu callback. Edit a workflow's properties.

Parameters

$wid: The workflow object.

Return value

HTML form and permissions table.

1 string reference to 'workflow_admin_ui_edit_form'
workflow_admin_ui_menu in workflow_admin_ui/workflow_admin_ui.module
Implements hook_menu().

File

workflow_admin_ui/workflow_admin_ui.pages.inc, line 226
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_edit_form($form, $form_state, $workflow = NULL) {
  $noyes = array(
    t('No'),
    t('Yes'),
  );

  // If we don't have a workflow by this point, we need to go back
  // to creating one at admin/config/workflow/workflow/add
  // I think the menu loader won't allow this to happen.
  if (!$workflow) {
    drupal_goto('admin/config/workflow/workflow/add');
  }
  else {

    // Let's add some breadcrumbs.
    workflow_admin_ui_breadcrumbs($workflow);
    $form = array();
    $form['workflow'] = array(
      '#type' => 'value',
      '#value' => $workflow,
    );
    $form['basic'] = array(
      '#type' => 'fieldset',
      '#title' => t('Workflow information'),
    );
    $form['basic']['wf_name'] = array(
      '#type' => 'textfield',
      '#default_value' => $workflow
        ->getName(),
      '#title' => t('Workflow Name'),
      '#maxlength' => '254',
      '#required' => TRUE,
    );
    $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' => 'radios',
      '#options' => $noyes,
      '#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' => 'radios',
      '#options' => $noyes,
      '#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']['tab_roles'] = array(
      '#type' => 'checkboxes',
      '#options' => workflow_admin_ui_get_roles(),
      '#default_value' => explode(',', $workflow->tab_roles),
      '#description' => t('Select any roles that should have access to the workflow tab on nodes that have a workflow.'),
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save configuration'),
    );
    return $form;
  }
}