[drupal-devel] Users self-publishing their content
Hi all- I asked about this on the support list first and have been looking into it, and wanted to see if you all could confirm my conclusions: I'm running a site(s) which is largely a group weblog (also some "stories"). The authors are trusted to not post nonsense or inappropriate material, but not trusted enough (mostly technically) to have full "admin nodes" privs where they can access each others' work. What they (undestandably IMO) want is the ability to save drafts, i.e. works in progress they don't yet want to publish. With the unmodified core Drupal codebase, I can have the default workflow be "publish" or not. And that works. They get once chance to write it, polish over and over, and hit "submit" -- it's published. Or I set the default to "not published", and they submit it, and then have no way to publish it and I (or another admin) has to publish it. So clearly (right?) I need to find another way to do this, it's not "out-of-the-box-able". A long while ago I tried using workflow.module to accomplish this, and had some issues I can't recall. So I hacked the hell out of a bunch of files, made a mess, and got what I wanted. But not in a resuable way. So this time I've tried to create a clean add-on module, using nodeapi hooks, and it *almost* works cleanly. I can easily get the 'Published' checkbox to appear correctly when the author has the appropriate permissions (in my lil' module), *but* node.module#validate resets the node->status flag on every form interaction. So at this point I stuck in: // "publish my content" is a priv defined in my module if (!user_access("publish my content")) { $node->status = in_array('status', $node_options); } around line 1238 or so in node.module, 4.6.2. Finally, my question: is there any way to do this cleanly -- without modifying core Drupal code? (as currently publishing appears to be an all-or-nothing situation). thanks in advance! === PS: my understanding is workflow.module is in flux right now, with issues with revisions. So I'd guess it won't be ready until post-4.7, but of course I need this sooner - like a week or two. -- ________________________________ toddgrimason*todd[ at ]slack.net
PS: my understanding is workflow.module is in flux right now, with issues with revisions. So I'd guess it won't be ready until post-4.7, but of course I need this sooner - like a week or two.
Workflow should do you what you want with the following patch to preserve revisions http://drupal.org/node/27007 provided you understand the issues. The nodeapi calls for nodes go like this: 1. nodeapi validate hook 2. (node is saved) 3. nodeapi insert/update hook a... modules respond b... modules respond c... modules respond ... workflow modules responds, fires actions, the last of which saves the node (go to 2) x... modules respond y... modules respond z... modules respond As you can see, we have some problems. Because module_invoke() works alphabetically, any modules with names alphabetically after "workflow" have not yet responded when the workflow hook is invoked. Remember, the workflow hook activity looks like this: 1. nodeapi insert/update is caught by workflow module 2. workflow module fires the 'transition pre' workflow hook to let modules know a transition is about to occur 3. modules have a chance to veto the workflow transition 4. if no module vetoes the transition, the 'transition post' workflow hook is fired so modules can respond to the workflow state change. So to move ahead, we need a 1a nodeapi hook that says, "validation passed and this node will now be saved" so workflow changes can happen there, and/or a 4 nodeapi hook that says, "the node has been saved, all modules have done their thing, it's safe to do a node_load and get a node that is in a consistent state". I'd like to see both because it gives maximum flexibility for workflow. For example, it's much more efficient to change the status of the node to published after validation but before saving than it is to use the current method of saving the node again.
Woah, lots there to digest. I need to catch up on workflow and revisions issues a bit before I could give much of an answer or even say "well of course". If I understand this much correctly though, patches are needed to core to get workflow working again - yes? Or actually to have any other module have a chance to intercept the node before it's saved, a post-validate or pre-save event is needed(what my lil'hack does). So since I'm in a hurry my mini-module and if-statement hack in node.module is what I need to run with for now. I'll try to catch up and provide some more useful input asap. Thanks for the info (and pointers to more). -- ________________________________ toddgrimason*todd[ at ]slack.net
participants (2)
-
John VanDyk -
Todd Grimason