[development] Question about Drupal ACLs

Nedjo Rogers nedjo at islandnet.com
Thu Jul 13 22:12:30 UTC 2006


> I'm curious to see if there are built in mechanisms or maybe other
> modules that will allow me to assign ACLs to specific nodes.  In
> particular I want to show or hide menu items and restrict access to
> their linked nodes based on a user's role.
>
> So far I haven't found anything (that works) fitting this description in
> Drupal or it's modules.  So my question is: Did I miss it, and if I
> didn't would people in the community be interested in a module that
> provided this level of access control?

To do this in a module, I guess you'd need to do something like this:

1. Add a role selection element to the node edit forms through form_alter, 
plus a #submit function that saves into a table with fields nid, rid.

2. Add a function example_node_roles($nid) to return the roles with access 
to a given node.

3. In a _menu hook, something like this:

global $user;
if (!$may_alter) {
  if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
    $items[] = array(
      'path' => 'node/'. arg(1),
      'access' => count(array_intersect(array_keys($user->roles), 
example_node_roles(arg(1)))) ? TRUE : FALSE
    );
  }
} 



More information about the development mailing list