Download & Extend

New node permission "view unpublished content"

Project:Drupal core
Version:8.x-dev
Component:node system
Category:feature request
Priority:normal
Assigned:typhonius
Status:needs review
Issue tags:permissions

Issue Summary

For a editorial office it's a worse way to use node access for their workflow:

  • Writers are only allowed to create unpublished nodes
  • Editors need access to every (so node_access isn't useful) unpublished node of the writers...
  • ...but they aren't allowed to publish the node, so I can't use "administer nodes" for the editors

-> the permission "view unpublished content" is required.

Here a first approach was made: #41188: More node permissions ("view unpublished nodes", "edit any node")
I just Copy'n'Paste a part of the patch #4 made there so I was able to add a "view unpublished nodes" permission for all node types and it seems to work quite well (see patch).

Now it would be nice to implement this per node type. Help is appreciated.

Comments

#1

Using the book module users with "view unpublished nodes" should be able to view the TOC of unpublished book nodes, add new pages etc. It is already described here:
#26552: Allow users with administer nodes perm. to create unpublished books. (Patch: http://drupal.org/files/issues/20070624_amdinbook.patch)

Files for modifying book and node module are attached. Additionally, the book module contains changes so that writers/editors without the "administer nodes" permission are able to set the weight of child book pages.

AttachmentSizeStatusTest resultOperations
view_unpublished_nodes_global.diff1.52 KBIdleFAILED: [[SimpleTest]]: [MySQL] Invalid patch format in view_unpublished_nodes_global.diff.View details | Re-test
view_unpublished_books.diff10.13 KBIdleFAILED: [[SimpleTest]]: [MySQL] Invalid patch format in view_unpublished_books.diff.View details | Re-test

#2

Just FYI: there are some very minor code style violations in the comments (space after the "//" and end the comment in a full-stop (period)).

#3

Thanks for the hint! Apart from that the comments are only temporary as long as I'm testing this for bugs respectively until a solution for per node type is written.

#4

Version:5.7» 7.x-dev

Moving this feature request to Drupal 7. For Drupal 5, this feature can be set up with the View Unpublished module.

--Andrew

#5

is this possible in d6?

#6

Status:needs work» active

Sure, but I had no need to port it to D6 'til now so there is no patch for D6. Maybe Override Node Publishing Options is a working alternative? I've created an issue there regarding unpublished node options: #334992: New access perm: View unpublished nodes

Nevertheless this node type permission included into core D7 would be nice. Changes could be done quite easy, see diff files posted above.

#7

This would be a very nice feature to have, as I couldn't believe it wasn't in D6 core.
Someone made a D6 port of a now unmaintained D5 module here #304173: Make it to work in Drupal 6.

I would really like to see this in D7 :x

The only available permission now is "View own unpublished content".
This could be expanded with "View all unpublshed content"
more fine grained control could allow for "View all unpublished nodes"

Any input on this ?

#8

sub

#9

I was really surprised this wasn't available in D6.
Really hope it makes it way to D7...

#10

Version:7.x-dev» 8.x-dev

As this doesn't fit into the feature exceptions, it's going to have to wait until D8.

#11

This would be extremely useful.

The view_unpublished module is good if you only need basic functionality.
But if you need to be able to view/edit unpublished revisions or use file
attachments on unpublished nodes or anything more than the most basic use
you run into problems.

Because node_access checks node status, you run into a lot of problems very quickly
if you are trying to get around this outside of core.

This would definitely be something that would be good to get into drupal 7.
It would certainly make it worth waiting for.

#12

err.. correct me if I'm wrong, bug D7 already has 'view own unpublished content'
maybe that's not what is being requested, but it seems pretty much similar

#13

This issue is also for "view any unpublished content" or something similar.

#14

Status:active» closed (duplicate)

Thanks for taking the time to report this issue.

However, I think that the most common use-cases are already covered by #452538: Enable Node Grants for Unpublished Nodes and thus marking as duplicate.

#15

Title:New node type permission "view unpublished content"» New node permission "view any unpublished content"
Version:8.x-dev» 7.x-dev
Status:closed (duplicate)» active

Reopening this issue as #452538: Enable Node Grants for Unpublished Nodes didn't solve it

That issue took care of node grants for unpublished and view own unpublished so
this issue is for "view any unpublished" or possibly "view NODE-TYPE unpublished"

#16

Subscribing.... BIG +1 for this feature!

#17

Subscribe

#18

Subscribing.

#19

Version:7.x-dev» 8.x-dev

This is a new feature. Far too late for D7. See #927792: Please explain what is still considered for D7

#20

+1

#21

+1.
Such a shame this did not get into D7 - the various threads started early enough. I have my own simple patches for 'view unpublished TYPE content' for D6 and D7 if anyone is interested.

Jonathan

#22

@jonathan1055 / #21: interesting, could you upload them as a zip file here in this thread?

#23

Yes certainly. They are not zipped, no need really. D6 created against 6.20 and D7 against 7.0, not against the latest dev, but they should both apply ok.

AttachmentSizeStatusTest resultOperations
_273595.23.node_.view_unpublished_nodes_D6.patch948 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch _273595.23.node_.view_unpublished_nodes_D6.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test
_273595.23.node_.view_unpublished_nodes_D7.patch1.11 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch _273595.23.node_.view_unpublished_nodes_D7.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#24

Status:active» needs review

Changing status

#25

Status:needs review» needs work

The last submitted patch, view_unpublished_books.diff, failed testing.

#26

For those searching, I've posted a D7 and new D6 version of the View Unpublished module on the project page: http://drupal.org/project/view_unpublished

#27

I try to add views unpublished support, please see http://drupal.org/node/773784#comment-4680180

#28

tagging

#29

Title:New node permission "view any unpublished content"» New node permission "view unpublished content"
Status:needs work» needs review

Patch that adds a 'view unpublished content' permission, makes the necessary changes to the access checks and adds a small test for the new permission.

AttachmentSizeStatusTest resultOperations
273595-view-unpublished-content-29.patch5.37 KBIdlePASSED: [[SimpleTest]]: [MySQL] 34,184 pass(es).View details | Re-test

#30

Wow. That's great. This is exactly what I'm looking for!

I installed your patch, but I didn't get it to work.

I'm trying to allow users to see their own unpublished nodes within views. They can see their nodes by accessing the node's page directly, but it does not show up in any views. It seems like the permission 'View own unpublished content' should take care of this, but unpublished nodes do not show up in views. Are talking about the same thing?

I'm trying to follow along what you did here in this patch. I see you added a 'View unpublished content' permission to the node section, but that seems odd. It is not clear what is meant by that and how it relates to 'View own unpublished content'. I'm not sure exactly what the intention is. Maybe it should read "'View own unpublished content in views'?

Hmmmm....

#31

Status:needs review» needs work

@#29 not fully reviewed, but first chunk seems to change indentation unnecessary
also, permission's name seems misleading (see #13 for a more appropriate suggestion)

#32

Status:needs work» needs review

Reroll that renames the permission to 'view any unpublished content' and fixes the indentation issue.

AttachmentSizeStatusTest resultOperations
view-unpublished-content-273595-32.patch4.17 KBIdlePASSED: [[SimpleTest]]: [MySQL] 36,675 pass(es).View details | Re-test
interdiff-29-32.txt5.26 KBIgnoredNoneNone

#33

Note that the recent block from node module calls node_get_recent() which does the same thing with these permissions.

#34

Hi Eric_A
Could you explain what you mean, I don't understand. Maybe I'm missing something, sorry.
Jonathan

#35

Hmm, I would really like this permission seperate for each Content Type and not globally for all content types in D7.

#36

+1 for #35

#37

Hmm, I would really like this permission seperate for each Content Type and not globally for all content types in D7.

If you mean you want drupal core permission changes in drupal 7 it probably won't happen.
Changes like that generally won't happen until the next major version.

If you mean you want it in drupal 8, unlike how the view own unpublished works in drupal 7, then I agree.

Maybe this issue could be done to get the view any unpublished nodes permission in and then a follow up issue could be done for both the view own unpublished and the view any unpublished, to move them to content type specific perms.

#38

+1 for #37
nevertheless, permission table gets bigger and bigger,
it would be nice to have configurable options to enable such permissions "for each" content type
but as rooby said @#37, lets start by having them globally at least

#39

We just got bit by this too. Very strange that this functionality was removed from administer content without a suitable replacement ever being offered. Lets please try to get this in soon (and hopefully backport to D7).

Can we get a re-roll of this patch? It no longer applies.

#40

Assigned to:Anonymous» typhonius
Status:needs review» needs work

I've just run into an issue with unpublished content on the admin/content page. I would think any kind of editorial workflow would allow users to edit other user's unpublished content. Currently this requires a contributed module to do. If D8 were to add in extra permissions however this would make things a whole lot simpler.

The way I see it there are three options ranging from simplest to most complex:

  1. Add in a 'View all unpublished content' permission
  2. Add in a 'View all unpublished $node->type' permission for extra granularity based on content type
  3. Extend #2 by adding in a complimentary 'View own unpublished $node->type' permission rather than the standard 'view own unpublished.

Assigning to myself to reroll a patch based on #2/#3 in the first instance. If a week goes by without a patch feel free to unassign!

#41

I like his proposal and I think it plays nicely with the issue mentioned here #26552: Allow users with administer nodes perm. to create unpublished books..

#42

@joel_osc:
In relation to books and unpublished access, this issue is also relevant: #520786: menu_tree_check_access: only filter by status = 1 for non content admins
However I assume menu_tree_check_access() might be changing due to all the menu changes in D8.

[EDIT] Actually I see now that they are partly duplicate issues, so I have mentioned it in the unpublished books issue.

#43

OK - here's a little patch that addresses #1 in comment 40 so people don't think I've forgotten this issue.

I'm going to extend further and add in view unpublished per content type shortly.

AttachmentSizeStatusTest resultOperations
273595-43-view_all_unpublished.patch3.58 KBIdleFAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.View details | Re-test

#44

Status:needs work» needs review

#45

Ok - here's a more granular patch with view unpublished permissions per content type.

AttachmentSizeStatusTest resultOperations
273595-45-view_unpublished_per_type.patch5.8 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 273595-45-view_unpublished_per_type.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#46

Status:needs review» needs work

The last submitted patch, 273595-45-view_unpublished_per_type.patch, failed testing.

#47

Status:needs work» needs review

#45: 273595-45-view_unpublished_per_type.patch queued for re-testing.

#48

#49

Status:needs review» needs work

The last submitted patch, 273595-45-view_unpublished_per_type.patch, failed testing.

#50

Status:needs work» needs review

Rerolled patch for latest D8 HEAD

AttachmentSizeStatusTest resultOperations
273595-50-view_unpublished_per_type.patch5.8 KBIdlePASSED: [[SimpleTest]]: [MySQL] 54,372 pass(es).View details | Re-test

#51

Marked #1388674: Add "View unpublished {node_type}" permission as a duplicate of this issue.

#52

I'm definitely liking this so far. Especially happy with the more granular options provided as well. Great work folks. Will allow others to continue testing before RTBC.

#53

#50 no longer applies. This is a reroll of #50.

AttachmentSizeStatusTest resultOperations
273595-53-unpublished-node-access.patch5.75 KBIdlePASSED: [[SimpleTest]]: [MySQL] 55,692 pass(es).View details | Re-test