0

Trying to write a custom module tying in ACL with commerce_license (to purchase access to content), but I'm not sure I'm implementing the ACL API correctly. Everything seams to be in the database, however. I'm probably missing a step, but I'm not sure what that is.

User is uid 3. Node I'm trying to access is node/23. ACL is 16.

ACL is listed in acl table. Node is listed in acl_node table, with grant view only. User is listed in acl_user table.

mysql> select * from acl WHERE acl_id = 16;
+--------+----------------------+-----------+--------+
| acl_id | module               | name      | number |
+--------+----------------------+-----------+--------+
|     16 | commerce_license_acl | ACL_4_23  |   NULL |
+--------+----------------------+-----------+--------+

mysql> select * from acl_node WHERE acl_id = 16;
+--------+-----+------------+--------------+--------------+----------+
| acl_id | nid | grant_view | grant_update | grant_delete | priority |
+--------+-----+------------+--------------+--------------+----------+
|     16 |  23 |          1 |            0 |            0 |        0 |
+--------+-----+------------+--------------+--------------+----------+

mysql> select * from acl_user WHERE acl_id = 16;
+--------+-----+
| acl_id | uid |
+--------+-----+
|     16 |   3 |
+--------+-----+

I've noticed that in the modules that use ACL, there are calls to "node_access_acquire_grants($node)" after the calls to acl_create_acl($module_name, $acl_name), acl_add_user($acl_id, $uid), and acl_node_add_acl($nid, $acl_id, $read, $update, $delete, $priority), so I've added that, too. However, I'm still missing something. The acl data seems to be being recorded, but the node access records are not. I'm using content_access (which also uses the acl module), but not getting the behavior I want.

What am I missing?

0

The issue that I was having was that my module didn't correctly implement one of ACL's hooks, [module_name]_enabled().

Prior to returning the grants, acl_node_access_records() checks to see if the module is enabled by firing off that hook, and does nothing if it doesn't exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.