Currently, you can only specify the state name via hitting an URL, it would be nice to have workflow_create_state_for_stateless_nodes() more programming friendly so that others can call that function in their module code.

I have a patch file that does just that for version 6.x-1.1. Hopefully this can help.

Comments

rdeboer’s picture

Assigned: Unassigned » rdeboer

Nice one Ye! Will include.

rdeboer’s picture

Status: Active » Fixed

Patch applied. Released ast 6.x-1.2

Status: Fixed » Closed (fixed)

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

HenryLTV’s picture

Status: Closed (fixed) » Active

Is it just me, or did the 6.x-1.2 release not properly remove line 57?

52 function workflow_create_state_for_stateless_nodes($state_name = NULL) {
53   // Get workflow state id either from function argument or last argument of URL.
54   // Then look up the id associated with the name.
55   $state_name = $state_name ? $state_name : end(arg());
56 
57   $state_name = end(arg());

The patch file shows line 57 completely removed. As it stands, because it hasn't been removed, $state_name will never take the argument value.

Please correct me if i'm wrong.

Thanks,
HenryLTV

HenryLTV’s picture

I've sorted this out. Here's my post that attempts to sort all of this out:
http://drupal.org/node/681932#comment-3575278

aidanlis’s picture

Category: feature » bug

Line 57 should be removed. Reclassing as a bug report, as the module does not do what it advertises on the front page.

achbed’s picture

Version: 6.x-1.1 » 6.x-1.2
Status: Active » Needs review
StatusFileSize
new7.22 KB

As noted, the 1.2 patch did not allow for programmatic access to the module code due to a bug on line 57. This patch addresses that issues and a whole lot more.

I've refactored the code quite a bit, moved all hard-coded URLs to constants (for easier changes as needed by end-users), re-worked the API function for consistency, and eliminated all UI calls (like drupal_set_message) from within the API function.

I've also reworked the URLs to utilize the ?destination= parameter in the calling URL if suppled, modified the URL structure handlers to better detect issues with passed URLs, as well as fixed a lot of the feedback messaging to be more helpful.

The attached patch should be applied to an UNMODIFIED 1.2 release. Applying other code fixes first will cause this patch to break.

Hope this helps someone!

rdeboer’s picture

That's great achbed!
Can you please also attach the result source. With all the changes you made it's probably easiest to just past that over the top and check it in.
Cheers!
Rik

achbed’s picture

StatusFileSize
new2.37 KB

Happy to! See attached.

achbed’s picture

oh, and for reference, this is the list of changes I put in my copy of the readmechangelog

6.x-1.3
=======
Added URL redirect after processing (supports destination parameter in URL if given)
Split URL processing and API function into two separate functions
Moved URL references to constants
Better handling of URL errors/input problems
Altered error and status messaging for clarity
Added separate published/unpublished node handling

achbed’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
Assigned: rdeboer » Unassigned
Status: Needs review » Closed (fixed)