Add the ability to publish / unpublish comments from rules.

Comments

Status: Needs review » Needs work

The last submitted patch, comment_actions.patch, failed testing.

JStanton’s picture

StatusFileSize
new1.32 KB

Rerolled correctly

JStanton’s picture

Status: Needs work » Needs review

Asking the testbot to test?

(Sorry, this is my first patch. Stumbling blindly thru it.)

Status: Needs review » Needs work

The last submitted patch, comment_actions-1315088-2.patch, failed testing.

JStanton’s picture

FWIW, this patch applies and works correctly. Is there a problem with the Rules tests in general?

mitchell’s picture

Version: 7.x-2.0 » 7.x-2.x-dev
Status: Needs work » Needs review
fago’s picture

Status: Needs review » Needs work

yes, the test bot has recently troubles with rules tests.

+++ b/modules/comment.rules.inc
@@ -54,6 +54,30 @@ function rules_comment_event_info() {
+  $actions = array('comment_publish_action', 'comment_unpublish_action');
+  foreach ($actions as $base) {
+    $action_name = str_replace('_action', '', $base);

Having to write those generic code for two actions looks odd. Let's better do this two action-infos without a foreach, so we don't need to fuddle with strings.

+++ b/modules/comment.rules.inc
@@ -63,5 +87,12 @@ function rules_comment_integration_access($type, $name) {
+  return user_access('administer nodes');

This should use the respective comment permission.

fago’s picture

FWIW, this patch applies and works correctly. Is there a problem with the Rules tests in general?

Yes, recently the bot has troubles with rules tests.

+++ b/modules/comment.rules.inc
@@ -54,6 +54,30 @@ function rules_comment_event_info() {
+  $core_actions = comment_action_info();
+  $actions = array('comment_publish_action', 'comment_unpublish_action');
+  foreach ($actions as $base) {
+    $action_name = str_replace('_action', '', $base);

Let's better save this foreach and string-fuddeling and just add the action-info for those two actions without generic-looping.
All we need to do is taking over the label, right?

+++ b/modules/comment.rules.inc
@@ -63,5 +87,12 @@ function rules_comment_integration_access($type, $name) {
+  return user_access('administer nodes');

Should use the respective comment permission.

pfructuoso’s picture

Status: Needs work » Needs review

Subscribe
I'm using this patch with last rules version and it works perfectly.

mitchell’s picture

Component: Provided Rules integration » Rules Core
Status: Needs review » Closed (duplicate)