SOURCES: drupal-comment.patch (NEW) - alternative comments moderat...
glen
glen at pld-linux.org
Wed Jan 11 17:12:46 CET 2006
Author: glen Date: Wed Jan 11 16:12:46 2006 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- alternative comments moderation patch
---- Files affected:
SOURCES:
drupal-comment.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/drupal-comment.patch
diff -u /dev/null SOURCES/drupal-comment.patch:1.1
--- /dev/null Wed Jan 11 17:12:46 2006
+++ SOURCES/drupal-comment.patch Wed Jan 11 17:12:41 2006
@@ -0,0 +1,122 @@
+rediff from from http://drupal.org/node/43145
+diff -ur -w drupal-4.6.5/modules/comment.module drupal-4.6.5.comment/modules/comment.module
+--- drupal-4.6.5/modules/comment.module 2005-11-15 22:37:56.000000000 +0200
++++ drupal-4.6.5.comment/modules/comment.module 2006-01-11 18:01:10.000000000 +0200
+@@ -92,7 +92,7 @@
+ $items[] = array('path' => 'admin/comment/edit', 'title' => t('edit comment'),
+ 'callback' => 'comment_admin_edit', 'access' => $access, 'type' => MENU_CALLBACK);
+ $items[] = array('path' => 'admin/comment/delete', 'title' => t('delete comment'),
+- 'callback' => 'comment_delete', 'access' => $access, 'type' => MENU_CALLBACK);
++ 'callback' => 'comment_delete', 'access' => 1, 'type' => MENU_CALLBACK);
+
+ // Tabs:
+ $items[] = array('path' => 'admin/comment/list', 'title' => t('list'),
+@@ -266,8 +266,13 @@
+ break;
+
+ case 'delete':
++ if(variable_get('comment_delete_mode', 0) == 1) {
++ db_query('UPDATE {comments} set status = 1 WHERE nid = %d', $node->nid);
++ db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid);
++ } else {
+ 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':
+@@ -320,6 +325,10 @@
+ $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')));
+ $output .= form_group(t('Comment posting settings'), $group);
+
++ $group = form_radios(t('Delete mode'), 'comment_delete_mode', variable_get('comment_delete_mode', 0), array(t('Delete'), t('Unpublish')));
++ $group .= form_radios(t('Node owner can delete node comments'), 'comment_moderating_nodeowner', variable_get('comment_moderating_nodeowner', 0), array(t('Disabled'), t('Enabled')));
++ $output .= form_group(t('Comment management settings'), $group);
++
+ $result = db_query('SELECT fid, filter FROM {moderation_filters} ');
+ while ($filter = db_fetch_object($result)) {
+ $thresholds[$filter->fid] = ($filter->filter);
+@@ -672,6 +681,7 @@
+
+ function comment_links($comment, $return = 1) {
+ global $user;
++ global $node_info;
+
+ $links = array();
+
+@@ -681,8 +691,15 @@
+ }
+
+ if (node_comment_mode($comment->nid) == 2) {
+- if (user_access('administer comments') && user_access('access administration pages')) {
++ if ($node_info['uid'] == $user->uid && variable_get('comment_moderating_nodeowner', 0) == 1 || user_access('administer comments') && user_access('access administration pages')) {
++ if (variable_get('comment_delete_mode', 0) == 1) {
++ $links[] = l(t('unpublish'), "admin/comment/delete/$comment->cid");
++ } else {
+ $links[] = l(t('delete'), "admin/comment/delete/$comment->cid");
++ }
++ }
++
++ if (user_access('administer comments') && user_access('access administration pages')) {
+ $links[] = l(t('edit'), "admin/comment/edit/$comment->cid");
+ $links[] = l(t('reply'), "comment/reply/$comment->nid/$comment->cid");
+ }
+@@ -707,6 +724,12 @@
+ function comment_render($node, $cid = 0) {
+ global $user;
+
++ // Give out node owner information to detect node owner:
++ global $node_info;
++ $node_info = array();
++ $node_info['uid'] = $node->uid;
++ $node_info['nid'] = $node->nid;
++
+ $mode = $_GET['mode'];
+ $order = $_GET['order'];
+ $threshold = $_GET['threshold'];
+@@ -959,9 +982,18 @@
+
+ $output = '';
+
++ // Access check
++ if (
++ user_access('administer comments')
++ || variable_get('comment_moderating_nodeowner', 0) == 1 // comment_moderating_nodeowner Enabled
++ && db_fetch_object(db_query('SELECT uid from {node} where nid = %d and uid = %d',$comment->nid,$GLOBALS['user']->uid)) // user owns node
++ ) {
++
+ // We'll only delete if the user has confirmed the
+ // deletion using the form in our else clause below.
++
+ if ($comment->cid && $_POST['edit']['confirm']) {
++
+ drupal_set_message(t('The comment and all its replies have been deleted.'));
+
+ // Delete comment and its replies.
+@@ -990,7 +1022,12 @@
+ drupal_set_message(t('The comment no longer exists.'));
+ }
+
++ } else {
++ drupal_set_message(t('You are not authorized to access this page.'));
++ }
++
+ print theme('page', $output);
++
+ }
+
+ function comment_save($id, $edit) {
+@@ -1609,8 +1646,13 @@
+
+ function _comment_delete_thread($comment) {
+ // Delete the comment:
++ if (variable_get('comment_delete_mode', 0) == 1) {
++ db_query('UPDATE {comments} set status = 1 WHERE cid = %d', $comment->cid);
++ watchdog('content', t('Comment: unpublished %subject.', array('%subject' => theme('placeholder', $comment->subject))));
++ } else {
+ db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid);
+ watchdog('content', t('Comment: deleted %subject.', array('%subject' => theme('placeholder', $comment->subject))));
++ }
+
+ module_invoke_all('comment', 'delete', $comment);
+
================================================================
More information about the pld-cvs-commit
mailing list