--- taxonomy_access.module.orig	Mon Jan 16 10:23:13 2006
+++ taxonomy_access.module	Mon Jan 16 11:33:03 2006
@@ -504,15 +504,13 @@ function taxonomy_access_nodeapi(&$node,
 
     // Enter new data into node_access to set permissions for the new node
     case 'update':
-      db_query('DELETE FROM {node_access} WHERE nid = %d AND realm = \'term_access\'', $node->nid);
       // intentional fall through to insert
 
     case 'insert':
       // Determine the category/categories the new node was assigned to
-      $tids = $node->taxonomy;
       db_query('DELETE FROM {node_access} WHERE nid = %d AND realm = \'term_access\'', $node->nid);
       // For nodes not assigned to a category
-      if (!$tids) {
+      if (!is_array($node->taxonomy)) {
         $query = db_query("SELECT * FROM {term_access} where tid = '0'");
         while ($result = db_fetch_object($query)) {
           db_query("DELETE FROM {node_access} WHERE nid=%d AND gid=%d AND realm='term_access'", $node->nid, $result->rid);
@@ -521,6 +519,19 @@ function taxonomy_access_nodeapi(&$node,
       }
       // For nodes assigned to a category
       else {
+        $tids = array();
+        foreach ($node->taxonomy as $term) {
+          if (is_array($term)) {
+            foreach ($term as $tid) {
+              if ($tid) {
+                $tids[] = $tid;
+              }
+            }
+          }
+          else if ($term) {
+            $tids[] = $term;
+          }
+        }
         // Query the term_access table to get the permissions for the new node's assigned category/categories
         // then make appropriate changes to the node_access table.
         $result = db_query("SELECT rid, BIT_OR(grant_view) AS grant_view, BIT_OR(grant_update) AS grant_update, BIT_OR(grant_delete) AS grant_delete FROM {term_access} WHERE tid IN ('".implode("','",array_values($tids))."') GROUP BY rid");
