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.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | revision_moderation-tokenrules.6.x-1.0-alpha1.patch | 6.57 KB | EmanueleQuinto |
| #12 | revision_moderation-376468-12.patch | 7.16 KB | les lim |
| #12 | revision_moderation.rules_.inc_.txt | 899 bytes | les lim |
| #10 | revision_moderation.patch | 6.84 KB | EmanueleQuinto |
| #3 | revision_moderation.rules_.inc_.txt | 805 bytes | EmanueleQuinto |
Comments
Comment #1
JuliaKM commentedSorry, wasn't able to get the files to add correctly last night. Here are the patch and inc files.
Comment #2
JuliaKM commentedComment #3
EmanueleQuinto commentedThanks 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).
Comment #4
JuliaKM commentedThanks 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.
Comment #5
EmanueleQuinto commentedUnfortunately revision delete is handled by node.module so it requires a core patch...
Comment #6
JuliaKM commentedComment #7
fagoadding 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.
Comment #8
fagohm, the other changes seem to be useful fixes though.
Anyway
+ if (module_exists('rules')) rules_invoke_event('revision_create', $node);
should use {}.
Comment #9
fagoalso see #351827: Upgrade path test/document
Comment #10
EmanueleQuinto commentedUpdated patch with curly braces for "if".
Comment #11
mitchell commentedupdating status
Comment #12
les limNice 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.
Comment #13
EmanueleQuinto commentedPatch 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.
Comment #14
JuliaKM commentedI 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.