简体   繁体   中英

Drupal 6 - retrieve list of users who can edit node x or simply get permissions for user y on node x

Anyone got any ideas?

I'm a tad stuck, trying to make an action run arbitrary php to execute upon publication of the most recent revision. What I'm trying to do is get a list of users to notify about the change, specifically the users who have permission to edit said node.

Now I've got the $object returning my node id so I'm fine there, and I can get a list of users easy enough to cycle through them and check permissions. The hard bit is the permission check itself. Nothing I've tried seems to be able to provide permissions for 'publish' or 'update' on node x for user y.

I'm using the nodeaccess module to give individual users access to specific nodes btw, just for fun.

If anyone else struggles with this, this is what I did.

//whichever nid goes in here, I put in a number to make this easy to read and understand.
$node_obj=node_load(598);
//$result_object contains the 'users' table with uid
while ($result_object=db_fetch_object($result))
{

   $this_user=$result_object->uid;
   $this_user_object=user_load($this_user);
   $access=node_access('update', $node_obj, $this_user_object);
   if ($access==1)
   {
     //mail the user or do whatever
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM