You are here

function data_taxonomy_save_term_array in Data 6

Save a term array, create a new one if it does not exist yet.

Parameters

$term: A taxonomy term array to look up and save.

$vid: A <em>numeric</em> vocabulary id (vid).

Return value

A taxonomy term array.

1 call to data_taxonomy_save_term_array()
_data_taxonomy_save_terms in data_taxonomy/data_taxonomy.module
Helper function, saves a series of taxonomy terms for a record.

File

data_taxonomy/data_taxonomy.module, line 321
Hooks and API functions for Data Node module.

Code

function data_taxonomy_save_term_array($term, $vid) {
  if (!isset($term[$vid])) {
    $term['vid'] = $vid;
  }
  if (!isset($term['tid']) || $term['vid'] != $vid) {
    if ($lookup = data_taxonomy_lookup_term($term['name'], $vid)) {
      $term = $term + $lookup;
    }
  }
  taxonomy_save_term($term);
  return $term;
}