Fixes, Integrating Rules Module and New Tokens
| Project: | Revision Moderation |
| Version: | 6.x-1.0-alpha1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | rules integration |
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.

#1
Sorry, wasn't able to get the files to add correctly last night. Here are the patch and inc files.
#2
#3
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).
#4
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.
#5
Unfortunately revision delete is handled by node.module so it requires a core patch...
#6
#7
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.
#8
hm, the other changes seem to be useful fixes though.
Anyway
+ if (module_exists('rules')) rules_invoke_event('revision_create', $node);
should use {}.
#9
also see #351827: Upgrade path test/document
#10
Updated patch with curly braces for "if".
#11
updating status
#12
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.