I needed to integrate the Rules module with Revision Moderation on a project and thought someone might find the code useful.

This was the code that I added so that a user could be notified via email using the Rules module when a new revision is created. Please let me know if you are interested in seeing the rule I am using. I have it set up to email the page author when a revision is submitted to their page.

Here's what my patch (revision_mod_token_021809.patch) and added file (revision_moderation.rules.inc) contain:

Rules
- I added a new rules event called "revision_create" for when a new revision is created.

Added Tokens
- [node:revision-author-name] I wanted to be able to have the revision author name included in Rules emails.
- [node:revision-diff-link] This is a link to the diff page for a submitted revision
- [node:revision-moderation] Whether revision moderation is on (this was in the 5.x version of the module)
- [node:revision] Whether a new revision is to be created (this was in the 5.x version of the module)
- [node:vid] = The node revision ID

Cleanup
- When I ran the code through the Coder module, there a few problems with t() that are fixed now.

This code is still in very rough form. It would be great if someone else could improve it.

Comments

JuliaKM’s picture

Sorry, wasn't able to get the files to add correctly last night. Here are the patch and inc files.

JuliaKM’s picture

EmanueleQuinto’s picture

StatusFileSize
new6.77 KB
new805 bytes

Thanks Julia, we found the patch useful, it's exactly what we need.

Indeed we need another rule to notify author of the revision when it is approved so we add "revision_publish" (maybe would be nice to add "revision_delete" as well).

Attached revised rule.inc and patch (small typo corrected).

JuliaKM’s picture

Thanks Emanuele! Revision publish is a great addition. I would definitely find revision delete useful as well. I hope that our patches get added to the module.

EmanueleQuinto’s picture

Unfortunately revision delete is handled by node.module so it requires a core patch...

JuliaKM’s picture

Status: Needs work » Needs review
fago’s picture

Status: Needs review » Needs work
Issue tags: +rules integration

adding those events seems to make sense, however the patch contains a lot of other stuff too. Make sure it contains only relevant changes.
Also have a look at the coding style: http://drupal.org/coding-standards

I think there was also some workflow-ng integration that should be ported to rules.

fago’s picture

Title: Integrating Rules Module and New Tokens » Fixes, Integrating Rules Module and New Tokens

hm, the other changes seem to be useful fixes though.

Anyway
+ if (module_exists('rules')) rules_invoke_event('revision_create', $node);
should use {}.

fago’s picture

EmanueleQuinto’s picture

StatusFileSize
new6.84 KB

Updated patch with curly braces for "if".

mitchell’s picture

Status: Needs work » Needs review

updating status

les lim’s picture

Nice work! I needed access to user conditionals on the revision_create event, which I built on top of the patch in #10 and the rules.inc file in #3. Re-attached below.

EmanueleQuinto’s picture

Patch for revision_moderation module updated for 6.x-1.0-alpha1.

Please note the patch fix menu title/description that need to be "untranslated" in drupal 6.

JuliaKM’s picture

I plan on updating this for alpha 2 next week. I can break it out so that the patch for the new rule is separate if that would make the patch more likely to be accepted.