function taxonomy_save_vocabulary in Drupal 5
Same name and namespace in other branches
- 4 modules/taxonomy.module \taxonomy_save_vocabulary()
- 6 modules/taxonomy/taxonomy.module \taxonomy_save_vocabulary()
2 calls to taxonomy_save_vocabulary()
- taxonomy_form_vocabulary_submit in modules/
taxonomy/ taxonomy.module - Accept the form submission for a vocabulary and save the results.
- _forum_get_vid in modules/
forum/ forum.module - Returns the vocabulary id for forum navigation.
File
- modules/
taxonomy/ taxonomy.module, line 316 - Enables the organization of content into categories.
Code
function taxonomy_save_vocabulary(&$edit) {
$edit['nodes'] = empty($edit['nodes']) ? array() : $edit['nodes'];
if ($edit['vid'] && $edit['name']) {
db_query("UPDATE {vocabulary} SET name = '%s', description = '%s', help = '%s', multiple = %d, required = %d, hierarchy = %d, relations = %d, tags = %d, weight = %d, module = '%s' WHERE vid = %d", $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy', $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 ($edit['vid']) {
$status = taxonomy_del_vocabulary($edit['vid']);
}
else {
$edit['vid'] = db_next_id('{vocabulary}_vid');
db_query("INSERT INTO {vocabulary} (vid, name, description, help, multiple, required, hierarchy, relations, tags, weight, module) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s')", $edit['vid'], $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy');
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;
}