1 rediff from from http://drupal.org/node/43145
2 diff -ur -w drupal-4.6.5/modules/comment.module drupal-4.6.5.comment/modules/comment.module
3 --- drupal-4.6.5/modules/comment.module 2005-11-15 22:37:56.000000000 +0200
4 +++ drupal-4.6.5.comment/modules/comment.module 2006-01-11 18:01:10.000000000 +0200
6 $items[] = array('path' => 'admin/comment/edit', 'title' => t('edit comment'),
7 'callback' => 'comment_admin_edit', 'access' => $access, 'type' => MENU_CALLBACK);
8 $items[] = array('path' => 'admin/comment/delete', 'title' => t('delete comment'),
9 - 'callback' => 'comment_delete', 'access' => $access, 'type' => MENU_CALLBACK);
10 + 'callback' => 'comment_delete', 'access' => 1, 'type' => MENU_CALLBACK);
13 $items[] = array('path' => 'admin/comment/list', 'title' => t('list'),
18 + if(variable_get('comment_delete_mode', 0) == 1) {
19 + db_query('UPDATE {comments} set status = 1 WHERE nid = %d', $node->nid);
20 + db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid);
22 db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid);
23 db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid);
29 $group .= form_radios(t('Location of comment submission form'), 'comment_form_location', variable_get('comment_form_location', 0), array(t('Display on separate page'), t('Display below post or comments')));
30 $output .= form_group(t('Comment posting settings'), $group);
32 + $group = form_radios(t('Delete mode'), 'comment_delete_mode', variable_get('comment_delete_mode', 0), array(t('Delete'), t('Unpublish')));
33 + $group .= form_radios(t('Node owner can delete node comments'), 'comment_moderating_nodeowner', variable_get('comment_moderating_nodeowner', 0), array(t('Disabled'), t('Enabled')));
34 + $output .= form_group(t('Comment management settings'), $group);
36 $result = db_query('SELECT fid, filter FROM {moderation_filters} ');
37 while ($filter = db_fetch_object($result)) {
38 $thresholds[$filter->fid] = ($filter->filter);
41 function comment_links($comment, $return = 1) {
50 if (node_comment_mode($comment->nid) == 2) {
51 - if (user_access('administer comments') && user_access('access administration pages')) {
52 + if ($node_info['uid'] == $user->uid && variable_get('comment_moderating_nodeowner', 0) == 1 || user_access('administer comments') && user_access('access administration pages')) {
53 + if (variable_get('comment_delete_mode', 0) == 1) {
54 + $links[] = l(t('unpublish'), "admin/comment/delete/$comment->cid");
56 $links[] = l(t('delete'), "admin/comment/delete/$comment->cid");
60 + if (user_access('administer comments') && user_access('access administration pages')) {
61 $links[] = l(t('edit'), "admin/comment/edit/$comment->cid");
62 $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
65 function comment_render($node, $cid = 0) {
68 + // Give out node owner information to detect node owner:
70 + $node_info = array();
71 + $node_info['uid'] = $node->uid;
72 + $node_info['nid'] = $node->nid;
74 $mode = $_GET['mode'];
75 $order = $_GET['order'];
76 $threshold = $_GET['threshold'];
83 + user_access('administer comments')
84 + || variable_get('comment_moderating_nodeowner', 0) == 1 // comment_moderating_nodeowner Enabled
85 + && db_fetch_object(db_query('SELECT uid from {node} where nid = %d and uid = %d',$comment->nid,$GLOBALS['user']->uid)) // user owns node
88 // We'll only delete if the user has confirmed the
89 // deletion using the form in our else clause below.
91 if ($comment->cid && $_POST['edit']['confirm']) {
93 drupal_set_message(t('The comment and all its replies have been deleted.'));
95 // Delete comment and its replies.
97 drupal_set_message(t('The comment no longer exists.'));
101 + drupal_set_message(t('You are not authorized to access this page.'));
104 print theme('page', $output);
108 function comment_save($id, $edit) {
109 @@ -1609,8 +1646,13 @@
111 function _comment_delete_thread($comment) {
112 // Delete the comment:
113 + if (variable_get('comment_delete_mode', 0) == 1) {
114 + db_query('UPDATE {comments} set status = 1 WHERE cid = %d', $comment->cid);
115 + watchdog('content', t('Comment: unpublished %subject.', array('%subject' => theme('placeholder', $comment->subject))));
117 db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
118 watchdog('content', t('Comment: deleted %subject.', array('%subject' => theme('placeholder', $comment->subject))));
121 module_invoke_all('comment', 'delete', $comment);