function tripal_library_add_taxonomy
1.x tripal_library.admin.inc | tripal_library_add_taxonomy($node, $library_id) |
Add the library as a taxonomy term for associating with library_features
Related topics
File
- tripal_library/
includes/ tripal_library.admin.inc, line 307
Code
function tripal_library_add_taxonomy($node, $library_id) {
//include the file containing the required functions. We only have to
// do this because Drupal 6 fails to do this globally for us and
// the drupal_execute function below won't work
module_load_include('inc', 'taxonomy', 'taxonomy.admin');
/* // get the vocabulary id
$vocabularies = taxonomy_get_vocabularies();
$vid = NULL;
foreach($vocabularies as $vocab){
if($vocab->name == 'DNA Libraries'){
$vid = $vocab->vid;
}
}
if(!$vid){ */
// add the vocabulary
$vocab_form['values']['name'] = 'DNA Libraries';
$vocab_form['values']['description'] = 'Allows for associating/searching of library features by library name';
$vocab_form['values']['help'] = '';
$vocab_form['values']['module'] = 'taxonomy';
drupal_execute('taxonomy_form_vocabulary', $vocab_form);
return;
// }
// make sure this term doesn't already exist. If it doesn't then add it
if ($vid) {
$tree = taxonomy_get_tree($vid);
$found = 0;
foreach ($tree as $term) {
if ($term->name == $node->title) {
$found = 1;
}
}
// add the term to the vocabulary
if (!$found) {
$form_state = array();
$form_state['values']['name'] = $node->title;
$form_state['values']['description'] = $library_id;
drupal_execute('taxonomy_form_term', $form_state, $vid);
}
}
}