Same name and namespace in other branches
  1. 4.6.x modules/taxonomy.module \taxonomy_save_vocabulary()
  2. 4.7.x modules/taxonomy.module \taxonomy_save_vocabulary()
  3. 5.x modules/taxonomy/taxonomy.module \taxonomy_save_vocabulary()
5 calls to taxonomy_save_vocabulary()
forum_enable in modules/forum/forum.install
forum_update_6000 in modules/forum/forum.install
Create the forum vocabulary if does not exist. Assign the vocabulary a low weight so it will appear first in forum topic create and edit forms. Do not just call forum_enable() because in future versions it might do something different.
taxonomy_check_vocabulary_hierarchy in modules/taxonomy/taxonomy.module
Dynamically check and update the hierarachy flag of a vocabulary. Checks and updates the hierarchy flag of a vocabulary.
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.

File

modules/taxonomy/taxonomy.module, line 196
Enables the organization of content into categories.

Code

function taxonomy_save_vocabulary(&$edit) {
  $edit['nodes'] = empty($edit['nodes']) ? array() : $edit['nodes'];
  if (!isset($edit['module'])) {
    $edit['module'] = 'taxonomy';
  }
  if (!empty($edit['vid']) && !empty($edit['name'])) {
    drupal_write_record('vocabulary', $edit, 'vid');
    db_query("DELETE FROM {vocabulary_node_types} WHERE vid = %d", $edit['vid']);
    foreach ($edit['nodes'] as $type => $selected) {
      db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type);
    }
    module_invoke_all('taxonomy', 'update', 'vocabulary', $edit);
    $status = SAVED_UPDATED;
  }
  else {
    if (!empty($edit['vid'])) {
      $status = taxonomy_del_vocabulary($edit['vid']);
    }
    else {
      drupal_write_record('vocabulary', $edit);
      foreach ($edit['nodes'] as $type => $selected) {
        db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type);
      }
      module_invoke_all('taxonomy', 'insert', 'vocabulary', $edit);
      $status = SAVED_NEW;
    }
  }
  cache_clear_all();
  return $status;
}