1
votes

In summary, I am looking for a content-based access control solution, NOT a user role-based solution.

The scenario: Page 1 contains content from various access control levels (i.e. levels a, b, and c).

Currently in Drupal, you can display/hide content based on user role. However, I want to block access to the entire page if the user is not in the highest content level required.

Example: A user with access level a and/or b would be blocked from seeing page 1, but a user with at least level c would be able to see the page and all of the content on it.

The catch being that the per-page access levels must be dynamic to prevent incorrect page tagging as content is added, updated, or removed.

Does a module like this exist already, and if so, what is it?

If this doesn't exist, is there a straightforward way of implementing this?

Server configuration is Drupal 7 with some Open Atrium 2 modules.

1

1 Answers

0
votes

I'm not sure on what you mean on access control levels, but lets say they are functions you can call (with returns).

In this case you should implement hook_node_access for controlling access to a node or hook_field_access for controlling access to a field.

https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_access/7 You should return 'NODE_ACCESS_DENY' from it if you want to deny acces.

https://api.drupal.org/api/drupal/modules%21field%21field.api.php/function/hook_field_access/7 You should return FALSE if you want to deny access to a field.