Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.709
diff -u -d -F^\s*function -r1.709 node.module
--- modules/node/node.module	20 Oct 2006 21:00:16 -0000	1.709
+++ modules/node/node.module	21 Oct 2006 15:59:57 -0000
@@ -41,7 +41,7 @@ function node_help($section) {
       return '<p>'. t('To create a new content type, enter the human-readable name, the machine-readable name, and all other relevant fields that are on this page. Once created, users of your site will be able to create posts that are instances of this content type.');
   }
 
-  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions') {
+  if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions' && arg(4) != 'delete' && arg(4) != 'revert') {
     return t('The revisions let you track differences between multiple versions of a post.');
   }
 
@@ -1102,12 +1102,37 @@ function node_menu($may_cache) {
           'access' => node_access('delete', $node),
           'weight' => 1,
           'type' => MENU_CALLBACK);
+
+        // Revisions tab and subpages
         $revisions_access = ((user_access('view revisions') || user_access('administer nodes')) && node_access('view', $node) && db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', arg(1))) > 1);
         $items[] = array('path' => 'node/'. arg(1) .'/revisions', 'title' => t('revisions'),
-          'callback' => 'node_revisions',
+          'callback' => 'node_revision_overview',
+          'callback arguments' => array($node),
           'access' => $revisions_access,
           'weight' => 2,
           'type' => MENU_LOCAL_TASK);
+
+        if (arg(2) == 'revisions' && is_numeric(arg(3))) {
+          $revision = node_load(arg(1), arg(3));
+          if ($revision->nid) {
+            $items[] = array('path' => 'node/'. arg(1) .'/revisions/'. arg(3) .'/view',
+              'title' => t('Revision of @title from @date', array('@title' => $revision->title, '@date' => format_date($revision->revision_timestamp))),
+              'callback' => 'node_view',
+              'callback arguments' => array($revision),
+              'access' => $revisions_access,
+              'type' => MENU_CALLBACK);
+            $items[] = array('path' => 'node/'. arg(1) .'/revisions/'. arg(3) .'/delete', 'title' => t('delete revision'),
+              'callback' => 'drupal_get_form',
+              'callback arguments' => array('node_revision_delete', $revision),
+              'access' => $revisions_access,
+              'type' => MENU_CALLBACK);
+            $items[] = array('path' => 'node/'. arg(1) .'/revisions/'. arg(3) .'/revert', 'title' => t('revert revision'),
+              'callback' => 'drupal_get_form',
+              'callback arguments' => array('node_revision_revert', $revision),
+              'access' => $revisions_access,
+              'type' => MENU_CALLBACK);
+          }
+        }
       }
     }
 
