--- revision_moderation.module.old	2008-12-27 23:27:14.000000000 +0100
+++ revision_moderation.module	2009-03-03 15:14:59.000000000 +0100
@@ -17,7 +17,7 @@ function revision_moderation_menu() {
 
   // Admin menu
   $items['admin/content/node/revisions'] = array(
-    'title' => t('Pending revisions'),
+    'title' => 'Pending revisions',
     'page callback' => 'revision_moderation_pending_revisions_admin',
     'access arguments' => array('administer nodes'),
     'type' => MENU_LOCAL_TASK,
@@ -25,16 +25,16 @@ function revision_moderation_menu() {
 
   // Admin menu
   $items['admin/settings/revision_moderation'] = array(
-    'title' => t('Revision moderation'),
+    'title' => 'Revision moderation',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('revision_moderation_settings'),
-    'description' => t('Configure revision publishing options.'),
+    'description' => 'Configure revision publishing options.',
     'access arguments' => array('administer nodes'),
   );
 
   // Callback to allow users to edit revisions.
   $items['node/%node/revisions/%/edit'] = array(
-    'title' => t('Edit revision'),
+    'title' => 'Edit revision',
     'load arguments' => array(3),
     'page callback' => 'revision_moderation_edit',
     'page arguments' => array(1),
@@ -47,7 +47,7 @@ function revision_moderation_menu() {
 
   // Callback to allow users to publish revisions directly.
   $items['node/%node/revisions/%/publish'] = array(
-    'title' => t('Publish revision'),
+    'title' => 'Publish revision',
     'load arguments' => array(3),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('revision_moderation_publish_confirm', 1),
@@ -189,7 +189,7 @@ function revision_moderation_nodeapi(&$n
 
   // Only do this logic for non-admin users on nodes with revision moderation
   // turned on.
-  // And not editing a chose revision
+  // And not editing a chosen revision
   if ($node->nid && $node->revision_moderation == 1 && arg(2) != 'revisions'
     && (!user_access('administer nodes') || !variable_get('revision_moderation_exempt', 1))) {
     switch ($op) {
@@ -219,6 +219,9 @@ function revision_moderation_nodeapi(&$n
 
           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.'));
+
+          if (module_exists('rules'))  rules_invoke_event('revision_create', $node);
+
         }
         break;
     }
@@ -360,10 +363,11 @@ function revision_moderation_edit($node)
  *   The node object for which revision is to be published.
  */
 function revision_moderation_publish_confirm($form_state, $node) {
-  $form['node_id'] = array('#type' => 'value', '#value' => $node->nid);
-  $form['title'] = array('#type' => 'value', '#value' => $node->title);
-  $form['revision'] = array('#type' => 'value', '#value' => $node->vid);
-  $form['type'] = array('#type' => 'value', '#value' => $node->type);
+  $form['node_id']      = array('#type' => 'value', '#value' => $node->nid);
+  $form['title']        = array('#type' => 'value', '#value' => $node->title);
+  $form['revision']     = array('#type' => 'value', '#value' => $node->vid);
+  $form['revision_uid'] = array('#type' => 'value', '#value' => $node->revision_uid);
+  $form['type']         = array('#type' => 'value', '#value' => $node->type);
 
   return confirm_form($form, t('Are you sure you want to publish this revision for %title?', array('%title' => $node->title)), 'node/'. $node->nid .'/revisions/'. $node->vid, t('Publishing this revision will make it public for all users.'), t('Publish'), t('Cancel'));
 }
@@ -373,10 +377,11 @@ function revision_moderation_publish_con
  * Publishes a revision directly.
  */
 function revision_moderation_publish_confirm_submit($form, &$form_state) {
-  $nid = $form_state['values']['node_id'];
+  $nid   = $form_state['values']['node_id'];
   $title = $form_state['values']['title'];
-  $vid = $form_state['values']['revision'];
-  $type = $form_state['values']['type'];
+  $vid   = $form_state['values']['revision'];
+  $type  = $form_state['values']['type'];
+  $ruid  = $form_state['values']['revision_uid'];
 
   db_query("UPDATE {node} SET vid = %d, title = '%s' WHERE nid = %d", $vid, $title, $nid);
   // Clear the cache so an anonymous poster can see the changes
@@ -384,4 +389,53 @@ function revision_moderation_publish_con
   drupal_set_message('The selected revision has been published.');
   watchdog('content', '@type: published %title revision %revision', array('@type' => t($type), '%title' => $title, '%revision' => $vid), WATCHDOG_NOTICE, l(t('view'), "node/$nid/revisions/$vid/view"));
   $form_state['redirect'] = 'node/'. $nid;
+
+  if (module_exists('rules')) {
+    $node  = node_load($nid);
+    $ruser = user_load($ruid);
+    rules_invoke_event('revision_publish', $node, $ruser);
+  }
+}
+
+/**
+ * Implementation of hook_token_values().
+ */
+function revision_moderation_token_values($type, $object = NULL, $options = array()) {
+  $values = array();
+  if ($type == 'node') {
+    $values['vid'] = $object->vid;
+    $current_vid = db_result(db_query('SELECT vid FROM {node} WHERE nid = %d', $object->nid));
+    $current_revision_author = db_result(db_query('SELECT uid FROM {node_revisions} WHERE vid = %d', $object->vid));
+    if (module_exists('diff')) {
+      if ($object->vid > $current_vid) {
+        $difflink = "node/$object->nid/revisions/view/$current_vid/$object->vid";
+      }
+      else {
+        $difflink = "node/$object->nid/revisions/view/$object->vid/$current_vid";
+      }
+      $values['revision-diff-link'] = url($difflink, array('absolute' => TRUE));
+    }
+    $values['revision-moderation'] = $object->revision_moderation ? t('on') : t('off');
+    $values['revision'] = $object->revision ? t('on') : t('off');
+
+    //find the author of a revision
+    $revision_author = user_load(array('uid' => $current_revision_author));
+    $values['revision-author-name'] = $revision_author->name;
+  }
+  return $values;
+}
+
+/**
+ * Implementation of hook_token_list().
+ */
+function revision_moderation_token_list($type = 'all') {
+  if ($type == 'node') {
+    $tokens = array();
+    $tokens['node']['revision-author-name'] = t('The name of the revision author'); 
+    $tokens['node']['revision-diff-link'] = t('A link to compare two revisions (requires diff)');
+    $tokens['node']['revision-moderation'] = t('Whether revision moderation is on. (@on/@off)', array('@on' => t('on'), '@off' => t('off')));
+    $tokens['node']['revision'] = t('Whether a new revision is to be created. (@on/@off)', array('@on' => t('on'), '@off' => t('off')));
+    $tokens['node']['vid'] = t('Node revision ID');
+    return $tokens;
+  }
 }
