--- tac_lite/tac_lite.module	2010-10-23 02:46:48.000000000 +0600
+++ tac_lite_copy/tac_lite.module	2011-01-24 15:04:08.326149003 +0600
@@ -548,3 +548,40 @@ function tac_lite_db_rewrite_sql($query,
     return array('join' => $join, 'where' => $where);
   }
 }
+
+
+/**
+ * Implementation of hook_taxonomy().
+ *
+ * This hook allows modules to take action when the terms and vocabularies in the taxonomy are modified.
+ */
+
+function tac_lite_taxonomy($op, $type, $array = NULL)
+{
+   global $user;
+
+   if ($op == "insert" && $type == "term")
+   {
+      $tac_lite_categories = variable_get('tac_lite_categories', NULL);
+      $tid = $array['tid'];
+      $vid = $array['vid'];
+
+      if (in_array($vid, $tac_lite_categories))
+      {
+         $schemes_number = variable_get('tac_lite_schemes', NULL);
+         for ($i = 1; $i <= $schemes_number; $i++)
+         {
+            $tac_lite_config = variable_get('tac_lite_config_scheme_'.$i, TRUE);
+            if (in_array('grant_update', $tac_lite_config))
+            {
+               $terms_restricted = variable_get('tac_lite_grants_scheme_'.$i, NULL);
+               
+               $user_roles = array_keys($user->roles);
+               foreach ($user_roles as $rid)
+                  $terms_restricted[$rid][1][$tid] = "$tid";
+               variable_set('tac_lite_grants_scheme_'.$i, $terms_restricted);
+            }
+         }
+      }
+   }
+}
