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
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