You are here

function taxonomy_access_delete_term_grants in Taxonomy Access Control 7

Deletes module configurations for the given term IDs.

Parameters

int|array $term_ids: A single term ID or an array of term IDs.

int|null $rid: (optional) A single role ID. Defaults to NULL.

bool $update_nodes: (optional) A flag to determine whether nodes should be queued for update. Defaults to TRUE.

Return value

bool TRUE on success, or FALSE on failure.

Related topics

5 calls to taxonomy_access_delete_term_grants()
taxonomy_access_delete_selected_submit in ./taxonomy_access.admin.inc
Form submission handler for taxonomy_access_admin_role().
taxonomy_access_disable_vocab in ./taxonomy_access.module
Disables a vocabulary for the given role.
taxonomy_access_enable in ./taxonomy_access.install
Implements hook_enable().
taxonomy_access_set_term_grants in ./taxonomy_access.module
Updates term grants for a role.
taxonomy_access_taxonomy_term_delete in ./taxonomy_access.module
Implements hook_taxonomy_term_delete().

File

./taxonomy_access.module, line 1080
Allows administrators to specify access control for taxonomy categories.

Code

function taxonomy_access_delete_term_grants($term_ids, $rid = NULL, $update_nodes = TRUE) {

  // Accept either a single term ID or an array thereof.
  if (is_numeric($term_ids)) {
    $term_ids = array(
      $term_ids,
    );
  }
  if (empty($term_ids)) {
    return FALSE;
  }
  if ($update_nodes) {

    // Cache the list of nodes that will be affected by this change.
    $affected_nodes = _taxonomy_access_get_nodes_for_terms($term_ids);
    taxonomy_access_affected_nodes($affected_nodes);
    unset($affected_nodes);
  }

  // Delete our database records for these terms.
  $query = db_delete('taxonomy_access_term')
    ->condition('tid', $term_ids);
  if (!empty($rid)) {
    $query
      ->condition('rid', $rid);
  }
  $query
    ->execute();
  unset($term_ids);
  unset($query);
  return TRUE;
}