You are here

function taxonomy_access_taxonomy in Taxonomy Access Control 5.2

Same name and namespace in other branches
  1. 5 taxonomy_access.module \taxonomy_access_taxonomy()
  2. 6 taxonomy_access.module \taxonomy_access_taxonomy()

Implementation of hook_taxonomy Hook_taxonomy is called when changes are made to the taxonomy structure

File

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

Code

function taxonomy_access_taxonomy($op, $type, $array = NULL) {
  if ($type == 'term') {
    switch ($op) {
      case 'delete':

        // delete everything from term_access and node_access
        // issue #167977 - klance
        $affected_nodes = _taxonomy_access_get_nodes_for_term($array['tid']);
        db_query('DELETE FROM {term_access} WHERE tid = %d', $array['tid']);

        // issue #167977 - klance
        _taxonomy_access_node_access_update($affected_nodes);

        //node_access_rebuild();
        break;
    }
  }
  if ($type == 'vocabulary') {
    switch ($op) {
      case 'delete':

        // delete vocabulary from table 'term_access_defaults'
        // issue #167977 - klance
        $affected_nodes = _taxonomy_access_get_nodes_for_vocabulary($array['vid'], NULL);
        db_query('DELETE FROM {term_access_defaults} WHERE vid = %d', $array['vid']);

        // issue #167977 - klance
        _taxonomy_access_node_access_update($affected_nodes);

        // TODO: need rebuild here? can we avoid multiple rebuilds on large vocab delete?
        break;
    }
  }
  return;
}