taxonomy_vocabulary_save

Versions
7
taxonomy_vocabulary_save($vocabulary)

Save a vocabulary given a vocabulary object.

▾ 7 functions call taxonomy_vocabulary_save()

default_install in profiles/default/default.install
Implements hook_install().
forum_enable in modules/forum/forum.install
taxonomy_check_vocabulary_hierarchy in modules/taxonomy/taxonomy.module
Dynamically check and update the hierarchy flag of a vocabulary.
taxonomy_form_term_submit in modules/taxonomy/taxonomy.admin.inc
Submit handler to insert or update a term.
taxonomy_form_vocabulary_submit in modules/taxonomy/taxonomy.admin.inc
Accept the form submission for a vocabulary and save the results.
taxonomy_overview_terms_submit in modules/taxonomy/taxonomy.admin.inc
Submit handler for terms overview form.
taxonomy_overview_vocabularies_submit in modules/taxonomy/taxonomy.admin.inc
Submit handler for vocabularies overview. Updates changed vocabulary weights.

Code

modules/taxonomy/taxonomy.module, line 331

<?php
function taxonomy_vocabulary_save($vocabulary) {

  if (!empty($vocabulary->name)) {
    // Prevent leading and trailing spaces in vocabulary names.
    $vocabulary->name = trim($vocabulary->name);
  }

  if (!isset($vocabulary->module)) {
    $vocabulary->module = 'taxonomy';
  }

  if (!empty($vocabulary->vid) && !empty($vocabulary->name)) {
    $status = drupal_write_record('taxonomy_vocabulary', $vocabulary, 'vid');
    module_invoke_all('taxonomy_vocabulary_update', $vocabulary);
  }
  elseif (empty($vocabulary->vid)) {
    $status = drupal_write_record('taxonomy_vocabulary', $vocabulary);
    field_attach_create_bundle('taxonomy_term', $vocabulary->machine_name);
    taxonomy_vocabulary_create_field($vocabulary);
    module_invoke_all('taxonomy_vocabulary_insert', $vocabulary);
  }

  cache_clear_all();
  entity_get_controller('taxonomy_vocabulary')->resetCache();

  return $status;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.