Publish nodes permission

jgoldberg - January 25, 2008 - 16:25
Project:Drupal
Version:7.x-dev
Component:node system
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

In our instance of Drupal, we allow authenticated users to publish to the front page. The only way to give users this privilege is to give them access to the "administer nodes" permission:

  $form['options'] = array(
    '#type' => 'fieldset',
    '#access' => user_access('administer nodes'),
    '#title' => t('Publishing options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 25,
  );
...

However, because of the way node_access is implemented, having the "administer nodes" privilege gives you full access to all node operations, including editing other users nodes:

function node_access($op, $node, $account = NULL) {
...
  if (user_access('administer nodes', $account)) {
    return TRUE;
  }

The patch included creates a new permission, "publish nodes," which allows an admin to select which groups should be able to publish nodes, thus separating the privilege from the ability to administer nodes.

AttachmentSizeStatusTest resultOperations
node.patch1.37 KBIgnoredNoneNone

#1

keith.smith - January 25, 2008 - 20:16
Version:6.x-dev» 7.x-dev
Category:bug report» feature request

This is a very good idea.

But... it seems more like a feature request for 7. As has been often pointed out, it is late in the day for adding new permissions in 6.

#2

jgoldberg - January 25, 2008 - 23:11

Yeah, it should probably wait until 7. I do want to emphasize that I still think this is a defect; the ability to publish and promote should not be tied directly to the ability to edit nodes.

#3

webchick - January 25, 2008 - 23:58

What if we did an #access property on each of those checkboxes. Then contrib could do whatever it wanted, without adding another 50,000 permissions.

#4

jgoldberg - January 26, 2008 - 01:05

Webchick, I'm not sure if I understand what are you are proposing.

#5

webchick - January 26, 2008 - 01:59

haha. chalk that up to trying to write a reply just before dinner. :) please disregard.

I misread your description of the patch as you doing an if (user_access('publish nodes')) around the fieldset, rather than an #access property. I see now that you're just changing the permission the #access property checks.

#6

jgoldberg - February 5, 2008 - 23:34

Now that a 7.x branch is open, can we reconsider this patch.

#7

catch - February 13, 2008 - 15:57
Title:Can't let users publish nodes without also giving them edit priviledges» Publish nodes permission

It's a good idea. There's an issue somewhere to do the same thing for 'sticky' as well, although I can't find it right now.

The node permissions section is getting very long, but we should find a way to deal with that in the ui, and ideally get rid of "administer nodes" entirely since it mainly causes confusion.

#8

jgoldberg - February 13, 2008 - 16:43

The node permissions section is getting very long, but we should find a way to deal with that in the ui, and ideally get rid of "administer nodes" entirely since it mainly causes confusion.

I can't agree more. A separate permissions section for nodes would be very nice.

#9

jstoller - February 14, 2008 - 01:05

I think this is just one more symptom of the need for a more comprehensive user access system. See this feature request for one idea.

#10

jacobroufa - February 27, 2008 - 19:46

As it is, can that patch submitted above be used in D5 or D6? I am not a developer but desparately in need of something like this for a project I'm working on... I can't give users of a certain role Administer Nodes permissions because then they have too much control, but they need to be able to access Unpublished nodes of one nodetype in order to do their job. Unless someone has another idea as to how I might accomplish that? I think the idea behind this patch is a great one and I look forward to seeing it develop into more of a feature in D7

#11

jgoldberg - February 28, 2008 - 14:47

@ jacobroufa - You might want to also check out Does an unpublished status mean Draft or Disabled? which I opened along with this ticket. In the mean time, you might want to check out the Views module; you may be able to leverage it if you are trying to pull up lists of unpublished nodes.

#12

jacobroufa - February 28, 2008 - 17:30

Using Views to get a list of the unpublished nodes is not the issue though... Allowing someone other than the creator of that node to even see it, let alone edit, review, and publish it is the issue. Even if the person (not creator) trying to view this node has permissions to view, edit, and edit own nodetype, they still can't. Thanks for putting up this patch jgoldberg!

#13

catch - February 29, 2008 - 06:05

jacob: if you create a view that doesn't filter by whether a post is published or not (or only shows unpublished nodes) - then any user will be able to read them from the view since it bypasses the access restriction completely - just make it a "full node" view so they can read the whole thing.

#14

jacobroufa - March 6, 2008 - 16:30

@catch :

i need to be able to edit the nodes, not just view them. there are very detailed solutions such as nodeaccess or taxonomy access control that will bypass the core access structure. i dont need that level of granularity... just a per nodetype administrative access to view edit and publish unpublished nodes.
thanks for the help!

#15

jacobroufa - March 7, 2008 - 18:02
Assigned to:Anonymous» jacobroufa
Status:needs review» fixed

I installed the patch and it didn't really do anything useful aside from creating an "administer nodes" permission that wasn't called that. Same thing, different name. http://drupal.org/project/publishcontent is a project I've created after hacking around core a bit and deciding that I need to make it a module, not hack core (bad practice). This module, once completed (working on transferring hack to module now and should be out in a week or two) will give another level of permission of "publish content" for each nodetype in the system, in addition to the create, edit, and edit own permissions. This allows a role to view, edit, and publish unpublished nodes of each nodetype selected. First version will be 5.x with 6.x coming out shortly after. I will also propose that this become a part of core in 7.x as per the wish list presented in Dries' State of Drupal address at the beginning of Drupalcon this year.

#16

catch - March 7, 2008 - 19:08
Status:fixed» active

Putting this back to active, since it looks like the module will be turned into a patch later.

#17

jgoldberg - March 8, 2008 - 06:56
Assigned to:jacobroufa» Anonymous
Status:active» needs review

@ jacobroufa: I'm not sure my patch addresses whatever problem you are having. The main purpose of it is to untie the ability to manage a node's publish status from the ability to administer nodes (edit other users' posts, for example).

#18

Rob Loach - April 2, 2008 - 15:26
Status:needs review» needs work

Will need reroll with the permission description.

#19

maximago - April 7, 2008 - 16:56

Where can we get this one: http://drupal.org/project/publishcontent ?

We really need this module in this scenario:
We have several installations. Some posts are transfered from one system to others with feedAPI. On the receiving platform, the authors should not edit the posts, put unpublish them.
So, this module is really a fantastic idea!
DG, maximago.de

#20

K4m1K4tz3 - April 13, 2008 - 13:46

This project sounds interesting. I would like to use "publishcontent" on my Drupal 6 installation. So what is the status of this project?

#21

jgoldberg - April 17, 2008 - 13:32
Status:needs work» needs review

Rerolled a patch that meets the 7.x permission guidelines.

AttachmentSizeStatusTest resultOperations
node-214190-2.patch1.53 KBIdleFailed: Failed to apply patch.View details | Re-test

#22

Mez - July 7, 2008 - 15:11

This patch just changes the option for all publishing options to a new permission.

The following patch (against drupal 6.2) gives more granular control (only over publishing items - as this is all I needed to add permissions for)

AttachmentSizeStatusTest resultOperations
publish_own.diff3.05 KBIdleFailed: Failed to apply patch.View details | Re-test

#23

Arancaytar - July 16, 2008 - 12:20

#282122: D7UX: "Save draft" and "Publish" buttons on node forms is (kind of) dependent on this patch.

Mez: If you want your patch to be considered, you must submit it against D7. Features are not added to the stable version.

#24

Anonymous (not verified) - November 11, 2008 - 10:50
Status:needs review» needs work

The last submitted patch failed testing.

#25

David_Rothstein - May 28, 2009 - 04:15

Subscribing (and bumping)... I've been wondering lately about the fact that as of D6 we have granular "delete" permissions in Drupal but not granular "publish/unpublish" permissions. It seems like the latter would often be more useful.

#26

shark - August 18, 2009 - 04:11

Subscribing.

 
 

Drupal is a registered trademark of Dries Buytaert.