### Eclipse Workspace Patch 1.0
#P simple_access
Index: simple_access.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simple_access/simple_access.module,v
retrieving revision 1.25
diff -u -r1.25 simple_access.module
--- simple_access.module	10 Mar 2007 04:46:13 -0000	1.25
+++ simple_access.module	31 May 2007 21:57:43 -0000
@@ -117,8 +117,43 @@
 /**
  * Implementation of hook_node_access_records
  */
-function simple_access_node_access_records($node)
-{
+function simple_access_node_access_records($node) {
+
+    /**
+   * Testing mod to simple_access to preserve node access settings on
+   * reversion of revisions.
+   * If we get here but $node->simple_access isn't set then we didn't get
+   * here via a form, and therefore none of the check boxes are set.
+   * We load the access rules from the database and assemble them in to
+   * $node->simple_access here, to simulate a form.
+   *
+   * The following lines come from simple_access_form, with a slight modification
+   * to assemble the grants in the right format!
+   */
+  if (!isset($node->simple_access)) {
+    // Load the grants from the database.
+    $result = db_query('SELECT na.gid, na.grant_view, na.grant_update, na.grant_delete FROM {node_access} na WHERE na.nid = %d AND na.realm = \'simple_access\'', $node->nid);
+    while($grant = db_fetch_object($result)) {
+      if ($grant->gid > 0) {
+        if ($grant->grant_view) {
+          $views['checks'][$grant->gid] = $grant->gid;
+        }
+        if ($grant->grant_update) {
+          $updates['checks'][$grant->gid] = $grant->gid;
+        }
+        if ($grant->grant_delete) {
+          $deletes['checks'][$grant->gid] = $grant->gid;
+        }
+      }
+    }
+    $node->simple_access = array(
+      'view' => $views,
+      'update' => $updates,
+      'delete' => $deletes
+    );
+  }
+  // End of new code
+
   $records = array();
 
   if ($node->simple_access) {
@@ -154,14 +189,14 @@
       }
     }
   }
-  // if there are new view recrods set
+  // if there are no view records set
   if (!$views) {
     $records[] = array(
       'realm' => 'simple_access',
       'gid' => 0,
       'grant_view' => 1,
       'grant_update' => 0,
-      'grant_update' => 0,
+      'grant_delete' => 0,
       'priority' => 1,
     );
   }
@@ -240,7 +275,7 @@
     $count = count($variable) ? count($variable) : 1;
     $percent = 90/$count;
 
-    // Get the array of checkbox options to use for each form element.  
+    // Get the array of checkbox options to use for each form element.
     // If the "Show groups even when user is not a member" setting is
     // enabled, or if the current user has 'administer nodes', let
     // them choose from any of the SA groups.
@@ -466,7 +501,7 @@
   */
 function simple_access_groups_from_roles($roles) {
   // there probably should be some 'static' stuff going on here
-  // always return gid 0 just to be safe. 
+  // always return gid 0 just to be safe.
   $gids = array(0);
   $result = db_query("SELECT gid FROM {simple_access_roles} WHERE rid IN (%s)", implode(",", $roles));
   while ($g = db_fetch_object($result)) {
