Index: workflow.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.module,v retrieving revision 1.54.2.16 diff -u -r1.54.2.16 workflow.module --- workflow.module 14 Jan 2008 17:11:57 -0000 1.54.2.16 +++ workflow.module 6 Feb 2008 02:12:02 -0000 @@ -149,9 +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) { $wid = workflow_get_workflow_for_type($node->type); $name = check_plain(workflow_get_name($wid)); // see if scheduling information is present @@ -315,7 +315,8 @@ if (sizeof($choices) == 1) { $form['workflow'][$name] = array( '#type' => 'hidden', - '#value' => $current + '#value' => $current, + '#parents' => array('workflow'), ); } else { @@ -383,8 +384,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,10 +572,7 @@ $roles = 'ALL'; } $transitions = workflow_allowable_transitions($current_sid, 'to', $roles); - - if ($current_sid == _workflow_creation_state($wid)) { // include current state if not (creation) - unset($transitions[$current_sid]); - } + return $transitions; } @@ -829,20 +828,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; } @@ -1080,17 +1074,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, + ); } } }