You are here

function taxonomy_access_term_submit in Taxonomy Access Control 6

Submit handler for term deletions. Overrides term deletion handling to determine what node access to update.

Return value

Confirmation form, or nothing, as appropriate.

1 string reference to 'taxonomy_access_term_submit'
taxonomy_access_form_taxonomy_form_term_alter in ./taxonomy_access.module
Implements hook_form_FORM_ID_alter() for taxonomy-form-term. Overriding the term deletion form's submit handler allows us to determine which {node_access} entries must be updated before the {term_data} and {term_node} records are deleted from the…

File

./taxonomy_access.module, line 262
Allows administrators to specify how each category (in the taxonomy) can be used by various roles.

Code

function taxonomy_access_term_submit(&$form, &$form_state) {

  // If we are deleting a term, override the default behavior.
  if ($form_state['clicked_button']['#value'] == t('Delete')) {

    // If the user has already confirmed deletion, proceed.
    if ($form_state['values']['delete'] === TRUE) {
      $tid = $form_state['values']['tid'];
      _taxonomy_access_del_term($tid);

      // Determine which nodes belong to this term and its children and cache.
      $affected_nodes = _taxonomy_access_get_nodes_for_term($tid, TRUE);
      _taxonomy_access_cache_affected_nodes($affected_nodes);

      // Proceed with term deletion.
      return taxonomy_term_confirm_delete_submit($form, $form_state);
    }

    // Otherwise, rebuild the form to confirm deletion as in default handler.
    $form_state['rebuild'] = TRUE;
    $form_state['confirm_delete'] = TRUE;
    return;
  }
  else {
    taxonomy_form_term_submit($form, $form_state);
  }
}