Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi there,
based on the example I started to build an custom acl module. The acl entries are build in the db, that is working, but I have one question left.. for the first :-)
I use devel to show the realms of a node. I'm wondering, why my custom acl rule is not shown up in the debug blocks. This is my code so far. You see it's taken from the example. I could imagine, that I have to use "hook_node_grants()" and some more hooks to make this working?! ACL is not creating a realm automatically?
unction vf_acl_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'update':
case 'insert':
if($node->type == 'blog_crosspost' || 'blog_pm' || 'blog_comment' || 'blog_private_post')
{
//dsm($node);
// ???
/* if($acl_id = acl_get_id_by_name('acl_example', $node->nid)){
//we start of with a clean slate. We don't want strange users to be kept in the system
//since we only add users once in a while this does not impact user performance
acl_delete_acl($acl_id);
//we do not have a function that allows us to remove all users at once so this is a good future option
} */
//we create an ACL that we will use on every file or node that is in someway attached to this node
//we decide to name it to the id of the node since the name of the node can change in an other phase.
//dsm('creating a new acl for '.$node->nid);
acl_node_access_records($node);
$acl_id = acl_create_new_acl('vf-moderator','node' .$node->nid);
// gid
$gid = current($node->og_groups);
//get all moderators from the group
$group_moderators = vf_acl_group_moderators($gid,3);
dsm($group_moderators);
//make our array unique
$group_moderators = array_unique($group_moderators);
//assign these users to the ACL
foreach($group_moderators as $uid) {
acl_add_user($acl_id, $uid);
}
//assign the ACL to the node (View Yes, Write No, Delete No)
acl_node_add_acl($node->nid,$acl_id,1,0,0,0);
//assign the ACL to the nodes (View Yes, Write No, Delete No)
// foreach($nodes as $nid) {
//acl_node_add_acl($nid,$acl_id,1,0,0,5);
//}
}
}
}
/**
* Used by the ACL module.
*/
function vf_acl_enabled() {
return !content_access_disabling();
}
/**
* Implementation of hook_disable().
*/
function vf_acl_disable() {
teytel_permissions_disabling(TRUE);
}
/**
* Remembers if we have disabled access.
*/
function vf_acl_disabling($set = NULL) {
static $disabling = FALSE;
if (isset($set)) {
$disabling = $set;
}
return $disabling;
}
Comment | File | Size | Author |
---|---|---|---|
Bildschirmfoto 2013-03-26 um 10.33.32.png | 31.77 KB | Apfel007 |
Comments
Comment #1
salvisThis looks reasonable, except for the acl_node_access_records() call, which doesn't belong here.
You realize that this works only with new and updated nodes, right?
Comment #2
salvis