--- modules/taxonomy_access/taxonomy_access.module	2007-07-03 18:19:48.000000000 -0400
+++ modules/taxonomy_access/taxonomy_access.module	2008-01-24 16:23:37.726477524 -0500
@@ -174,7 +174,7 @@ function taxonomy_access_menu($may_cache
       );
   }
   // Only include administrative callbacks and css if we are viewing an admin page.
-  else if (arg(0) == 'admin' AND arg(1) == 'user' AND arg(2) == 'taxonomy_access') {
+  else if (arg(0) == 'admin' AND ((arg(1) == 'user' AND arg(2) == 'taxonomy_access') OR (arg(1) == 'content' AND arg(2) == 'taxonomy'))) {
     $path = drupal_get_path('module', 'taxonomy_access');
     include_once($path . '/taxonomy_access_admin.inc');
     drupal_add_css($path . '/admin.css');
@@ -234,15 +234,23 @@ function taxonomy_access_taxonomy($op, $
   if ($type == 'term') {
     switch($op) {
       case 'delete': // delete everything from term_access and node_access
+        // issue #167977 - klance
+        $affected_nodes = _taxonomy_access_get_nodes_for_term($array['tid']);
         db_query('DELETE FROM {term_access} WHERE tid = %d',$array['tid']);
-        node_access_rebuild();
+        // issue #167977 - klance
+        _taxonomy_access_node_access_update($affected_nodes);
+        //node_access_rebuild();
         break;
     }
   }
   if ($type == 'vocabulary') {
     switch($op) {
       case 'delete': // delete vocabulary from table 'term_access_defaults'
+        // issue #167977 - klance
+        $affected_nodes = _taxonomy_access_get_nodes_for_vocabulary($array['vid'], NULL);
         db_query('DELETE FROM {term_access_defaults} WHERE vid = %d',$array['vid']);
+        // issue #167977 - klance
+        _taxonomy_access_node_access_update($affected_nodes);
         // TODO: need rebuild here? can we avoid multiple rebuilds on large vocab delete?
         break;
     }
@@ -282,13 +290,16 @@ function taxonomy_access_db_rewrite_sql(
       else {
         $rids[] = 1;
       }
-      
+
       $sql = db_query('SELECT t.tid AS tid, t.vid AS vid FROM {term_data} t
                       INNER JOIN {term_access_defaults} tdg ON tdg.vid=0
                       LEFT JOIN {term_access_defaults} td ON td.vid=t.vid AND td.rid=tdg.rid
                       LEFT JOIN {term_access} ta ON ta.tid=t.tid AND ta.rid=tdg.rid
                       WHERE tdg.rid IN ('.implode(',',$rids).")
-                      GROUP BY t.tid HAVING BIT_OR(COALESCE(ta.grant_$op, td.grant_$op, tdg.grant_$op))");
+                      GROUP BY t.tid, t.vid HAVING BIT_OR(COALESCE(ta.grant_$op, td.grant_$op, tdg.grant_$op)) > 0");
+                      // issue #172675 - Ddaffyd
+                      // GROUP BY t.tid HAVING BIT_OR(COALESCE(ta.grant_$op, td.grant_$op, tdg.grant_$op))");
+
       while ($result = db_fetch_object($sql)) {
         $tids[]= $result->tid;
         $vids[$result->vid]= $result->vid;
