You are here

function workflow_tab_form in Workflow 5.2

Same name and namespace in other branches
  1. 5 workflow.module \workflow_tab_form()
  2. 6.2 workflow.pages.inc \workflow_tab_form()
  3. 6 workflow.pages.inc \workflow_tab_form()
  4. 7 workflow.pages.inc \workflow_tab_form()

Creates form definition of the workflow editing form.

Parameters

$node: Node for which workflow information will be displayed.

$wid: The workflow ID.

unknown_type $states: Array of states for the workflow.

$current: The current state that this node is in.

Return value

Form definition.

1 string reference to 'workflow_tab_form'
workflow_tab_page in ./workflow.module
Menu callback. Displays the workflow information for a node.

File

./workflow.module, line 253

Code

function workflow_tab_form(&$node, $wid, $states, $current) {
  $form = array();
  $choices = workflow_field_choices($node);
  $min = $states[$current] == t('(creation)') ? 1 : 2;

  // Only build form if user has possible target state(s).
  if (count($choices) >= $min) {
    $wid = workflow_get_workflow_for_type($node->type);
    $name = check_plain(t(workflow_get_name($wid)));

    // See if scheduling information is present.
    if ($node->_workflow_scheduled_timestamp && $node->_workflow_scheduled_sid) {
      global $user;
      if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
        $timezone = $user->timezone;
      }
      else {
        $timezone = variable_get('date_default_timezone', 0);
      }

      // The default value should be the upcoming sid.
      $current = $node->_workflow_scheduled_sid;
      $timestamp = $node->_workflow_scheduled_timestamp;
      $comment = $node->_workflow_scheduled_comment;
    }
    workflow_node_form($form, t('Change %s state', array(
      '%s' => $name,
    )), $name, $current, $choices, $timestamp, $comment);
    $form['node'] = array(
      '#type' => 'value',
      '#value' => $node,
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
    );
  }
  return $form;
}