Fixes, Integrating Rules Module and New Tokens

JuliaKM - February 19, 2009 - 04:10
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
Description

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

JuliaKM - February 19, 2009 - 12:34

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

#2

JuliaKM - February 19, 2009 - 12:42

#3

EmanueleQuinto - March 4, 2009 - 09:37

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

JuliaKM - March 4, 2009 - 22:58

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

EmanueleQuinto - March 5, 2009 - 15:44

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

#6

JuliaKM - March 9, 2009 - 00:05
Status:needs work» needs review

#7

fago - March 25, 2009 - 14:40
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

fago - March 25, 2009 - 14:43
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

fago - March 25, 2009 - 14:47

#10

EmanueleQuinto - March 26, 2009 - 10:42

Updated patch with curly braces for "if".

AttachmentSize
revision_moderation.patch 6.84 KB

#11

opensanta - April 4, 2009 - 19:22
Status:needs work» needs review

updating status

#12

lesmana - November 13, 2009 - 21:34

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
 
 

Drupal is a registered trademark of Dries Buytaert.