summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-08-31 21:58:36 +0000
committerDries Buytaert <dries@buytaert.net>2006-08-31 21:58:36 +0000
commit49fa25fb7658ada5ee242853d3ed301d0a0b05a9 (patch)
tree12fb57e50398413cc420df5ed486b77b9c996aa2 /modules/taxonomy/taxonomy.module
parentc64db1da29a6b2067f09e66e5e85e8877b489cb0 (diff)
downloadbrdo-49fa25fb7658ada5ee242853d3ed301d0a0b05a9.tar.gz
brdo-49fa25fb7658ada5ee242853d3ed301d0a0b05a9.tar.bz2
- Rollback of patch #68418: clean up node submit hooks. Needs more thinkering.
Restores the old node API.
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r--modules/taxonomy/taxonomy.module52
1 files changed, 26 insertions, 26 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 82fd2bbea..bece3b163 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -606,10 +606,6 @@ function taxonomy_get_vocabularies($type = NULL) {
*/
function taxonomy_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
- // inject custom validate and submit handlers
- $form['#validate']['taxonomy_node_validate'] = array();
- $form['#submit']['taxonomy_node_submit'] = array();
-
$node = $form['#node'];
if (!isset($node->taxonomy)) {
@@ -676,10 +672,6 @@ function taxonomy_form_alter($form_id, &$form) {
$form['taxonomy'] += array('#type' => 'fieldset', '#title' => t('Categories'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, '#weight' => -3);
}
}
-
- if ($form_id == 'node_delete_confirm') {
- $form['#submit']['taxonomy_node_delete_confirm_submit'] = array();
- }
}
/**
@@ -713,9 +705,9 @@ function taxonomy_node_get_terms($nid, $key = 'tid') {
/**
* Make sure incoming vids are free tagging enabled.
*/
-function taxonomy_node_validate($form_id, $node) {
- if ($node['taxonomy']) {
- $terms = $node['taxonomy'];
+function taxonomy_node_validate(&$node) {
+ if ($node->taxonomy) {
+ $terms = $node->taxonomy;
if ($terms['tags']) {
foreach ($terms['tags'] as $vid => $vid_value) {
$vocabulary = taxonomy_get_vocabulary($vid);
@@ -732,14 +724,14 @@ function taxonomy_node_validate($form_id, $node) {
/**
* Save term associations for a given node.
*/
-function taxonomy_node_submit($form_id, $node) {
- taxonomy_node_delete($node->nid);
+function taxonomy_node_save($nid, $terms) {
+ taxonomy_node_delete($nid);
// Free tagging vocabularies do not send their tids in the form,
// so we'll detect them here and process them independently.
- if (isset($node->taxonomy['tags'])) {
- $typed_input = $node->taxonomy['tags'];
- unset($node->taxonomy['tags']);
+ if (isset($terms['tags'])) {
+ $typed_input = $terms['tags'];
+ unset($terms['tags']);
foreach ($typed_input as $vid => $vid_value) {
// This regexp allows the following types of user input:
@@ -775,27 +767,27 @@ function taxonomy_node_submit($form_id, $node) {
// Defend against duplicate, different cased tags
if (!isset($inserted[$typed_term_tid])) {
- db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $typed_term_tid);
+ db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $typed_term_tid);
$inserted[$typed_term_tid] = TRUE;
}
}
}
}
- if (is_array($node->taxonomy)) {
- foreach ($node->taxonomy as $term) {
+ if (is_array($terms)) {
+ foreach ($terms as $term) {
if (is_array($term)) {
foreach ($term as $tid) {
if ($tid) {
- db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $tid);
+ db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $tid);
}
}
}
else if (is_object($term)) {
- db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $term->tid);
+ db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term->tid);
}
else if ($term) {
- db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $node->nid, $term);
+ db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term);
}
}
}
@@ -1165,6 +1157,18 @@ function taxonomy_nodeapi($node, $op, $arg = 0) {
case 'load':
$output['taxonomy'] = taxonomy_node_get_terms($node->nid);
return $output;
+ case 'insert':
+ taxonomy_node_save($node->nid, $node->taxonomy);
+ break;
+ case 'update':
+ taxonomy_node_save($node->nid, $node->taxonomy);
+ break;
+ case 'delete':
+ taxonomy_node_delete($node->nid);
+ break;
+ case 'validate':
+ taxonomy_node_validate($node);
+ break;
case 'rss item':
return taxonomy_rss_item($node);
case 'update index':
@@ -1172,10 +1176,6 @@ function taxonomy_nodeapi($node, $op, $arg = 0) {
}
}
-function taxonomy_node_confirm_delete_submit($form_id, $form_values) {
- taxonomy_node_delete($form_values['node']->nid);
-}
-
/**
* Implementation of hook_nodeapi('update_index').
*/