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?
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | alter_default_node_permissions-2087443-1.patch | 2.12 KB | bvanmeurs |
Comments
Comment #1
bvanmeurs commentedComment #2
bvanmeurs commentedComment #3
salvisHave you tried to use the Rules module?
Comment #4
bvanmeurs commentedAlthough 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.
Comment #5
salvisThe 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.
Comment #6
bvanmeurs commentedHi 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
Comment #7
bvanmeurs commentedComment #8
bvanmeurs commentedAlas, I ended up running into this bug:
https://drupal.org/node/1097248
Issue is still active.
Comment #9
gisleThis 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