diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-08-29 18:43:26 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-08-29 18:43:26 +0000 |
commit | 5524604a951f1158ea33584630c0811c217a1346 (patch) | |
tree | df956d335db604bc16f9e627be3f88b2f26884b1 /modules/comment/comment.module | |
parent | 78ee75f1a2ecc6a788dcf697d36783798ecbbe12 (diff) | |
download | brdo-5524604a951f1158ea33584630c0811c217a1346.tar.gz brdo-5524604a951f1158ea33584630c0811c217a1346.tar.bz2 |
- Patch #68418 by Moshe et al: clean up node submit hooks.
Diffstat (limited to 'modules/comment/comment.module')
-rw-r--r-- | modules/comment/comment.module | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 80802d8d9..06aaeec89 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -280,6 +280,7 @@ function comment_form_alter($form_id, &$form) { } elseif (isset($form['type'])) { if ($form['type']['#value'] .'_node_form' == $form_id) { + $form['#submit']['comment_node_submit'] = array(); $node = $form['#node']; $form['comment_settings'] = array( '#type' => 'fieldset', @@ -297,6 +298,10 @@ function comment_form_alter($form_id, &$form) { ); } } + + if ($form_id == 'node_delete_confirm') { + $form['#submit']['comment_node_delete_confirm_submit'] = array(); + } } /** @@ -315,15 +320,6 @@ function comment_nodeapi(&$node, $op, $arg = 0) { } break; - case 'insert': - db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid); - break; - - case 'delete': - db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); - break; - case 'update index': $text = ''; $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED); @@ -346,6 +342,17 @@ function comment_nodeapi(&$node, $op, $arg = 0) { } } +function comment_node_delete_confirm_submit($form_id, $form_values) { + db_query('DELETE FROM {comments} WHERE nid = %d', $form_values['node']->nid); + db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $form_values['node']->nid); +} + +function comment_node_submit($form_id, $node) { + if ($node->is_new) { + db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->created, $node->uid); + } +} + /** * Implementation of hook_user(). * |