开发者

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 trie开发者_如何学JAVAd 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
   }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