Index: content_access.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_access/Attic/content_access.admin.inc,v
retrieving revision 1.1.2.23
diff -u -r1.1.2.23 content_access.admin.inc
--- content_access.admin.inc	31 Jul 2009 10:03:22 -0000	1.1.2.23
+++ content_access.admin.inc	14 Jan 2011 12:13:33 -0000
@@ -11,6 +11,32 @@
 define('CONTENT_ACCESS_MASS_UPDATE_THRESHOLD', 1000);
 
 /**
+ * Module settings form.
+ */
+function content_access_settings_form() {
+  $form['content_access_use_core_perm'] = array(
+    '#type' => 'checkbox',
+    '#title' => t("Use built-in Drupal's permissions for edit/delete operations"),
+    '#description' => t("This option is enabled by default. If you uncheck it,
+      Content access will not override core Drupal's permissions for edit/delete
+      operations. It will write node grants to node_access table. This is
+      powerful for using with
+      <a href='http://drupal.org/project/module_grants'>Module grants</a>
+      and other access modules.<br />
+      <b>Note: node access permissions will be rebuilt.</b>"),
+    '#default_value' => variable_get('content_access_use_core_perm', TRUE),
+  );
+  $form['#submit'][] = 'content_access_settings_form_submit';
+  return system_settings_form($form);
+}
+
+function content_access_settings_form_submit($form, &$form_state) {
+  if (variable_get('content_access_use_core_perm', TRUE) != $form_state['values']['content_access_use_core_perm']) {
+    node_access_rebuild(TRUE);
+  }
+}
+
+/**
  * Per node settings page.
  */
 function content_access_page(&$form_state, $node) {
@@ -99,6 +125,31 @@
 function content_access_admin_settings(&$form_state, $type) {
   $form_state['type'] = $type;
 
+  if (!variable_get('content_access_use_core_perm', TRUE) && !$form_state['post']) {
+
+    // Set warning message if some core update/delete permissions are enabled.
+    $result = db_query("SELECT rid, perm FROM permission");
+    $roles = user_roles();
+    $perms = array(
+      'edit any '. $type .' content',
+      'edit own '. $type .' content',
+      'delete any '. $type .' content',
+      'delete own '. $type .' content',
+    );
+    while ($row = db_fetch_object($result)) {
+      $role_perms = explode(', ', $row->perm);
+      if (in_array('administer nodes', $role_perms)
+        || (count(array_diff($perms, $role_perms)) == 4)) {
+        unset($roles[$row->rid]);
+      }
+    }
+    if (count($roles)) {
+      drupal_set_message('Warning: some of edit/delete permissions are enabled for following roles:'
+        . theme_item_list($roles)
+        . 'Enabled prmissions will override Content access settings for node type <i>' . $type . '</i>.' , 'warning');
+    }
+  }
+
   // Add role based per content type settings
   $defaults = array();
   foreach (_content_access_get_operations() as $op) {
@@ -140,16 +191,19 @@
 }
 
 function content_access_admin_settings_submit($form, &$form_state) {
-  // Where possible let the drupal permissions system handle access control.
-  $permissions = content_access_get_permissions_by_role();
-  foreach (array('update', 'update_own', 'delete', 'delete_own') as $op) {
-    foreach ($form_state['values'][$op] as $rid => $value) {
-      $permissions[$rid][ content_access_get_permission_by_op($op, $form_state['type']) ] = $value;
+  
+  if (variable_get('content_access_use_core_perm', TRUE)) {
+    // Where possible let the drupal permissions system handle access control.
+    $permissions = content_access_get_permissions_by_role();
+    foreach (array('update', 'update_own', 'delete', 'delete_own') as $op) {
+      foreach ($form_state['values'][$op] as $rid => $value) {
+        $permissions[$rid][ content_access_get_permission_by_op($op, $form_state['type']) ] = $value;
+      }
+      // Don't save the setting, so its default value (get permission) is applied always.
+      unset($form_state['values'][$op]);
     }
-    // Don't save the setting, so its default value (get permission) is applied always.
-    unset($form_state['values'][$op]);
+    content_access_save_permissions($permissions);
   }
-  content_access_save_permissions($permissions);
 
   // Update content access settings
   $settings = content_access_get_settings();
Index: content_access.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/content_access/Attic/content_access.module,v
retrieving revision 1.1.2.9.2.19
diff -u -r1.1.2.9.2.19 content_access.module
--- content_access.module	31 Jul 2009 09:46:36 -0000	1.1.2.9.2.19
+++ content_access.module	25 Jan 2011 08:23:20 -0000
@@ -12,6 +12,14 @@
 function content_access_menu() {
   $items = array();
 
+  $items['admin/settings/content_access'] = array(
+    'title' => 'Content access settings',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('content_access_settings_form'),
+    'access callback' => 'content_access_admin_settings_access',
+    'file' => 'content_access.admin.inc',
+  );
+
   $items['node/%node/access'] = array(
     'title' => 'Access control',
     'page callback' => 'drupal_get_form',
@@ -60,10 +68,14 @@
  * Implementation of hook_node_grants().
  */
 function content_access_node_grants($account, $op) {
-  return array(
+  $grants = array(
     'content_access_author' => array($account->uid),
     'content_access_rid' => array_keys($account->roles),
   );
+  if (!variable_get('content_access_use_core_perm', TRUE)) {
+    $grants['all'] = array(0);
+  }
+  return $grants;
 }
 
 /**
@@ -235,18 +247,19 @@
  * Gets the name of a permission for the given operation, if there is a suiting one.
  */
 function content_access_get_permission_by_op($op, $type) {
-  switch ($op) {
-    default:
-      return FALSE;
-    case 'update':
-      return 'edit any '. $type .' content';
-    case 'update_own':
-      return 'edit own '. $type .' content';
-    case 'delete':
-      return 'delete any '. $type .' content';
-    case 'delete_own':
-      return 'delete own '. $type .' content';
+  if (variable_get('content_access_use_core_perm', TRUE)) {
+    switch ($op) {
+      case 'update':
+        return 'edit any '. $type .' content';
+      case 'update_own':
+        return 'edit own '. $type .' content';
+      case 'delete':
+        return 'delete any '. $type .' content';
+      case 'delete_own':
+        return 'delete own '. $type .' content';
+    }
   }
+  return FALSE;
 }
 
 /**
@@ -256,21 +269,29 @@
   // Cache per type default grants in a static array
   static $defaults = array();
 
+  // If uses core update/delete permissions, proccess only with view grant.
+  $ops = variable_get('content_access_use_core_perm', TRUE)
+    ? array('view') : array('view', 'update', 'delete');
+
   if (!isset($defaults[$node->type])) {
     $grants = array();
-
-    // Only process the 'view' op as node_access() will take care of edit and delete
-    foreach (content_access_get_settings('view', $node->type) as $rid) {
-      $grants[$rid]['grant_view'] = 1;
-      $grants[$rid] = content_access_proccess_grant($grants[$rid], $rid, $node);
+    foreach ($ops as $op) {
+      foreach (content_access_get_settings($op, $node->type) as $rid) {
+        $grants[$rid]['grant_' . $op] = 1;
+      }
+    }
+    foreach ($grants as $rid => &$rid_grants) {
+      $rid_grants = content_access_proccess_grant($rid_grants, $rid, $node);
     }
     $defaults[$node->type] = $grants;
   }
 
   // Care for the author grant.
   $grant = $grants = array();
-  $grant['grant_view'] = content_access_own_op($node, content_access_get_settings('view', $node->type), content_access_get_settings('view_own', $node->type));
-  if ($grant['grant_view']) {
+  foreach ($ops as $op) {
+    $grant['grant_' . $op] = content_access_own_op($node, content_access_get_settings($op, $node->type), content_access_get_settings($op . '_own', $node->type));
+  }
+  if (count($grant)) {
     $grant['realm'] = 'content_access_author';
     $grants = array('author' => content_access_proccess_grant($grant, $node->uid, $node));
   }

