Hello, elliotttf.

I apologise for bad English. First of all, thanks for your remarkable module! In the course of its use I had a following problem. I have tried to use it with module Rules. I wanted to connect with Event "A comment has been unpublished" the Action. That is I needed to adhere event "generated" by your module to some reaction. However, as I have found out event "unpublished" the module does not generate. I have correctly understood?

It would be desirable, that this event was generated. If it is possible, make, please, such possibility.

Comments

snupy’s picture

elliotttf

Has understood itself. Perhaps, it is useful to you. There are 2 problems:

1. In function comment_publish_publish_form_submit() (a file comment_publish.pages.inc) you update a database. It seems to me, it not absolutely successful decision. It is better to use standard functions API:

comment_unpublish_action()
comment_publish_action()

Which on idea should cause corresponding events (publish and unpublish). However here there is 2nd problem:

2. http://drupal.org/node/900396

elliotttf’s picture

Status: Active » Needs review

I think I understand what you're saying. I've updated the dev branch to invoke the comment API more correctly. Try checking that out from CVS, or apply this patch to the 6.x-1.0 release and let me know if it works:


Index: comment_publish.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_publish/comment_publish.pages.inc,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 comment_publish.pages.inc
--- comment_publish.pages.inc	27 Jan 2011 06:34:31 -0000	1.1.2.3
+++ comment_publish.pages.inc	31 Jan 2011 05:08:48 -0000
@@ -52,6 +52,8 @@ function comment_publish_publish_form($f
 function comment_publish_publish_form_submit($form, &$form_state) {
   if (db_query("UPDATE {comments} SET status=%d WHERE cid=%d", $form_state['values']['action'], $form_state['values']['cid'])) {
     _comment_update_node_statistics($form_state['values']['nid']);
+    $comment = db_fetch_object(db_query("SELECT * FROM {comments} WHERE cid=%d", $form_state['values']['cid']));
+    comment_invoke_comment($comment, ($form_state['values']['action'] ? 'unpublish' : 'publish'));
     drupal_set_message(t('The comment was @action successfully', array('@action' => ($form_state['values']['action'] ? 'unpublished' : 'published'))));
   }
   else {
@@ -117,6 +119,7 @@ function comment_publish_js($node, $cid,
   $success = db_query("UPDATE {comments} SET status=%d WHERE cid=%d", $comment->status, $comment->cid);
   if ($success) {
     _comment_update_node_statistics($comment->nid);
+    comment_invoke_comment($comment, ($comment->status ? 'publish' : 'unpublish'));
 
     watchdog('comment_publish', '@name @action comment @cid', array('@name' => $user->name, '@action' => $action, '@cid' => $comment->cid));
     return drupal_json(array('status' => $success, 'data' => array('status' => $comment->status, 'format' => $foutput)));
snupy’s picture

elliotttf

Thanks. All works...

… except 2nd point :). Let's wait, when will correct.