--- taxonomy_access_admin.inc.orig	2010-01-19 14:00:08.000000000 -0700
+++ taxonomy_access_admin.inc	2010-01-19 14:22:52.000000000 -0700
@@ -179,6 +179,10 @@ function taxonomy_access_admin_form($for
       '#type' => 'select',
       '#options' => $add_items,
     );
+    $form['new']['recursive'] = array(
+      '#type' => 'select',
+      '#options' => array('Normal', 'Recursive'),
+    );
     $form['new']['add'] = array(
       '#type' => 'submit',
       '#value' => t('Add'),
@@ -256,7 +260,8 @@ function theme_taxonomy_access_admin_for
   }
   if (isset($form['new'])) {
     $row = array(
-             array('data' => drupal_render($form['new']['item']), 'colspan' => 2), 
+             drupal_render($form['new']['item']), 
+             drupal_render($form['new']['recursive']), 
              drupal_render($form['new']['add'])
            );
     foreach ($node_grant_types as $grant) {
@@ -313,7 +318,11 @@ function taxonomy_access_admin_form_subm
     $new = $values['new'];
     list($type, $id) = explode(' ', $new['item']);
     if ($type == 'term') {
-      taxonomy_access_grant_update($id, $values['rid'], $new['grants']);
+      if ($new['recursive'] == 1) {
+		taxonomy_access_recursive_grant_update($id, $values['rid'], $new['grants']);
+	  } else {
+	    taxonomy_access_grant_update($id, $values['rid'], $new['grants']);
+	  }
     }
     elseif ($type == 'default') {
       taxonomy_access_defaults_update($id, $values['rid'], $new['grants']);
@@ -383,6 +392,20 @@ function taxonomy_access_grant_update($t
 }
 
 /**
+ * Recursively updates permissions for a role for a term
+ * - gets all the children terms and calls a grant update for each of them
+ */
+function taxonomy_access_recursive_grant_update($tid, $rid = null, $grants = null) {
+  // run the original
+  taxonomy_access_grant_update($tid, $rid, $grants);
+  // run the children
+  $result = db_query('SELECT th.tid FROM {term_hierarchy} th WHERE th.parent = %d', $tid);
+  while ($row = db_fetch_array($result)) {
+	taxonomy_access_grant_update($row['tid'], $rid, $grants);
+  }
+}
+
+/**
  * Updates default permissions for a role for a vocabulary
  * @param $vid
  *   The vocab to add the permission for.
