You are here

function workbench_access_taxonomy_term_insert in Workbench Access 7

Implements hook_taxonomy_term_insert().

If a new term is added, check to see if we need to create a section.

File

modules/taxonomy.workbench_access.inc, line 351
Taxonomy integration for Workbench Access.

Code

function workbench_access_taxonomy_term_insert($term) {
  if (variable_get('workbench_access') != 'taxonomy' || !variable_get('workbench_access_auto_assign', 1)) {
    return;
  }
  $active = array_filter(variable_get('workbench_access_taxonomy', array()));
  if (in_array($term->vocabulary_machine_name, $active)) {
    $section = array(
      'access_id' => $term->tid,
      'access_type' => 'taxonomy',
      'access_scheme' => 'taxonomy',
      'access_type_id' => $term->vocabulary_machine_name,
    );
    workbench_access_section_save($section);
  }
}