As current version of workflow lacks integration with Rules, so I've ported integration module from D5. Just unzip the archive into your workflow module folder (or, actually any module folder) and enable module.

Comments

alanburke’s picture

Subscribe.
Will hopefully get a chance to test sometime soon

leoklein’s picture

Thanks. This is great!

crea’s picture

Category: support » feature
Status: Needs review » Needs work

Same as #257833: When saving a node, the workflow ng transition rule is triggered, even though workflow has not changed
I think that checking tokens in Rules is ugly.
What about 2 Rules events:

  1. Workflow state changed
  2. Workflow comment was added

This needs some more thought, so setting it to "needs work"

crea’s picture

Title: Port of workflow_ng integration to D6 » Rules integration for Workflow
Version: 6.x-1.1 » 6.x-1.x-dev
Component: -workflow_workflow_ng » Code
Status: Needs work » Needs review
Issue tags: +rules integration
StatusFileSize
new1.62 KB

Here is updated module. Changes from original port posted in this issue:

  • No more "Workflow updated" event with it's uglyness.
  • New event "Workflow state has been changed" is invoked when state really did change.
  • No more comparing tokens to find out!

  • New event "Workflow comment was added".
  • It is invoked when workflow is updated with comment, but no state change happened.
    Note 1: in case workflow state has changed and comment was added at the same time only "Workflow state has been changed" rule will be invoked, not both.
    Note 2: currently it is commented in module code, because for proper work it requires patch #472966: Avoid execute_transition twice (when using Rules, Actions) (see comments in module code).

klausi’s picture

Assigned: Unassigned » klausi
Status: Needs review » Needs work
Issue tags: +gsoc:rulesmonkey

I will work on the Rules integration during my Google Summer of Code project.
* I will recycle your code and extend it
* I will provide valid patches against the Workflow CVS dev branch
* I think we do not need a separate module. I will let the code live in a workflow.rules.inc file

crea’s picture

Great news.
Too bad your patches won't be commited cause workflow seems to be unmaintained. So if you intend to make it part of Workflow, obtain commit access also, hehe...

klausi’s picture

StatusFileSize
new6.29 KB

Here is a first patch. Currently there is only one event that occurs if a transition to a different state has been made. A condition is also included to check the transition states.

TODO:
* Add event for non-state-changing transitions with comments

What other events, conditions and actions would you like?

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new7.38 KB

New patch:
* Added event for workflow comments only (also added unset($node->workflow_comment); to avoid double execution of a state transition, inspired by #472966: Avoid execute_transition twice (when using Rules, Actions)).
* Also added $node->workflow = $sid; after the transition to avoid the double execution.

crea’s picture

Status: Needs review » Needs work

I think you should not put fix from #472966: Avoid execute_transition twice (when using Rules, Actions) inside this patch, because duplicate runs is different problem, not just local to Rules integration and that patch in #472966: Avoid execute_transition twice (when using Rules, Actions) also should fix subsequent duplicate runs for other modules.
Stating that Workflow integration requires that patch would be enough.

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new6 KB

OK, I added a patch suggestion in #472966: Avoid execute_transition twice (when using Rules, Actions).
This patch here depends on my patch there, so apply the other patch first.

klausi’s picture

fago’s picture

Status: Needs review » Reviewed & tested by the community

I applied the patch from http://drupal.org/node/472966#comment-1906724 and give this a test. I tried both events, the condition and also using the core action with rules - works as it should :) Also code style is looking fine, so I set this to RTBC.

Having this integration would help the user that want to use workflow with rules (see #396086: Help using Workflow's states with Rules) a lot, till know users relied upon tokens to detect workflow transitions. Having the separate condition of this patch is much better.

gagarine’s picture

track

Edit: After all i use trigger (integrated in D6 core & with workflow) to fire rule sets.

csc4’s picture

Tracking

gagarine’s picture

I try patch #11 with #9 on #472966: Avoid execute_transition twice (when using Rules, Actions) .
All seem to work fine thanks

2 feature requests:
- access to the "unchanged content" on the event "workflow state has change".
- on the event "content is going to be saved" a condition to check the value of the new workflow sate.

Edit: perhaps this bug can help #327144: workflow-state tokens are reversed

hefox’s picture

StatusFileSize
new3.09 KB

Great patch;

For the lazy minded that don't want to add ORs for each potential state, the which state could be a multi select under "check workflow state"

Attached patch changes that, haven't tested heavily. (assumed patch 11 applied, ie doesn't include 11).

hefox’s picture

I've had some issue with this, same as in #445084: Adjust module weight from 0 however adjusting weight did not help. The triggered rule was returning the $node in the array('node'=>$node) format to resave in a 'custom php' do action. (The rule was set up to set published, changed date to now when workflow state changed to my 'published' state).

hefox’s picture

(Nevermind, probably the subsquent patch will fix it).

miro_dietiker’s picture

StatusFileSize
new6.45 KB

I've had an ugly issue with this patch: http://drupal.org/node/616664
Indeed it was only with the single selectable implementation from klausi nr 11... where too strict checks led to this issue.
Rules integration checked for === between numbers as string and numbers as int - whereas they where treated unidentical

Switching to the multiple selectable version containing checks with in_array led to a perfect working solution.

I'm going to submit a new patch containing checked workflow.module rules integration with multiple support (11 and 16) with tiny formatting corrections. This patch should really be production ready and candidate for CVS now.

Rerolled against current -dev of today, with need to change one hunk.

miro_dietiker’s picture

Assigned: klausi » Unassigned

making it unassigned.

shawn dearmond’s picture

I applied #19 to 6.x-1.3 and it worked great. Thanks!

designerbrent’s picture

What needs to happen to get this committed?

crea’s picture

Well..the module needs active maintainer. Seems to be unsupported.

Encarte’s picture

subscribe

infojunkie’s picture

subscribe

mxt’s picture

subscribe

jvandyk’s picture

Status: Reviewed & tested by the community » Fixed

Applied to 6.x-1.x-dev along with most of http://drupal.org/node/472966#comment-1906724.

bakr’s picture

have anyone been successful in running

workflow 6.14
along with drupal 6.16
along with rules integration for workflow

I seem to get error message about a function override issue

Now I got it.. the Dev version simply works

Now the taxonomy assignment of Current and Old is working properly... sure it is fixed.

Within the Rules module, just use the textual comparison and compare the state tokens with state names.

I also deleted the above mentioned integration module from the modules directory, as no more need for it, and was causing funtion override issue.

mxt’s picture

Status: Fixed » Active

I've noticed that there's only a "Check workflow transition" condition available, but I'd need a condition like "content has workflow status" to check if a content is in a particular workflow status.

Thank you

crea’s picture

Status: Active » Fixed

@MXT
please don't reopen old threads. Your question sounds like a feature request so please open a separate one. Thank you.

Status: Fixed » Closed (fixed)
Issue tags: -rules integration, -gsoc:rulesmonkey

Automatically closed -- issue fixed for 2 weeks with no activity.