It seems like the user might want to put published content into one state, and unpublished content into another state.

Example, all of my unpublished items should go to the state "Draft" while all my published items should go to the state "Live."

Comments

mineshaftgap’s picture

StatusFileSize
new3.74 KB

Here is a quick try at adding this feature. Note that it changes the URL so that you now have to specify if it is published or unpublished:

/content/set_unpublished_workflow_state/in-review
/content/set_published_workflow_state/live

rdeboer’s picture

Nice one, mineshaftgap!

Tim-Erwin’s picture

StatusFileSize
new2.56 KB

Hi!

Maybe I should have looked here before writing the same stuff on my own. Whatever, it's really simple anyways. My version behaves as the present version unless you insert a "published" or "unpublished" in URL. For instance:

/content/set_workflow_state/published/Public

or

/content/set_workflow_state/unpublished/Review

and this still works as before for all nodes regardless their status

/content/set_workflow_state/Review

I like this solution a little better because it doesn't break current behavior and it's programmed simpler.

Regards
Tim

rdeboer’s picture

Status: Active » Needs review

Thanks Tim!
@mineshaftgap: are you happy with Tim's solution to be included in the next release in preference to your own?
Rik

mineshaftgap’s picture

Absolutely! I just needed a quick solution for myself and thought that it could help others.

eriktoyra’s picture

Status: Needs review » Reviewed & tested by the community

Tested Tim-Erwins patch. It works great for what it says it should handle. However, I think we should clarify that this patch does not solve the situation where pending revisions of a published node is available. The node will be set in "Public" state and the latest revision of the node will be published.

HenryLTV’s picture

#3 patch by Tim-Erwin works, but there's a GOTCHA here. For version 6.x-1.2 it actually works only because the http://drupal.org/node/849734 patch was "effectively" not applied.

You can see how the actual patch differs from what was released from my post on that thread: http://drupal.org/node/849734#comment-3574968

If you apply the 849734 patch manually AS-IS along with #3 patch to version 6.x-1.1, you will get the "Invalid workflow state" error because $state_name will erroneously have the state value passed as an argument to the workflow_create_state_for_stateless_nodes() function, therefore $state_name will never be set to end(arg()). Tim-Erwin's #3 patch for 6.x-1.1 assumes $state_name will always be the last arg().

But #3 patch works with release 6.x-1.2 because of:

  $state_name = $state_name ? $state_name : end(arg());
  $state_name = end(arg());

So $state_name will always take the end(arg()) value and always ignores the passed-in value. Programmitically speaking 6.x-1.2 doesn't really do anything but allow you to pass in an argument that will get overridden by end(arg()) anyway. Not sure what the reasoning here is unless I'm missing something here.

Bottom line, you must apply #3 to version 6.x-1.2 and not use the 849734 submitted patch because these 2 patches don't work together. Unfortunately you still won't have the ability to call the workflow_create_state_for_stateless_nodes() function from code and pass in an argument. Sorry that I don't have the time to solve that issue since I don't currently require that capability.

Hope this saves someone else the time to sort all this out!

Best,
HenryLTV

rdeboer’s picture

Thanks Henry!

achbed’s picture

Status: Reviewed & tested by the community » Closed (fixed)