Index: workflow.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.module,v
retrieving revision 1.51.2.1
diff -u -p -r1.51.2.1 workflow.module
--- workflow.module   11 Nov 2006 20:05:24 -0000   1.51.2.1
+++ workflow.module   30 Nov 2006 08:27:45 -0000
@@ -103,7 +103,7 @@ function workflow_menu($may_cache) {
           'access'   => array_intersect($roles, $allowed_roles) || user_access('administer nodes'),
           'type'     => MENU_LOCAL_TASK,
           'weight'   => 2,
-          'callback' => 'workflow_tab_page', 
+          'callback' => 'workflow_tab_page',
           'callback arguments' => arg(1),
          );
       }
@@ -123,8 +123,9 @@ function workflow_tab_page($nid) {
   $output = '<p>'. t('Current state: %state', array('%state' => check_plain($states[$current]))) . "</p>\n";
 
   $choices = workflow_field_choices($node);
-  $min = $states[$current] == t('(creation)') ? 1 : 2;
-  if (count($choices) >= $min) { // bail out if user has no new target state(s)
+
+  // Bail out if user doesn't have any target workflow state.
+  if (count($choices) >= 1) {
     ksort($choices);
     $wid = workflow_get_workflow_for_type($node->type);
     $name = check_plain(workflow_get_name($wid));
@@ -149,13 +150,13 @@ function workflow_tab_page($nid) {
   while ($history = db_fetch_object($result)) {
     $rows[] = array(
       format_date($history->stamp),
-      check_plain($states[$history->old_sid]), 
-      check_plain($states[$history->sid]), 
-      theme('username', $history), 
+      check_plain($states[$history->old_sid]),
+      check_plain($states[$history->sid]),
+      theme('username', $history),
       check_plain($history->comment)
     );
   }
-  
+
   $output .= theme('table', array(t('Date'), t('Old State'), t('New State'), t('By'), t('Comment')), $rows, array('class' => 'workflow_history'), t('Workflow History'));
   $output .= theme('pager', $states_per_page);
   return $output;
@@ -186,7 +187,7 @@ function workflow_tab_submit($form_id, $
  *          view              view                   view
  *                   submit                 submit
  *                   insert                 update
- * 
+ *
  */
 function workflow_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
   switch ($op) {
@@ -226,7 +227,7 @@ function workflow_nodeapi(&$node, $op, $
 /**
  * Add the actual form widgets for workflow change to the passed in form.
  *
- * @param array $form 
+ * @param array $form
  * @param string $name
  * @param string $current
  * @param array $choices
@@ -235,7 +236,8 @@ function workflow_node_form(&$form, $tit
   if (sizeof($choices) == 1) {
     $form['workflow'][$name] = array(
       '#type' => 'hidden',
-      '#value' => $current
+      '#value' => $current,
+      '#parents' => array('workflow'),
     );
   }
   else {
@@ -268,8 +270,9 @@ function workflow_form_alter($form_id, &
     $wid = workflow_get_workflow_for_type($node->type);
     $states = workflow_get_states($wid) + array(t('(creation)'));
     $current = workflow_node_current_state($node);
-    $min = $states[$current] == t('(creation)') ? 1 : 2;
-    if (count($choices) < $min) { // bail out if user has no new target state(s)
+
+    // Bail out if user doesn't have any target workflow state.
+    if (count($choices) < 1) {
       return;
     }
     ksort($choices);
@@ -341,7 +344,7 @@ function workflow_execute_transition($no
   $type = check_plain(node_get_name($node->type)); //module_invoke($node->type, 'node_name', $node);
   $state_name = check_plain($state_name);
   watchdog('workflow', t('State of %type %node_title set to %state_name', array('%type' => $type, '%node_title' => theme('placeholder', $node->title), '%state_name' => $state_name)), WATCHDOG_NOTICE, l('view', $node->nid));
- 
+
   // Notify modules that transition has occurred. Actions should take place
   // in response to this callback, not the previous one.
   module_invoke_all('workflow', 'transition post', $old_sid, $sid, $node);
@@ -432,9 +435,6 @@ function workflow_field_choices($node) {
   }
   $transitions = workflow_allowable_transitions($current_sid, 'to', $roles);
 
-  if ($current_sid != _workflow_creation_state($wid)) { // include current state if not (creation)
-    $transitions = array($current_sid => $states[$current_sid]) + $transitions;
-  }
   return $transitions;
 }
 
@@ -660,20 +660,15 @@ function theme_workflow_edit($form) {
         if ($nested_name == t('(creation)')) {
           continue; // don't allow transition TO (creation)
         }
-        if ($nested_state_id != $state_id) {
-          // need to render checkboxes for transition from $state to $nested_state
-          $from = $state_id;
-          $to = $nested_state_id;
-          $cell = '';
-          foreach ($roles as $rid => $role_name) {
-            $cell .= form_render($form['transitions'][$from][$to][$rid]);
-            //$cell .= form_render($form['transitions']["transitions][$from][$to][$rid"]);
-          }
-          $row[] = array('data' => $cell);
-        }
-        else {
-          $row[] = array('data' => '');
+
+        // Render checkboxes for transition from $state to $nested_state.
+        $from = $state_id;
+        $to = $nested_state_id;
+        $cell = '';
+        foreach ($roles as $rid => $role_name) {
+          $cell .= form_render($form['transitions'][$from][$to][$rid]);
         }
+        $row[] = array('data' => $cell);
       }
       $rows[] = $row;
     }
@@ -849,17 +844,17 @@ function workflow_transition_grid_form($
       if ($nested_name == t('(creation)')) {
         continue; // don't allow transition TO (creation)
       }
-      if ($nested_state_id != $state_id) {
-        // need to generate checkboxes for transition from $state to $nested_state
-        $from = $state_id;
-        $to = $nested_state_id;
-        foreach ($roles as $rid => $role_name) {
-          $tid = workflow_get_transition_id($from, $to);
-          $form[$from][$to][$rid] = array(
-            '#type' => 'checkbox',
-            '#title' => $role_name,
-            '#default_value' => $tid ? workflow_transition_allowed($tid, $rid) : FALSE);
-        }
+
+      // Generate checkboxes for transition from $state to $nested_state.
+      $from = $state_id;
+      $to = $nested_state_id;
+      foreach ($roles as $rid => $role_name) {
+        $tid = workflow_get_transition_id($from, $to);
+        $form[$from][$to][$rid] = array(
+          '#type' => 'checkbox',
+          '#title' => $role_name,
+          '#default_value' => $tid ? workflow_transition_allowed($tid, $rid) : FALSE,
+        );
       }
     }
   }
