]>
Commit | Line | Data |
---|---|---|
2ec7e08e ER |
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 | |
5 | @@ -92,7 +92,7 @@ | |
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); | |
11 | ||
12 | // Tabs: | |
13 | $items[] = array('path' => 'admin/comment/list', 'title' => t('list'), | |
14 | @@ -266,8 +266,13 @@ | |
15 | break; | |
16 | ||
17 | case 'delete': | |
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); | |
21 | + } else { | |
22 | db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid); | |
23 | db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); | |
24 | + } | |
25 | break; | |
26 | ||
27 | case 'update index': | |
28 | @@ -320,6 +325,10 @@ | |
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); | |
31 | ||
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); | |
35 | + | |
36 | $result = db_query('SELECT fid, filter FROM {moderation_filters} '); | |
37 | while ($filter = db_fetch_object($result)) { | |
38 | $thresholds[$filter->fid] = ($filter->filter); | |
39 | @@ -672,6 +681,7 @@ | |
40 | ||
41 | function comment_links($comment, $return = 1) { | |
42 | global $user; | |
43 | + global $node_info; | |
44 | ||
45 | $links = array(); | |
46 | ||
47 | @@ -681,8 +691,15 @@ | |
48 | } | |
49 | ||
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"); | |
55 | + } else { | |
56 | $links[] = l(t('delete'), "admin/comment/delete/$comment->cid"); | |
57 | + } | |
58 | + } | |
59 | + | |
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"); | |
63 | } | |
64 | @@ -707,6 +724,12 @@ | |
65 | function comment_render($node, $cid = 0) { | |
66 | global $user; | |
67 | ||
68 | + // Give out node owner information to detect node owner: | |
69 | + global $node_info; | |
70 | + $node_info = array(); | |
71 | + $node_info['uid'] = $node->uid; | |
72 | + $node_info['nid'] = $node->nid; | |
73 | + | |
74 | $mode = $_GET['mode']; | |
75 | $order = $_GET['order']; | |
76 | $threshold = $_GET['threshold']; | |
77 | @@ -959,9 +982,18 @@ | |
78 | ||
79 | $output = ''; | |
80 | ||
81 | + // Access check | |
82 | + if ( | |
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 | |
86 | + ) { | |
87 | + | |
88 | // We'll only delete if the user has confirmed the | |
89 | // deletion using the form in our else clause below. | |
90 | + | |
91 | if ($comment->cid && $_POST['edit']['confirm']) { | |
92 | + | |
93 | drupal_set_message(t('The comment and all its replies have been deleted.')); | |
94 | ||
95 | // Delete comment and its replies. | |
96 | @@ -990,7 +1022,12 @@ | |
97 | drupal_set_message(t('The comment no longer exists.')); | |
98 | } | |
99 | ||
100 | + } else { | |
101 | + drupal_set_message(t('You are not authorized to access this page.')); | |
102 | + } | |
103 | + | |
104 | print theme('page', $output); | |
105 | + | |
106 | } | |
107 | ||
108 | function comment_save($id, $edit) { | |
109 | @@ -1609,8 +1646,13 @@ | |
110 | ||
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)))); | |
116 | + } else { | |
117 | db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid); | |
118 | watchdog('content', t('Comment: deleted %subject.', array('%subject' => theme('placeholder', $comment->subject)))); | |
119 | + } | |
120 | ||
121 | module_invoke_all('comment', 'delete', $comment); | |
122 |