Download & Extend

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

Issue Summary

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

#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).

AttachmentSize
revision_moderation.rules_.inc_.txt 805 bytes
revision_moderation.patch 6.77 KB

#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

Status:needs work» needs review

#7

Status:needs review» needs work

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

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 {}.

#9

#10

Updated patch with curly braces for "if".

AttachmentSize
revision_moderation.patch 6.84 KB

#11

Status:needs work» needs review

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.

AttachmentSize
revision_moderation-376468-12.patch 7.16 KB
revision_moderation.rules_.inc_.txt 899 bytes

#13

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.

AttachmentSize
revision_moderation-tokenrules.6.x-1.0-alpha1.patch 6.57 KB

#14

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.