--- revision_moderation.module-rev273082.svn000.tmp.module	Tue May  5 15:59:05 2009
+++ revision_moderation/revision_moderation.module	Thu Apr 16 13:32:45 2009
@@ -127,6 +127,7 @@
  * Implementation of hook_nodeapi().
  */
 function revision_moderation_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
+  $args = arg();
   switch ($op) {
     case 'insert':
       // Store revision moderation setting of this node.
@@ -233,6 +234,28 @@
         break;
     }
   }
+  else if ($node->nid && $node->revision_moderation == 1 && end($args) == 'edit') {
+    switch ($op) {
+      case 'prepare':
+		$revision_author = user_load($node->revision_uid);
+  		drupal_set_message(t('You are currently editing a revision of this post created on @date by !author.', array('@date' => format_date($node->revision_timestamp, 'small'), '!author' => theme('username', $revision_author))));
+        break;
+      case 'presave':
+        $current_vid = db_result(db_query('SELECT vid FROM {node} WHERE nid = %d', $node->nid));
+        $node->original_node = node_load($node->nid, $current_vid);
+        break;
+
+      case 'update':
+        if (isset($node->original_node)) {
+          // Update node table's vid to the original value.
+
+          db_query("UPDATE {node} SET vid = %d, title = '%s', status = %d, moderate = %d WHERE nid = %d", $node->original_node->vid, $node->original_node->title, $node->original_node->status, $node->original_node->moderate, $node->nid);
+          drupal_set_message(t('Your changes have been submitted for moderation.'));
+        }
+        break;
+    }
+  }
+ 
 }
 
 /**
@@ -358,8 +381,8 @@
  */
 function revision_moderation_edit($node) {
   // Get username for the revision rather than the original node.
-  $revision_author = user_load($node->revision_uid);
-  drupal_set_message(t('You are currently editing a revision of this post created on @date by !author.', array('@date' => format_date($node->revision_timestamp, 'small'), '!author' => theme('username', $revision_author))));
+  //$revision_author = user_load($node->revision_uid);
+  //drupal_set_message(t('You are currently editing a revision of this post created on @date by !author.', array('@date' => format_date($node->revision_timestamp, 'small'), '!author' => theme('username', $revision_author))));
   return drupal_get_form($node->type .'_node_form', $node);
 }
 
