Project:modr8
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:critical
Assigned:Unassigned
Status:needs review

Issue Summary

Hi,
Wouldn't it be nice to have rules integration with modr8.
This way the same things can be achieved my creating the right rules (www.drupal.org/project/rules).
Thanks for considering this!

Greetings, Martijn

Comments

#1

Priority:normal» critical

I've got to agree here. One problem I'm running into is that without the ability to have mdr8 publish content (as opposed to marking moderated), unmoderated content can appear in various places such as my sitemap. The current fix is to turn down sitemap updating to 12 hours giving me time to moderate content, however this is not a good fix and could be greatly improved with a few rules based on the approval of moderated content.

#2

Status:active» needs review

The following code adds a condition for whether the node is in the moderation queue. Since modr8 calls node_save the rule would be triggered on saving existing content. It should go into a file called modr8.rules.inc

<?php
/**
* Implementation of hook_rules_condition_info()
*/
function modr8_rules_condition_info() {
$items = array();

$defaults = array(
'arguments' => array(
'node' => array('type' => 'node', 'label' => t('Content')),
),
'module' => 'Node',
);

$items['rules_condition_content_is_moderated'] = $defaults + array(
'label' => t('Content is in moderation queue'),
);

return $items;
}

/**
* Condition: Check if the node is in the moderation queue
*/
function rules_condition_content_is_moderated(&$node, $settings) {
return $node->moderate == 1;
}

function rules_condition_content_is_moderated_label($settings, $argument_labels) {
return t('@node is in moderation queue', $argument_labels);
}

#3

I took the code above a little further and added an action: "Approve content". Since maintenance is unknown, I'd rather add this here than on in the Rules feature request.

I used this to approve referenced content when new content of a specific type is created.

NOTE: This does not add a log entry to the modr8 log reports. Someone else will have to continue with this.

(Add these 2 pages to [your_site]/sites/all/modules/rules/rules/modules)

AttachmentSize
modr8-rules.zip 1.87 KB