You are here

function _tac_lite_get_terms in Taxonomy Access Control Lite 5

Same name and namespace in other branches
  1. 8 tac_lite.module \_tac_lite_get_terms()
  2. 6 tac_lite.module \_tac_lite_get_terms()
  3. 7 tac_lite.module \_tac_lite_get_terms()
1 call to _tac_lite_get_terms()
tac_lite_node_access_records in ./tac_lite.module
Implementation of hook_node_access_records

File

./tac_lite.module, line 346
Control access to site content based on taxonomy, roles and users.

Code

function _tac_lite_get_terms(&$node) {
  $tids = array();

  // emulating code from taxonomy_node_save here.
  // note that free tagging vocabs not currently supported
  if (count($node->taxonomy)) {
    foreach ($node->taxonomy as $term) {
      if (is_array($term)) {
        foreach ($term as $tid) {
          if (is_numeric($tid)) {
            $tids[$tid] = $tid;
          }
          else {

            // non-numeric means free-tagging vocabulary.
            // we do not support.  Do nothing.
          }
        }
      }
      else {
        if (is_object($term)) {

          // in drupal 5 term is an object.  Is this right?
          $tids[$term->tid] = $term->tid;
        }
        else {
          if (is_numeric($term)) {

            // $term is a tid.
            $tids[$term] = $term;
          }
          else {
            if ($term) {
              drupal_set_message(t('Unexpected term value "%term" in tac_lite.', array(
                '%term' => $term,
              )), 'error');
            }
          }
        }
      }
    }
  }
  return $tids;
}