You are here

function _tac_lite_get_terms in Taxonomy Access Control Lite 6

Same name and namespace in other branches
  1. 8 tac_lite.module \_tac_lite_get_terms()
  2. 5 tac_lite.module \_tac_lite_get_terms()
  3. 7 tac_lite.module \_tac_lite_get_terms()

Get terms from a newly udpated node. Terms are placed in $node->taxonomy by the form.

1 call to _tac_lite_get_terms()
tac_lite_node_access_records in ./tac_lite.module
Implements hook_node_access_records().

File

./tac_lite.module, line 402
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.
          }
        }
      }
      elseif (is_object($term)) {

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

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