@@ -1529,7 +1554,7 @@ function node_multiple_delete_confirm_su
 }
 
 /**
- * Generate an overview table of older revisions of a node.
+ * Menu callback; Generate an overview table of older revisions of a node.
  */
 function node_revision_overview($node) {
   drupal_set_title(t('Revisions for %title', array('%title' => $node->title)));
@@ -1575,13 +1600,23 @@ function node_revision_overview($node) {
 }
 
 /**
+ * Menu callback; Confirm a revert to an older version
+ */
+function node_revision_revert($node) {
+  $form = array();
+  $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
+  $form['revision'] = array('#type' => 'hidden', '#value' => $node->vid);
+  return confirm_form($form, t('Are you sure you want to revert %title back to revision %name?', array('%name' => $node->vid, '%title' => $node->title)), 'node/'. $node->nid .'/revisions');
+}
+
+/**
  * Revert to the revision with the specified revision number. A node and nodeapi "update" event is triggered
  * (via the node_save() call) when a revision is reverted.
  */
-function node_revision_revert($nid, $revision) {
+function node_revision_revert_submit($form_id, $form_values) {
   global $user;
 
-  $node = node_load($nid, $revision);
+  $node = node_load($form_values['nid'], $form_values['revision']);
   if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
     if ($node->vid) {
       $node->revision = 1;
@@ -1593,42 +1628,52 @@ function node_revision_revert($nid, $rev
       node_save($node);
 
       drupal_set_message(t('%title has been reverted back to the revision from %revision-date', array('%revision-date' => format_date($node->revision_timestamp), '%title' => $node->title)));
-      watchdog('content', t('@type: reverted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $revision)));
+      watchdog('content', t('@type: reverted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $form_values['revision'])));
     }
     else {
       drupal_set_message(t('You tried to revert to an invalid revision.'), 'error');
     }
-    drupal_goto('node/'. $nid .'/revisions');
+    drupal_goto('node/'. $form_values['nid'] .'/revisions');
   }
   drupal_access_denied();
 }
 
 /**
+ * Menu callback; Confirm deletion of revisions
+ */
+function node_revision_delete($node) {
+  $form = array();
+  $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
+  $form['revision'] = array('#type' => 'hidden', '#value' => $node->vid);
+  return confirm_form($form, t('Are you sure you want to delete the revision %name from %title?', array('%name' => $node->vid, '%title' => $node->title)), 'node/'. $node->nid .'/revisions');
+}
+
+/**
  * Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a
  * revision is deleted.
  */
-function node_revision_delete($nid, $revision) {
+function node_revision_delete_submit($form_id, $form_values) {
   if (user_access('administer nodes')) {
-    $node = node_load($nid);
+    $node = node_load($form_values['nid']);
     if (node_access('delete', $node)) {
       // Don't delete the current revision
-      if ($revision != $node->vid) {
-        $node = node_load($nid, $revision);
+      if ($form_values['revision'] != $node->vid) {
+        $node = node_load($form_values['nid'], $form_values['revision']);
 
-        db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $nid, $revision);
+        db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $form_values['nid'], $form_values['revision']);
         node_invoke_nodeapi($node, 'delete revision');
-        drupal_set_message(t('Deleted %title revision %revision.', array('%title' => $node->title, '%revision' => $revision)));
-        watchdog('content', t('@type: deleted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $revision)));
+        drupal_set_message(t('Deleted %title revision %revision.', array('%title' => $node->title, '%revision' => $form_values['revision'])));
+        watchdog('content', t('@type: deleted %title revision %revision.', array('@type' => t($node->type), '%title' => $node->title, '%revision' => $form_values['revision'])));
       }
 
       else {
         drupal_set_message(t('Deletion failed. You tried to delete the current revision.'));
       }
-      if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $nid)) > 1) {
-        drupal_goto("node/$nid/revisions");
+      if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $form_values['nid'])) > 1) {
+        drupal_goto('node/'. $form_values['nid'] .'/revisions');
       }
       else {
-        drupal_goto("node/$nid");
+        drupal_goto('node/'. $form_values['nid']);
       }
     }
   }
@@ -2211,44 +2256,6 @@ function node_delete($nid) {
 }
 
 /**
- * Menu callback for revisions related activities.
- */
-function node_revisions() {
-  if (is_numeric(arg(1)) && arg(2) == 'revisions') {
-    $op = arg(4) ? arg(4) : 'overview';
-    switch ($op) {
-      case 'overview':
-        $node = node_load(arg(1));
-        if ((user_access('view revisions') || user_access('administer nodes')) && node_access('view', $node)) {
-          return node_revision_overview($node);
-        }
-        drupal_access_denied();
-        return;
-      case 'view':
-        if (is_numeric(arg(3))) {
-          $node = node_load(arg(1), arg(3));
-          if ($node->nid) {
-            if ((user_access('view revisions') || user_access('administer nodes')) && node_access('view', $node)) {
-              drupal_set_title(t('Revision of %title from %date', array('%title' => $node->title, '%date' => format_date($node->revision_timestamp))));
-              return node_show($node, arg(2));
-            }
-            drupal_access_denied();
-            return;
-          }
-        }
-        break;
-      case 'revert':
-        node_revision_revert(arg(1), arg(3));
-        break;
-      case 'delete':
-        node_revision_delete(arg(1), arg(3));
-        break;
-    }
-  }
-  drupal_not_found();
-}
-
-/**
  * Menu callback; Generate a listing of promoted nodes.
  */
 function node_page_default() {
