$vocab_name, 'multiple' => 0, 'required' => 0, 'hierarchy' => 0, 'relations' => 0, 'module' => 'event', 'weight' => 0, 'nodes' => $content_types, ); $vocabulary = array_merge($defaults, $properties); taxonomy_save_vocabulary($vocabulary); $return = install_taxonomy_get_vid($vocab_name); return $return; } /** * Create a new taxonomy term. * * @param $vid * The vocabulary ID * @param $name * The text name of the new term. * @param $description * Term description. * @return integer * The database ID of the created term. */ function install_taxonomy_add_term($vid, $name, $description = '', $properties = array()) { $return = 0; // default properties. $defaults = array( 'name' => $name, 'description' => $description, 'parent' => array(), 'relations' => array(), 'weight' => 0, 'vid' => $vid, ); $term = array_merge($defaults, $properties); taxonomy_save_term($term); $return = install_taxonomy_get_tid($name); return $return; } /** * Assign a term to a node. * * TODO: NOT TESTED FOR D6 - MAY STILL BE ONLY D5 * NOTE: does not check whether the assignment is valid. * * @param $vocab * The vocabulary ID. * @param $name * The text name of the new term. */ function install_taxonomy_assign_nid_tid($nid, $tid) { if (!$tid || !$nid) { return; } db_query('DELETE FROM {term_node} WHERE nid = %d AND tid = %d', $nid, $tid); db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $tid); }