You are here

function taxonomy_access_delete_selected_submit in Taxonomy Access Control 7

Form submission handler for taxonomy_access_admin_role().

Processes submissions for the "Delete selected" button.

@todo The parent form could probably be refactored to make this more efficient (by putting these elements in a flat list) but that would require changing taxonomy_access_grant_table() and taxonomy_access_build_row().

1 string reference to 'taxonomy_access_delete_selected_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 743
Administrative interface for taxonomy access control.

Code

function taxonomy_access_delete_selected_submit($form, &$form_state) {
  $rid = intval($form_state['values']['rid']);
  $delete_tids = array();
  foreach ($form_state['values']['grants'] as $vid => $tids) {
    foreach ($tids as $tid => $record) {
      if (!empty($record['remove'])) {
        $delete_tids[] = $tid;
      }
    }
  }
  if ($rid) {
    if (taxonomy_access_delete_term_grants($delete_tids, $rid)) {
      drupal_set_message(format_plural(sizeof($delete_tids), '1 term access rule was deleted.', '@count term access rules were deleted.'));
    }
    else {
      drupal_set_message(t('The records could not be deleted.'), 'warning');
    }
  }
}