You are here

function _taxonomy_access_get_nodes_for_term in Taxonomy Access Control 6

Same name and namespace in other branches
  1. 5.2 taxonomy_access.module \_taxonomy_access_get_nodes_for_term()

Gets node ids associated with a given term.

Parameters

$tid: The term id for which to retrieve associated nodes.

$get_children: Whether to recursively get nodes tagged with the term's children as well.

Return value

An array of node ids associated with the given term.

3 calls to _taxonomy_access_get_nodes_for_term()
taxonomy_access_admin_form_submit in ./taxonomy_access.admin.inc
Submit handler for the administration form at admin/user/taxonomy_access.
taxonomy_access_set_term_grants in ./taxonomy_access.module
Updates permissions for a role for a term. Note: This function adds nodes to the affected nodes cache. Callers should run _taxonomy_access_node_access_update() on _taxonomy_access_cache_affected_nodes() after all changes are processed.
taxonomy_access_term_submit in ./taxonomy_access.module
Submit handler for term deletions. Overrides term deletion handling to determine what node access to update.

File

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

Code

function _taxonomy_access_get_nodes_for_term($tid, $get_children = FALSE) {
  $nids = array();
  $result = db_query("SELECT nid FROM {term_node} WHERE tid = %d", $tid);
  while ($node = db_fetch_object($result)) {
    $nids[] = $node->nid;
  }

  // If requested, get nodes tagged with all children as well.
  if ($get_children) {
    $child_tids = _taxonomy_access_get_descendants($tid);
    if (sizeof($child_tids) > 0) {
      $child_r = db_query('SELECT nid FROM {term_node} WHERE tid IN ' . '(' . db_placeholders($child_tids, 'int') . ')', $child_tids);
      while ($node = db_fetch_object($child_r)) {
        $nids[] = $node->nid;
      }
    }
  }
  return $nids;
}