? workflow-comments-edit.patch
Index: workflow.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.module,v
retrieving revision 1.83
diff -u -p -r1.83 workflow.module
--- workflow.module	1 Jan 2009 21:09:16 -0000	1.83
+++ workflow.module	22 Apr 2009 14:05:23 -0000
@@ -331,7 +331,7 @@ function workflow_transition($node, $sid
  * @param $choices
  *   An array of possible target states.
  */
-function workflow_node_form(&$form, $form_state, $title, $name, $current, $choices, $timestamp = NULL, $comment = NULL) {
+function workflow_node_form(&$form, $form_state, $title, $name, $current, $choices, $timestamp = NULL, $comment = NULL, $history = NULL) {
   // No sense displaying choices if there is only one choice.
   if (sizeof($choices) == 1) {
     $form['workflow'][$name] = array(
@@ -394,7 +394,12 @@ function workflow_node_form(&$form, $for
       '#description' => t('A comment to put in the workflow log.'),
       '#default_value' => $comment,
       '#rows' => 2,
-    );      
+    );
+    $form['workflow']['workflow_quick_history'] = array(
+      '#title' => t('History'),
+      '#value' => $history,
+      '#description' => t('History of workflow changes.'),
+    );
   }
 }
 
@@ -466,8 +471,8 @@ function workflow_form_alter(&$form, $fo
     if (isset($form_state['values']['workflow_comment'])) {
       $comment = $form_state['values']['workflow_comment'];
     }
-
-    workflow_node_form($form, $form_state, $name, $name, $current, $choices, $timestamp, $comment);
+    $history = workflow_quick_history_table($node);
+    workflow_node_form($form, $form_state, t('Change %s state', array('%s' => $name)), $name, $current, $choices, $timestamp, $comment, $history);
   }
 }
@@ -1508,4 +1513,43 @@ function workflow_token_list($type = 'al
   }
 
   return $tokens;
-}
\ No newline at end of file
+}
+
+function workflow_quick_history_table($node = NULL) {
+  // drupal_set_title(check_plain($node->title));
+  $wid = workflow_get_workflow_for_type($node->type);
+  $states_per_page = variable_get('workflow_states_per_page', 20);
+
+  $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 1 ORDER BY sid");
+  while ($data = db_fetch_object($result)) {
+    $states[$data->sid] = $data->state;
+  }
+  $deleted_states = array();
+  $result = db_query("SELECT sid, state FROM {workflow_states} WHERE status = 0 ORDER BY sid");
+  while ($data = db_fetch_object($result)) {
+    $deleted_states[$data->sid] = $data->state;
+  }
+  $current = workflow_node_current_state($node);
+  // theme_workflow_current_state() must run state through check_plain().
+  $output = '<p>'. t('Current state: ') . $states[$current] . "</p>\n";
+  //$output .= drupal_get_form('workflow_tab_form', $node, $wid, $states, $current);
+  $result = pager_query("SELECT h.*, u.name FROM {workflow_node_history} h LEFT JOIN {users} u ON h.uid = u.uid WHERE nid = %d ORDER BY hid DESC", $states_per_page, 0, NULL, $node->nid);
+  $rows = array();
+  while ($history = db_fetch_object($result)) {
+    if ($history->sid == $current && !isset($deleted_states[$history->sid]) && !isset($current_themed)) {
+      // Theme the current state differently so it stands out.
+      $state_name = "<b>" . check_plain($states[$history->sid]) . "</b>";
+    }
+    else {
+      // Regular state.
+      $state_name = check_plain($states[$history->sid]);
+    }
+
+    $old_state_name = check_plain($states[$history->old_sid]);
+    $comment = $history->comment;
+    $header = array(t('Comment'), t('Old State'), t('New State')); 
+    $rows[] = array('comment' => $comment, 'old_state' => $old_state_name, 'new_state' => $state_name);
+  }
+  $output .= theme_table($header, $rows);
+  return $output;
+}
