The "Choose xxx state" choices in the workflow tab page does not match the transitions allowed in the workflow settings page. The problem seems to be with the function below.

<?php
function workflow_allowable_transitions($sid, $dir = 'to', $roles = 'ALL') {
  $transitions = array();
  $field       = $dir == 'to' ? 'target_sid' : 'sid';
  $field_where = $dir != 'to' ? 'target_sid' : 'sid';
  $result = db_query("(SELECT t.tid, t.%s as state_id, s.state as state_name, s.weight as state_weight FROM "
    . "{workflow_transitions} t INNER JOIN {workflow_states} s ON s.sid = "
    . "t.%s WHERE t.%s = %d) "
    . "UNION "
    . "(SELECT s.sid as tid, s.sid as state_id, s.state as state_name, s.weight as state_weight FROM "
    . "{workflow_states} s WHERE s.sid = %d) "
    . "ORDER BY state_weight", $field, $field, $field_where, $sid, $sid);

  while ($t = db_fetch_object($result)) {
    // derick: START *****
    // derick: bug fix, should be comparing to current sid instead
    //if ($roles == 'ALL' || ($t->tid == $t->state_id) || workflow_transition_allowed($t->tid, $roles)) {
    if ($roles == 'ALL' || ($sid == $t->state_id) || workflow_transition_allowed($t->tid, $roles)) {
    // derick: END *****
      //$state_id = str_pad($t->state_id, 5, '0', STR_PAD_LEFT);
      $state_id = $t->state_id;
      $transitions[$state_id] = $t->state_name;
    }
  }
    
  return $transitions;
}
?>

Comments

JacobSingh’s picture

Status: Needs review » Closed (duplicate)