Workbench moderation currently does not have a rules condition to check if a node was previously published. This would suit instances where it is required for an email notification to be sent one time only and that would be when the content is first published.
The only other condition that comes close to this is "Content's current moderation state" but this would cause unnecessary emails being sent to users since it does not check the moderation history.
This patch simply adds the new condition to workbench_moderation.rules.inc and uses the workbench_moderation_node_history table to get the moderation history.
Comment | File | Size | Author |
---|---|---|---|
#7 | workbench_moderation-rules-condition-2313071-7.patch | 1.92 KB | ronaldmulero |
| |||
#3 | workbench_moderation-rules-condition-2313071-3.patch | 1.85 KB | phergo |
#1 | workbench_moderation-rules-condition-2313071-1.patch | 1.67 KB | mrrfakier |
Comments
Comment #1
mrrfakier CreditAttribution: mrrfakier commentedComment #3
phergo CreditAttribution: phergo commentedHi tlp027,
Your patch doesn't work for me. Your 'if' sentence always returns TRUE when a node is 'published' at first time. We have modified your patch in order to fix it.
Thanks a lot. Your patch was very helpful ;).
Comment #4
phergo CreditAttribution: phergo commentedComment #5
AnybodyThanks a lot for this patch.
Patch #3 applies cleanly against the latest .dev version and works great!
This is really really helpful and I needed it for example to give points to users and to create an other entity. Please apply this patch to the module.
Comment #6
mstrelan CreditAttribution: mstrelan commentedThat's a bit convoluted. How about this.
The
vid
condition negates the need for$node->workbench_moderation['current']->state
. And the try/catch is not really necessary.Comment #7
ronaldmulero CreditAttribution: ronaldmulero at U.Group commentedBased on the original description of this issue: that the Action should be triggered "one time only and that would be when the content is first published", none of the above solutions worked for me.
mrrfakier #1 was the closest, but only worked if
if ( $count == 1 && ($node->workbench_moderation['current']->state == 'published') ) {
was changed toif ( $count == 1 && ($node->workbench_moderation['current']->state != 'published') ) {
or else it triggered every time the node was republished.phergo #3 is more coding standards compliant, but didn't work for me.
mstrelan suggested change in #6 is cleaner, but also triggered every time the node was republished.
I rolled a hybrid patch of all 3, updating the condition label and function name along the way. The following Rules workflow only triggers the Action the first time a node is published and never again.
Needs tests.