--- /opt/drupal/drupalmodule/drupal-src-temp/workflow/workflow.module	2006-01-26 17:05:15.000000000 -0800
+++ workflow.module	2006-01-29 14:54:16.000000000 -0800
@@ -175,7 +175,8 @@
       '#title' => $name,
       '#options' => $choices,
       '#parents' => array('workflow'),
-      '#default_value' => intval($current)
+      '#default_value' => intval($current),
+      '#description' => workflow_field_choice_descriptions($choices), 
     );
   }
 }
@@ -258,6 +259,23 @@
 }
 
 /**
+ * Get the descriptions of the states one can move to for a given node.
+ * Use choices so that all the logic I don't follow has been done already :)
+ * @param object $choices array
+ * @return array of descriptions
+ */
+function workflow_field_choice_descriptions($choices) {
+  $description = "States:<br><ul>";
+  foreach ($choices as $key=>$name)
+  {
+     $stateobject = db_fetch_object(db_query("SELECT description FROM {workflow_states} WHERE sid=%d",$key));
+     $description .= "<li>".$name." : ".$stateobject->description."</li>";
+  }
+  $description .="</ul>";
+  return $description;
+}
+
+/**
  * Get the current state of a given node.
  *
  * @param object $node
@@ -546,6 +564,12 @@
     '#size'  => '16',
     '#maxlength' => '254',
   );
+  $form['state_description'] = array(
+    '#type'  => 'textarea',
+    '#title' => t('State description'),
+    '#columns'  => '50',
+    '#rows' => '2',
+  );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save'));
   $form['wid'] = array('#type' => 'value', '#value' => $wid);
   $output = drupal_get_form('workflow_state_add', $form);
@@ -553,13 +577,16 @@
 }
 
 function workflow_state_add_validate($form_id, $form_values) {
-  if ($form_values['state_name'] == '') {
+  if ($form_values['state_name'] == '' ) {
     form_set_error('', t('Please provide a nonblank name for the new state.'));
   }
+  if ($form_values['state_description'] == '' ) {
+    form_set_error('', t('Please provide a nonblank description for the new state.'));
+  }
 }
 
 function workflow_state_add_submit($form_id, $form_values) {
-  workflow_state_create($form_values['wid'], $form_values['state_name']);
+  workflow_state_create($form_values['wid'], $form_values['state_name'],$form_values['state_description']);
   drupal_set_message(t('The workflow state was created.'));
   drupal_goto('admin/workflow');
 }
@@ -1112,11 +1139,11 @@
  * @return
  *   The ID of the workflow state
  */
-function workflow_state_create($wid, $name) {
+function workflow_state_create($wid, $name, $description=NULL) {
   $wid = intval($wid);
   $sid = db_next_id('workflow_state');
-  db_query("INSERT INTO {workflow_states} (sid, wid, state, sysid) VALUES (%d, %d, '%s', %d)",
-    $sid, $wid, $name, 0);
+  db_query("INSERT INTO {workflow_states} (sid, wid, state, sysid,description) VALUES (%d, %d, '%s', %d,'%s')",
+    $sid, $wid, $name, 0,$description);
   return $sid;
 }
 
@@ -1272,4 +1299,4 @@
   global $user;
   db_query("INSERT INTO {workflow_node} (nid, sid, uid, start) VALUES (%d, %d, %d, %d)",
     $node->nid, $sid, $user->uid, time());
-}
\ No newline at end of file
+}
