My use case is: I need to do stuff when content is affiliated to a new domain.

I couldn't do that with rules. Tried using node data comparison condition with the node saving event, but since domain affiliation is not a field, I could not compare the data.

Also, domain access has a bunch of hooks, but no hook for such situation. But that's another issue, on another module. :-)

I think it would be great to have the following events:

  • Node is added to a domain
  • Node is removed from a domain
  • User is added to a domain
  • User is removed from a domain

Thanks

Comments

shushu’s picture

Project: Domain Rules » Domain
Version: 7.x-1.6 » 7.x-3.x-dev

Hi,
I understand your needs, but looking into the domain module code it seems those hooks are really missing, and that I won't be able to easily implement those events without them.
_domain_store_grants() seems to be the place needs to be patched and to add the hooks.
It also need to properly show the old domains of a node, new domains of a node, and the "diff" between them.
When this data will exist, I will be happy to implement the Rules events for it.

@tomyinhauser, sorry.

agentrickard’s picture

Interesting. Problem is, I don't use Rules.

I would prefer this be supported in Domain Rules (which is where Rules integration should go).

What you would need to do is read hook_node_presave(), I suspect, and fire a Rules hook there. Really, what you're checking for is if a value of the field has changed on the node (or the user).

shushu’s picture

@agentrickard, thanks.

Trying to grab the info from hook_node_presave() might be problematic and depend on the order of the things.
May I provide a patch that wil call a hook in _domain_store_grants() /
Do you think it will be the right place to put it ?

Thanks,
Shushu

agentrickard’s picture

That might be the safest place, because by that point, we've determined what grants to store.

I'd prefer to put a hook in there that Domain Rules can respond to. I really don't want to maintain Rules integration code.

shushu’s picture

Sure, I never thought you will maintain the rules integration. I just need the hook in the right spot.
I will keep you updated.
Thanks,
Shushu