diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-10-02 16:15:56 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-10-02 16:15:56 +0000 |
commit | 4bb5080ebe210c5fc0e90549dcacfb088d4cbce3 (patch) | |
tree | b96ad761a3142351804d6108b23759deb1440451 /modules/taxonomy/taxonomy.module | |
parent | c389c90529d45b33c21f55fc7b7f4539fcea762c (diff) | |
download | brdo-4bb5080ebe210c5fc0e90549dcacfb088d4cbce3.tar.gz brdo-4bb5080ebe210c5fc0e90549dcacfb088d4cbce3.tar.bz2 |
- Patch #169982 by moshe, eaton, bjaspan, nedjo, yched, et al: missing feature from schema API: load/save records based upon schema.
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r-- | modules/taxonomy/taxonomy.module | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 3fc560c22..fe8547bee 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -165,8 +165,12 @@ function taxonomy_menu() { 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'])) { - 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']); + 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); @@ -178,8 +182,7 @@ function taxonomy_save_vocabulary(&$edit) { $status = taxonomy_del_vocabulary($edit['vid']); } else { - db_query("INSERT INTO {vocabulary} (name, description, help, multiple, required, hierarchy, relations, tags, weight, module) VALUES ('%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s')", $edit['name'], isset($edit['description']) ? $edit['description'] : NULL, isset($edit['help']) ? $edit['help'] : NULL, $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], isset($edit['tags']) ? $edit['tags'] : NULL, $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy'); - $edit['vid'] = db_last_insert_id('vocabulary', 'vid'); + 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); } @@ -231,7 +234,7 @@ function taxonomy_save_term(&$form_values) { ); if (!empty($form_values['tid']) && $form_values['name']) { - db_query("UPDATE {term_data} SET name = '%s', description = '%s', weight = %d WHERE tid = %d", $form_values['name'], $form_values['description'], $form_values['weight'], $form_values['tid']); + drupal_write_record('term_data', $form_values, 'tid'); $hook = 'update'; $status = SAVED_UPDATED; } @@ -239,8 +242,7 @@ function taxonomy_save_term(&$form_values) { return taxonomy_del_term($form_values['tid']); } else { - db_query("INSERT INTO {term_data} (name, description, vid, weight) VALUES ('%s', '%s', %d, %d)", $form_values['name'], $form_values['description'], $form_values['vid'], $form_values['weight']); - $form_values['tid'] = db_last_insert_id('term_data', 'tid'); + drupal_write_record('term_data', $form_values); $hook = 'insert'; $status = SAVED_NEW; } |