Node View Permission Restriction for Drupal
March 7, 2011 3:38 PM   Subscribe

What is the best solution for my problems with allowing users (students) to restrict view permissions of their own content in Drupal?

I have the latest version of Drupal 6.x installed. On my site, I have two roles, Student and Teacher. For the classroom work I'm doing, it's important for me to allow students the option (for every individual assignment submitted) to choose to post content so that it either is viewable by all Students (and me), or viewable only by themselves and me.

I'd been using node-privacy-byrole for this for several past versions of classroom websites, and all had been working well. In fact, the reason I didn't upgrade to Drupal 7 is that there isn't a version of the node-privacy-byrole module out for it. In the past, students would check the View permissions for Students to set their assignment as viewable by all, and uncheck it to leave it viewable only by themselves and me.

With my most recent website, however, restricting the ability of Students to view content (unchecking the View permissions for Students) doesn't just hide content from other students, it hides it from the submitting student, too - so their submission is posted but they immediately get a "you do not have permission to access this node" error. I can see their content, but they are unable to see their own content.

I'm willing to fix node-privacy-byrole if there's a solution out there (I'm a reasonably proficient coder, but not an expert. It's also possible I'm just blind to something I've misconfigured).

I'm willing to consider another node access module if there's a better solution (and I'm willing to upgrade to Drupal 7) if that's the best option.

I'm interested in the shortest route to a solution, because the course started today - I didn't catch the bug until they started using the site - so I'd prefer to avoid any extended downtime.
posted by Chanther to Computers & Internet (2 answers total) 2 users marked this as a favorite
 
I don't know the node privacy byrole, but there's at least 12 ways to do this in Drupal. Here's how I would approach it:

Have you looked at the Views Or module? (Dev version, I know... I've used it on 6.x production sites before with no problems.) Basically, I'm thinking that you could set it up this way:

1. Add a CCK on the content type so you can choose "Everyone can see this" or "Only my teacher and I can see this".
2. In your View, use Views Or to create two sets of filters.

It should filter this way:

Either
a) "Everyone can see this"
OR
d) "Only my teacher and I can see this"
e) User = author
OR
f) User = Teacher

If the content is public to all, it will pass the first test. If the content is protected and another student is looking, the filter won't pass any of those three tests. If it's protected and the author-student is looking, it will pass the second test. If a teacher is looking, it will pass the third test.
posted by heatherann at 5:22 PM on March 7, 2011


Here's another way I would try it:

Install Workflow. Create a workflow for your content type and add two states: Public and Private. Set the permissions so that Students and Teachers can view nodes in the state 'Public', but only Teachers and the node author can view nodes in the state 'Private'. (This assumes that the Student in question is always the original node author. It will respect node authorship over role.) Make sure you give Students the right to move a node between workflow states, and enable nodes to move in the following ways:

creation -> Public (and make this trigger the node to become Published)
creation -> Private (and make this trigger the node to become Published—this module will restrict access even if it's Published)
Public -> Private
Private -> Public

(There's some documentation on Workflow here: http://dontai.com/wp/2009/04/01/drupal-6-workflow-documentation/. Workflow is a great module, but the documentation leaves much to be desired. The Revisioning module documentation has some useful introductions to it since they are used together so often.)

Oh, and know that Workflow is set up to trump Permissions, so if you're scratching your head 3 months about why it's not respecting the Permissions you've set... Check your Workflow settings.
posted by heatherann at 5:37 PM on March 7, 2011


« Older Is there a sticky note app that will source and...   |   NYC Place to Write Newer »
This thread is closed to new comments.