Cloning permissions from one node to another

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
oxford-dev's picture

I have a gallery setup whereby a gallery is a node and a gallery can have many child image nodes.

So far so good.

However, I would like to configure the setup so that when a user sets the node access permissions for the gallery (using UserRElationships Node Access), that same permission is applied to all child nodes.

I was thinking that this could be achieved in triggered rules, eg after a gallery is updated and after an image is created.

However I cant find out how I:

a) get the permissions of a particular node

and

b) set the permissions of a node.

My workflow would be:

$perms = permissions of node A

foreach(child of Node A -> $child)
{
$child->perms = $perms;
}