I made some changes to the Restricted Content module based on needs at my organization:
- Added a class for menu items called restricted-content (that way we can easily theme menu links to restricted pages)
- Added an action to add restrictions to a node and to remove all restrictions
- Added a boolean Views filter for whether or not content is restricted

FYI: I'm pretty sure there's a better way to implement the actions.

Julia

Comments

JuliaKM’s picture

StatusFileSize
new5.84 KB

Here's the patch for your review.

JuliaKM’s picture

On second thought, don't apply the patch. The menu function adds the restricted-content class to non-restricted nodes and seems to be rather impossible to easily remove. Working on a fix.

JuliaKM’s picture

StatusFileSize
new13.83 KB

Here's an updated patch with a couple more improvements and a fix for #2:
- added a new type of message so the three types of messages are now: a message when the user has special access to the content, a message when the user is anonymous, a message when the user is authenticated but does not have access to the content
- added tokens for all three messages.

JuliaKM’s picture

StatusFileSize
new14.92 KB

Thought I'd try out creating a patch in git. Here's a new version of the patch created with git format-patch.

JuliaKM’s picture

Status: Active » Needs review
aliciatheduff’s picture

Tried this patch out, when I hit pages I don't have access to I get this warning:

warning: Missing argument 3 for theme_display_restriction() in /Applications/MAMP/htdocs/teachers/sites/all/modules/restricted_content/restricted_content.module on line 382.

Hope that helps.

JuliaKM’s picture

Status: Needs review » Needs work
JuliaKM’s picture

Status: Needs work » Needs review
StatusFileSize
new14.2 KB

Thanks aliciatheduff for testing the patch! Here's a new version. When I ran it locally, the php warning did not appear. The small change I made was to go from:

function theme_display_restriction($message, $status, $content) {

to:

function theme_display_restriction($message, $status, $content = NULL) {

I should note that this patch also applies the fix for inserting a nid of 0 into the database found in #826350: Inserting "nid = 0" into db during node add

mattcasey’s picture

tested the patch in #8, git returned some 'trailing whitespace' errors on line 97,105,109,118, and 119, but I was able to use the Views boolean filter.