- Patch #306224 by catch, sun: add proper taxonomy term hooks.
parent
ad41b6dd93
commit
ba1af44375
|
@ -14,19 +14,27 @@ function taxonomy_test_taxonomy_term_load($term) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_taxonomy_term_save().
|
||||
* Implementation of hook_taxonomy_term_insert().
|
||||
*/
|
||||
function taxonomy_test_taxonomy_term_save($term) {
|
||||
function taxonomy_test_taxonomy_term_insert($term) {
|
||||
if (!empty($term->antonyms)) {
|
||||
foreach (explode ("\n", str_replace("\r", '', $term->antonyms)) as $antonym) {
|
||||
if ($antonym) {
|
||||
db_insert('term_antonym')->fields(array('tid' => $term->tid, 'name' => rtrim($antonym)))->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_taxonomy_term_update().
|
||||
*/
|
||||
function taxonomy_test_taxonomy_term_update($term) {
|
||||
taxonomy_test_taxonomy_term_delete($term);
|
||||
if (!empty($term->antonyms)) {
|
||||
foreach (explode ("\n", str_replace("\r", '', $term->antonyms)) as $antonym) {
|
||||
if ($antonym) {
|
||||
db_insert('term_antonym')
|
||||
->fields(array(
|
||||
'tid' => $term->tid,
|
||||
'name' => rtrim($antonym),
|
||||
))
|
||||
->execute();
|
||||
db_insert('term_antonym')->fields(array('tid' => $term->tid, 'name' => rtrim($antonym)))->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ function taxonomy_save_term(&$form_values) {
|
|||
|
||||
if (!empty($form_values['tid']) && $form_values['name']) {
|
||||
$status = drupal_write_record('term_data', $form_values, 'tid');
|
||||
module_invoke_all('taxonomy_term_save', $term);
|
||||
module_invoke_all('taxonomy_term_insert', $term);
|
||||
}
|
||||
elseif (!empty($form_values['tid'])) {
|
||||
return taxonomy_del_term($form_values['tid']);
|
||||
|
@ -335,7 +335,7 @@ function taxonomy_save_term(&$form_values) {
|
|||
else {
|
||||
$status = drupal_write_record('term_data', $form_values);
|
||||
$term->tid = $form_values['tid'];
|
||||
module_invoke_all('taxonomy_term_save', $term);
|
||||
module_invoke_all('taxonomy_term_update', $term);
|
||||
}
|
||||
|
||||
db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $form_values['tid'], $form_values['tid']);
|
||||
|
|
Loading…
Reference in New Issue