--- node.module	Thu Mar 23 08:32:01 2006
+++ patches/node.module	Thu Mar 23 08:32:43 2006
@@ -484,7 +484,9 @@
   }
 
   // Insert the node into the database:
-  db_query($node_query, $node_table_values);
+  if (!$node->draft) {
+    db_query($node_query, $node_table_values);
+  }
   db_query($revisions_query, $revisions_table_values);
 
   // Call the node specific callback (if any):
@@ -585,7 +587,7 @@
  * Implementation of hook_perm().
  */
 function node_perm() {
-  return array('administer nodes', 'access content', 'view revisions', 'revert revisions');
+  return array('administer nodes', 'access content', 'view revisions', 'publish revisions', 'publish revisions', 'delete revisions');
 }
 
 /**
@@ -1339,14 +1341,18 @@
 function node_revision_overview($node) {
   drupal_set_title(t('Revisions for %title', array('%title' => check_plain($node->title))));
 
-  $header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 2));
+  $header = array(t('Revision'), array('data' => t('Operations'), 'colspan' => 3));
 
   $revisions = node_revision_list($node);
-
+  
   $rows = array();
-  $revert_permission = FALSE;
-  if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
-    $revert_permission = TRUE;
+  $publish_permission = FALSE;
+  if ((user_access('publish revisions') || user_access('administer nodes')) && node_access('update', $node)) {
+    $publish_permission = TRUE;
+  }
+  $edit_permission = FALSE;
+  if ((user_access('edit revisions') || user_access('administer nodes')) && node_access('update', $node)) {
+    $edit_permission = TRUE;
   }
   $delete_permission = FALSE;
   if (user_access('administer nodes')) {
@@ -1358,15 +1364,22 @@
 
     if ($revision->current_vid > 0) {
       $row[] = array('data' => t('%date by %username', array('%date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid"), '%username' => theme('username', $revision)))
-                               . (($revision->log != '') ? '<p class="revision-log">'. filter_xss($revision->log) .'</p>' : ''),
-                     'class' => 'revision-current');
-      $operations[] = array('data' => theme('placeholder', t('current revision')), 'class' => 'revision-current', 'colspan' => 2);
+                . (($revision->log != '') ? '<p class="revision-log">'. filter_xss($revision->log) .'</p>' : ''),
+      'class' => 'revision-current');
+      $operations[] = array('data' => theme('placeholder', t('published')), 'class' => 'revision-current');
+      if ($edit_permission) {
+        $operations[] = l(t('edit'), "node/$node->nid/revisions/$revision->vid/edit");
+        $operations[] ="&nbsp;";
+      }     
     }
     else {
       $row[] = t('%date by %username', array('%date' => l(format_date($revision->timestamp, 'small'), "node/$node->nid/revisions/$revision->vid/view"), '%username' => theme('username', $revision)))
                . (($revision->log != '') ? '<p class="revision-log">'. filter_xss($revision->log) .'</p>' : '');
-      if ($revert_permission) {
-        $operations[] = l(t('revert'), "node/$node->nid/revisions/$revision->vid/revert");
+      if ($publish_permission) {
+        $operations[] = l(t('publish'), "node/$node->nid/revisions/$revision->vid/publish");
+      }
+      if ($edit_permission) {
+        $operations[] = l(t('edit'), "node/$node->nid/revisions/$revision->vid/edit");
       }
       if ($delete_permission) {
         $operations[] = l(t('delete'), "node/$node->nid/revisions/$revision->vid/delete");
@@ -1380,26 +1393,22 @@
 }
 
 /**
- * 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.
+ * Set specified revision as the published revision.
  */
-function node_revision_revert($nid, $revision) {
+function node_revision_publish($nid, $vid) {
   global $user;
 
-  $node = node_load($nid, $revision);
-  if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
+  $node = node_load($nid, $vid);
+  if ((user_access('publish revisions') || user_access('administer nodes')) && node_access('update', $node)) {
     if ($node->vid) {
-      $node->revision = 1;
-      $node->log = t('Copy of the revision from %date.', array('%date' => theme('placeholder', format_date($node->revision_timestamp))));
-      $node->taxonomy = array_keys($node->taxonomy);
-
-      node_save($node);
-
-      drupal_set_message(t('%title has been reverted back to the revision from %revision-date', array('%revision-date' => theme('placeholder', format_date($node->revision_timestamp)), '%title' => theme('placeholder', check_plain($node->title)))));
-      watchdog('content', t('%type: reverted %title revision %revision.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $revision))));
+      db_query("UPDATE {node} SET vid=$vid WHERE nid = $nid");
+//Not sure if switching published should make a log entry
+//      $node->log = t('Publish revision from %date.', array('%date' => theme('placeholder', format_date($node->revision_timestamp))));
+      drupal_set_message(t('The revision of %title from %revision-date has been published', array('%revision-date' => theme('placeholder', format_date($node->revision_timestamp)), '%title' => theme('placeholder', check_plain($node->title)))));
+      watchdog('content', t('%type: published %title revision %revision.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $vid))));
     }
     else {
-      drupal_set_message(t('You tried to revert to an invalid revision.'), 'error');
+      drupal_set_message(t('You tried to publish an invalid revision.'), 'error');
     }
     drupal_goto('node/'. $nid .'/revisions');
   }
@@ -1407,6 +1416,28 @@
 }
 
 /**
+ * Edit a revision (probably create new revision)
+ */
+function node_revision_edit($nid, $vid, $copy=1) {
+  global $user;
+
+  $node = node_load($nid, $vid);
+  if ((user_access('edit revisions') || user_access('administer nodes')) && node_access('update', $node)) {
+    if ($node->nid) {
+      $node->revision=$copy ? 1 : 0;
+      $node->draft=1;
+      drupal_set_title(check_plain($node->title));
+      return node_form($node);
+    }
+    else {
+      drupal_set_message(t('Invalid revision.'), 'error');
+      drupal_not_found();
+    }
+  }
+  else drupal_access_denied();
+}
+
+/**
  * Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a
  * revision is deleted.
  */
@@ -1692,6 +1723,8 @@
   foreach (array('nid', 'vid', 'uid', 'created', 'changed', 'type') as $key) {
     $form[$key] = array('#type' => 'value', '#value' => $node->$key);
   }
+  $form['draft'] = array('#type' => 'value', '#value' => 1);
+  $form['#node'] = $node;
 
   // Get the node-specific bits.
   $form = array_merge_recursive($form, node_invoke($node, 'form'));
@@ -2007,15 +2040,21 @@
           }
         }
         break;
-      case 'revert':
-        node_revision_revert(arg(1), arg(3));
+      case 'publish':
+        node_revision_publish(arg(1), arg(3));
+        break;
+      case 'edit':
+        return node_revision_edit(arg(1), arg(3));
+        break;
+      case 'copy':
+        node_revision_copy(arg(1), arg(3));
         break;
       case 'delete':
         node_revision_delete(arg(1), arg(3));
         break;
     }
   }
-  drupal_not_found();
+  else drupal_not_found();
 }
 
 /**
