summaryrefslogtreecommitdiff
path: root/modules/comment/comment.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/comment/comment.module')
-rw-r--r--modules/comment/comment.module25
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().
*