I want to try to set the default node permissions based on a property of that node on my website. A 'meeting' node for the department 'management' should be by default not accessible for anonymous users, while the meetings for other departments should. Editors in my system do not have content_access permissions (and that's for their own protection!) so I need to provide an automatical solution.

I found that content_access lacks good hooks in general, and it does not provide any way of doing what I need.

I think that this would be perfectly possible if content_access_per_node_setting would use a content_access_get_default_node_settings($op, $node) instead of content_access_get_settings() directly.
Then in that new function a drupal_alter hook can be implemented, which in turn can be used to change the default permissions based on the properties of the specific node.

I see only advantages of this change. When node-specific content access settings are enabled, and the admin screen with content access settings for a specific node is loaded, these defaults will be shown and can be manually edited. Otherwise the altered settings will be used.

I've tested the changes manually but don't know how I can test the drupal_alter in the test cases. I would need to add a module, solely for testing purposes. It should not be installable as a normal module. Does anyone know how to do that?

Comments

bvanmeurs’s picture

bvanmeurs’s picture

Status: Active » Needs review
salvis’s picture

Have you tried to use the Rules module?

bvanmeurs’s picture

Although rules are flexible, they don't seem flexible enough. Although I can 'filter' out the correct nodes, I can't change the content_access permission for one operation for a particular role. There are no content_access related actions available at all.

Still, I would prefer to have an alter hook in this situation. It's more flexible.

salvis’s picture

The node-specific actions would come from ACL, which is required for per-node access control.

I've never actually used this myself, but I thought this was working. If not, then it's a bug.

bvanmeurs’s picture

Hi Salvis,

You are correct. It's in the content_access_acl module. After I disabled it, I was able to do what I want.

This fixes it for me. However, content_access could use some more hooks.

Thanks for your help!

Bas

bvanmeurs’s picture

Status: Needs review » Fixed
bvanmeurs’s picture

Status: Fixed » Active

Alas, I ended up running into this bug:
https://drupal.org/node/1097248

Issue is still active.

gisle’s picture

Assigned: bvanmeurs » Unassigned
Status: Active » Closed (outdated)

This issue has not received any updates in the previous 6 years. If you believe it to still be relevant, you are encouraged to reopen the issue and update it.

If you got an email about this Issue status update, it is because you at one time (possibly a very long time ago), subscribed to it. To learn how to unsubscribe yourself, please visit: https://www.drupal.org/project/webmasters/issues/3142987