? simple_access.install
Index: simple_access.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/simple_access/simple_access.module,v
retrieving revision 1.18
diff -u -F^f -r1.18 simple_access.module
--- simple_access.module	26 Feb 2006 21:02:32 -0000	1.18
+++ simple_access.module	6 Mar 2006 05:20:50 -0000
@@ -87,6 +87,26 @@ function simple_access_node_grants($acco
  */
 function simple_access_nodeapi(&$node, $op, $arg = 0) {
   switch ($op) {
+    case 'validate':
+      if (is_array($node->simple_access)) {
+        foreach ($node->simple_access as $type => $array) {
+          if (array_sum($array['checks'])) {
+            $sa_controlled = true;
+            break;
+          }
+        }
+      }
+      if (is_array($node->og_groups) && array_sum($node->og_groups) && $sa_controlled) {
+        form_set_error('', t('Access cannot be used if content is within a group.'));
+        foreach ($node->simple_access as $type => $array) {
+          foreach ($array['checks'] as $gid => $checked) {
+            if ($checked) {
+              form_set_error("simple_access][$type][checks][$gid", '');
+            }
+          }
+        }
+      }
+      break;
     case 'delete':
       // When a node is deleted, delete any relevant grants.
       db_query('DELETE FROM {node_access} WHERE nid = %d AND realm = \'simple_access\'', $node->nid);
@@ -95,7 +115,11 @@ function simple_access_nodeapi(&$node, $
     case 'update':
       // if user doesn't have administer nodes permission, then the simple_access
       // boxes weren't on the page... so don't parse what ain't there! (see 'else')
-      if (user_access('assign access to nodes')) {
+      if ($node->type == 'og' || (is_array($node->og_groups) && array_sum($node->og_groups))) {
+        // remove all access for nodes which are covered by og.
+        db_query('DELETE FROM {node_access} WHERE nid = %d AND realm = \'simple_access\'', $node->nid);
+      }
+      elseif (user_access('assign access to nodes')) {
         // Clear out any existing grants for the node. Don't worry, we'll set them again.
         db_query('DELETE FROM {node_access} WHERE nid = %d AND realm = \'simple_access\'', $node->nid);
         $views = FALSE;
@@ -144,7 +168,7 @@ function simple_access_nodeapi(&$node, $
 
 function simple_access_form_alter($form_id, &$form){
   // if this is a node form...
-  if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+  if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && $form_id != 'og_node_form' && (!is_array($form['#node']->og_groups) || !array_sum($form['#node']->og_groups))) {
     $simple_access_form = simple_access_form($form['#node']);
     $form = array_merge($form, $simple_access_form);
   }
@@ -663,4 +687,4 @@ function simple_access_nodes() {
 }
 
 
-?>
\ No newline at end of file
+?>
