Index: workflow.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.module,v retrieving revision 1.54.2.6 diff -u -r1.54.2.6 workflow.module --- workflow.module 2 Mar 2007 20:51:57 -0000 1.54.2.6 +++ workflow.module 29 May 2007 01:17:22 -0000 @@ -149,8 +149,9 @@ function workflow_tab_form(&$node, $wid, $states, $current) { $form = array(); $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)); @@ -315,7 +316,8 @@ if (sizeof($choices) == 1) { $form['workflow'][$name] = array( '#type' => 'hidden', - '#value' => $current + '#value' => $current, + '#parents' => array('workflow'), ); } else { @@ -383,8 +385,9 @@ $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; } @@ -570,9 +573,6 @@ } $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; } @@ -822,20 +822,15 @@ 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 .= drupal_render($form['transitions'][$from][$to][$rid]); - //$cell .= drupal_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 .= drupal_render($form['transitions'][$from][$to][$rid]); } + $row[] = array('data' => $cell); } $rows[] = $row; } @@ -1073,17 +1068,17 @@ 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, + ); } } }