Allowing node publishing/unpublishing for a non-node admin

22 July 2008

So I'm working on a project now where nodes are mass-imported from a third party. By default, these nodes are unpublished until the delegated party can add additional information that the import can't capture. We publish the node when it's through being reviewed and updated.

To be clear, the workflow looks like:
1) Import nodes (CCK type: "Item"), default status is Unpublished.
2) User with "Reviewer" role looks at the queue of Items that needs reviewed
3) Reviewer reviews Item nodes, then sets them as Published.

Here's the problem though:
A Drupal user role can't publish/unpublish nodes without the "Administer Nodes" permission from node.module. Whoops! That means the subset of users we entrust to review and publish these nodes can also delete them, create new nodes of any type, and so forth. Far from ideal.

The solution is a mashup of code I assembled together. First on the list is the Override Node Options module. This module allows a Role to be able to publish/unpublish the nodes they already have permission to Create or Edit.

That's all fine and good, but they won't be able to *see* those unpublished nodes to make the change (they'll get tossed to an access denied page) without the View Unpublished module. Put these two together and we can do this!

Step 1: Grab and install the modules
Download the Override Node Options and the View Unpublished modules. Install them.

Step 2: Permissions
Navigate to your access control page at /admin/user/access and set the following permissions for each role you want to do this for:
"override node publishing options" - checked
create/edit XXXX content - checked as appropriate (where XXXX is the content type you want to enable this for).
"use view_unpublished module" - checked
"view unpublished XXXX content" - checked (where XXXX is the content type you want to enable this for).

That's it! Simple! Those roles can now publish and unpublish content for the node types you enabled in step 2, and view those same ones when they're unpublished.

Caveats:
This isn't going to change your Views, so if you have a published = yes filter on a View, that's something to be aware of. On this project I'm on, I've got a seperate view where published = no, specifically.

Shout out:
Thanks to Brad Bowman for the view_unpublished code. Standing on his shoulders I modularized it and took care of module weight (has to be lighter than node.module -- the install hook should handle this automagically now).

Tagged:

0 comments on Allowing node publishing/unpublishing for a non-node admin

    Post new comment

    The content of this field is kept private and will not be shown publicly.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <embed> <blockquote>
    • Lines and paragraphs break automatically.
    • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <csss>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>.

    More information about formatting options