Re: uc_nodetype: module to purchase right to publish node

Posts: 28
Joined: 04/04/2008

I've been following the threads here on this subject as well as reading dozens of posts on drupal.org and other articles about this. I think I've found a solution that will work for me without having to create a new module!

What I need to do is give a user (must be logged in) the ability to create and pay for a node strictly for a site moderator(without administrator access) to view. The node includes CCK imagefield where they can upload multiple images. So the node needs to be created as unpublished but a person who does not have administrator access needs to be able to see it.

I haven't worked out all the kinks yet but to accomplish this I am using the following modules...

Ubercart (of course)
uc_node_atc contrib module (to link a node to a product)
CCK (including imagefield and computedfield)
Workflow_ng (Not the same as Workflow! That was the source of alot of confusion for me)
Workflow (including workflow_access)
Actions
Inline Registration (this adds the registration/login form to the node creation form)

The Workflow and Actions modules must be the latest versions which include the new Drupal 6 actions.

Here are the steps I've taken to accomplish this:

  • Create a content type for the node to be submitted ("submission type" for example). This type includes two computed fields, price and quantity.
  • Create a product class ("submission product"). This is because I will eventually have multiple products of this kind.
  • Create a "submission product" node that the "submission type" node(s) will be mapped to.
  • Map the fields in the Node to Product settings
  • Create a Workflow (NOT Workflow_ng) with two states, "created" and "paid for". Then click Actions to assign access levels based on states and state transitions. For instance while in "created" state the author can edit the node but not in "paid for" state. Only moderators can view the node in "paid for" state.
  • Now go to Workflow_ng and create a rule with "Content created" event, with condition "Content has type" of "submission type(s)", and actions "Add node to cart" and "Page Redirect". This actually maps the submission node to the product node and adds the product node to the cart thanks to uc_node_atc. Then redirects to the cart.
  • Create another rule with the event "A payment gets entered for an order". The conditions are "Check the order balance" which should be 0 or less and "Order has a product of a particular class" which should be the product class created in step two. Add the Action "Execute custom PHP code". My custom php code gets the submitted node from the order and runs the action 'workflow_select_next_state_action' on it. This is one of the default actions included with the Workflow module. You can see this action in the Actions section under Site configuration where there should be an action called "Change workflow state of post to next state".

This worked perfectly! I created a "submission node" which put the node in the "created state" and redirected me to the cart. Once I went through the checkout process and paid, the submission node was changed to the "paid for" state.

Now i need to be able to list all nodes in the "paid for" state for the moderator. This screams Views so I'll be working on that next.

One of the kinks I need to work out is cleaning up submission nodes that were never paid for. I'll probably use Workflow itself to delete nodes that are in the "created" state for more than a specified amount of time.

Hope this helps someone or gives them some ideas. Let me know what you think. I'll be back to post more after I'm done cheering if this works as planned or crying if it doesn't. Smiling

--

Chisholm Technologies, Inc.
Custom software development since 1999!
www.chisholmtech.com

uc_nodetype: module to purchase right to publish node By: JuliaKM (32 replies) Fri, 12/07/2007 - 15:38