You are here

function taxonomy_access_add_term_submit in Taxonomy Access Control 7

Form submission handler for taxonomy_access_admin_role().

Processes submissions for the term 'Add' button.

1 string reference to 'taxonomy_access_add_term_submit'
taxonomy_access_admin_role in ./taxonomy_access.admin.inc
Form constructor for a form to manage grants by role.

File

./taxonomy_access.admin.inc, line 614
Administrative interface for taxonomy access control.

Code

function taxonomy_access_add_term_submit($form, &$form_state) {
  $vid = $form_state['clicked_button']['#name'];
  $new = $form_state['values']['new'][$vid];
  $rid = $form_state['values']['rid'];
  list($type, $id) = explode(' ', $new['item']);
  $rows = array();
  $rows[$id] = _taxonomy_access_format_grant_record($id, $rid, $new['grants'][$vid][TAXONOMY_ACCESS_VOCABULARY_DEFAULT]);

  // If we are adding children recursively, add those as well.
  if ($new['recursive'] == 1) {
    $children = _taxonomy_access_get_descendants($id);
    foreach ($children as $tid) {
      $rows[$tid] = _taxonomy_access_format_grant_record($tid, $rid, $new['grants'][$vid][TAXONOMY_ACCESS_VOCABULARY_DEFAULT]);
    }
  }

  // Set the grants for the row or rows.
  taxonomy_access_set_term_grants($rows);
}