You are here

function taxonomy_access_disable_vocab in Taxonomy Access Control 7

Disables a vocabulary for the given role.

Parameters

int $vid: The vocabulary ID to enable.

int $rid: The role ID.

Return value

bool TRUE on success, or FALSE on failure.

See also

taxonomy_access_delete_role_grants()

1 call to taxonomy_access_disable_vocab()
taxonomy_access_disable_vocab_confirm_submit in ./taxonomy_access.admin.inc
Form submission handler for taxonomy_access_disable_vocab_confirm().

File

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

Code

function taxonomy_access_disable_vocab($vid, $rid) {
  $rid = intval($rid);
  $vid = intval($vid);

  // Do not allow the global default to be deleted this way.
  // Deleting the global default would disable the role.
  if (!$vid || !$rid) {
    return FALSE;
  }

  // Delete the vocabulary default.
  taxonomy_access_delete_default_grants($vid, $rid);

  // Delete the role's term access rules for the vocabulary.
  // First check which term records are enabled so we can update node access.
  $tids = db_query("SELECT ta.tid\n       FROM {taxonomy_access_term} ta\n       INNER JOIN {taxonomy_term_data} td ON ta.tid = td.tid\n       WHERE td.vid = :vid AND ta.rid = :rid", array(
    ':vid' => $vid,
    ':rid' => $rid,
  ))
    ->fetchCol();
  taxonomy_access_delete_term_grants($tids, $rid);
  return TRUE;
}